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,
61 /// Value is validly encoded but is dangerous to use.
63 /// This is used for things like [`ChannelManager`] deserialization where we want to ensure
64 /// that we don't use a [`ChannelManager`] which is in out of sync with the [`ChannelMonitor`].
65 /// This indicates that there is a critical implementation flaw in the storage implementation
66 /// and it's unsafe to continue.
68 /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
69 /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
72 use lightning::ln::msgs::DecodeError as DecodeErrorImport;
73 pub(crate) type nativeDecodeError = DecodeErrorImport;
77 pub(crate) fn to_native(&self) -> nativeDecodeError {
79 DecodeError::UnknownVersion => nativeDecodeError::UnknownVersion,
80 DecodeError::UnknownRequiredFeature => nativeDecodeError::UnknownRequiredFeature,
81 DecodeError::InvalidValue => nativeDecodeError::InvalidValue,
82 DecodeError::ShortRead => nativeDecodeError::ShortRead,
83 DecodeError::BadLengthDescriptor => nativeDecodeError::BadLengthDescriptor,
84 DecodeError::Io (ref a, ) => {
85 let mut a_nonref = Clone::clone(a);
86 nativeDecodeError::Io (
87 a_nonref.to_rust_kind(),
90 DecodeError::UnsupportedCompression => nativeDecodeError::UnsupportedCompression,
91 DecodeError::DangerousValue => nativeDecodeError::DangerousValue,
95 pub(crate) fn into_native(self) -> nativeDecodeError {
97 DecodeError::UnknownVersion => nativeDecodeError::UnknownVersion,
98 DecodeError::UnknownRequiredFeature => nativeDecodeError::UnknownRequiredFeature,
99 DecodeError::InvalidValue => nativeDecodeError::InvalidValue,
100 DecodeError::ShortRead => nativeDecodeError::ShortRead,
101 DecodeError::BadLengthDescriptor => nativeDecodeError::BadLengthDescriptor,
102 DecodeError::Io (mut a, ) => {
103 nativeDecodeError::Io (
107 DecodeError::UnsupportedCompression => nativeDecodeError::UnsupportedCompression,
108 DecodeError::DangerousValue => nativeDecodeError::DangerousValue,
112 pub(crate) fn from_native(native: &DecodeErrorImport) -> Self {
113 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeDecodeError) };
115 nativeDecodeError::UnknownVersion => DecodeError::UnknownVersion,
116 nativeDecodeError::UnknownRequiredFeature => DecodeError::UnknownRequiredFeature,
117 nativeDecodeError::InvalidValue => DecodeError::InvalidValue,
118 nativeDecodeError::ShortRead => DecodeError::ShortRead,
119 nativeDecodeError::BadLengthDescriptor => DecodeError::BadLengthDescriptor,
120 nativeDecodeError::Io (ref a, ) => {
121 let mut a_nonref = Clone::clone(a);
123 crate::c_types::IOError::from_rust_kind(a_nonref),
126 nativeDecodeError::UnsupportedCompression => DecodeError::UnsupportedCompression,
127 nativeDecodeError::DangerousValue => DecodeError::DangerousValue,
131 pub(crate) fn native_into(native: nativeDecodeError) -> Self {
133 nativeDecodeError::UnknownVersion => DecodeError::UnknownVersion,
134 nativeDecodeError::UnknownRequiredFeature => DecodeError::UnknownRequiredFeature,
135 nativeDecodeError::InvalidValue => DecodeError::InvalidValue,
136 nativeDecodeError::ShortRead => DecodeError::ShortRead,
137 nativeDecodeError::BadLengthDescriptor => DecodeError::BadLengthDescriptor,
138 nativeDecodeError::Io (mut a, ) => {
140 crate::c_types::IOError::from_rust_kind(a),
143 nativeDecodeError::UnsupportedCompression => DecodeError::UnsupportedCompression,
144 nativeDecodeError::DangerousValue => DecodeError::DangerousValue,
148 /// Frees any resources used by the DecodeError
150 pub extern "C" fn DecodeError_free(this_ptr: DecodeError) { }
151 /// Creates a copy of the DecodeError
153 pub extern "C" fn DecodeError_clone(orig: &DecodeError) -> DecodeError {
157 /// Used only if an object of this type is returned as a trait impl by a method
158 pub(crate) extern "C" fn DecodeError_clone_void(this_ptr: *const c_void) -> *mut c_void {
159 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const DecodeError)).clone() })) as *mut c_void
162 /// Used only if an object of this type is returned as a trait impl by a method
163 pub(crate) extern "C" fn DecodeError_free_void(this_ptr: *mut c_void) {
164 let _ = unsafe { Box::from_raw(this_ptr as *mut DecodeError) };
167 /// Utility method to constructs a new UnknownVersion-variant DecodeError
168 pub extern "C" fn DecodeError_unknown_version() -> DecodeError {
169 DecodeError::UnknownVersion}
171 /// Utility method to constructs a new UnknownRequiredFeature-variant DecodeError
172 pub extern "C" fn DecodeError_unknown_required_feature() -> DecodeError {
173 DecodeError::UnknownRequiredFeature}
175 /// Utility method to constructs a new InvalidValue-variant DecodeError
176 pub extern "C" fn DecodeError_invalid_value() -> DecodeError {
177 DecodeError::InvalidValue}
179 /// Utility method to constructs a new ShortRead-variant DecodeError
180 pub extern "C" fn DecodeError_short_read() -> DecodeError {
181 DecodeError::ShortRead}
183 /// Utility method to constructs a new BadLengthDescriptor-variant DecodeError
184 pub extern "C" fn DecodeError_bad_length_descriptor() -> DecodeError {
185 DecodeError::BadLengthDescriptor}
187 /// Utility method to constructs a new Io-variant DecodeError
188 pub extern "C" fn DecodeError_io(a: crate::c_types::IOError) -> DecodeError {
192 /// Utility method to constructs a new UnsupportedCompression-variant DecodeError
193 pub extern "C" fn DecodeError_unsupported_compression() -> DecodeError {
194 DecodeError::UnsupportedCompression}
196 /// Utility method to constructs a new DangerousValue-variant DecodeError
197 pub extern "C" fn DecodeError_dangerous_value() -> DecodeError {
198 DecodeError::DangerousValue}
199 /// Get a string which allows debug introspection of a DecodeError object
200 pub extern "C" fn DecodeError_debug_str_void(o: *const c_void) -> Str {
201 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::DecodeError }).into()}
202 /// Generates a non-cryptographic 64-bit hash of the DecodeError.
204 pub extern "C" fn DecodeError_hash(o: &DecodeError) -> u64 {
205 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
207 let mut hasher = core::hash::SipHasher::new();
208 core::hash::Hash::hash(&o.to_native(), &mut hasher);
209 core::hash::Hasher::finish(&hasher)
211 /// Checks if two DecodeErrors contain equal inner contents.
212 /// This ignores pointers and is_owned flags and looks at the values in fields.
214 pub extern "C" fn DecodeError_eq(a: &DecodeError, b: &DecodeError) -> bool {
215 if &a.to_native() == &b.to_native() { true } else { false }
218 use lightning::ln::msgs::Init as nativeInitImport;
219 pub(crate) type nativeInit = nativeInitImport;
221 /// An [`init`] message to be sent to or received from a peer.
223 /// [`init`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-init-message
227 /// A pointer to the opaque Rust object.
229 /// Nearly everywhere, inner must be non-null, however in places where
230 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
231 pub inner: *mut nativeInit,
232 /// Indicates that this is the only struct which contains the same pointer.
234 /// Rust functions which take ownership of an object provided via an argument require
235 /// this to be true and invalidate the object pointed to by inner.
241 if self.is_owned && !<*mut nativeInit>::is_null(self.inner) {
242 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
246 /// Frees any resources used by the Init, if is_owned is set and inner is non-NULL.
248 pub extern "C" fn Init_free(this_obj: Init) { }
250 /// Used only if an object of this type is returned as a trait impl by a method
251 pub(crate) extern "C" fn Init_free_void(this_ptr: *mut c_void) {
252 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInit) };
256 pub(crate) fn get_native_ref(&self) -> &'static nativeInit {
257 unsafe { &*ObjOps::untweak_ptr(self.inner) }
259 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInit {
260 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
262 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
263 pub(crate) fn take_inner(mut self) -> *mut nativeInit {
264 assert!(self.is_owned);
265 let ret = ObjOps::untweak_ptr(self.inner);
266 self.inner = core::ptr::null_mut();
270 /// The relevant features which the sender supports.
272 pub extern "C" fn Init_get_features(this_ptr: &Init) -> crate::lightning::ln::features::InitFeatures {
273 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
274 crate::lightning::ln::features::InitFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::InitFeatures<>) as *mut _) }, is_owned: false }
276 /// The relevant features which the sender supports.
278 pub extern "C" fn Init_set_features(this_ptr: &mut Init, mut val: crate::lightning::ln::features::InitFeatures) {
279 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
281 /// Indicates chains the sender is interested in.
283 /// If there are no common chains, the connection will be closed.
285 /// Returns a copy of the field.
287 pub extern "C" fn Init_get_networks(this_ptr: &Init) -> crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ {
288 let mut inner_val = this_ptr.get_native_mut_ref().networks.clone();
289 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ::None } else { crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ::Some( { let mut local_inner_val_0 = Vec::new(); for mut item in inner_val.unwrap().drain(..) { local_inner_val_0.push( { crate::c_types::ThirtyTwoBytes { data: *item.as_ref() } }); }; local_inner_val_0.into() }) };
292 /// Indicates chains the sender is interested in.
294 /// If there are no common chains, the connection will be closed.
296 pub extern "C" fn Init_set_networks(this_ptr: &mut Init, mut val: crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ) {
297 let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { let mut local_val_0 = Vec::new(); for mut item in { val_opt.take() }.into_rust().drain(..) { local_val_0.push( { ::bitcoin::blockdata::constants::ChainHash::from(&item.data) }); }; local_val_0 }})} };
298 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.networks = local_val;
300 /// The receipient's network address.
302 /// This adds the option to report a remote IP address back to a connecting peer using the init
303 /// message. A node can decide to use that information to discover a potential update to its
304 /// public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing
307 pub extern "C" fn Init_get_remote_network_address(this_ptr: &Init) -> crate::c_types::derived::COption_SocketAddressZ {
308 let mut inner_val = &mut this_ptr.get_native_mut_ref().remote_network_address;
309 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_SocketAddressZ::None } else { crate::c_types::derived::COption_SocketAddressZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { crate::lightning::ln::msgs::SocketAddress::native_into((*inner_val.as_ref().unwrap()).clone()) }) };
312 /// The receipient's network address.
314 /// This adds the option to report a remote IP address back to a connecting peer using the init
315 /// message. A node can decide to use that information to discover a potential update to its
316 /// public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing
319 pub extern "C" fn Init_set_remote_network_address(this_ptr: &mut Init, mut val: crate::c_types::derived::COption_SocketAddressZ) {
320 let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_native() }})} };
321 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.remote_network_address = local_val;
323 /// Constructs a new Init given each field
326 pub extern "C" fn Init_new(mut features_arg: crate::lightning::ln::features::InitFeatures, mut networks_arg: crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ, mut remote_network_address_arg: crate::c_types::derived::COption_SocketAddressZ) -> Init {
327 let mut local_networks_arg = { /*networks_arg*/ let networks_arg_opt = networks_arg; if networks_arg_opt.is_none() { None } else { Some({ { let mut local_networks_arg_0 = Vec::new(); for mut item in { networks_arg_opt.take() }.into_rust().drain(..) { local_networks_arg_0.push( { ::bitcoin::blockdata::constants::ChainHash::from(&item.data) }); }; local_networks_arg_0 }})} };
328 let mut local_remote_network_address_arg = { /*remote_network_address_arg*/ let remote_network_address_arg_opt = remote_network_address_arg; if remote_network_address_arg_opt.is_none() { None } else { Some({ { { remote_network_address_arg_opt.take() }.into_native() }})} };
329 Init { inner: ObjOps::heap_alloc(nativeInit {
330 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
331 networks: local_networks_arg,
332 remote_network_address: local_remote_network_address_arg,
335 impl Clone for Init {
336 fn clone(&self) -> Self {
338 inner: if <*mut nativeInit>::is_null(self.inner) { core::ptr::null_mut() } else {
339 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
345 /// Used only if an object of this type is returned as a trait impl by a method
346 pub(crate) extern "C" fn Init_clone_void(this_ptr: *const c_void) -> *mut c_void {
347 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeInit)).clone() })) as *mut c_void
350 /// Creates a copy of the Init
351 pub extern "C" fn Init_clone(orig: &Init) -> Init {
354 /// Get a string which allows debug introspection of a Init object
355 pub extern "C" fn Init_debug_str_void(o: *const c_void) -> Str {
356 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::Init }).into()}
357 /// Generates a non-cryptographic 64-bit hash of the Init.
359 pub extern "C" fn Init_hash(o: &Init) -> u64 {
360 if o.inner.is_null() { return 0; }
361 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
363 let mut hasher = core::hash::SipHasher::new();
364 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
365 core::hash::Hasher::finish(&hasher)
367 /// Checks if two Inits contain equal inner contents.
368 /// This ignores pointers and is_owned flags and looks at the values in fields.
369 /// Two objects with NULL inner values will be considered "equal" here.
371 pub extern "C" fn Init_eq(a: &Init, b: &Init) -> bool {
372 if a.inner == b.inner { return true; }
373 if a.inner.is_null() || b.inner.is_null() { return false; }
374 if a.get_native_ref() == b.get_native_ref() { true } else { false }
377 use lightning::ln::msgs::ErrorMessage as nativeErrorMessageImport;
378 pub(crate) type nativeErrorMessage = nativeErrorMessageImport;
380 /// An [`error`] message to be sent to or received from a peer.
382 /// [`error`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages
385 pub struct ErrorMessage {
386 /// A pointer to the opaque Rust object.
388 /// Nearly everywhere, inner must be non-null, however in places where
389 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
390 pub inner: *mut nativeErrorMessage,
391 /// Indicates that this is the only struct which contains the same pointer.
393 /// Rust functions which take ownership of an object provided via an argument require
394 /// this to be true and invalidate the object pointed to by inner.
398 impl Drop for ErrorMessage {
400 if self.is_owned && !<*mut nativeErrorMessage>::is_null(self.inner) {
401 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
405 /// Frees any resources used by the ErrorMessage, if is_owned is set and inner is non-NULL.
407 pub extern "C" fn ErrorMessage_free(this_obj: ErrorMessage) { }
409 /// Used only if an object of this type is returned as a trait impl by a method
410 pub(crate) extern "C" fn ErrorMessage_free_void(this_ptr: *mut c_void) {
411 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeErrorMessage) };
415 pub(crate) fn get_native_ref(&self) -> &'static nativeErrorMessage {
416 unsafe { &*ObjOps::untweak_ptr(self.inner) }
418 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeErrorMessage {
419 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
421 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
422 pub(crate) fn take_inner(mut self) -> *mut nativeErrorMessage {
423 assert!(self.is_owned);
424 let ret = ObjOps::untweak_ptr(self.inner);
425 self.inner = core::ptr::null_mut();
429 /// The channel ID involved in the error.
431 /// All-0s indicates a general error unrelated to a specific channel, after which all channels
432 /// with the sending peer should be closed.
434 pub extern "C" fn ErrorMessage_get_channel_id(this_ptr: &ErrorMessage) -> crate::lightning::ln::types::ChannelId {
435 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
436 crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
438 /// The channel ID involved in the error.
440 /// All-0s indicates a general error unrelated to a specific channel, after which all channels
441 /// with the sending peer should be closed.
443 pub extern "C" fn ErrorMessage_set_channel_id(this_ptr: &mut ErrorMessage, mut val: crate::lightning::ln::types::ChannelId) {
444 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
446 /// A possibly human-readable error description.
448 /// The string should be sanitized before it is used (e.g., emitted to logs or printed to
449 /// `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in
450 /// the terminal emulator or the logging subsystem.
452 pub extern "C" fn ErrorMessage_get_data(this_ptr: &ErrorMessage) -> crate::c_types::Str {
453 let mut inner_val = &mut this_ptr.get_native_mut_ref().data;
454 inner_val.as_str().into()
456 /// A possibly human-readable error description.
458 /// The string should be sanitized before it is used (e.g., emitted to logs or printed to
459 /// `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in
460 /// the terminal emulator or the logging subsystem.
462 pub extern "C" fn ErrorMessage_set_data(this_ptr: &mut ErrorMessage, mut val: crate::c_types::Str) {
463 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string();
465 /// Constructs a new ErrorMessage given each field
468 pub extern "C" fn ErrorMessage_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut data_arg: crate::c_types::Str) -> ErrorMessage {
469 ErrorMessage { inner: ObjOps::heap_alloc(nativeErrorMessage {
470 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
471 data: data_arg.into_string(),
474 impl Clone for ErrorMessage {
475 fn clone(&self) -> Self {
477 inner: if <*mut nativeErrorMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
478 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
484 /// Used only if an object of this type is returned as a trait impl by a method
485 pub(crate) extern "C" fn ErrorMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
486 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeErrorMessage)).clone() })) as *mut c_void
489 /// Creates a copy of the ErrorMessage
490 pub extern "C" fn ErrorMessage_clone(orig: &ErrorMessage) -> ErrorMessage {
493 /// Get a string which allows debug introspection of a ErrorMessage object
494 pub extern "C" fn ErrorMessage_debug_str_void(o: *const c_void) -> Str {
495 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ErrorMessage }).into()}
496 /// Generates a non-cryptographic 64-bit hash of the ErrorMessage.
498 pub extern "C" fn ErrorMessage_hash(o: &ErrorMessage) -> u64 {
499 if o.inner.is_null() { return 0; }
500 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
502 let mut hasher = core::hash::SipHasher::new();
503 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
504 core::hash::Hasher::finish(&hasher)
506 /// Checks if two ErrorMessages contain equal inner contents.
507 /// This ignores pointers and is_owned flags and looks at the values in fields.
508 /// Two objects with NULL inner values will be considered "equal" here.
510 pub extern "C" fn ErrorMessage_eq(a: &ErrorMessage, b: &ErrorMessage) -> bool {
511 if a.inner == b.inner { return true; }
512 if a.inner.is_null() || b.inner.is_null() { return false; }
513 if a.get_native_ref() == b.get_native_ref() { true } else { false }
516 use lightning::ln::msgs::WarningMessage as nativeWarningMessageImport;
517 pub(crate) type nativeWarningMessage = nativeWarningMessageImport;
519 /// A [`warning`] message to be sent to or received from a peer.
521 /// [`warning`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages
524 pub struct WarningMessage {
525 /// A pointer to the opaque Rust object.
527 /// Nearly everywhere, inner must be non-null, however in places where
528 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
529 pub inner: *mut nativeWarningMessage,
530 /// Indicates that this is the only struct which contains the same pointer.
532 /// Rust functions which take ownership of an object provided via an argument require
533 /// this to be true and invalidate the object pointed to by inner.
537 impl Drop for WarningMessage {
539 if self.is_owned && !<*mut nativeWarningMessage>::is_null(self.inner) {
540 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
544 /// Frees any resources used by the WarningMessage, if is_owned is set and inner is non-NULL.
546 pub extern "C" fn WarningMessage_free(this_obj: WarningMessage) { }
548 /// Used only if an object of this type is returned as a trait impl by a method
549 pub(crate) extern "C" fn WarningMessage_free_void(this_ptr: *mut c_void) {
550 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeWarningMessage) };
553 impl WarningMessage {
554 pub(crate) fn get_native_ref(&self) -> &'static nativeWarningMessage {
555 unsafe { &*ObjOps::untweak_ptr(self.inner) }
557 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeWarningMessage {
558 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
560 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
561 pub(crate) fn take_inner(mut self) -> *mut nativeWarningMessage {
562 assert!(self.is_owned);
563 let ret = ObjOps::untweak_ptr(self.inner);
564 self.inner = core::ptr::null_mut();
568 /// The channel ID involved in the warning.
570 /// All-0s indicates a warning unrelated to a specific channel.
572 pub extern "C" fn WarningMessage_get_channel_id(this_ptr: &WarningMessage) -> crate::lightning::ln::types::ChannelId {
573 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
574 crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
576 /// The channel ID involved in the warning.
578 /// All-0s indicates a warning unrelated to a specific channel.
580 pub extern "C" fn WarningMessage_set_channel_id(this_ptr: &mut WarningMessage, mut val: crate::lightning::ln::types::ChannelId) {
581 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
583 /// A possibly human-readable warning description.
585 /// The string should be sanitized before it is used (e.g. emitted to logs or printed to
586 /// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
587 /// the terminal emulator or the logging subsystem.
589 pub extern "C" fn WarningMessage_get_data(this_ptr: &WarningMessage) -> crate::c_types::Str {
590 let mut inner_val = &mut this_ptr.get_native_mut_ref().data;
591 inner_val.as_str().into()
593 /// A possibly human-readable warning description.
595 /// The string should be sanitized before it is used (e.g. emitted to logs or printed to
596 /// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
597 /// the terminal emulator or the logging subsystem.
599 pub extern "C" fn WarningMessage_set_data(this_ptr: &mut WarningMessage, mut val: crate::c_types::Str) {
600 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string();
602 /// Constructs a new WarningMessage given each field
605 pub extern "C" fn WarningMessage_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut data_arg: crate::c_types::Str) -> WarningMessage {
606 WarningMessage { inner: ObjOps::heap_alloc(nativeWarningMessage {
607 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
608 data: data_arg.into_string(),
611 impl Clone for WarningMessage {
612 fn clone(&self) -> Self {
614 inner: if <*mut nativeWarningMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
615 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
621 /// Used only if an object of this type is returned as a trait impl by a method
622 pub(crate) extern "C" fn WarningMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
623 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeWarningMessage)).clone() })) as *mut c_void
626 /// Creates a copy of the WarningMessage
627 pub extern "C" fn WarningMessage_clone(orig: &WarningMessage) -> WarningMessage {
630 /// Get a string which allows debug introspection of a WarningMessage object
631 pub extern "C" fn WarningMessage_debug_str_void(o: *const c_void) -> Str {
632 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::WarningMessage }).into()}
633 /// Generates a non-cryptographic 64-bit hash of the WarningMessage.
635 pub extern "C" fn WarningMessage_hash(o: &WarningMessage) -> u64 {
636 if o.inner.is_null() { return 0; }
637 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
639 let mut hasher = core::hash::SipHasher::new();
640 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
641 core::hash::Hasher::finish(&hasher)
643 /// Checks if two WarningMessages contain equal inner contents.
644 /// This ignores pointers and is_owned flags and looks at the values in fields.
645 /// Two objects with NULL inner values will be considered "equal" here.
647 pub extern "C" fn WarningMessage_eq(a: &WarningMessage, b: &WarningMessage) -> bool {
648 if a.inner == b.inner { return true; }
649 if a.inner.is_null() || b.inner.is_null() { return false; }
650 if a.get_native_ref() == b.get_native_ref() { true } else { false }
653 use lightning::ln::msgs::Ping as nativePingImport;
654 pub(crate) type nativePing = nativePingImport;
656 /// A [`ping`] message to be sent to or received from a peer.
658 /// [`ping`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-ping-and-pong-messages
662 /// A pointer to the opaque Rust object.
664 /// Nearly everywhere, inner must be non-null, however in places where
665 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
666 pub inner: *mut nativePing,
667 /// Indicates that this is the only struct which contains the same pointer.
669 /// Rust functions which take ownership of an object provided via an argument require
670 /// this to be true and invalidate the object pointed to by inner.
676 if self.is_owned && !<*mut nativePing>::is_null(self.inner) {
677 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
681 /// Frees any resources used by the Ping, if is_owned is set and inner is non-NULL.
683 pub extern "C" fn Ping_free(this_obj: Ping) { }
685 /// Used only if an object of this type is returned as a trait impl by a method
686 pub(crate) extern "C" fn Ping_free_void(this_ptr: *mut c_void) {
687 let _ = unsafe { Box::from_raw(this_ptr as *mut nativePing) };
691 pub(crate) fn get_native_ref(&self) -> &'static nativePing {
692 unsafe { &*ObjOps::untweak_ptr(self.inner) }
694 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePing {
695 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
697 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
698 pub(crate) fn take_inner(mut self) -> *mut nativePing {
699 assert!(self.is_owned);
700 let ret = ObjOps::untweak_ptr(self.inner);
701 self.inner = core::ptr::null_mut();
705 /// The desired response length.
707 pub extern "C" fn Ping_get_ponglen(this_ptr: &Ping) -> u16 {
708 let mut inner_val = &mut this_ptr.get_native_mut_ref().ponglen;
711 /// The desired response length.
713 pub extern "C" fn Ping_set_ponglen(this_ptr: &mut Ping, mut val: u16) {
714 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.ponglen = val;
716 /// The ping packet size.
718 /// This field is not sent on the wire. byteslen zeros are sent.
720 pub extern "C" fn Ping_get_byteslen(this_ptr: &Ping) -> u16 {
721 let mut inner_val = &mut this_ptr.get_native_mut_ref().byteslen;
724 /// The ping packet size.
726 /// This field is not sent on the wire. byteslen zeros are sent.
728 pub extern "C" fn Ping_set_byteslen(this_ptr: &mut Ping, mut val: u16) {
729 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.byteslen = val;
731 /// Constructs a new Ping given each field
734 pub extern "C" fn Ping_new(mut ponglen_arg: u16, mut byteslen_arg: u16) -> Ping {
735 Ping { inner: ObjOps::heap_alloc(nativePing {
736 ponglen: ponglen_arg,
737 byteslen: byteslen_arg,
740 impl Clone for Ping {
741 fn clone(&self) -> Self {
743 inner: if <*mut nativePing>::is_null(self.inner) { core::ptr::null_mut() } else {
744 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
750 /// Used only if an object of this type is returned as a trait impl by a method
751 pub(crate) extern "C" fn Ping_clone_void(this_ptr: *const c_void) -> *mut c_void {
752 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativePing)).clone() })) as *mut c_void
755 /// Creates a copy of the Ping
756 pub extern "C" fn Ping_clone(orig: &Ping) -> Ping {
759 /// Get a string which allows debug introspection of a Ping object
760 pub extern "C" fn Ping_debug_str_void(o: *const c_void) -> Str {
761 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::Ping }).into()}
762 /// Generates a non-cryptographic 64-bit hash of the Ping.
764 pub extern "C" fn Ping_hash(o: &Ping) -> u64 {
765 if o.inner.is_null() { return 0; }
766 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
768 let mut hasher = core::hash::SipHasher::new();
769 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
770 core::hash::Hasher::finish(&hasher)
772 /// Checks if two Pings contain equal inner contents.
773 /// This ignores pointers and is_owned flags and looks at the values in fields.
774 /// Two objects with NULL inner values will be considered "equal" here.
776 pub extern "C" fn Ping_eq(a: &Ping, b: &Ping) -> bool {
777 if a.inner == b.inner { return true; }
778 if a.inner.is_null() || b.inner.is_null() { return false; }
779 if a.get_native_ref() == b.get_native_ref() { true } else { false }
782 use lightning::ln::msgs::Pong as nativePongImport;
783 pub(crate) type nativePong = nativePongImport;
785 /// A [`pong`] message to be sent to or received from a peer.
787 /// [`pong`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-ping-and-pong-messages
791 /// A pointer to the opaque Rust object.
793 /// Nearly everywhere, inner must be non-null, however in places where
794 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
795 pub inner: *mut nativePong,
796 /// Indicates that this is the only struct which contains the same pointer.
798 /// Rust functions which take ownership of an object provided via an argument require
799 /// this to be true and invalidate the object pointed to by inner.
805 if self.is_owned && !<*mut nativePong>::is_null(self.inner) {
806 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
810 /// Frees any resources used by the Pong, if is_owned is set and inner is non-NULL.
812 pub extern "C" fn Pong_free(this_obj: Pong) { }
814 /// Used only if an object of this type is returned as a trait impl by a method
815 pub(crate) extern "C" fn Pong_free_void(this_ptr: *mut c_void) {
816 let _ = unsafe { Box::from_raw(this_ptr as *mut nativePong) };
820 pub(crate) fn get_native_ref(&self) -> &'static nativePong {
821 unsafe { &*ObjOps::untweak_ptr(self.inner) }
823 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePong {
824 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
826 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
827 pub(crate) fn take_inner(mut self) -> *mut nativePong {
828 assert!(self.is_owned);
829 let ret = ObjOps::untweak_ptr(self.inner);
830 self.inner = core::ptr::null_mut();
834 /// The pong packet size.
836 /// This field is not sent on the wire. byteslen zeros are sent.
838 pub extern "C" fn Pong_get_byteslen(this_ptr: &Pong) -> u16 {
839 let mut inner_val = &mut this_ptr.get_native_mut_ref().byteslen;
842 /// The pong packet size.
844 /// This field is not sent on the wire. byteslen zeros are sent.
846 pub extern "C" fn Pong_set_byteslen(this_ptr: &mut Pong, mut val: u16) {
847 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.byteslen = val;
849 /// Constructs a new Pong given each field
852 pub extern "C" fn Pong_new(mut byteslen_arg: u16) -> Pong {
853 Pong { inner: ObjOps::heap_alloc(nativePong {
854 byteslen: byteslen_arg,
857 impl Clone for Pong {
858 fn clone(&self) -> Self {
860 inner: if <*mut nativePong>::is_null(self.inner) { core::ptr::null_mut() } else {
861 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
867 /// Used only if an object of this type is returned as a trait impl by a method
868 pub(crate) extern "C" fn Pong_clone_void(this_ptr: *const c_void) -> *mut c_void {
869 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativePong)).clone() })) as *mut c_void
872 /// Creates a copy of the Pong
873 pub extern "C" fn Pong_clone(orig: &Pong) -> Pong {
876 /// Get a string which allows debug introspection of a Pong object
877 pub extern "C" fn Pong_debug_str_void(o: *const c_void) -> Str {
878 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::Pong }).into()}
879 /// Generates a non-cryptographic 64-bit hash of the Pong.
881 pub extern "C" fn Pong_hash(o: &Pong) -> u64 {
882 if o.inner.is_null() { return 0; }
883 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
885 let mut hasher = core::hash::SipHasher::new();
886 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
887 core::hash::Hasher::finish(&hasher)
889 /// Checks if two Pongs contain equal inner contents.
890 /// This ignores pointers and is_owned flags and looks at the values in fields.
891 /// Two objects with NULL inner values will be considered "equal" here.
893 pub extern "C" fn Pong_eq(a: &Pong, b: &Pong) -> bool {
894 if a.inner == b.inner { return true; }
895 if a.inner.is_null() || b.inner.is_null() { return false; }
896 if a.get_native_ref() == b.get_native_ref() { true } else { false }
899 use lightning::ln::msgs::CommonOpenChannelFields as nativeCommonOpenChannelFieldsImport;
900 pub(crate) type nativeCommonOpenChannelFields = nativeCommonOpenChannelFieldsImport;
902 /// Contains fields that are both common to [`open_channel`] and `open_channel2` messages.
904 /// [`open_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message
907 pub struct CommonOpenChannelFields {
908 /// A pointer to the opaque Rust object.
910 /// Nearly everywhere, inner must be non-null, however in places where
911 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
912 pub inner: *mut nativeCommonOpenChannelFields,
913 /// Indicates that this is the only struct which contains the same pointer.
915 /// Rust functions which take ownership of an object provided via an argument require
916 /// this to be true and invalidate the object pointed to by inner.
920 impl Drop for CommonOpenChannelFields {
922 if self.is_owned && !<*mut nativeCommonOpenChannelFields>::is_null(self.inner) {
923 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
927 /// Frees any resources used by the CommonOpenChannelFields, if is_owned is set and inner is non-NULL.
929 pub extern "C" fn CommonOpenChannelFields_free(this_obj: CommonOpenChannelFields) { }
931 /// Used only if an object of this type is returned as a trait impl by a method
932 pub(crate) extern "C" fn CommonOpenChannelFields_free_void(this_ptr: *mut c_void) {
933 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCommonOpenChannelFields) };
936 impl CommonOpenChannelFields {
937 pub(crate) fn get_native_ref(&self) -> &'static nativeCommonOpenChannelFields {
938 unsafe { &*ObjOps::untweak_ptr(self.inner) }
940 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommonOpenChannelFields {
941 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
943 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
944 pub(crate) fn take_inner(mut self) -> *mut nativeCommonOpenChannelFields {
945 assert!(self.is_owned);
946 let ret = ObjOps::untweak_ptr(self.inner);
947 self.inner = core::ptr::null_mut();
951 /// The genesis hash of the blockchain where the channel is to be opened
953 pub extern "C" fn CommonOpenChannelFields_get_chain_hash(this_ptr: &CommonOpenChannelFields) -> *const [u8; 32] {
954 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
957 /// The genesis hash of the blockchain where the channel is to be opened
959 pub extern "C" fn CommonOpenChannelFields_set_chain_hash(this_ptr: &mut CommonOpenChannelFields, mut val: crate::c_types::ThirtyTwoBytes) {
960 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
962 /// A temporary channel ID
963 /// For V2 channels: derived using a zeroed out value for the channel acceptor's revocation basepoint
964 /// For V1 channels: a temporary channel ID, until the funding outpoint is announced
966 pub extern "C" fn CommonOpenChannelFields_get_temporary_channel_id(this_ptr: &CommonOpenChannelFields) -> crate::lightning::ln::types::ChannelId {
967 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
968 crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
970 /// A temporary channel ID
971 /// For V2 channels: derived using a zeroed out value for the channel acceptor's revocation basepoint
972 /// For V1 channels: a temporary channel ID, until the funding outpoint is announced
974 pub extern "C" fn CommonOpenChannelFields_set_temporary_channel_id(this_ptr: &mut CommonOpenChannelFields, mut val: crate::lightning::ln::types::ChannelId) {
975 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = *unsafe { Box::from_raw(val.take_inner()) };
977 /// For V1 channels: The channel value
978 /// For V2 channels: Part of the channel value contributed by the channel initiator
980 pub extern "C" fn CommonOpenChannelFields_get_funding_satoshis(this_ptr: &CommonOpenChannelFields) -> u64 {
981 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
984 /// For V1 channels: The channel value
985 /// For V2 channels: Part of the channel value contributed by the channel initiator
987 pub extern "C" fn CommonOpenChannelFields_set_funding_satoshis(this_ptr: &mut CommonOpenChannelFields, mut val: u64) {
988 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
990 /// The threshold below which outputs on transactions broadcast by the channel initiator will be
993 pub extern "C" fn CommonOpenChannelFields_get_dust_limit_satoshis(this_ptr: &CommonOpenChannelFields) -> u64 {
994 let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
997 /// The threshold below which outputs on transactions broadcast by the channel initiator will be
1000 pub extern "C" fn CommonOpenChannelFields_set_dust_limit_satoshis(this_ptr: &mut CommonOpenChannelFields, mut val: u64) {
1001 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
1003 /// The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi
1005 pub extern "C" fn CommonOpenChannelFields_get_max_htlc_value_in_flight_msat(this_ptr: &CommonOpenChannelFields) -> u64 {
1006 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
1009 /// The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi
1011 pub extern "C" fn CommonOpenChannelFields_set_max_htlc_value_in_flight_msat(this_ptr: &mut CommonOpenChannelFields, mut val: u64) {
1012 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
1014 /// The minimum HTLC size incoming to channel initiator, in milli-satoshi
1016 pub extern "C" fn CommonOpenChannelFields_get_htlc_minimum_msat(this_ptr: &CommonOpenChannelFields) -> u64 {
1017 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
1020 /// The minimum HTLC size incoming to channel initiator, in milli-satoshi
1022 pub extern "C" fn CommonOpenChannelFields_set_htlc_minimum_msat(this_ptr: &mut CommonOpenChannelFields, mut val: u64) {
1023 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
1025 /// The feerate for the commitment transaction set by the channel initiator until updated by
1028 pub extern "C" fn CommonOpenChannelFields_get_commitment_feerate_sat_per_1000_weight(this_ptr: &CommonOpenChannelFields) -> u32 {
1029 let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_feerate_sat_per_1000_weight;
1032 /// The feerate for the commitment transaction set by the channel initiator until updated by
1035 pub extern "C" fn CommonOpenChannelFields_set_commitment_feerate_sat_per_1000_weight(this_ptr: &mut CommonOpenChannelFields, mut val: u32) {
1036 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_feerate_sat_per_1000_weight = val;
1038 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1039 /// broadcast a commitment transaction
1041 pub extern "C" fn CommonOpenChannelFields_get_to_self_delay(this_ptr: &CommonOpenChannelFields) -> u16 {
1042 let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
1045 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1046 /// broadcast a commitment transaction
1048 pub extern "C" fn CommonOpenChannelFields_set_to_self_delay(this_ptr: &mut CommonOpenChannelFields, mut val: u16) {
1049 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
1051 /// The maximum number of inbound HTLCs towards channel initiator
1053 pub extern "C" fn CommonOpenChannelFields_get_max_accepted_htlcs(this_ptr: &CommonOpenChannelFields) -> u16 {
1054 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
1057 /// The maximum number of inbound HTLCs towards channel initiator
1059 pub extern "C" fn CommonOpenChannelFields_set_max_accepted_htlcs(this_ptr: &mut CommonOpenChannelFields, mut val: u16) {
1060 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
1062 /// The channel initiator's key controlling the funding transaction
1064 pub extern "C" fn CommonOpenChannelFields_get_funding_pubkey(this_ptr: &CommonOpenChannelFields) -> crate::c_types::PublicKey {
1065 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
1066 crate::c_types::PublicKey::from_rust(&inner_val)
1068 /// The channel initiator's key controlling the funding transaction
1070 pub extern "C" fn CommonOpenChannelFields_set_funding_pubkey(this_ptr: &mut CommonOpenChannelFields, mut val: crate::c_types::PublicKey) {
1071 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
1073 /// Used to derive a revocation key for transactions broadcast by counterparty
1075 pub extern "C" fn CommonOpenChannelFields_get_revocation_basepoint(this_ptr: &CommonOpenChannelFields) -> crate::c_types::PublicKey {
1076 let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
1077 crate::c_types::PublicKey::from_rust(&inner_val)
1079 /// Used to derive a revocation key for transactions broadcast by counterparty
1081 pub extern "C" fn CommonOpenChannelFields_set_revocation_basepoint(this_ptr: &mut CommonOpenChannelFields, mut val: crate::c_types::PublicKey) {
1082 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
1084 /// A payment key to channel initiator for transactions broadcast by counterparty
1086 pub extern "C" fn CommonOpenChannelFields_get_payment_basepoint(this_ptr: &CommonOpenChannelFields) -> crate::c_types::PublicKey {
1087 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_basepoint;
1088 crate::c_types::PublicKey::from_rust(&inner_val)
1090 /// A payment key to channel initiator for transactions broadcast by counterparty
1092 pub extern "C" fn CommonOpenChannelFields_set_payment_basepoint(this_ptr: &mut CommonOpenChannelFields, mut val: crate::c_types::PublicKey) {
1093 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_basepoint = val.into_rust();
1095 /// Used to derive a payment key to channel initiator for transactions broadcast by channel
1098 pub extern "C" fn CommonOpenChannelFields_get_delayed_payment_basepoint(this_ptr: &CommonOpenChannelFields) -> crate::c_types::PublicKey {
1099 let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
1100 crate::c_types::PublicKey::from_rust(&inner_val)
1102 /// Used to derive a payment key to channel initiator for transactions broadcast by channel
1105 pub extern "C" fn CommonOpenChannelFields_set_delayed_payment_basepoint(this_ptr: &mut CommonOpenChannelFields, mut val: crate::c_types::PublicKey) {
1106 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
1108 /// Used to derive an HTLC payment key to channel initiator
1110 pub extern "C" fn CommonOpenChannelFields_get_htlc_basepoint(this_ptr: &CommonOpenChannelFields) -> crate::c_types::PublicKey {
1111 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
1112 crate::c_types::PublicKey::from_rust(&inner_val)
1114 /// Used to derive an HTLC payment key to channel initiator
1116 pub extern "C" fn CommonOpenChannelFields_set_htlc_basepoint(this_ptr: &mut CommonOpenChannelFields, mut val: crate::c_types::PublicKey) {
1117 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
1119 /// The first to-be-broadcast-by-channel-initiator transaction's per commitment point
1121 pub extern "C" fn CommonOpenChannelFields_get_first_per_commitment_point(this_ptr: &CommonOpenChannelFields) -> crate::c_types::PublicKey {
1122 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
1123 crate::c_types::PublicKey::from_rust(&inner_val)
1125 /// The first to-be-broadcast-by-channel-initiator transaction's per commitment point
1127 pub extern "C" fn CommonOpenChannelFields_set_first_per_commitment_point(this_ptr: &mut CommonOpenChannelFields, mut val: crate::c_types::PublicKey) {
1128 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
1130 /// The channel flags to be used
1132 pub extern "C" fn CommonOpenChannelFields_get_channel_flags(this_ptr: &CommonOpenChannelFields) -> u8 {
1133 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_flags;
1136 /// The channel flags to be used
1138 pub extern "C" fn CommonOpenChannelFields_set_channel_flags(this_ptr: &mut CommonOpenChannelFields, mut val: u8) {
1139 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_flags = val;
1141 /// Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we
1142 /// collaboratively close
1144 pub extern "C" fn CommonOpenChannelFields_get_shutdown_scriptpubkey(this_ptr: &CommonOpenChannelFields) -> crate::c_types::derived::COption_CVec_u8ZZ {
1145 let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey;
1146 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().to_bytes().into() }) };
1149 /// Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we
1150 /// collaboratively close
1152 pub extern "C" fn CommonOpenChannelFields_set_shutdown_scriptpubkey(this_ptr: &mut CommonOpenChannelFields, mut val: crate::c_types::derived::COption_CVec_u8ZZ) {
1153 let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::ScriptBuf::from({ val_opt.take() }.into_rust()) }})} };
1154 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val;
1156 /// The channel type that this channel will represent
1158 /// If this is `None`, we derive the channel type from the intersection of our
1159 /// feature bits with our counterparty's feature bits from the [`Init`] message.
1161 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1163 pub extern "C" fn CommonOpenChannelFields_get_channel_type(this_ptr: &CommonOpenChannelFields) -> crate::lightning::ln::features::ChannelTypeFeatures {
1164 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1165 let mut local_inner_val = crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false };
1168 /// The channel type that this channel will represent
1170 /// If this is `None`, we derive the channel type from the intersection of our
1171 /// feature bits with our counterparty's feature bits from the [`Init`] message.
1173 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1175 pub extern "C" fn CommonOpenChannelFields_set_channel_type(this_ptr: &mut CommonOpenChannelFields, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1176 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1177 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1179 /// Constructs a new CommonOpenChannelFields given each field
1181 /// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
1184 pub extern "C" fn CommonOpenChannelFields_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut temporary_channel_id_arg: crate::lightning::ln::types::ChannelId, mut funding_satoshis_arg: u64, mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut htlc_minimum_msat_arg: u64, mut commitment_feerate_sat_per_1000_weight_arg: u32, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16, mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_basepoint_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey, mut first_per_commitment_point_arg: crate::c_types::PublicKey, mut channel_flags_arg: u8, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_CVec_u8ZZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures) -> CommonOpenChannelFields {
1185 let mut local_shutdown_scriptpubkey_arg = { /*shutdown_scriptpubkey_arg*/ let shutdown_scriptpubkey_arg_opt = shutdown_scriptpubkey_arg; if shutdown_scriptpubkey_arg_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::ScriptBuf::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} };
1186 let mut local_channel_type_arg = if channel_type_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_type_arg.take_inner()) } }) };
1187 CommonOpenChannelFields { inner: ObjOps::heap_alloc(nativeCommonOpenChannelFields {
1188 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
1189 temporary_channel_id: *unsafe { Box::from_raw(temporary_channel_id_arg.take_inner()) },
1190 funding_satoshis: funding_satoshis_arg,
1191 dust_limit_satoshis: dust_limit_satoshis_arg,
1192 max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg,
1193 htlc_minimum_msat: htlc_minimum_msat_arg,
1194 commitment_feerate_sat_per_1000_weight: commitment_feerate_sat_per_1000_weight_arg,
1195 to_self_delay: to_self_delay_arg,
1196 max_accepted_htlcs: max_accepted_htlcs_arg,
1197 funding_pubkey: funding_pubkey_arg.into_rust(),
1198 revocation_basepoint: revocation_basepoint_arg.into_rust(),
1199 payment_basepoint: payment_basepoint_arg.into_rust(),
1200 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
1201 htlc_basepoint: htlc_basepoint_arg.into_rust(),
1202 first_per_commitment_point: first_per_commitment_point_arg.into_rust(),
1203 channel_flags: channel_flags_arg,
1204 shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg,
1205 channel_type: local_channel_type_arg,
1206 }), is_owned: true }
1208 impl Clone for CommonOpenChannelFields {
1209 fn clone(&self) -> Self {
1211 inner: if <*mut nativeCommonOpenChannelFields>::is_null(self.inner) { core::ptr::null_mut() } else {
1212 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1218 /// Used only if an object of this type is returned as a trait impl by a method
1219 pub(crate) extern "C" fn CommonOpenChannelFields_clone_void(this_ptr: *const c_void) -> *mut c_void {
1220 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeCommonOpenChannelFields)).clone() })) as *mut c_void
1223 /// Creates a copy of the CommonOpenChannelFields
1224 pub extern "C" fn CommonOpenChannelFields_clone(orig: &CommonOpenChannelFields) -> CommonOpenChannelFields {
1227 /// Get a string which allows debug introspection of a CommonOpenChannelFields object
1228 pub extern "C" fn CommonOpenChannelFields_debug_str_void(o: *const c_void) -> Str {
1229 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::CommonOpenChannelFields }).into()}
1230 /// Generates a non-cryptographic 64-bit hash of the CommonOpenChannelFields.
1232 pub extern "C" fn CommonOpenChannelFields_hash(o: &CommonOpenChannelFields) -> u64 {
1233 if o.inner.is_null() { return 0; }
1234 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1235 #[allow(deprecated)]
1236 let mut hasher = core::hash::SipHasher::new();
1237 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1238 core::hash::Hasher::finish(&hasher)
1240 /// Checks if two CommonOpenChannelFieldss contain equal inner contents.
1241 /// This ignores pointers and is_owned flags and looks at the values in fields.
1242 /// Two objects with NULL inner values will be considered "equal" here.
1244 pub extern "C" fn CommonOpenChannelFields_eq(a: &CommonOpenChannelFields, b: &CommonOpenChannelFields) -> bool {
1245 if a.inner == b.inner { return true; }
1246 if a.inner.is_null() || b.inner.is_null() { return false; }
1247 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1250 use lightning::ln::msgs::OpenChannel as nativeOpenChannelImport;
1251 pub(crate) type nativeOpenChannel = nativeOpenChannelImport;
1253 /// An [`open_channel`] message to be sent to or received from a peer.
1255 /// Used in V1 channel establishment
1257 /// [`open_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message
1260 pub struct OpenChannel {
1261 /// A pointer to the opaque Rust object.
1263 /// Nearly everywhere, inner must be non-null, however in places where
1264 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1265 pub inner: *mut nativeOpenChannel,
1266 /// Indicates that this is the only struct which contains the same pointer.
1268 /// Rust functions which take ownership of an object provided via an argument require
1269 /// this to be true and invalidate the object pointed to by inner.
1273 impl Drop for OpenChannel {
1274 fn drop(&mut self) {
1275 if self.is_owned && !<*mut nativeOpenChannel>::is_null(self.inner) {
1276 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1280 /// Frees any resources used by the OpenChannel, if is_owned is set and inner is non-NULL.
1282 pub extern "C" fn OpenChannel_free(this_obj: OpenChannel) { }
1284 /// Used only if an object of this type is returned as a trait impl by a method
1285 pub(crate) extern "C" fn OpenChannel_free_void(this_ptr: *mut c_void) {
1286 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOpenChannel) };
1290 pub(crate) fn get_native_ref(&self) -> &'static nativeOpenChannel {
1291 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1293 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOpenChannel {
1294 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1296 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1297 pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannel {
1298 assert!(self.is_owned);
1299 let ret = ObjOps::untweak_ptr(self.inner);
1300 self.inner = core::ptr::null_mut();
1304 /// Common fields of `open_channel(2)`-like messages
1306 pub extern "C" fn OpenChannel_get_common_fields(this_ptr: &OpenChannel) -> crate::lightning::ln::msgs::CommonOpenChannelFields {
1307 let mut inner_val = &mut this_ptr.get_native_mut_ref().common_fields;
1308 crate::lightning::ln::msgs::CommonOpenChannelFields { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::CommonOpenChannelFields<>) as *mut _) }, is_owned: false }
1310 /// Common fields of `open_channel(2)`-like messages
1312 pub extern "C" fn OpenChannel_set_common_fields(this_ptr: &mut OpenChannel, mut val: crate::lightning::ln::msgs::CommonOpenChannelFields) {
1313 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.common_fields = *unsafe { Box::from_raw(val.take_inner()) };
1315 /// The amount to push to the counterparty as part of the open, in milli-satoshi
1317 pub extern "C" fn OpenChannel_get_push_msat(this_ptr: &OpenChannel) -> u64 {
1318 let mut inner_val = &mut this_ptr.get_native_mut_ref().push_msat;
1321 /// The amount to push to the counterparty as part of the open, in milli-satoshi
1323 pub extern "C" fn OpenChannel_set_push_msat(this_ptr: &mut OpenChannel, mut val: u64) {
1324 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.push_msat = val;
1326 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1328 pub extern "C" fn OpenChannel_get_channel_reserve_satoshis(this_ptr: &OpenChannel) -> u64 {
1329 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
1332 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1334 pub extern "C" fn OpenChannel_set_channel_reserve_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
1335 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
1337 /// Constructs a new OpenChannel given each field
1340 pub extern "C" fn OpenChannel_new(mut common_fields_arg: crate::lightning::ln::msgs::CommonOpenChannelFields, mut push_msat_arg: u64, mut channel_reserve_satoshis_arg: u64) -> OpenChannel {
1341 OpenChannel { inner: ObjOps::heap_alloc(nativeOpenChannel {
1342 common_fields: *unsafe { Box::from_raw(common_fields_arg.take_inner()) },
1343 push_msat: push_msat_arg,
1344 channel_reserve_satoshis: channel_reserve_satoshis_arg,
1345 }), is_owned: true }
1347 impl Clone for OpenChannel {
1348 fn clone(&self) -> Self {
1350 inner: if <*mut nativeOpenChannel>::is_null(self.inner) { core::ptr::null_mut() } else {
1351 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1357 /// Used only if an object of this type is returned as a trait impl by a method
1358 pub(crate) extern "C" fn OpenChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
1359 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOpenChannel)).clone() })) as *mut c_void
1362 /// Creates a copy of the OpenChannel
1363 pub extern "C" fn OpenChannel_clone(orig: &OpenChannel) -> OpenChannel {
1366 /// Get a string which allows debug introspection of a OpenChannel object
1367 pub extern "C" fn OpenChannel_debug_str_void(o: *const c_void) -> Str {
1368 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::OpenChannel }).into()}
1369 /// Generates a non-cryptographic 64-bit hash of the OpenChannel.
1371 pub extern "C" fn OpenChannel_hash(o: &OpenChannel) -> u64 {
1372 if o.inner.is_null() { return 0; }
1373 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1374 #[allow(deprecated)]
1375 let mut hasher = core::hash::SipHasher::new();
1376 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1377 core::hash::Hasher::finish(&hasher)
1379 /// Checks if two OpenChannels contain equal inner contents.
1380 /// This ignores pointers and is_owned flags and looks at the values in fields.
1381 /// Two objects with NULL inner values will be considered "equal" here.
1383 pub extern "C" fn OpenChannel_eq(a: &OpenChannel, b: &OpenChannel) -> bool {
1384 if a.inner == b.inner { return true; }
1385 if a.inner.is_null() || b.inner.is_null() { return false; }
1386 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1389 use lightning::ln::msgs::OpenChannelV2 as nativeOpenChannelV2Import;
1390 pub(crate) type nativeOpenChannelV2 = nativeOpenChannelV2Import;
1392 /// An open_channel2 message to be sent by or received from the channel initiator.
1394 /// Used in V2 channel establishment
1398 pub struct OpenChannelV2 {
1399 /// A pointer to the opaque Rust object.
1401 /// Nearly everywhere, inner must be non-null, however in places where
1402 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1403 pub inner: *mut nativeOpenChannelV2,
1404 /// Indicates that this is the only struct which contains the same pointer.
1406 /// Rust functions which take ownership of an object provided via an argument require
1407 /// this to be true and invalidate the object pointed to by inner.
1411 impl Drop for OpenChannelV2 {
1412 fn drop(&mut self) {
1413 if self.is_owned && !<*mut nativeOpenChannelV2>::is_null(self.inner) {
1414 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1418 /// Frees any resources used by the OpenChannelV2, if is_owned is set and inner is non-NULL.
1420 pub extern "C" fn OpenChannelV2_free(this_obj: OpenChannelV2) { }
1422 /// Used only if an object of this type is returned as a trait impl by a method
1423 pub(crate) extern "C" fn OpenChannelV2_free_void(this_ptr: *mut c_void) {
1424 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOpenChannelV2) };
1427 impl OpenChannelV2 {
1428 pub(crate) fn get_native_ref(&self) -> &'static nativeOpenChannelV2 {
1429 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1431 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOpenChannelV2 {
1432 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1434 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1435 pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannelV2 {
1436 assert!(self.is_owned);
1437 let ret = ObjOps::untweak_ptr(self.inner);
1438 self.inner = core::ptr::null_mut();
1442 /// Common fields of `open_channel(2)`-like messages
1444 pub extern "C" fn OpenChannelV2_get_common_fields(this_ptr: &OpenChannelV2) -> crate::lightning::ln::msgs::CommonOpenChannelFields {
1445 let mut inner_val = &mut this_ptr.get_native_mut_ref().common_fields;
1446 crate::lightning::ln::msgs::CommonOpenChannelFields { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::CommonOpenChannelFields<>) as *mut _) }, is_owned: false }
1448 /// Common fields of `open_channel(2)`-like messages
1450 pub extern "C" fn OpenChannelV2_set_common_fields(this_ptr: &mut OpenChannelV2, mut val: crate::lightning::ln::msgs::CommonOpenChannelFields) {
1451 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.common_fields = *unsafe { Box::from_raw(val.take_inner()) };
1453 /// The feerate for the funding transaction set by the channel initiator
1455 pub extern "C" fn OpenChannelV2_get_funding_feerate_sat_per_1000_weight(this_ptr: &OpenChannelV2) -> u32 {
1456 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_feerate_sat_per_1000_weight;
1459 /// The feerate for the funding transaction set by the channel initiator
1461 pub extern "C" fn OpenChannelV2_set_funding_feerate_sat_per_1000_weight(this_ptr: &mut OpenChannelV2, mut val: u32) {
1462 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_feerate_sat_per_1000_weight = val;
1464 /// The locktime for the funding transaction
1466 pub extern "C" fn OpenChannelV2_get_locktime(this_ptr: &OpenChannelV2) -> u32 {
1467 let mut inner_val = &mut this_ptr.get_native_mut_ref().locktime;
1470 /// The locktime for the funding transaction
1472 pub extern "C" fn OpenChannelV2_set_locktime(this_ptr: &mut OpenChannelV2, mut val: u32) {
1473 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.locktime = val;
1475 /// The second to-be-broadcast-by-channel-initiator transaction's per commitment point
1477 pub extern "C" fn OpenChannelV2_get_second_per_commitment_point(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1478 let mut inner_val = &mut this_ptr.get_native_mut_ref().second_per_commitment_point;
1479 crate::c_types::PublicKey::from_rust(&inner_val)
1481 /// The second to-be-broadcast-by-channel-initiator transaction's per commitment point
1483 pub extern "C" fn OpenChannelV2_set_second_per_commitment_point(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1484 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.second_per_commitment_point = val.into_rust();
1486 /// Optionally, a requirement that only confirmed inputs can be added
1488 pub extern "C" fn OpenChannelV2_get_require_confirmed_inputs(this_ptr: &OpenChannelV2) -> crate::c_types::derived::COption_NoneZ {
1489 let mut inner_val = &mut this_ptr.get_native_mut_ref().require_confirmed_inputs;
1490 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_NoneZ::None } else { crate::c_types::derived::COption_NoneZ::Some /* { () /**/ } */ };
1493 /// Optionally, a requirement that only confirmed inputs can be added
1495 pub extern "C" fn OpenChannelV2_set_require_confirmed_inputs(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::derived::COption_NoneZ) {
1496 let mut local_val = if val.is_some() { Some( { () /*val.take()*/ }) } else { None };
1497 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.require_confirmed_inputs = local_val;
1499 /// Constructs a new OpenChannelV2 given each field
1502 pub extern "C" fn OpenChannelV2_new(mut common_fields_arg: crate::lightning::ln::msgs::CommonOpenChannelFields, mut funding_feerate_sat_per_1000_weight_arg: u32, mut locktime_arg: u32, mut second_per_commitment_point_arg: crate::c_types::PublicKey, mut require_confirmed_inputs_arg: crate::c_types::derived::COption_NoneZ) -> OpenChannelV2 {
1503 let mut local_require_confirmed_inputs_arg = if require_confirmed_inputs_arg.is_some() { Some( { () /*require_confirmed_inputs_arg.take()*/ }) } else { None };
1504 OpenChannelV2 { inner: ObjOps::heap_alloc(nativeOpenChannelV2 {
1505 common_fields: *unsafe { Box::from_raw(common_fields_arg.take_inner()) },
1506 funding_feerate_sat_per_1000_weight: funding_feerate_sat_per_1000_weight_arg,
1507 locktime: locktime_arg,
1508 second_per_commitment_point: second_per_commitment_point_arg.into_rust(),
1509 require_confirmed_inputs: local_require_confirmed_inputs_arg,
1510 }), is_owned: true }
1512 impl Clone for OpenChannelV2 {
1513 fn clone(&self) -> Self {
1515 inner: if <*mut nativeOpenChannelV2>::is_null(self.inner) { core::ptr::null_mut() } else {
1516 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1522 /// Used only if an object of this type is returned as a trait impl by a method
1523 pub(crate) extern "C" fn OpenChannelV2_clone_void(this_ptr: *const c_void) -> *mut c_void {
1524 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOpenChannelV2)).clone() })) as *mut c_void
1527 /// Creates a copy of the OpenChannelV2
1528 pub extern "C" fn OpenChannelV2_clone(orig: &OpenChannelV2) -> OpenChannelV2 {
1531 /// Get a string which allows debug introspection of a OpenChannelV2 object
1532 pub extern "C" fn OpenChannelV2_debug_str_void(o: *const c_void) -> Str {
1533 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::OpenChannelV2 }).into()}
1534 /// Generates a non-cryptographic 64-bit hash of the OpenChannelV2.
1536 pub extern "C" fn OpenChannelV2_hash(o: &OpenChannelV2) -> u64 {
1537 if o.inner.is_null() { return 0; }
1538 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1539 #[allow(deprecated)]
1540 let mut hasher = core::hash::SipHasher::new();
1541 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1542 core::hash::Hasher::finish(&hasher)
1544 /// Checks if two OpenChannelV2s contain equal inner contents.
1545 /// This ignores pointers and is_owned flags and looks at the values in fields.
1546 /// Two objects with NULL inner values will be considered "equal" here.
1548 pub extern "C" fn OpenChannelV2_eq(a: &OpenChannelV2, b: &OpenChannelV2) -> bool {
1549 if a.inner == b.inner { return true; }
1550 if a.inner.is_null() || b.inner.is_null() { return false; }
1551 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1554 use lightning::ln::msgs::CommonAcceptChannelFields as nativeCommonAcceptChannelFieldsImport;
1555 pub(crate) type nativeCommonAcceptChannelFields = nativeCommonAcceptChannelFieldsImport;
1557 /// Contains fields that are both common to [`accept_channel`] and `accept_channel2` messages.
1559 /// [`accept_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-accept_channel-message
1562 pub struct CommonAcceptChannelFields {
1563 /// A pointer to the opaque Rust object.
1565 /// Nearly everywhere, inner must be non-null, however in places where
1566 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1567 pub inner: *mut nativeCommonAcceptChannelFields,
1568 /// Indicates that this is the only struct which contains the same pointer.
1570 /// Rust functions which take ownership of an object provided via an argument require
1571 /// this to be true and invalidate the object pointed to by inner.
1575 impl Drop for CommonAcceptChannelFields {
1576 fn drop(&mut self) {
1577 if self.is_owned && !<*mut nativeCommonAcceptChannelFields>::is_null(self.inner) {
1578 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1582 /// Frees any resources used by the CommonAcceptChannelFields, if is_owned is set and inner is non-NULL.
1584 pub extern "C" fn CommonAcceptChannelFields_free(this_obj: CommonAcceptChannelFields) { }
1586 /// Used only if an object of this type is returned as a trait impl by a method
1587 pub(crate) extern "C" fn CommonAcceptChannelFields_free_void(this_ptr: *mut c_void) {
1588 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCommonAcceptChannelFields) };
1591 impl CommonAcceptChannelFields {
1592 pub(crate) fn get_native_ref(&self) -> &'static nativeCommonAcceptChannelFields {
1593 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1595 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommonAcceptChannelFields {
1596 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1598 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1599 pub(crate) fn take_inner(mut self) -> *mut nativeCommonAcceptChannelFields {
1600 assert!(self.is_owned);
1601 let ret = ObjOps::untweak_ptr(self.inner);
1602 self.inner = core::ptr::null_mut();
1606 /// The same `temporary_channel_id` received from the initiator's `open_channel2` or `open_channel` message.
1608 pub extern "C" fn CommonAcceptChannelFields_get_temporary_channel_id(this_ptr: &CommonAcceptChannelFields) -> crate::lightning::ln::types::ChannelId {
1609 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
1610 crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
1612 /// The same `temporary_channel_id` received from the initiator's `open_channel2` or `open_channel` message.
1614 pub extern "C" fn CommonAcceptChannelFields_set_temporary_channel_id(this_ptr: &mut CommonAcceptChannelFields, mut val: crate::lightning::ln::types::ChannelId) {
1615 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = *unsafe { Box::from_raw(val.take_inner()) };
1617 /// The threshold below which outputs on transactions broadcast by the channel acceptor will be
1620 pub extern "C" fn CommonAcceptChannelFields_get_dust_limit_satoshis(this_ptr: &CommonAcceptChannelFields) -> u64 {
1621 let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
1624 /// The threshold below which outputs on transactions broadcast by the channel acceptor will be
1627 pub extern "C" fn CommonAcceptChannelFields_set_dust_limit_satoshis(this_ptr: &mut CommonAcceptChannelFields, mut val: u64) {
1628 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
1630 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
1632 pub extern "C" fn CommonAcceptChannelFields_get_max_htlc_value_in_flight_msat(this_ptr: &CommonAcceptChannelFields) -> u64 {
1633 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
1636 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
1638 pub extern "C" fn CommonAcceptChannelFields_set_max_htlc_value_in_flight_msat(this_ptr: &mut CommonAcceptChannelFields, mut val: u64) {
1639 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
1641 /// The minimum HTLC size incoming to channel acceptor, in milli-satoshi
1643 pub extern "C" fn CommonAcceptChannelFields_get_htlc_minimum_msat(this_ptr: &CommonAcceptChannelFields) -> u64 {
1644 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
1647 /// The minimum HTLC size incoming to channel acceptor, in milli-satoshi
1649 pub extern "C" fn CommonAcceptChannelFields_set_htlc_minimum_msat(this_ptr: &mut CommonAcceptChannelFields, mut val: u64) {
1650 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
1652 /// Minimum depth of the funding transaction before the channel is considered open
1654 pub extern "C" fn CommonAcceptChannelFields_get_minimum_depth(this_ptr: &CommonAcceptChannelFields) -> u32 {
1655 let mut inner_val = &mut this_ptr.get_native_mut_ref().minimum_depth;
1658 /// Minimum depth of the funding transaction before the channel is considered open
1660 pub extern "C" fn CommonAcceptChannelFields_set_minimum_depth(this_ptr: &mut CommonAcceptChannelFields, mut val: u32) {
1661 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.minimum_depth = val;
1663 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1664 /// broadcast a commitment transaction
1666 pub extern "C" fn CommonAcceptChannelFields_get_to_self_delay(this_ptr: &CommonAcceptChannelFields) -> u16 {
1667 let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
1670 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1671 /// broadcast a commitment transaction
1673 pub extern "C" fn CommonAcceptChannelFields_set_to_self_delay(this_ptr: &mut CommonAcceptChannelFields, mut val: u16) {
1674 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
1676 /// The maximum number of inbound HTLCs towards channel acceptor
1678 pub extern "C" fn CommonAcceptChannelFields_get_max_accepted_htlcs(this_ptr: &CommonAcceptChannelFields) -> u16 {
1679 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
1682 /// The maximum number of inbound HTLCs towards channel acceptor
1684 pub extern "C" fn CommonAcceptChannelFields_set_max_accepted_htlcs(this_ptr: &mut CommonAcceptChannelFields, mut val: u16) {
1685 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
1687 /// The channel acceptor's key controlling the funding transaction
1689 pub extern "C" fn CommonAcceptChannelFields_get_funding_pubkey(this_ptr: &CommonAcceptChannelFields) -> crate::c_types::PublicKey {
1690 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
1691 crate::c_types::PublicKey::from_rust(&inner_val)
1693 /// The channel acceptor's key controlling the funding transaction
1695 pub extern "C" fn CommonAcceptChannelFields_set_funding_pubkey(this_ptr: &mut CommonAcceptChannelFields, mut val: crate::c_types::PublicKey) {
1696 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
1698 /// Used to derive a revocation key for transactions broadcast by counterparty
1700 pub extern "C" fn CommonAcceptChannelFields_get_revocation_basepoint(this_ptr: &CommonAcceptChannelFields) -> crate::c_types::PublicKey {
1701 let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
1702 crate::c_types::PublicKey::from_rust(&inner_val)
1704 /// Used to derive a revocation key for transactions broadcast by counterparty
1706 pub extern "C" fn CommonAcceptChannelFields_set_revocation_basepoint(this_ptr: &mut CommonAcceptChannelFields, mut val: crate::c_types::PublicKey) {
1707 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
1709 /// A payment key to channel acceptor for transactions broadcast by counterparty
1711 pub extern "C" fn CommonAcceptChannelFields_get_payment_basepoint(this_ptr: &CommonAcceptChannelFields) -> crate::c_types::PublicKey {
1712 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_basepoint;
1713 crate::c_types::PublicKey::from_rust(&inner_val)
1715 /// A payment key to channel acceptor for transactions broadcast by counterparty
1717 pub extern "C" fn CommonAcceptChannelFields_set_payment_basepoint(this_ptr: &mut CommonAcceptChannelFields, mut val: crate::c_types::PublicKey) {
1718 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_basepoint = val.into_rust();
1720 /// Used to derive a payment key to channel acceptor for transactions broadcast by channel
1723 pub extern "C" fn CommonAcceptChannelFields_get_delayed_payment_basepoint(this_ptr: &CommonAcceptChannelFields) -> crate::c_types::PublicKey {
1724 let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
1725 crate::c_types::PublicKey::from_rust(&inner_val)
1727 /// Used to derive a payment key to channel acceptor for transactions broadcast by channel
1730 pub extern "C" fn CommonAcceptChannelFields_set_delayed_payment_basepoint(this_ptr: &mut CommonAcceptChannelFields, mut val: crate::c_types::PublicKey) {
1731 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
1733 /// Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty
1735 pub extern "C" fn CommonAcceptChannelFields_get_htlc_basepoint(this_ptr: &CommonAcceptChannelFields) -> crate::c_types::PublicKey {
1736 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
1737 crate::c_types::PublicKey::from_rust(&inner_val)
1739 /// Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty
1741 pub extern "C" fn CommonAcceptChannelFields_set_htlc_basepoint(this_ptr: &mut CommonAcceptChannelFields, mut val: crate::c_types::PublicKey) {
1742 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
1744 /// The first to-be-broadcast-by-channel-acceptor transaction's per commitment point
1746 pub extern "C" fn CommonAcceptChannelFields_get_first_per_commitment_point(this_ptr: &CommonAcceptChannelFields) -> crate::c_types::PublicKey {
1747 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
1748 crate::c_types::PublicKey::from_rust(&inner_val)
1750 /// The first to-be-broadcast-by-channel-acceptor transaction's per commitment point
1752 pub extern "C" fn CommonAcceptChannelFields_set_first_per_commitment_point(this_ptr: &mut CommonAcceptChannelFields, mut val: crate::c_types::PublicKey) {
1753 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
1755 /// Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we
1756 /// collaboratively close
1758 pub extern "C" fn CommonAcceptChannelFields_get_shutdown_scriptpubkey(this_ptr: &CommonAcceptChannelFields) -> crate::c_types::derived::COption_CVec_u8ZZ {
1759 let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey;
1760 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().to_bytes().into() }) };
1763 /// Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we
1764 /// collaboratively close
1766 pub extern "C" fn CommonAcceptChannelFields_set_shutdown_scriptpubkey(this_ptr: &mut CommonAcceptChannelFields, mut val: crate::c_types::derived::COption_CVec_u8ZZ) {
1767 let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::ScriptBuf::from({ val_opt.take() }.into_rust()) }})} };
1768 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val;
1770 /// The channel type that this channel will represent. If none is set, we derive the channel
1771 /// type from the intersection of our feature bits with our counterparty's feature bits from
1772 /// the Init message.
1774 /// This is required to match the equivalent field in [`OpenChannel`] or [`OpenChannelV2`]'s
1775 /// [`CommonOpenChannelFields::channel_type`].
1777 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1779 pub extern "C" fn CommonAcceptChannelFields_get_channel_type(this_ptr: &CommonAcceptChannelFields) -> crate::lightning::ln::features::ChannelTypeFeatures {
1780 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1781 let mut local_inner_val = crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false };
1784 /// The channel type that this channel will represent. If none is set, we derive the channel
1785 /// type from the intersection of our feature bits with our counterparty's feature bits from
1786 /// the Init message.
1788 /// This is required to match the equivalent field in [`OpenChannel`] or [`OpenChannelV2`]'s
1789 /// [`CommonOpenChannelFields::channel_type`].
1791 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1793 pub extern "C" fn CommonAcceptChannelFields_set_channel_type(this_ptr: &mut CommonAcceptChannelFields, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1794 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1795 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1797 /// Constructs a new CommonAcceptChannelFields given each field
1799 /// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
1802 pub extern "C" fn CommonAcceptChannelFields_new(mut temporary_channel_id_arg: crate::lightning::ln::types::ChannelId, mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut htlc_minimum_msat_arg: u64, mut minimum_depth_arg: u32, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16, mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_basepoint_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey, mut first_per_commitment_point_arg: crate::c_types::PublicKey, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_CVec_u8ZZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures) -> CommonAcceptChannelFields {
1803 let mut local_shutdown_scriptpubkey_arg = { /*shutdown_scriptpubkey_arg*/ let shutdown_scriptpubkey_arg_opt = shutdown_scriptpubkey_arg; if shutdown_scriptpubkey_arg_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::ScriptBuf::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} };
1804 let mut local_channel_type_arg = if channel_type_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_type_arg.take_inner()) } }) };
1805 CommonAcceptChannelFields { inner: ObjOps::heap_alloc(nativeCommonAcceptChannelFields {
1806 temporary_channel_id: *unsafe { Box::from_raw(temporary_channel_id_arg.take_inner()) },
1807 dust_limit_satoshis: dust_limit_satoshis_arg,
1808 max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg,
1809 htlc_minimum_msat: htlc_minimum_msat_arg,
1810 minimum_depth: minimum_depth_arg,
1811 to_self_delay: to_self_delay_arg,
1812 max_accepted_htlcs: max_accepted_htlcs_arg,
1813 funding_pubkey: funding_pubkey_arg.into_rust(),
1814 revocation_basepoint: revocation_basepoint_arg.into_rust(),
1815 payment_basepoint: payment_basepoint_arg.into_rust(),
1816 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
1817 htlc_basepoint: htlc_basepoint_arg.into_rust(),
1818 first_per_commitment_point: first_per_commitment_point_arg.into_rust(),
1819 shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg,
1820 channel_type: local_channel_type_arg,
1821 }), is_owned: true }
1823 impl Clone for CommonAcceptChannelFields {
1824 fn clone(&self) -> Self {
1826 inner: if <*mut nativeCommonAcceptChannelFields>::is_null(self.inner) { core::ptr::null_mut() } else {
1827 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1833 /// Used only if an object of this type is returned as a trait impl by a method
1834 pub(crate) extern "C" fn CommonAcceptChannelFields_clone_void(this_ptr: *const c_void) -> *mut c_void {
1835 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeCommonAcceptChannelFields)).clone() })) as *mut c_void
1838 /// Creates a copy of the CommonAcceptChannelFields
1839 pub extern "C" fn CommonAcceptChannelFields_clone(orig: &CommonAcceptChannelFields) -> CommonAcceptChannelFields {
1842 /// Get a string which allows debug introspection of a CommonAcceptChannelFields object
1843 pub extern "C" fn CommonAcceptChannelFields_debug_str_void(o: *const c_void) -> Str {
1844 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::CommonAcceptChannelFields }).into()}
1845 /// Generates a non-cryptographic 64-bit hash of the CommonAcceptChannelFields.
1847 pub extern "C" fn CommonAcceptChannelFields_hash(o: &CommonAcceptChannelFields) -> u64 {
1848 if o.inner.is_null() { return 0; }
1849 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1850 #[allow(deprecated)]
1851 let mut hasher = core::hash::SipHasher::new();
1852 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1853 core::hash::Hasher::finish(&hasher)
1855 /// Checks if two CommonAcceptChannelFieldss contain equal inner contents.
1856 /// This ignores pointers and is_owned flags and looks at the values in fields.
1857 /// Two objects with NULL inner values will be considered "equal" here.
1859 pub extern "C" fn CommonAcceptChannelFields_eq(a: &CommonAcceptChannelFields, b: &CommonAcceptChannelFields) -> bool {
1860 if a.inner == b.inner { return true; }
1861 if a.inner.is_null() || b.inner.is_null() { return false; }
1862 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1865 use lightning::ln::msgs::AcceptChannel as nativeAcceptChannelImport;
1866 pub(crate) type nativeAcceptChannel = nativeAcceptChannelImport;
1868 /// An [`accept_channel`] message to be sent to or received from a peer.
1870 /// Used in V1 channel establishment
1872 /// [`accept_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-accept_channel-message
1875 pub struct AcceptChannel {
1876 /// A pointer to the opaque Rust object.
1878 /// Nearly everywhere, inner must be non-null, however in places where
1879 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1880 pub inner: *mut nativeAcceptChannel,
1881 /// Indicates that this is the only struct which contains the same pointer.
1883 /// Rust functions which take ownership of an object provided via an argument require
1884 /// this to be true and invalidate the object pointed to by inner.
1888 impl Drop for AcceptChannel {
1889 fn drop(&mut self) {
1890 if self.is_owned && !<*mut nativeAcceptChannel>::is_null(self.inner) {
1891 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1895 /// Frees any resources used by the AcceptChannel, if is_owned is set and inner is non-NULL.
1897 pub extern "C" fn AcceptChannel_free(this_obj: AcceptChannel) { }
1899 /// Used only if an object of this type is returned as a trait impl by a method
1900 pub(crate) extern "C" fn AcceptChannel_free_void(this_ptr: *mut c_void) {
1901 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAcceptChannel) };
1904 impl AcceptChannel {
1905 pub(crate) fn get_native_ref(&self) -> &'static nativeAcceptChannel {
1906 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1908 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAcceptChannel {
1909 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1911 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1912 pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannel {
1913 assert!(self.is_owned);
1914 let ret = ObjOps::untweak_ptr(self.inner);
1915 self.inner = core::ptr::null_mut();
1919 /// Common fields of `accept_channel(2)`-like messages
1921 pub extern "C" fn AcceptChannel_get_common_fields(this_ptr: &AcceptChannel) -> crate::lightning::ln::msgs::CommonAcceptChannelFields {
1922 let mut inner_val = &mut this_ptr.get_native_mut_ref().common_fields;
1923 crate::lightning::ln::msgs::CommonAcceptChannelFields { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::CommonAcceptChannelFields<>) as *mut _) }, is_owned: false }
1925 /// Common fields of `accept_channel(2)`-like messages
1927 pub extern "C" fn AcceptChannel_set_common_fields(this_ptr: &mut AcceptChannel, mut val: crate::lightning::ln::msgs::CommonAcceptChannelFields) {
1928 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.common_fields = *unsafe { Box::from_raw(val.take_inner()) };
1930 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1932 pub extern "C" fn AcceptChannel_get_channel_reserve_satoshis(this_ptr: &AcceptChannel) -> u64 {
1933 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
1936 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1938 pub extern "C" fn AcceptChannel_set_channel_reserve_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
1939 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
1941 /// Constructs a new AcceptChannel given each field
1944 pub extern "C" fn AcceptChannel_new(mut common_fields_arg: crate::lightning::ln::msgs::CommonAcceptChannelFields, mut channel_reserve_satoshis_arg: u64) -> AcceptChannel {
1945 AcceptChannel { inner: ObjOps::heap_alloc(nativeAcceptChannel {
1946 common_fields: *unsafe { Box::from_raw(common_fields_arg.take_inner()) },
1947 channel_reserve_satoshis: channel_reserve_satoshis_arg,
1948 }), is_owned: true }
1950 impl Clone for AcceptChannel {
1951 fn clone(&self) -> Self {
1953 inner: if <*mut nativeAcceptChannel>::is_null(self.inner) { core::ptr::null_mut() } else {
1954 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1960 /// Used only if an object of this type is returned as a trait impl by a method
1961 pub(crate) extern "C" fn AcceptChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
1962 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeAcceptChannel)).clone() })) as *mut c_void
1965 /// Creates a copy of the AcceptChannel
1966 pub extern "C" fn AcceptChannel_clone(orig: &AcceptChannel) -> AcceptChannel {
1969 /// Get a string which allows debug introspection of a AcceptChannel object
1970 pub extern "C" fn AcceptChannel_debug_str_void(o: *const c_void) -> Str {
1971 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::AcceptChannel }).into()}
1972 /// Generates a non-cryptographic 64-bit hash of the AcceptChannel.
1974 pub extern "C" fn AcceptChannel_hash(o: &AcceptChannel) -> u64 {
1975 if o.inner.is_null() { return 0; }
1976 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1977 #[allow(deprecated)]
1978 let mut hasher = core::hash::SipHasher::new();
1979 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1980 core::hash::Hasher::finish(&hasher)
1982 /// Checks if two AcceptChannels contain equal inner contents.
1983 /// This ignores pointers and is_owned flags and looks at the values in fields.
1984 /// Two objects with NULL inner values will be considered "equal" here.
1986 pub extern "C" fn AcceptChannel_eq(a: &AcceptChannel, b: &AcceptChannel) -> bool {
1987 if a.inner == b.inner { return true; }
1988 if a.inner.is_null() || b.inner.is_null() { return false; }
1989 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1992 use lightning::ln::msgs::AcceptChannelV2 as nativeAcceptChannelV2Import;
1993 pub(crate) type nativeAcceptChannelV2 = nativeAcceptChannelV2Import;
1995 /// An accept_channel2 message to be sent by or received from the channel accepter.
1997 /// Used in V2 channel establishment
2001 pub struct AcceptChannelV2 {
2002 /// A pointer to the opaque Rust object.
2004 /// Nearly everywhere, inner must be non-null, however in places where
2005 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2006 pub inner: *mut nativeAcceptChannelV2,
2007 /// Indicates that this is the only struct which contains the same pointer.
2009 /// Rust functions which take ownership of an object provided via an argument require
2010 /// this to be true and invalidate the object pointed to by inner.
2014 impl Drop for AcceptChannelV2 {
2015 fn drop(&mut self) {
2016 if self.is_owned && !<*mut nativeAcceptChannelV2>::is_null(self.inner) {
2017 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2021 /// Frees any resources used by the AcceptChannelV2, if is_owned is set and inner is non-NULL.
2023 pub extern "C" fn AcceptChannelV2_free(this_obj: AcceptChannelV2) { }
2025 /// Used only if an object of this type is returned as a trait impl by a method
2026 pub(crate) extern "C" fn AcceptChannelV2_free_void(this_ptr: *mut c_void) {
2027 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAcceptChannelV2) };
2030 impl AcceptChannelV2 {
2031 pub(crate) fn get_native_ref(&self) -> &'static nativeAcceptChannelV2 {
2032 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2034 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAcceptChannelV2 {
2035 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2037 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2038 pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannelV2 {
2039 assert!(self.is_owned);
2040 let ret = ObjOps::untweak_ptr(self.inner);
2041 self.inner = core::ptr::null_mut();
2045 /// Common fields of `accept_channel(2)`-like messages
2047 pub extern "C" fn AcceptChannelV2_get_common_fields(this_ptr: &AcceptChannelV2) -> crate::lightning::ln::msgs::CommonAcceptChannelFields {
2048 let mut inner_val = &mut this_ptr.get_native_mut_ref().common_fields;
2049 crate::lightning::ln::msgs::CommonAcceptChannelFields { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::CommonAcceptChannelFields<>) as *mut _) }, is_owned: false }
2051 /// Common fields of `accept_channel(2)`-like messages
2053 pub extern "C" fn AcceptChannelV2_set_common_fields(this_ptr: &mut AcceptChannelV2, mut val: crate::lightning::ln::msgs::CommonAcceptChannelFields) {
2054 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.common_fields = *unsafe { Box::from_raw(val.take_inner()) };
2056 /// Part of the channel value contributed by the channel acceptor
2058 pub extern "C" fn AcceptChannelV2_get_funding_satoshis(this_ptr: &AcceptChannelV2) -> u64 {
2059 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
2062 /// Part of the channel value contributed by the channel acceptor
2064 pub extern "C" fn AcceptChannelV2_set_funding_satoshis(this_ptr: &mut AcceptChannelV2, mut val: u64) {
2065 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
2067 /// The second to-be-broadcast-by-channel-acceptor transaction's per commitment point
2069 pub extern "C" fn AcceptChannelV2_get_second_per_commitment_point(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2070 let mut inner_val = &mut this_ptr.get_native_mut_ref().second_per_commitment_point;
2071 crate::c_types::PublicKey::from_rust(&inner_val)
2073 /// The second to-be-broadcast-by-channel-acceptor transaction's per commitment point
2075 pub extern "C" fn AcceptChannelV2_set_second_per_commitment_point(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2076 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.second_per_commitment_point = val.into_rust();
2078 /// Optionally, a requirement that only confirmed inputs can be added
2080 pub extern "C" fn AcceptChannelV2_get_require_confirmed_inputs(this_ptr: &AcceptChannelV2) -> crate::c_types::derived::COption_NoneZ {
2081 let mut inner_val = &mut this_ptr.get_native_mut_ref().require_confirmed_inputs;
2082 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_NoneZ::None } else { crate::c_types::derived::COption_NoneZ::Some /* { () /**/ } */ };
2085 /// Optionally, a requirement that only confirmed inputs can be added
2087 pub extern "C" fn AcceptChannelV2_set_require_confirmed_inputs(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::derived::COption_NoneZ) {
2088 let mut local_val = if val.is_some() { Some( { () /*val.take()*/ }) } else { None };
2089 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.require_confirmed_inputs = local_val;
2091 /// Constructs a new AcceptChannelV2 given each field
2094 pub extern "C" fn AcceptChannelV2_new(mut common_fields_arg: crate::lightning::ln::msgs::CommonAcceptChannelFields, mut funding_satoshis_arg: u64, mut second_per_commitment_point_arg: crate::c_types::PublicKey, mut require_confirmed_inputs_arg: crate::c_types::derived::COption_NoneZ) -> AcceptChannelV2 {
2095 let mut local_require_confirmed_inputs_arg = if require_confirmed_inputs_arg.is_some() { Some( { () /*require_confirmed_inputs_arg.take()*/ }) } else { None };
2096 AcceptChannelV2 { inner: ObjOps::heap_alloc(nativeAcceptChannelV2 {
2097 common_fields: *unsafe { Box::from_raw(common_fields_arg.take_inner()) },
2098 funding_satoshis: funding_satoshis_arg,
2099 second_per_commitment_point: second_per_commitment_point_arg.into_rust(),
2100 require_confirmed_inputs: local_require_confirmed_inputs_arg,
2101 }), is_owned: true }
2103 impl Clone for AcceptChannelV2 {
2104 fn clone(&self) -> Self {
2106 inner: if <*mut nativeAcceptChannelV2>::is_null(self.inner) { core::ptr::null_mut() } else {
2107 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2113 /// Used only if an object of this type is returned as a trait impl by a method
2114 pub(crate) extern "C" fn AcceptChannelV2_clone_void(this_ptr: *const c_void) -> *mut c_void {
2115 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeAcceptChannelV2)).clone() })) as *mut c_void
2118 /// Creates a copy of the AcceptChannelV2
2119 pub extern "C" fn AcceptChannelV2_clone(orig: &AcceptChannelV2) -> AcceptChannelV2 {
2122 /// Get a string which allows debug introspection of a AcceptChannelV2 object
2123 pub extern "C" fn AcceptChannelV2_debug_str_void(o: *const c_void) -> Str {
2124 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::AcceptChannelV2 }).into()}
2125 /// Generates a non-cryptographic 64-bit hash of the AcceptChannelV2.
2127 pub extern "C" fn AcceptChannelV2_hash(o: &AcceptChannelV2) -> u64 {
2128 if o.inner.is_null() { return 0; }
2129 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
2130 #[allow(deprecated)]
2131 let mut hasher = core::hash::SipHasher::new();
2132 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
2133 core::hash::Hasher::finish(&hasher)
2135 /// Checks if two AcceptChannelV2s contain equal inner contents.
2136 /// This ignores pointers and is_owned flags and looks at the values in fields.
2137 /// Two objects with NULL inner values will be considered "equal" here.
2139 pub extern "C" fn AcceptChannelV2_eq(a: &AcceptChannelV2, b: &AcceptChannelV2) -> bool {
2140 if a.inner == b.inner { return true; }
2141 if a.inner.is_null() || b.inner.is_null() { return false; }
2142 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2145 use lightning::ln::msgs::FundingCreated as nativeFundingCreatedImport;
2146 pub(crate) type nativeFundingCreated = nativeFundingCreatedImport;
2148 /// A [`funding_created`] message to be sent to or received from a peer.
2150 /// Used in V1 channel establishment
2152 /// [`funding_created`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_created-message
2155 pub struct FundingCreated {
2156 /// A pointer to the opaque Rust object.
2158 /// Nearly everywhere, inner must be non-null, however in places where
2159 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2160 pub inner: *mut nativeFundingCreated,
2161 /// Indicates that this is the only struct which contains the same pointer.
2163 /// Rust functions which take ownership of an object provided via an argument require
2164 /// this to be true and invalidate the object pointed to by inner.
2168 impl Drop for FundingCreated {
2169 fn drop(&mut self) {
2170 if self.is_owned && !<*mut nativeFundingCreated>::is_null(self.inner) {
2171 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2175 /// Frees any resources used by the FundingCreated, if is_owned is set and inner is non-NULL.
2177 pub extern "C" fn FundingCreated_free(this_obj: FundingCreated) { }
2179 /// Used only if an object of this type is returned as a trait impl by a method
2180 pub(crate) extern "C" fn FundingCreated_free_void(this_ptr: *mut c_void) {
2181 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeFundingCreated) };
2184 impl FundingCreated {
2185 pub(crate) fn get_native_ref(&self) -> &'static nativeFundingCreated {
2186 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2188 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingCreated {
2189 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2191 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2192 pub(crate) fn take_inner(mut self) -> *mut nativeFundingCreated {
2193 assert!(self.is_owned);
2194 let ret = ObjOps::untweak_ptr(self.inner);
2195 self.inner = core::ptr::null_mut();
2199 /// A temporary channel ID, until the funding is established
2201 pub extern "C" fn FundingCreated_get_temporary_channel_id(this_ptr: &FundingCreated) -> crate::lightning::ln::types::ChannelId {
2202 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
2203 crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
2205 /// A temporary channel ID, until the funding is established
2207 pub extern "C" fn FundingCreated_set_temporary_channel_id(this_ptr: &mut FundingCreated, mut val: crate::lightning::ln::types::ChannelId) {
2208 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = *unsafe { Box::from_raw(val.take_inner()) };
2210 /// The funding transaction ID
2212 pub extern "C" fn FundingCreated_get_funding_txid(this_ptr: &FundingCreated) -> *const [u8; 32] {
2213 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_txid;
2216 /// The funding transaction ID
2218 pub extern "C" fn FundingCreated_set_funding_txid(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
2219 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_txid = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
2221 /// The specific output index funding this channel
2223 pub extern "C" fn FundingCreated_get_funding_output_index(this_ptr: &FundingCreated) -> u16 {
2224 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_index;
2227 /// The specific output index funding this channel
2229 pub extern "C" fn FundingCreated_set_funding_output_index(this_ptr: &mut FundingCreated, mut val: u16) {
2230 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_index = val;
2232 /// The signature of the channel initiator (funder) on the initial commitment transaction
2234 pub extern "C" fn FundingCreated_get_signature(this_ptr: &FundingCreated) -> crate::c_types::ECDSASignature {
2235 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
2236 crate::c_types::ECDSASignature::from_rust(&inner_val)
2238 /// The signature of the channel initiator (funder) on the initial commitment transaction
2240 pub extern "C" fn FundingCreated_set_signature(this_ptr: &mut FundingCreated, mut val: crate::c_types::ECDSASignature) {
2241 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
2243 /// Constructs a new FundingCreated given each field
2246 pub extern "C" fn FundingCreated_new(mut temporary_channel_id_arg: crate::lightning::ln::types::ChannelId, mut funding_txid_arg: crate::c_types::ThirtyTwoBytes, mut funding_output_index_arg: u16, mut signature_arg: crate::c_types::ECDSASignature) -> FundingCreated {
2247 FundingCreated { inner: ObjOps::heap_alloc(nativeFundingCreated {
2248 temporary_channel_id: *unsafe { Box::from_raw(temporary_channel_id_arg.take_inner()) },
2249 funding_txid: ::bitcoin::hash_types::Txid::from_slice(&funding_txid_arg.data[..]).unwrap(),
2250 funding_output_index: funding_output_index_arg,
2251 signature: signature_arg.into_rust(),
2252 }), is_owned: true }
2254 impl Clone for FundingCreated {
2255 fn clone(&self) -> Self {
2257 inner: if <*mut nativeFundingCreated>::is_null(self.inner) { core::ptr::null_mut() } else {
2258 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2264 /// Used only if an object of this type is returned as a trait impl by a method
2265 pub(crate) extern "C" fn FundingCreated_clone_void(this_ptr: *const c_void) -> *mut c_void {
2266 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeFundingCreated)).clone() })) as *mut c_void
2269 /// Creates a copy of the FundingCreated
2270 pub extern "C" fn FundingCreated_clone(orig: &FundingCreated) -> FundingCreated {
2273 /// Get a string which allows debug introspection of a FundingCreated object
2274 pub extern "C" fn FundingCreated_debug_str_void(o: *const c_void) -> Str {
2275 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::FundingCreated }).into()}
2276 /// Generates a non-cryptographic 64-bit hash of the FundingCreated.
2278 pub extern "C" fn FundingCreated_hash(o: &FundingCreated) -> u64 {
2279 if o.inner.is_null() { return 0; }
2280 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
2281 #[allow(deprecated)]
2282 let mut hasher = core::hash::SipHasher::new();
2283 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
2284 core::hash::Hasher::finish(&hasher)
2286 /// Checks if two FundingCreateds contain equal inner contents.
2287 /// This ignores pointers and is_owned flags and looks at the values in fields.
2288 /// Two objects with NULL inner values will be considered "equal" here.
2290 pub extern "C" fn FundingCreated_eq(a: &FundingCreated, b: &FundingCreated) -> bool {
2291 if a.inner == b.inner { return true; }
2292 if a.inner.is_null() || b.inner.is_null() { return false; }
2293 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2296 use lightning::ln::msgs::FundingSigned as nativeFundingSignedImport;
2297 pub(crate) type nativeFundingSigned = nativeFundingSignedImport;
2299 /// A [`funding_signed`] message to be sent to or received from a peer.
2301 /// Used in V1 channel establishment
2303 /// [`funding_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_signed-message
2306 pub struct FundingSigned {
2307 /// A pointer to the opaque Rust object.
2309 /// Nearly everywhere, inner must be non-null, however in places where
2310 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2311 pub inner: *mut nativeFundingSigned,
2312 /// Indicates that this is the only struct which contains the same pointer.
2314 /// Rust functions which take ownership of an object provided via an argument require
2315 /// this to be true and invalidate the object pointed to by inner.
2319 impl Drop for FundingSigned {
2320 fn drop(&mut self) {
2321 if self.is_owned && !<*mut nativeFundingSigned>::is_null(self.inner) {
2322 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2326 /// Frees any resources used by the FundingSigned, if is_owned is set and inner is non-NULL.
2328 pub extern "C" fn FundingSigned_free(this_obj: FundingSigned) { }
2330 /// Used only if an object of this type is returned as a trait impl by a method
2331 pub(crate) extern "C" fn FundingSigned_free_void(this_ptr: *mut c_void) {
2332 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeFundingSigned) };
2335 impl FundingSigned {
2336 pub(crate) fn get_native_ref(&self) -> &'static nativeFundingSigned {
2337 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2339 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingSigned {
2340 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2342 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2343 pub(crate) fn take_inner(mut self) -> *mut nativeFundingSigned {
2344 assert!(self.is_owned);
2345 let ret = ObjOps::untweak_ptr(self.inner);
2346 self.inner = core::ptr::null_mut();
2352 pub extern "C" fn FundingSigned_get_channel_id(this_ptr: &FundingSigned) -> crate::lightning::ln::types::ChannelId {
2353 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2354 crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
2358 pub extern "C" fn FundingSigned_set_channel_id(this_ptr: &mut FundingSigned, mut val: crate::lightning::ln::types::ChannelId) {
2359 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
2361 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
2363 pub extern "C" fn FundingSigned_get_signature(this_ptr: &FundingSigned) -> crate::c_types::ECDSASignature {
2364 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
2365 crate::c_types::ECDSASignature::from_rust(&inner_val)
2367 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
2369 pub extern "C" fn FundingSigned_set_signature(this_ptr: &mut FundingSigned, mut val: crate::c_types::ECDSASignature) {
2370 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
2372 /// Constructs a new FundingSigned given each field
2375 pub extern "C" fn FundingSigned_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut signature_arg: crate::c_types::ECDSASignature) -> FundingSigned {
2376 FundingSigned { inner: ObjOps::heap_alloc(nativeFundingSigned {
2377 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
2378 signature: signature_arg.into_rust(),
2379 }), is_owned: true }
2381 impl Clone for FundingSigned {
2382 fn clone(&self) -> Self {
2384 inner: if <*mut nativeFundingSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
2385 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2391 /// Used only if an object of this type is returned as a trait impl by a method
2392 pub(crate) extern "C" fn FundingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
2393 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeFundingSigned)).clone() })) as *mut c_void
2396 /// Creates a copy of the FundingSigned
2397 pub extern "C" fn FundingSigned_clone(orig: &FundingSigned) -> FundingSigned {
2400 /// Get a string which allows debug introspection of a FundingSigned object
2401 pub extern "C" fn FundingSigned_debug_str_void(o: *const c_void) -> Str {
2402 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::FundingSigned }).into()}
2403 /// Generates a non-cryptographic 64-bit hash of the FundingSigned.
2405 pub extern "C" fn FundingSigned_hash(o: &FundingSigned) -> u64 {
2406 if o.inner.is_null() { return 0; }
2407 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
2408 #[allow(deprecated)]
2409 let mut hasher = core::hash::SipHasher::new();
2410 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
2411 core::hash::Hasher::finish(&hasher)
2413 /// Checks if two FundingSigneds contain equal inner contents.
2414 /// This ignores pointers and is_owned flags and looks at the values in fields.
2415 /// Two objects with NULL inner values will be considered "equal" here.
2417 pub extern "C" fn FundingSigned_eq(a: &FundingSigned, b: &FundingSigned) -> bool {
2418 if a.inner == b.inner { return true; }
2419 if a.inner.is_null() || b.inner.is_null() { return false; }
2420 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2423 use lightning::ln::msgs::ChannelReady as nativeChannelReadyImport;
2424 pub(crate) type nativeChannelReady = nativeChannelReadyImport;
2426 /// A [`channel_ready`] message to be sent to or received from a peer.
2428 /// [`channel_ready`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-channel_ready-message
2431 pub struct ChannelReady {
2432 /// A pointer to the opaque Rust object.
2434 /// Nearly everywhere, inner must be non-null, however in places where
2435 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2436 pub inner: *mut nativeChannelReady,
2437 /// Indicates that this is the only struct which contains the same pointer.
2439 /// Rust functions which take ownership of an object provided via an argument require
2440 /// this to be true and invalidate the object pointed to by inner.
2444 impl Drop for ChannelReady {
2445 fn drop(&mut self) {
2446 if self.is_owned && !<*mut nativeChannelReady>::is_null(self.inner) {
2447 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2451 /// Frees any resources used by the ChannelReady, if is_owned is set and inner is non-NULL.
2453 pub extern "C" fn ChannelReady_free(this_obj: ChannelReady) { }
2455 /// Used only if an object of this type is returned as a trait impl by a method
2456 pub(crate) extern "C" fn ChannelReady_free_void(this_ptr: *mut c_void) {
2457 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelReady) };
2461 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelReady {
2462 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2464 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelReady {
2465 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2467 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2468 pub(crate) fn take_inner(mut self) -> *mut nativeChannelReady {
2469 assert!(self.is_owned);
2470 let ret = ObjOps::untweak_ptr(self.inner);
2471 self.inner = core::ptr::null_mut();
2477 pub extern "C" fn ChannelReady_get_channel_id(this_ptr: &ChannelReady) -> crate::lightning::ln::types::ChannelId {
2478 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2479 crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
2483 pub extern "C" fn ChannelReady_set_channel_id(this_ptr: &mut ChannelReady, mut val: crate::lightning::ln::types::ChannelId) {
2484 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
2486 /// The per-commitment point of the second commitment transaction
2488 pub extern "C" fn ChannelReady_get_next_per_commitment_point(this_ptr: &ChannelReady) -> crate::c_types::PublicKey {
2489 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
2490 crate::c_types::PublicKey::from_rust(&inner_val)
2492 /// The per-commitment point of the second commitment transaction
2494 pub extern "C" fn ChannelReady_set_next_per_commitment_point(this_ptr: &mut ChannelReady, mut val: crate::c_types::PublicKey) {
2495 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
2497 /// If set, provides a `short_channel_id` alias for this channel.
2499 /// The sender will accept payments to be forwarded over this SCID and forward them to this
2500 /// messages' recipient.
2502 pub extern "C" fn ChannelReady_get_short_channel_id_alias(this_ptr: &ChannelReady) -> crate::c_types::derived::COption_u64Z {
2503 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id_alias;
2504 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) };
2507 /// If set, provides a `short_channel_id` alias for this channel.
2509 /// The sender will accept payments to be forwarded over this SCID and forward them to this
2510 /// messages' recipient.
2512 pub extern "C" fn ChannelReady_set_short_channel_id_alias(this_ptr: &mut ChannelReady, mut val: crate::c_types::derived::COption_u64Z) {
2513 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
2514 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id_alias = local_val;
2516 /// Constructs a new ChannelReady given each field
2519 pub extern "C" fn ChannelReady_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut next_per_commitment_point_arg: crate::c_types::PublicKey, mut short_channel_id_alias_arg: crate::c_types::derived::COption_u64Z) -> ChannelReady {
2520 let mut local_short_channel_id_alias_arg = if short_channel_id_alias_arg.is_some() { Some( { short_channel_id_alias_arg.take() }) } else { None };
2521 ChannelReady { inner: ObjOps::heap_alloc(nativeChannelReady {
2522 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
2523 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
2524 short_channel_id_alias: local_short_channel_id_alias_arg,
2525 }), is_owned: true }
2527 impl Clone for ChannelReady {
2528 fn clone(&self) -> Self {
2530 inner: if <*mut nativeChannelReady>::is_null(self.inner) { core::ptr::null_mut() } else {
2531 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2537 /// Used only if an object of this type is returned as a trait impl by a method
2538 pub(crate) extern "C" fn ChannelReady_clone_void(this_ptr: *const c_void) -> *mut c_void {
2539 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelReady)).clone() })) as *mut c_void
2542 /// Creates a copy of the ChannelReady
2543 pub extern "C" fn ChannelReady_clone(orig: &ChannelReady) -> ChannelReady {
2546 /// Get a string which allows debug introspection of a ChannelReady object
2547 pub extern "C" fn ChannelReady_debug_str_void(o: *const c_void) -> Str {
2548 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ChannelReady }).into()}
2549 /// Generates a non-cryptographic 64-bit hash of the ChannelReady.
2551 pub extern "C" fn ChannelReady_hash(o: &ChannelReady) -> u64 {
2552 if o.inner.is_null() { return 0; }
2553 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
2554 #[allow(deprecated)]
2555 let mut hasher = core::hash::SipHasher::new();
2556 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
2557 core::hash::Hasher::finish(&hasher)
2559 /// Checks if two ChannelReadys contain equal inner contents.
2560 /// This ignores pointers and is_owned flags and looks at the values in fields.
2561 /// Two objects with NULL inner values will be considered "equal" here.
2563 pub extern "C" fn ChannelReady_eq(a: &ChannelReady, b: &ChannelReady) -> bool {
2564 if a.inner == b.inner { return true; }
2565 if a.inner.is_null() || b.inner.is_null() { return false; }
2566 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2569 use lightning::ln::msgs::Stfu as nativeStfuImport;
2570 pub(crate) type nativeStfu = nativeStfuImport;
2572 /// An stfu (quiescence) message to be sent by or received from the stfu initiator.
2576 /// A pointer to the opaque Rust object.
2578 /// Nearly everywhere, inner must be non-null, however in places where
2579 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2580 pub inner: *mut nativeStfu,
2581 /// Indicates that this is the only struct which contains the same pointer.
2583 /// Rust functions which take ownership of an object provided via an argument require
2584 /// this to be true and invalidate the object pointed to by inner.
2588 impl Drop for Stfu {
2589 fn drop(&mut self) {
2590 if self.is_owned && !<*mut nativeStfu>::is_null(self.inner) {
2591 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2595 /// Frees any resources used by the Stfu, if is_owned is set and inner is non-NULL.
2597 pub extern "C" fn Stfu_free(this_obj: Stfu) { }
2599 /// Used only if an object of this type is returned as a trait impl by a method
2600 pub(crate) extern "C" fn Stfu_free_void(this_ptr: *mut c_void) {
2601 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeStfu) };
2605 pub(crate) fn get_native_ref(&self) -> &'static nativeStfu {
2606 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2608 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeStfu {
2609 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2611 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2612 pub(crate) fn take_inner(mut self) -> *mut nativeStfu {
2613 assert!(self.is_owned);
2614 let ret = ObjOps::untweak_ptr(self.inner);
2615 self.inner = core::ptr::null_mut();
2619 /// The channel ID where quiescence is intended
2621 pub extern "C" fn Stfu_get_channel_id(this_ptr: &Stfu) -> crate::lightning::ln::types::ChannelId {
2622 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2623 crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
2625 /// The channel ID where quiescence is intended
2627 pub extern "C" fn Stfu_set_channel_id(this_ptr: &mut Stfu, mut val: crate::lightning::ln::types::ChannelId) {
2628 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
2630 /// Initiator flag, 1 if initiating, 0 if replying to an stfu.
2632 pub extern "C" fn Stfu_get_initiator(this_ptr: &Stfu) -> u8 {
2633 let mut inner_val = &mut this_ptr.get_native_mut_ref().initiator;
2636 /// Initiator flag, 1 if initiating, 0 if replying to an stfu.
2638 pub extern "C" fn Stfu_set_initiator(this_ptr: &mut Stfu, mut val: u8) {
2639 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.initiator = val;
2641 /// Constructs a new Stfu given each field
2644 pub extern "C" fn Stfu_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut initiator_arg: u8) -> Stfu {
2645 Stfu { inner: ObjOps::heap_alloc(nativeStfu {
2646 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
2647 initiator: initiator_arg,
2648 }), is_owned: true }
2650 impl Clone for Stfu {
2651 fn clone(&self) -> Self {
2653 inner: if <*mut nativeStfu>::is_null(self.inner) { core::ptr::null_mut() } else {
2654 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2660 /// Used only if an object of this type is returned as a trait impl by a method
2661 pub(crate) extern "C" fn Stfu_clone_void(this_ptr: *const c_void) -> *mut c_void {
2662 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeStfu)).clone() })) as *mut c_void
2665 /// Creates a copy of the Stfu
2666 pub extern "C" fn Stfu_clone(orig: &Stfu) -> Stfu {
2669 /// Get a string which allows debug introspection of a Stfu object
2670 pub extern "C" fn Stfu_debug_str_void(o: *const c_void) -> Str {
2671 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::Stfu }).into()}
2672 /// Checks if two Stfus contain equal inner contents.
2673 /// This ignores pointers and is_owned flags and looks at the values in fields.
2674 /// Two objects with NULL inner values will be considered "equal" here.
2676 pub extern "C" fn Stfu_eq(a: &Stfu, b: &Stfu) -> bool {
2677 if a.inner == b.inner { return true; }
2678 if a.inner.is_null() || b.inner.is_null() { return false; }
2679 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2682 use lightning::ln::msgs::Splice as nativeSpliceImport;
2683 pub(crate) type nativeSplice = nativeSpliceImport;
2685 /// A splice message to be sent by or received from the stfu initiator (splice initiator).
2689 /// A pointer to the opaque Rust object.
2691 /// Nearly everywhere, inner must be non-null, however in places where
2692 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2693 pub inner: *mut nativeSplice,
2694 /// Indicates that this is the only struct which contains the same pointer.
2696 /// Rust functions which take ownership of an object provided via an argument require
2697 /// this to be true and invalidate the object pointed to by inner.
2701 impl Drop for Splice {
2702 fn drop(&mut self) {
2703 if self.is_owned && !<*mut nativeSplice>::is_null(self.inner) {
2704 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2708 /// Frees any resources used by the Splice, if is_owned is set and inner is non-NULL.
2710 pub extern "C" fn Splice_free(this_obj: Splice) { }
2712 /// Used only if an object of this type is returned as a trait impl by a method
2713 pub(crate) extern "C" fn Splice_free_void(this_ptr: *mut c_void) {
2714 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeSplice) };
2718 pub(crate) fn get_native_ref(&self) -> &'static nativeSplice {
2719 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2721 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeSplice {
2722 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2724 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2725 pub(crate) fn take_inner(mut self) -> *mut nativeSplice {
2726 assert!(self.is_owned);
2727 let ret = ObjOps::untweak_ptr(self.inner);
2728 self.inner = core::ptr::null_mut();
2732 /// The channel ID where splicing is intended
2734 pub extern "C" fn Splice_get_channel_id(this_ptr: &Splice) -> crate::lightning::ln::types::ChannelId {
2735 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2736 crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
2738 /// The channel ID where splicing is intended
2740 pub extern "C" fn Splice_set_channel_id(this_ptr: &mut Splice, mut val: crate::lightning::ln::types::ChannelId) {
2741 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
2743 /// The genesis hash of the blockchain where the channel is intended to be spliced
2745 pub extern "C" fn Splice_get_chain_hash(this_ptr: &Splice) -> *const [u8; 32] {
2746 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
2749 /// The genesis hash of the blockchain where the channel is intended to be spliced
2751 pub extern "C" fn Splice_set_chain_hash(this_ptr: &mut Splice, mut val: crate::c_types::ThirtyTwoBytes) {
2752 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
2754 /// The intended change in channel capacity: the amount to be added (positive value)
2755 /// or removed (negative value) by the sender (splice initiator) by splicing into/from the channel.
2757 pub extern "C" fn Splice_get_relative_satoshis(this_ptr: &Splice) -> i64 {
2758 let mut inner_val = &mut this_ptr.get_native_mut_ref().relative_satoshis;
2761 /// The intended change in channel capacity: the amount to be added (positive value)
2762 /// or removed (negative value) by the sender (splice initiator) by splicing into/from the channel.
2764 pub extern "C" fn Splice_set_relative_satoshis(this_ptr: &mut Splice, mut val: i64) {
2765 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.relative_satoshis = val;
2767 /// The feerate for the new funding transaction, set by the splice initiator
2769 pub extern "C" fn Splice_get_funding_feerate_perkw(this_ptr: &Splice) -> u32 {
2770 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_feerate_perkw;
2773 /// The feerate for the new funding transaction, set by the splice initiator
2775 pub extern "C" fn Splice_set_funding_feerate_perkw(this_ptr: &mut Splice, mut val: u32) {
2776 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_feerate_perkw = val;
2778 /// The locktime for the new funding transaction
2780 pub extern "C" fn Splice_get_locktime(this_ptr: &Splice) -> u32 {
2781 let mut inner_val = &mut this_ptr.get_native_mut_ref().locktime;
2784 /// The locktime for the new funding transaction
2786 pub extern "C" fn Splice_set_locktime(this_ptr: &mut Splice, mut val: u32) {
2787 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.locktime = val;
2789 /// The key of the sender (splice initiator) controlling the new funding transaction
2791 pub extern "C" fn Splice_get_funding_pubkey(this_ptr: &Splice) -> crate::c_types::PublicKey {
2792 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
2793 crate::c_types::PublicKey::from_rust(&inner_val)
2795 /// The key of the sender (splice initiator) controlling the new funding transaction
2797 pub extern "C" fn Splice_set_funding_pubkey(this_ptr: &mut Splice, mut val: crate::c_types::PublicKey) {
2798 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
2800 /// Constructs a new Splice given each field
2803 pub extern "C" fn Splice_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut relative_satoshis_arg: i64, mut funding_feerate_perkw_arg: u32, mut locktime_arg: u32, mut funding_pubkey_arg: crate::c_types::PublicKey) -> Splice {
2804 Splice { inner: ObjOps::heap_alloc(nativeSplice {
2805 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
2806 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
2807 relative_satoshis: relative_satoshis_arg,
2808 funding_feerate_perkw: funding_feerate_perkw_arg,
2809 locktime: locktime_arg,
2810 funding_pubkey: funding_pubkey_arg.into_rust(),
2811 }), is_owned: true }
2813 impl Clone for Splice {
2814 fn clone(&self) -> Self {
2816 inner: if <*mut nativeSplice>::is_null(self.inner) { core::ptr::null_mut() } else {
2817 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2823 /// Used only if an object of this type is returned as a trait impl by a method
2824 pub(crate) extern "C" fn Splice_clone_void(this_ptr: *const c_void) -> *mut c_void {
2825 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeSplice)).clone() })) as *mut c_void
2828 /// Creates a copy of the Splice
2829 pub extern "C" fn Splice_clone(orig: &Splice) -> Splice {
2832 /// Get a string which allows debug introspection of a Splice object
2833 pub extern "C" fn Splice_debug_str_void(o: *const c_void) -> Str {
2834 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::Splice }).into()}
2835 /// Checks if two Splices contain equal inner contents.
2836 /// This ignores pointers and is_owned flags and looks at the values in fields.
2837 /// Two objects with NULL inner values will be considered "equal" here.
2839 pub extern "C" fn Splice_eq(a: &Splice, b: &Splice) -> bool {
2840 if a.inner == b.inner { return true; }
2841 if a.inner.is_null() || b.inner.is_null() { return false; }
2842 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2845 use lightning::ln::msgs::SpliceAck as nativeSpliceAckImport;
2846 pub(crate) type nativeSpliceAck = nativeSpliceAckImport;
2848 /// A splice_ack message to be received by or sent to the splice initiator.
2852 pub struct SpliceAck {
2853 /// A pointer to the opaque Rust object.
2855 /// Nearly everywhere, inner must be non-null, however in places where
2856 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2857 pub inner: *mut nativeSpliceAck,
2858 /// Indicates that this is the only struct which contains the same pointer.
2860 /// Rust functions which take ownership of an object provided via an argument require
2861 /// this to be true and invalidate the object pointed to by inner.
2865 impl Drop for SpliceAck {
2866 fn drop(&mut self) {
2867 if self.is_owned && !<*mut nativeSpliceAck>::is_null(self.inner) {
2868 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2872 /// Frees any resources used by the SpliceAck, if is_owned is set and inner is non-NULL.
2874 pub extern "C" fn SpliceAck_free(this_obj: SpliceAck) { }
2876 /// Used only if an object of this type is returned as a trait impl by a method
2877 pub(crate) extern "C" fn SpliceAck_free_void(this_ptr: *mut c_void) {
2878 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeSpliceAck) };
2882 pub(crate) fn get_native_ref(&self) -> &'static nativeSpliceAck {
2883 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2885 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeSpliceAck {
2886 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2888 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2889 pub(crate) fn take_inner(mut self) -> *mut nativeSpliceAck {
2890 assert!(self.is_owned);
2891 let ret = ObjOps::untweak_ptr(self.inner);
2892 self.inner = core::ptr::null_mut();
2896 /// The channel ID where splicing is intended
2898 pub extern "C" fn SpliceAck_get_channel_id(this_ptr: &SpliceAck) -> crate::lightning::ln::types::ChannelId {
2899 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2900 crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
2902 /// The channel ID where splicing is intended
2904 pub extern "C" fn SpliceAck_set_channel_id(this_ptr: &mut SpliceAck, mut val: crate::lightning::ln::types::ChannelId) {
2905 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
2907 /// The genesis hash of the blockchain where the channel is intended to be spliced
2909 pub extern "C" fn SpliceAck_get_chain_hash(this_ptr: &SpliceAck) -> *const [u8; 32] {
2910 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
2913 /// The genesis hash of the blockchain where the channel is intended to be spliced
2915 pub extern "C" fn SpliceAck_set_chain_hash(this_ptr: &mut SpliceAck, mut val: crate::c_types::ThirtyTwoBytes) {
2916 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
2918 /// The intended change in channel capacity: the amount to be added (positive value)
2919 /// or removed (negative value) by the sender (splice acceptor) by splicing into/from the channel.
2921 pub extern "C" fn SpliceAck_get_relative_satoshis(this_ptr: &SpliceAck) -> i64 {
2922 let mut inner_val = &mut this_ptr.get_native_mut_ref().relative_satoshis;
2925 /// The intended change in channel capacity: the amount to be added (positive value)
2926 /// or removed (negative value) by the sender (splice acceptor) by splicing into/from the channel.
2928 pub extern "C" fn SpliceAck_set_relative_satoshis(this_ptr: &mut SpliceAck, mut val: i64) {
2929 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.relative_satoshis = val;
2931 /// The key of the sender (splice acceptor) controlling the new funding transaction
2933 pub extern "C" fn SpliceAck_get_funding_pubkey(this_ptr: &SpliceAck) -> crate::c_types::PublicKey {
2934 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
2935 crate::c_types::PublicKey::from_rust(&inner_val)
2937 /// The key of the sender (splice acceptor) controlling the new funding transaction
2939 pub extern "C" fn SpliceAck_set_funding_pubkey(this_ptr: &mut SpliceAck, mut val: crate::c_types::PublicKey) {
2940 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
2942 /// Constructs a new SpliceAck given each field
2945 pub extern "C" fn SpliceAck_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut relative_satoshis_arg: i64, mut funding_pubkey_arg: crate::c_types::PublicKey) -> SpliceAck {
2946 SpliceAck { inner: ObjOps::heap_alloc(nativeSpliceAck {
2947 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
2948 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
2949 relative_satoshis: relative_satoshis_arg,
2950 funding_pubkey: funding_pubkey_arg.into_rust(),
2951 }), is_owned: true }
2953 impl Clone for SpliceAck {
2954 fn clone(&self) -> Self {
2956 inner: if <*mut nativeSpliceAck>::is_null(self.inner) { core::ptr::null_mut() } else {
2957 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2963 /// Used only if an object of this type is returned as a trait impl by a method
2964 pub(crate) extern "C" fn SpliceAck_clone_void(this_ptr: *const c_void) -> *mut c_void {
2965 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeSpliceAck)).clone() })) as *mut c_void
2968 /// Creates a copy of the SpliceAck
2969 pub extern "C" fn SpliceAck_clone(orig: &SpliceAck) -> SpliceAck {
2972 /// Get a string which allows debug introspection of a SpliceAck object
2973 pub extern "C" fn SpliceAck_debug_str_void(o: *const c_void) -> Str {
2974 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::SpliceAck }).into()}
2975 /// Checks if two SpliceAcks contain equal inner contents.
2976 /// This ignores pointers and is_owned flags and looks at the values in fields.
2977 /// Two objects with NULL inner values will be considered "equal" here.
2979 pub extern "C" fn SpliceAck_eq(a: &SpliceAck, b: &SpliceAck) -> bool {
2980 if a.inner == b.inner { return true; }
2981 if a.inner.is_null() || b.inner.is_null() { return false; }
2982 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2985 use lightning::ln::msgs::SpliceLocked as nativeSpliceLockedImport;
2986 pub(crate) type nativeSpliceLocked = nativeSpliceLockedImport;
2988 /// A splice_locked message to be sent to or received from a peer.
2992 pub struct SpliceLocked {
2993 /// A pointer to the opaque Rust object.
2995 /// Nearly everywhere, inner must be non-null, however in places where
2996 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2997 pub inner: *mut nativeSpliceLocked,
2998 /// Indicates that this is the only struct which contains the same pointer.
3000 /// Rust functions which take ownership of an object provided via an argument require
3001 /// this to be true and invalidate the object pointed to by inner.
3005 impl Drop for SpliceLocked {
3006 fn drop(&mut self) {
3007 if self.is_owned && !<*mut nativeSpliceLocked>::is_null(self.inner) {
3008 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3012 /// Frees any resources used by the SpliceLocked, if is_owned is set and inner is non-NULL.
3014 pub extern "C" fn SpliceLocked_free(this_obj: SpliceLocked) { }
3016 /// Used only if an object of this type is returned as a trait impl by a method
3017 pub(crate) extern "C" fn SpliceLocked_free_void(this_ptr: *mut c_void) {
3018 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeSpliceLocked) };
3022 pub(crate) fn get_native_ref(&self) -> &'static nativeSpliceLocked {
3023 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3025 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeSpliceLocked {
3026 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3028 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3029 pub(crate) fn take_inner(mut self) -> *mut nativeSpliceLocked {
3030 assert!(self.is_owned);
3031 let ret = ObjOps::untweak_ptr(self.inner);
3032 self.inner = core::ptr::null_mut();
3038 pub extern "C" fn SpliceLocked_get_channel_id(this_ptr: &SpliceLocked) -> crate::lightning::ln::types::ChannelId {
3039 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3040 crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
3044 pub extern "C" fn SpliceLocked_set_channel_id(this_ptr: &mut SpliceLocked, mut val: crate::lightning::ln::types::ChannelId) {
3045 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
3047 /// Constructs a new SpliceLocked given each field
3050 pub extern "C" fn SpliceLocked_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId) -> SpliceLocked {
3051 SpliceLocked { inner: ObjOps::heap_alloc(nativeSpliceLocked {
3052 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
3053 }), is_owned: true }
3055 impl Clone for SpliceLocked {
3056 fn clone(&self) -> Self {
3058 inner: if <*mut nativeSpliceLocked>::is_null(self.inner) { core::ptr::null_mut() } else {
3059 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3065 /// Used only if an object of this type is returned as a trait impl by a method
3066 pub(crate) extern "C" fn SpliceLocked_clone_void(this_ptr: *const c_void) -> *mut c_void {
3067 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeSpliceLocked)).clone() })) as *mut c_void
3070 /// Creates a copy of the SpliceLocked
3071 pub extern "C" fn SpliceLocked_clone(orig: &SpliceLocked) -> SpliceLocked {
3074 /// Get a string which allows debug introspection of a SpliceLocked object
3075 pub extern "C" fn SpliceLocked_debug_str_void(o: *const c_void) -> Str {
3076 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::SpliceLocked }).into()}
3077 /// Checks if two SpliceLockeds contain equal inner contents.
3078 /// This ignores pointers and is_owned flags and looks at the values in fields.
3079 /// Two objects with NULL inner values will be considered "equal" here.
3081 pub extern "C" fn SpliceLocked_eq(a: &SpliceLocked, b: &SpliceLocked) -> bool {
3082 if a.inner == b.inner { return true; }
3083 if a.inner.is_null() || b.inner.is_null() { return false; }
3084 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3087 use lightning::ln::msgs::TxAddInput as nativeTxAddInputImport;
3088 pub(crate) type nativeTxAddInput = nativeTxAddInputImport;
3090 /// A tx_add_input message for adding an input during interactive transaction construction
3094 pub struct TxAddInput {
3095 /// A pointer to the opaque Rust object.
3097 /// Nearly everywhere, inner must be non-null, however in places where
3098 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3099 pub inner: *mut nativeTxAddInput,
3100 /// Indicates that this is the only struct which contains the same pointer.
3102 /// Rust functions which take ownership of an object provided via an argument require
3103 /// this to be true and invalidate the object pointed to by inner.
3107 impl Drop for TxAddInput {
3108 fn drop(&mut self) {
3109 if self.is_owned && !<*mut nativeTxAddInput>::is_null(self.inner) {
3110 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3114 /// Frees any resources used by the TxAddInput, if is_owned is set and inner is non-NULL.
3116 pub extern "C" fn TxAddInput_free(this_obj: TxAddInput) { }
3118 /// Used only if an object of this type is returned as a trait impl by a method
3119 pub(crate) extern "C" fn TxAddInput_free_void(this_ptr: *mut c_void) {
3120 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAddInput) };
3124 pub(crate) fn get_native_ref(&self) -> &'static nativeTxAddInput {
3125 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3127 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAddInput {
3128 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3130 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3131 pub(crate) fn take_inner(mut self) -> *mut nativeTxAddInput {
3132 assert!(self.is_owned);
3133 let ret = ObjOps::untweak_ptr(self.inner);
3134 self.inner = core::ptr::null_mut();
3140 pub extern "C" fn TxAddInput_get_channel_id(this_ptr: &TxAddInput) -> crate::lightning::ln::types::ChannelId {
3141 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3142 crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
3146 pub extern "C" fn TxAddInput_set_channel_id(this_ptr: &mut TxAddInput, mut val: crate::lightning::ln::types::ChannelId) {
3147 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
3149 /// A randomly chosen unique identifier for this input, which is even for initiators and odd for
3152 pub extern "C" fn TxAddInput_get_serial_id(this_ptr: &TxAddInput) -> u64 {
3153 let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
3156 /// A randomly chosen unique identifier for this input, which is even for initiators and odd for
3159 pub extern "C" fn TxAddInput_set_serial_id(this_ptr: &mut TxAddInput, mut val: u64) {
3160 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
3162 /// Serialized transaction that contains the output this input spends to verify that it is non
3165 pub extern "C" fn TxAddInput_get_prevtx(this_ptr: &TxAddInput) -> crate::lightning::util::ser::TransactionU16LenLimited {
3166 let mut inner_val = &mut this_ptr.get_native_mut_ref().prevtx;
3167 crate::lightning::util::ser::TransactionU16LenLimited { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::util::ser::TransactionU16LenLimited<>) as *mut _) }, is_owned: false }
3169 /// Serialized transaction that contains the output this input spends to verify that it is non
3172 pub extern "C" fn TxAddInput_set_prevtx(this_ptr: &mut TxAddInput, mut val: crate::lightning::util::ser::TransactionU16LenLimited) {
3173 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.prevtx = *unsafe { Box::from_raw(val.take_inner()) };
3175 /// The index of the output being spent
3177 pub extern "C" fn TxAddInput_get_prevtx_out(this_ptr: &TxAddInput) -> u32 {
3178 let mut inner_val = &mut this_ptr.get_native_mut_ref().prevtx_out;
3181 /// The index of the output being spent
3183 pub extern "C" fn TxAddInput_set_prevtx_out(this_ptr: &mut TxAddInput, mut val: u32) {
3184 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.prevtx_out = val;
3186 /// The sequence number of this input
3188 pub extern "C" fn TxAddInput_get_sequence(this_ptr: &TxAddInput) -> u32 {
3189 let mut inner_val = &mut this_ptr.get_native_mut_ref().sequence;
3192 /// The sequence number of this input
3194 pub extern "C" fn TxAddInput_set_sequence(this_ptr: &mut TxAddInput, mut val: u32) {
3195 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sequence = val;
3197 /// Constructs a new TxAddInput given each field
3200 pub extern "C" fn TxAddInput_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut serial_id_arg: u64, mut prevtx_arg: crate::lightning::util::ser::TransactionU16LenLimited, mut prevtx_out_arg: u32, mut sequence_arg: u32) -> TxAddInput {
3201 TxAddInput { inner: ObjOps::heap_alloc(nativeTxAddInput {
3202 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
3203 serial_id: serial_id_arg,
3204 prevtx: *unsafe { Box::from_raw(prevtx_arg.take_inner()) },
3205 prevtx_out: prevtx_out_arg,
3206 sequence: sequence_arg,
3207 }), is_owned: true }
3209 impl Clone for TxAddInput {
3210 fn clone(&self) -> Self {
3212 inner: if <*mut nativeTxAddInput>::is_null(self.inner) { core::ptr::null_mut() } else {
3213 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3219 /// Used only if an object of this type is returned as a trait impl by a method
3220 pub(crate) extern "C" fn TxAddInput_clone_void(this_ptr: *const c_void) -> *mut c_void {
3221 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxAddInput)).clone() })) as *mut c_void
3224 /// Creates a copy of the TxAddInput
3225 pub extern "C" fn TxAddInput_clone(orig: &TxAddInput) -> TxAddInput {
3228 /// Get a string which allows debug introspection of a TxAddInput object
3229 pub extern "C" fn TxAddInput_debug_str_void(o: *const c_void) -> Str {
3230 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxAddInput }).into()}
3231 /// Generates a non-cryptographic 64-bit hash of the TxAddInput.
3233 pub extern "C" fn TxAddInput_hash(o: &TxAddInput) -> u64 {
3234 if o.inner.is_null() { return 0; }
3235 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
3236 #[allow(deprecated)]
3237 let mut hasher = core::hash::SipHasher::new();
3238 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
3239 core::hash::Hasher::finish(&hasher)
3241 /// Checks if two TxAddInputs contain equal inner contents.
3242 /// This ignores pointers and is_owned flags and looks at the values in fields.
3243 /// Two objects with NULL inner values will be considered "equal" here.
3245 pub extern "C" fn TxAddInput_eq(a: &TxAddInput, b: &TxAddInput) -> bool {
3246 if a.inner == b.inner { return true; }
3247 if a.inner.is_null() || b.inner.is_null() { return false; }
3248 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3251 use lightning::ln::msgs::TxAddOutput as nativeTxAddOutputImport;
3252 pub(crate) type nativeTxAddOutput = nativeTxAddOutputImport;
3254 /// A tx_add_output message for adding an output during interactive transaction construction.
3258 pub struct TxAddOutput {
3259 /// A pointer to the opaque Rust object.
3261 /// Nearly everywhere, inner must be non-null, however in places where
3262 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3263 pub inner: *mut nativeTxAddOutput,
3264 /// Indicates that this is the only struct which contains the same pointer.
3266 /// Rust functions which take ownership of an object provided via an argument require
3267 /// this to be true and invalidate the object pointed to by inner.
3271 impl Drop for TxAddOutput {
3272 fn drop(&mut self) {
3273 if self.is_owned && !<*mut nativeTxAddOutput>::is_null(self.inner) {
3274 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3278 /// Frees any resources used by the TxAddOutput, if is_owned is set and inner is non-NULL.
3280 pub extern "C" fn TxAddOutput_free(this_obj: TxAddOutput) { }
3282 /// Used only if an object of this type is returned as a trait impl by a method
3283 pub(crate) extern "C" fn TxAddOutput_free_void(this_ptr: *mut c_void) {
3284 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAddOutput) };
3288 pub(crate) fn get_native_ref(&self) -> &'static nativeTxAddOutput {
3289 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3291 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAddOutput {
3292 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3294 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3295 pub(crate) fn take_inner(mut self) -> *mut nativeTxAddOutput {
3296 assert!(self.is_owned);
3297 let ret = ObjOps::untweak_ptr(self.inner);
3298 self.inner = core::ptr::null_mut();
3304 pub extern "C" fn TxAddOutput_get_channel_id(this_ptr: &TxAddOutput) -> crate::lightning::ln::types::ChannelId {
3305 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3306 crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
3310 pub extern "C" fn TxAddOutput_set_channel_id(this_ptr: &mut TxAddOutput, mut val: crate::lightning::ln::types::ChannelId) {
3311 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
3313 /// A randomly chosen unique identifier for this output, which is even for initiators and odd for
3316 pub extern "C" fn TxAddOutput_get_serial_id(this_ptr: &TxAddOutput) -> u64 {
3317 let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
3320 /// A randomly chosen unique identifier for this output, which is even for initiators and odd for
3323 pub extern "C" fn TxAddOutput_set_serial_id(this_ptr: &mut TxAddOutput, mut val: u64) {
3324 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
3326 /// The satoshi value of the output
3328 pub extern "C" fn TxAddOutput_get_sats(this_ptr: &TxAddOutput) -> u64 {
3329 let mut inner_val = &mut this_ptr.get_native_mut_ref().sats;
3332 /// The satoshi value of the output
3334 pub extern "C" fn TxAddOutput_set_sats(this_ptr: &mut TxAddOutput, mut val: u64) {
3335 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sats = val;
3337 /// The scriptPubKey for the output
3339 pub extern "C" fn TxAddOutput_get_script(this_ptr: &TxAddOutput) -> crate::c_types::derived::CVec_u8Z {
3340 let mut inner_val = &mut this_ptr.get_native_mut_ref().script;
3341 inner_val.as_bytes().to_vec().into()
3343 /// The scriptPubKey for the output
3345 pub extern "C" fn TxAddOutput_set_script(this_ptr: &mut TxAddOutput, mut val: crate::c_types::derived::CVec_u8Z) {
3346 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.script = ::bitcoin::blockdata::script::ScriptBuf::from(val.into_rust());
3348 /// Constructs a new TxAddOutput given each field
3351 pub extern "C" fn TxAddOutput_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut serial_id_arg: u64, mut sats_arg: u64, mut script_arg: crate::c_types::derived::CVec_u8Z) -> TxAddOutput {
3352 TxAddOutput { inner: ObjOps::heap_alloc(nativeTxAddOutput {
3353 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
3354 serial_id: serial_id_arg,
3356 script: ::bitcoin::blockdata::script::ScriptBuf::from(script_arg.into_rust()),
3357 }), is_owned: true }
3359 impl Clone for TxAddOutput {
3360 fn clone(&self) -> Self {
3362 inner: if <*mut nativeTxAddOutput>::is_null(self.inner) { core::ptr::null_mut() } else {
3363 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3369 /// Used only if an object of this type is returned as a trait impl by a method
3370 pub(crate) extern "C" fn TxAddOutput_clone_void(this_ptr: *const c_void) -> *mut c_void {
3371 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxAddOutput)).clone() })) as *mut c_void
3374 /// Creates a copy of the TxAddOutput
3375 pub extern "C" fn TxAddOutput_clone(orig: &TxAddOutput) -> TxAddOutput {
3378 /// Get a string which allows debug introspection of a TxAddOutput object
3379 pub extern "C" fn TxAddOutput_debug_str_void(o: *const c_void) -> Str {
3380 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxAddOutput }).into()}
3381 /// Generates a non-cryptographic 64-bit hash of the TxAddOutput.
3383 pub extern "C" fn TxAddOutput_hash(o: &TxAddOutput) -> u64 {
3384 if o.inner.is_null() { return 0; }
3385 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
3386 #[allow(deprecated)]
3387 let mut hasher = core::hash::SipHasher::new();
3388 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
3389 core::hash::Hasher::finish(&hasher)
3391 /// Checks if two TxAddOutputs contain equal inner contents.
3392 /// This ignores pointers and is_owned flags and looks at the values in fields.
3393 /// Two objects with NULL inner values will be considered "equal" here.
3395 pub extern "C" fn TxAddOutput_eq(a: &TxAddOutput, b: &TxAddOutput) -> bool {
3396 if a.inner == b.inner { return true; }
3397 if a.inner.is_null() || b.inner.is_null() { return false; }
3398 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3401 use lightning::ln::msgs::TxRemoveInput as nativeTxRemoveInputImport;
3402 pub(crate) type nativeTxRemoveInput = nativeTxRemoveInputImport;
3404 /// A tx_remove_input message for removing an input during interactive transaction construction.
3408 pub struct TxRemoveInput {
3409 /// A pointer to the opaque Rust object.
3411 /// Nearly everywhere, inner must be non-null, however in places where
3412 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3413 pub inner: *mut nativeTxRemoveInput,
3414 /// Indicates that this is the only struct which contains the same pointer.
3416 /// Rust functions which take ownership of an object provided via an argument require
3417 /// this to be true and invalidate the object pointed to by inner.
3421 impl Drop for TxRemoveInput {
3422 fn drop(&mut self) {
3423 if self.is_owned && !<*mut nativeTxRemoveInput>::is_null(self.inner) {
3424 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3428 /// Frees any resources used by the TxRemoveInput, if is_owned is set and inner is non-NULL.
3430 pub extern "C" fn TxRemoveInput_free(this_obj: TxRemoveInput) { }
3432 /// Used only if an object of this type is returned as a trait impl by a method
3433 pub(crate) extern "C" fn TxRemoveInput_free_void(this_ptr: *mut c_void) {
3434 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxRemoveInput) };
3437 impl TxRemoveInput {
3438 pub(crate) fn get_native_ref(&self) -> &'static nativeTxRemoveInput {
3439 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3441 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxRemoveInput {
3442 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3444 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3445 pub(crate) fn take_inner(mut self) -> *mut nativeTxRemoveInput {
3446 assert!(self.is_owned);
3447 let ret = ObjOps::untweak_ptr(self.inner);
3448 self.inner = core::ptr::null_mut();
3454 pub extern "C" fn TxRemoveInput_get_channel_id(this_ptr: &TxRemoveInput) -> crate::lightning::ln::types::ChannelId {
3455 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3456 crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
3460 pub extern "C" fn TxRemoveInput_set_channel_id(this_ptr: &mut TxRemoveInput, mut val: crate::lightning::ln::types::ChannelId) {
3461 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
3463 /// The serial ID of the input to be removed
3465 pub extern "C" fn TxRemoveInput_get_serial_id(this_ptr: &TxRemoveInput) -> u64 {
3466 let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
3469 /// The serial ID of the input to be removed
3471 pub extern "C" fn TxRemoveInput_set_serial_id(this_ptr: &mut TxRemoveInput, mut val: u64) {
3472 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
3474 /// Constructs a new TxRemoveInput given each field
3477 pub extern "C" fn TxRemoveInput_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut serial_id_arg: u64) -> TxRemoveInput {
3478 TxRemoveInput { inner: ObjOps::heap_alloc(nativeTxRemoveInput {
3479 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
3480 serial_id: serial_id_arg,
3481 }), is_owned: true }
3483 impl Clone for TxRemoveInput {
3484 fn clone(&self) -> Self {
3486 inner: if <*mut nativeTxRemoveInput>::is_null(self.inner) { core::ptr::null_mut() } else {
3487 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3493 /// Used only if an object of this type is returned as a trait impl by a method
3494 pub(crate) extern "C" fn TxRemoveInput_clone_void(this_ptr: *const c_void) -> *mut c_void {
3495 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxRemoveInput)).clone() })) as *mut c_void
3498 /// Creates a copy of the TxRemoveInput
3499 pub extern "C" fn TxRemoveInput_clone(orig: &TxRemoveInput) -> TxRemoveInput {
3502 /// Get a string which allows debug introspection of a TxRemoveInput object
3503 pub extern "C" fn TxRemoveInput_debug_str_void(o: *const c_void) -> Str {
3504 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxRemoveInput }).into()}
3505 /// Generates a non-cryptographic 64-bit hash of the TxRemoveInput.
3507 pub extern "C" fn TxRemoveInput_hash(o: &TxRemoveInput) -> u64 {
3508 if o.inner.is_null() { return 0; }
3509 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
3510 #[allow(deprecated)]
3511 let mut hasher = core::hash::SipHasher::new();
3512 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
3513 core::hash::Hasher::finish(&hasher)
3515 /// Checks if two TxRemoveInputs contain equal inner contents.
3516 /// This ignores pointers and is_owned flags and looks at the values in fields.
3517 /// Two objects with NULL inner values will be considered "equal" here.
3519 pub extern "C" fn TxRemoveInput_eq(a: &TxRemoveInput, b: &TxRemoveInput) -> bool {
3520 if a.inner == b.inner { return true; }
3521 if a.inner.is_null() || b.inner.is_null() { return false; }
3522 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3525 use lightning::ln::msgs::TxRemoveOutput as nativeTxRemoveOutputImport;
3526 pub(crate) type nativeTxRemoveOutput = nativeTxRemoveOutputImport;
3528 /// A tx_remove_output message for removing an output during interactive transaction construction.
3532 pub struct TxRemoveOutput {
3533 /// A pointer to the opaque Rust object.
3535 /// Nearly everywhere, inner must be non-null, however in places where
3536 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3537 pub inner: *mut nativeTxRemoveOutput,
3538 /// Indicates that this is the only struct which contains the same pointer.
3540 /// Rust functions which take ownership of an object provided via an argument require
3541 /// this to be true and invalidate the object pointed to by inner.
3545 impl Drop for TxRemoveOutput {
3546 fn drop(&mut self) {
3547 if self.is_owned && !<*mut nativeTxRemoveOutput>::is_null(self.inner) {
3548 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3552 /// Frees any resources used by the TxRemoveOutput, if is_owned is set and inner is non-NULL.
3554 pub extern "C" fn TxRemoveOutput_free(this_obj: TxRemoveOutput) { }
3556 /// Used only if an object of this type is returned as a trait impl by a method
3557 pub(crate) extern "C" fn TxRemoveOutput_free_void(this_ptr: *mut c_void) {
3558 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxRemoveOutput) };
3561 impl TxRemoveOutput {
3562 pub(crate) fn get_native_ref(&self) -> &'static nativeTxRemoveOutput {
3563 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3565 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxRemoveOutput {
3566 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3568 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3569 pub(crate) fn take_inner(mut self) -> *mut nativeTxRemoveOutput {
3570 assert!(self.is_owned);
3571 let ret = ObjOps::untweak_ptr(self.inner);
3572 self.inner = core::ptr::null_mut();
3578 pub extern "C" fn TxRemoveOutput_get_channel_id(this_ptr: &TxRemoveOutput) -> crate::lightning::ln::types::ChannelId {
3579 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3580 crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
3584 pub extern "C" fn TxRemoveOutput_set_channel_id(this_ptr: &mut TxRemoveOutput, mut val: crate::lightning::ln::types::ChannelId) {
3585 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
3587 /// The serial ID of the output to be removed
3589 pub extern "C" fn TxRemoveOutput_get_serial_id(this_ptr: &TxRemoveOutput) -> u64 {
3590 let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
3593 /// The serial ID of the output to be removed
3595 pub extern "C" fn TxRemoveOutput_set_serial_id(this_ptr: &mut TxRemoveOutput, mut val: u64) {
3596 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
3598 /// Constructs a new TxRemoveOutput given each field
3601 pub extern "C" fn TxRemoveOutput_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut serial_id_arg: u64) -> TxRemoveOutput {
3602 TxRemoveOutput { inner: ObjOps::heap_alloc(nativeTxRemoveOutput {
3603 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
3604 serial_id: serial_id_arg,
3605 }), is_owned: true }
3607 impl Clone for TxRemoveOutput {
3608 fn clone(&self) -> Self {
3610 inner: if <*mut nativeTxRemoveOutput>::is_null(self.inner) { core::ptr::null_mut() } else {
3611 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3617 /// Used only if an object of this type is returned as a trait impl by a method
3618 pub(crate) extern "C" fn TxRemoveOutput_clone_void(this_ptr: *const c_void) -> *mut c_void {
3619 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxRemoveOutput)).clone() })) as *mut c_void
3622 /// Creates a copy of the TxRemoveOutput
3623 pub extern "C" fn TxRemoveOutput_clone(orig: &TxRemoveOutput) -> TxRemoveOutput {
3626 /// Get a string which allows debug introspection of a TxRemoveOutput object
3627 pub extern "C" fn TxRemoveOutput_debug_str_void(o: *const c_void) -> Str {
3628 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxRemoveOutput }).into()}
3629 /// Generates a non-cryptographic 64-bit hash of the TxRemoveOutput.
3631 pub extern "C" fn TxRemoveOutput_hash(o: &TxRemoveOutput) -> u64 {
3632 if o.inner.is_null() { return 0; }
3633 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
3634 #[allow(deprecated)]
3635 let mut hasher = core::hash::SipHasher::new();
3636 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
3637 core::hash::Hasher::finish(&hasher)
3639 /// Checks if two TxRemoveOutputs contain equal inner contents.
3640 /// This ignores pointers and is_owned flags and looks at the values in fields.
3641 /// Two objects with NULL inner values will be considered "equal" here.
3643 pub extern "C" fn TxRemoveOutput_eq(a: &TxRemoveOutput, b: &TxRemoveOutput) -> bool {
3644 if a.inner == b.inner { return true; }
3645 if a.inner.is_null() || b.inner.is_null() { return false; }
3646 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3649 use lightning::ln::msgs::TxComplete as nativeTxCompleteImport;
3650 pub(crate) type nativeTxComplete = nativeTxCompleteImport;
3652 /// A tx_complete message signalling the conclusion of a peer's transaction contributions during
3653 /// interactive transaction construction.
3657 pub struct TxComplete {
3658 /// A pointer to the opaque Rust object.
3660 /// Nearly everywhere, inner must be non-null, however in places where
3661 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3662 pub inner: *mut nativeTxComplete,
3663 /// Indicates that this is the only struct which contains the same pointer.
3665 /// Rust functions which take ownership of an object provided via an argument require
3666 /// this to be true and invalidate the object pointed to by inner.
3670 impl Drop for TxComplete {
3671 fn drop(&mut self) {
3672 if self.is_owned && !<*mut nativeTxComplete>::is_null(self.inner) {
3673 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3677 /// Frees any resources used by the TxComplete, if is_owned is set and inner is non-NULL.
3679 pub extern "C" fn TxComplete_free(this_obj: TxComplete) { }
3681 /// Used only if an object of this type is returned as a trait impl by a method
3682 pub(crate) extern "C" fn TxComplete_free_void(this_ptr: *mut c_void) {
3683 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxComplete) };
3687 pub(crate) fn get_native_ref(&self) -> &'static nativeTxComplete {
3688 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3690 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxComplete {
3691 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3693 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3694 pub(crate) fn take_inner(mut self) -> *mut nativeTxComplete {
3695 assert!(self.is_owned);
3696 let ret = ObjOps::untweak_ptr(self.inner);
3697 self.inner = core::ptr::null_mut();
3703 pub extern "C" fn TxComplete_get_channel_id(this_ptr: &TxComplete) -> crate::lightning::ln::types::ChannelId {
3704 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3705 crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
3709 pub extern "C" fn TxComplete_set_channel_id(this_ptr: &mut TxComplete, mut val: crate::lightning::ln::types::ChannelId) {
3710 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
3712 /// Constructs a new TxComplete given each field
3715 pub extern "C" fn TxComplete_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId) -> TxComplete {
3716 TxComplete { inner: ObjOps::heap_alloc(nativeTxComplete {
3717 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
3718 }), is_owned: true }
3720 impl Clone for TxComplete {
3721 fn clone(&self) -> Self {
3723 inner: if <*mut nativeTxComplete>::is_null(self.inner) { core::ptr::null_mut() } else {
3724 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3730 /// Used only if an object of this type is returned as a trait impl by a method
3731 pub(crate) extern "C" fn TxComplete_clone_void(this_ptr: *const c_void) -> *mut c_void {
3732 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxComplete)).clone() })) as *mut c_void
3735 /// Creates a copy of the TxComplete
3736 pub extern "C" fn TxComplete_clone(orig: &TxComplete) -> TxComplete {
3739 /// Get a string which allows debug introspection of a TxComplete object
3740 pub extern "C" fn TxComplete_debug_str_void(o: *const c_void) -> Str {
3741 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxComplete }).into()}
3742 /// Generates a non-cryptographic 64-bit hash of the TxComplete.
3744 pub extern "C" fn TxComplete_hash(o: &TxComplete) -> u64 {
3745 if o.inner.is_null() { return 0; }
3746 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
3747 #[allow(deprecated)]
3748 let mut hasher = core::hash::SipHasher::new();
3749 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
3750 core::hash::Hasher::finish(&hasher)
3752 /// Checks if two TxCompletes contain equal inner contents.
3753 /// This ignores pointers and is_owned flags and looks at the values in fields.
3754 /// Two objects with NULL inner values will be considered "equal" here.
3756 pub extern "C" fn TxComplete_eq(a: &TxComplete, b: &TxComplete) -> bool {
3757 if a.inner == b.inner { return true; }
3758 if a.inner.is_null() || b.inner.is_null() { return false; }
3759 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3762 use lightning::ln::msgs::TxSignatures as nativeTxSignaturesImport;
3763 pub(crate) type nativeTxSignatures = nativeTxSignaturesImport;
3765 /// A tx_signatures message containing the sender's signatures for a transaction constructed with
3766 /// interactive transaction construction.
3770 pub struct TxSignatures {
3771 /// A pointer to the opaque Rust object.
3773 /// Nearly everywhere, inner must be non-null, however in places where
3774 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3775 pub inner: *mut nativeTxSignatures,
3776 /// Indicates that this is the only struct which contains the same pointer.
3778 /// Rust functions which take ownership of an object provided via an argument require
3779 /// this to be true and invalidate the object pointed to by inner.
3783 impl Drop for TxSignatures {
3784 fn drop(&mut self) {
3785 if self.is_owned && !<*mut nativeTxSignatures>::is_null(self.inner) {
3786 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3790 /// Frees any resources used by the TxSignatures, if is_owned is set and inner is non-NULL.
3792 pub extern "C" fn TxSignatures_free(this_obj: TxSignatures) { }
3794 /// Used only if an object of this type is returned as a trait impl by a method
3795 pub(crate) extern "C" fn TxSignatures_free_void(this_ptr: *mut c_void) {
3796 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxSignatures) };
3800 pub(crate) fn get_native_ref(&self) -> &'static nativeTxSignatures {
3801 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3803 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxSignatures {
3804 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3806 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3807 pub(crate) fn take_inner(mut self) -> *mut nativeTxSignatures {
3808 assert!(self.is_owned);
3809 let ret = ObjOps::untweak_ptr(self.inner);
3810 self.inner = core::ptr::null_mut();
3816 pub extern "C" fn TxSignatures_get_channel_id(this_ptr: &TxSignatures) -> crate::lightning::ln::types::ChannelId {
3817 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3818 crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
3822 pub extern "C" fn TxSignatures_set_channel_id(this_ptr: &mut TxSignatures, mut val: crate::lightning::ln::types::ChannelId) {
3823 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
3827 pub extern "C" fn TxSignatures_get_tx_hash(this_ptr: &TxSignatures) -> *const [u8; 32] {
3828 let mut inner_val = &mut this_ptr.get_native_mut_ref().tx_hash;
3833 pub extern "C" fn TxSignatures_set_tx_hash(this_ptr: &mut TxSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
3834 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.tx_hash = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
3836 /// The list of witnesses
3838 /// Returns a copy of the field.
3840 pub extern "C" fn TxSignatures_get_witnesses(this_ptr: &TxSignatures) -> crate::c_types::derived::CVec_WitnessZ {
3841 let mut inner_val = this_ptr.get_native_mut_ref().witnesses.clone();
3842 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { crate::c_types::Witness::from_bitcoin(&item) }); };
3843 local_inner_val.into()
3845 /// The list of witnesses
3847 pub extern "C" fn TxSignatures_set_witnesses(this_ptr: &mut TxSignatures, mut val: crate::c_types::derived::CVec_WitnessZ) {
3848 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_bitcoin() }); };
3849 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.witnesses = local_val;
3851 /// Optional signature for the shared input -- the previous funding outpoint -- signed by both peers
3853 pub extern "C" fn TxSignatures_get_funding_outpoint_sig(this_ptr: &TxSignatures) -> crate::c_types::derived::COption_ECDSASignatureZ {
3854 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_outpoint_sig;
3855 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ECDSASignatureZ::None } else { crate::c_types::derived::COption_ECDSASignatureZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { crate::c_types::ECDSASignature::from_rust(&(*inner_val.as_ref().unwrap()).clone()) }) };
3858 /// Optional signature for the shared input -- the previous funding outpoint -- signed by both peers
3860 pub extern "C" fn TxSignatures_set_funding_outpoint_sig(this_ptr: &mut TxSignatures, mut val: crate::c_types::derived::COption_ECDSASignatureZ) {
3861 let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_rust() }})} };
3862 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_outpoint_sig = local_val;
3864 /// Constructs a new TxSignatures given each field
3867 pub extern "C" fn TxSignatures_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut tx_hash_arg: crate::c_types::ThirtyTwoBytes, mut witnesses_arg: crate::c_types::derived::CVec_WitnessZ, mut funding_outpoint_sig_arg: crate::c_types::derived::COption_ECDSASignatureZ) -> TxSignatures {
3868 let mut local_witnesses_arg = Vec::new(); for mut item in witnesses_arg.into_rust().drain(..) { local_witnesses_arg.push( { item.into_bitcoin() }); };
3869 let mut local_funding_outpoint_sig_arg = { /*funding_outpoint_sig_arg*/ let funding_outpoint_sig_arg_opt = funding_outpoint_sig_arg; if funding_outpoint_sig_arg_opt.is_none() { None } else { Some({ { { funding_outpoint_sig_arg_opt.take() }.into_rust() }})} };
3870 TxSignatures { inner: ObjOps::heap_alloc(nativeTxSignatures {
3871 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
3872 tx_hash: ::bitcoin::hash_types::Txid::from_slice(&tx_hash_arg.data[..]).unwrap(),
3873 witnesses: local_witnesses_arg,
3874 funding_outpoint_sig: local_funding_outpoint_sig_arg,
3875 }), is_owned: true }
3877 impl Clone for TxSignatures {
3878 fn clone(&self) -> Self {
3880 inner: if <*mut nativeTxSignatures>::is_null(self.inner) { core::ptr::null_mut() } else {
3881 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3887 /// Used only if an object of this type is returned as a trait impl by a method
3888 pub(crate) extern "C" fn TxSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
3889 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxSignatures)).clone() })) as *mut c_void
3892 /// Creates a copy of the TxSignatures
3893 pub extern "C" fn TxSignatures_clone(orig: &TxSignatures) -> TxSignatures {
3896 /// Get a string which allows debug introspection of a TxSignatures object
3897 pub extern "C" fn TxSignatures_debug_str_void(o: *const c_void) -> Str {
3898 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxSignatures }).into()}
3899 /// Generates a non-cryptographic 64-bit hash of the TxSignatures.
3901 pub extern "C" fn TxSignatures_hash(o: &TxSignatures) -> u64 {
3902 if o.inner.is_null() { return 0; }
3903 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
3904 #[allow(deprecated)]
3905 let mut hasher = core::hash::SipHasher::new();
3906 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
3907 core::hash::Hasher::finish(&hasher)
3909 /// Checks if two TxSignaturess contain equal inner contents.
3910 /// This ignores pointers and is_owned flags and looks at the values in fields.
3911 /// Two objects with NULL inner values will be considered "equal" here.
3913 pub extern "C" fn TxSignatures_eq(a: &TxSignatures, b: &TxSignatures) -> bool {
3914 if a.inner == b.inner { return true; }
3915 if a.inner.is_null() || b.inner.is_null() { return false; }
3916 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3919 use lightning::ln::msgs::TxInitRbf as nativeTxInitRbfImport;
3920 pub(crate) type nativeTxInitRbf = nativeTxInitRbfImport;
3922 /// A tx_init_rbf message which initiates a replacement of the transaction after it's been
3927 pub struct TxInitRbf {
3928 /// A pointer to the opaque Rust object.
3930 /// Nearly everywhere, inner must be non-null, however in places where
3931 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3932 pub inner: *mut nativeTxInitRbf,
3933 /// Indicates that this is the only struct which contains the same pointer.
3935 /// Rust functions which take ownership of an object provided via an argument require
3936 /// this to be true and invalidate the object pointed to by inner.
3940 impl Drop for TxInitRbf {
3941 fn drop(&mut self) {
3942 if self.is_owned && !<*mut nativeTxInitRbf>::is_null(self.inner) {
3943 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3947 /// Frees any resources used by the TxInitRbf, if is_owned is set and inner is non-NULL.
3949 pub extern "C" fn TxInitRbf_free(this_obj: TxInitRbf) { }
3951 /// Used only if an object of this type is returned as a trait impl by a method
3952 pub(crate) extern "C" fn TxInitRbf_free_void(this_ptr: *mut c_void) {
3953 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxInitRbf) };
3957 pub(crate) fn get_native_ref(&self) -> &'static nativeTxInitRbf {
3958 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3960 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxInitRbf {
3961 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3963 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3964 pub(crate) fn take_inner(mut self) -> *mut nativeTxInitRbf {
3965 assert!(self.is_owned);
3966 let ret = ObjOps::untweak_ptr(self.inner);
3967 self.inner = core::ptr::null_mut();
3973 pub extern "C" fn TxInitRbf_get_channel_id(this_ptr: &TxInitRbf) -> crate::lightning::ln::types::ChannelId {
3974 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3975 crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
3979 pub extern "C" fn TxInitRbf_set_channel_id(this_ptr: &mut TxInitRbf, mut val: crate::lightning::ln::types::ChannelId) {
3980 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
3982 /// The locktime of the transaction
3984 pub extern "C" fn TxInitRbf_get_locktime(this_ptr: &TxInitRbf) -> u32 {
3985 let mut inner_val = &mut this_ptr.get_native_mut_ref().locktime;
3988 /// The locktime of the transaction
3990 pub extern "C" fn TxInitRbf_set_locktime(this_ptr: &mut TxInitRbf, mut val: u32) {
3991 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.locktime = val;
3993 /// The feerate of the transaction
3995 pub extern "C" fn TxInitRbf_get_feerate_sat_per_1000_weight(this_ptr: &TxInitRbf) -> u32 {
3996 let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_sat_per_1000_weight;
3999 /// The feerate of the transaction
4001 pub extern "C" fn TxInitRbf_set_feerate_sat_per_1000_weight(this_ptr: &mut TxInitRbf, mut val: u32) {
4002 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_sat_per_1000_weight = val;
4004 /// The number of satoshis the sender will contribute to or, if negative, remove from
4005 /// (e.g. splice-out) the funding output of the transaction
4007 pub extern "C" fn TxInitRbf_get_funding_output_contribution(this_ptr: &TxInitRbf) -> crate::c_types::derived::COption_i64Z {
4008 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_contribution;
4009 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_i64Z::None } else { crate::c_types::derived::COption_i64Z::Some( { inner_val.unwrap() }) };
4012 /// The number of satoshis the sender will contribute to or, if negative, remove from
4013 /// (e.g. splice-out) the funding output of the transaction
4015 pub extern "C" fn TxInitRbf_set_funding_output_contribution(this_ptr: &mut TxInitRbf, mut val: crate::c_types::derived::COption_i64Z) {
4016 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
4017 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_contribution = local_val;
4019 /// Constructs a new TxInitRbf given each field
4022 pub extern "C" fn TxInitRbf_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut locktime_arg: u32, mut feerate_sat_per_1000_weight_arg: u32, mut funding_output_contribution_arg: crate::c_types::derived::COption_i64Z) -> TxInitRbf {
4023 let mut local_funding_output_contribution_arg = if funding_output_contribution_arg.is_some() { Some( { funding_output_contribution_arg.take() }) } else { None };
4024 TxInitRbf { inner: ObjOps::heap_alloc(nativeTxInitRbf {
4025 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
4026 locktime: locktime_arg,
4027 feerate_sat_per_1000_weight: feerate_sat_per_1000_weight_arg,
4028 funding_output_contribution: local_funding_output_contribution_arg,
4029 }), is_owned: true }
4031 impl Clone for TxInitRbf {
4032 fn clone(&self) -> Self {
4034 inner: if <*mut nativeTxInitRbf>::is_null(self.inner) { core::ptr::null_mut() } else {
4035 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4041 /// Used only if an object of this type is returned as a trait impl by a method
4042 pub(crate) extern "C" fn TxInitRbf_clone_void(this_ptr: *const c_void) -> *mut c_void {
4043 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxInitRbf)).clone() })) as *mut c_void
4046 /// Creates a copy of the TxInitRbf
4047 pub extern "C" fn TxInitRbf_clone(orig: &TxInitRbf) -> TxInitRbf {
4050 /// Get a string which allows debug introspection of a TxInitRbf object
4051 pub extern "C" fn TxInitRbf_debug_str_void(o: *const c_void) -> Str {
4052 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxInitRbf }).into()}
4053 /// Generates a non-cryptographic 64-bit hash of the TxInitRbf.
4055 pub extern "C" fn TxInitRbf_hash(o: &TxInitRbf) -> u64 {
4056 if o.inner.is_null() { return 0; }
4057 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
4058 #[allow(deprecated)]
4059 let mut hasher = core::hash::SipHasher::new();
4060 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
4061 core::hash::Hasher::finish(&hasher)
4063 /// Checks if two TxInitRbfs contain equal inner contents.
4064 /// This ignores pointers and is_owned flags and looks at the values in fields.
4065 /// Two objects with NULL inner values will be considered "equal" here.
4067 pub extern "C" fn TxInitRbf_eq(a: &TxInitRbf, b: &TxInitRbf) -> bool {
4068 if a.inner == b.inner { return true; }
4069 if a.inner.is_null() || b.inner.is_null() { return false; }
4070 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4073 use lightning::ln::msgs::TxAckRbf as nativeTxAckRbfImport;
4074 pub(crate) type nativeTxAckRbf = nativeTxAckRbfImport;
4076 /// A tx_ack_rbf message which acknowledges replacement of the transaction after it's been
4081 pub struct TxAckRbf {
4082 /// A pointer to the opaque Rust object.
4084 /// Nearly everywhere, inner must be non-null, however in places where
4085 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4086 pub inner: *mut nativeTxAckRbf,
4087 /// Indicates that this is the only struct which contains the same pointer.
4089 /// Rust functions which take ownership of an object provided via an argument require
4090 /// this to be true and invalidate the object pointed to by inner.
4094 impl Drop for TxAckRbf {
4095 fn drop(&mut self) {
4096 if self.is_owned && !<*mut nativeTxAckRbf>::is_null(self.inner) {
4097 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4101 /// Frees any resources used by the TxAckRbf, if is_owned is set and inner is non-NULL.
4103 pub extern "C" fn TxAckRbf_free(this_obj: TxAckRbf) { }
4105 /// Used only if an object of this type is returned as a trait impl by a method
4106 pub(crate) extern "C" fn TxAckRbf_free_void(this_ptr: *mut c_void) {
4107 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAckRbf) };
4111 pub(crate) fn get_native_ref(&self) -> &'static nativeTxAckRbf {
4112 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4114 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAckRbf {
4115 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4117 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4118 pub(crate) fn take_inner(mut self) -> *mut nativeTxAckRbf {
4119 assert!(self.is_owned);
4120 let ret = ObjOps::untweak_ptr(self.inner);
4121 self.inner = core::ptr::null_mut();
4127 pub extern "C" fn TxAckRbf_get_channel_id(this_ptr: &TxAckRbf) -> crate::lightning::ln::types::ChannelId {
4128 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4129 crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
4133 pub extern "C" fn TxAckRbf_set_channel_id(this_ptr: &mut TxAckRbf, mut val: crate::lightning::ln::types::ChannelId) {
4134 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
4136 /// The number of satoshis the sender will contribute to or, if negative, remove from
4137 /// (e.g. splice-out) the funding output of the transaction
4139 pub extern "C" fn TxAckRbf_get_funding_output_contribution(this_ptr: &TxAckRbf) -> crate::c_types::derived::COption_i64Z {
4140 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_contribution;
4141 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_i64Z::None } else { crate::c_types::derived::COption_i64Z::Some( { inner_val.unwrap() }) };
4144 /// The number of satoshis the sender will contribute to or, if negative, remove from
4145 /// (e.g. splice-out) the funding output of the transaction
4147 pub extern "C" fn TxAckRbf_set_funding_output_contribution(this_ptr: &mut TxAckRbf, mut val: crate::c_types::derived::COption_i64Z) {
4148 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
4149 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_contribution = local_val;
4151 /// Constructs a new TxAckRbf given each field
4154 pub extern "C" fn TxAckRbf_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut funding_output_contribution_arg: crate::c_types::derived::COption_i64Z) -> TxAckRbf {
4155 let mut local_funding_output_contribution_arg = if funding_output_contribution_arg.is_some() { Some( { funding_output_contribution_arg.take() }) } else { None };
4156 TxAckRbf { inner: ObjOps::heap_alloc(nativeTxAckRbf {
4157 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
4158 funding_output_contribution: local_funding_output_contribution_arg,
4159 }), is_owned: true }
4161 impl Clone for TxAckRbf {
4162 fn clone(&self) -> Self {
4164 inner: if <*mut nativeTxAckRbf>::is_null(self.inner) { core::ptr::null_mut() } else {
4165 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4171 /// Used only if an object of this type is returned as a trait impl by a method
4172 pub(crate) extern "C" fn TxAckRbf_clone_void(this_ptr: *const c_void) -> *mut c_void {
4173 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxAckRbf)).clone() })) as *mut c_void
4176 /// Creates a copy of the TxAckRbf
4177 pub extern "C" fn TxAckRbf_clone(orig: &TxAckRbf) -> TxAckRbf {
4180 /// Get a string which allows debug introspection of a TxAckRbf object
4181 pub extern "C" fn TxAckRbf_debug_str_void(o: *const c_void) -> Str {
4182 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxAckRbf }).into()}
4183 /// Generates a non-cryptographic 64-bit hash of the TxAckRbf.
4185 pub extern "C" fn TxAckRbf_hash(o: &TxAckRbf) -> u64 {
4186 if o.inner.is_null() { return 0; }
4187 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
4188 #[allow(deprecated)]
4189 let mut hasher = core::hash::SipHasher::new();
4190 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
4191 core::hash::Hasher::finish(&hasher)
4193 /// Checks if two TxAckRbfs contain equal inner contents.
4194 /// This ignores pointers and is_owned flags and looks at the values in fields.
4195 /// Two objects with NULL inner values will be considered "equal" here.
4197 pub extern "C" fn TxAckRbf_eq(a: &TxAckRbf, b: &TxAckRbf) -> bool {
4198 if a.inner == b.inner { return true; }
4199 if a.inner.is_null() || b.inner.is_null() { return false; }
4200 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4203 use lightning::ln::msgs::TxAbort as nativeTxAbortImport;
4204 pub(crate) type nativeTxAbort = nativeTxAbortImport;
4206 /// A tx_abort message which signals the cancellation of an in-progress transaction negotiation.
4210 pub struct TxAbort {
4211 /// A pointer to the opaque Rust object.
4213 /// Nearly everywhere, inner must be non-null, however in places where
4214 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4215 pub inner: *mut nativeTxAbort,
4216 /// Indicates that this is the only struct which contains the same pointer.
4218 /// Rust functions which take ownership of an object provided via an argument require
4219 /// this to be true and invalidate the object pointed to by inner.
4223 impl Drop for TxAbort {
4224 fn drop(&mut self) {
4225 if self.is_owned && !<*mut nativeTxAbort>::is_null(self.inner) {
4226 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4230 /// Frees any resources used by the TxAbort, if is_owned is set and inner is non-NULL.
4232 pub extern "C" fn TxAbort_free(this_obj: TxAbort) { }
4234 /// Used only if an object of this type is returned as a trait impl by a method
4235 pub(crate) extern "C" fn TxAbort_free_void(this_ptr: *mut c_void) {
4236 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAbort) };
4240 pub(crate) fn get_native_ref(&self) -> &'static nativeTxAbort {
4241 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4243 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAbort {
4244 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4246 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4247 pub(crate) fn take_inner(mut self) -> *mut nativeTxAbort {
4248 assert!(self.is_owned);
4249 let ret = ObjOps::untweak_ptr(self.inner);
4250 self.inner = core::ptr::null_mut();
4256 pub extern "C" fn TxAbort_get_channel_id(this_ptr: &TxAbort) -> crate::lightning::ln::types::ChannelId {
4257 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4258 crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
4262 pub extern "C" fn TxAbort_set_channel_id(this_ptr: &mut TxAbort, mut val: crate::lightning::ln::types::ChannelId) {
4263 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
4267 /// Returns a copy of the field.
4269 pub extern "C" fn TxAbort_get_data(this_ptr: &TxAbort) -> crate::c_types::derived::CVec_u8Z {
4270 let mut inner_val = this_ptr.get_native_mut_ref().data.clone();
4271 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
4272 local_inner_val.into()
4276 pub extern "C" fn TxAbort_set_data(this_ptr: &mut TxAbort, mut val: crate::c_types::derived::CVec_u8Z) {
4277 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
4278 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = local_val;
4280 /// Constructs a new TxAbort given each field
4283 pub extern "C" fn TxAbort_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut data_arg: crate::c_types::derived::CVec_u8Z) -> TxAbort {
4284 let mut local_data_arg = Vec::new(); for mut item in data_arg.into_rust().drain(..) { local_data_arg.push( { item }); };
4285 TxAbort { inner: ObjOps::heap_alloc(nativeTxAbort {
4286 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
4287 data: local_data_arg,
4288 }), is_owned: true }
4290 impl Clone for TxAbort {
4291 fn clone(&self) -> Self {
4293 inner: if <*mut nativeTxAbort>::is_null(self.inner) { core::ptr::null_mut() } else {
4294 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4300 /// Used only if an object of this type is returned as a trait impl by a method
4301 pub(crate) extern "C" fn TxAbort_clone_void(this_ptr: *const c_void) -> *mut c_void {
4302 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxAbort)).clone() })) as *mut c_void
4305 /// Creates a copy of the TxAbort
4306 pub extern "C" fn TxAbort_clone(orig: &TxAbort) -> TxAbort {
4309 /// Get a string which allows debug introspection of a TxAbort object
4310 pub extern "C" fn TxAbort_debug_str_void(o: *const c_void) -> Str {
4311 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TxAbort }).into()}
4312 /// Generates a non-cryptographic 64-bit hash of the TxAbort.
4314 pub extern "C" fn TxAbort_hash(o: &TxAbort) -> u64 {
4315 if o.inner.is_null() { return 0; }
4316 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
4317 #[allow(deprecated)]
4318 let mut hasher = core::hash::SipHasher::new();
4319 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
4320 core::hash::Hasher::finish(&hasher)
4322 /// Checks if two TxAborts contain equal inner contents.
4323 /// This ignores pointers and is_owned flags and looks at the values in fields.
4324 /// Two objects with NULL inner values will be considered "equal" here.
4326 pub extern "C" fn TxAbort_eq(a: &TxAbort, b: &TxAbort) -> bool {
4327 if a.inner == b.inner { return true; }
4328 if a.inner.is_null() || b.inner.is_null() { return false; }
4329 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4332 use lightning::ln::msgs::Shutdown as nativeShutdownImport;
4333 pub(crate) type nativeShutdown = nativeShutdownImport;
4335 /// A [`shutdown`] message to be sent to or received from a peer.
4337 /// [`shutdown`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-initiation-shutdown
4340 pub struct Shutdown {
4341 /// A pointer to the opaque Rust object.
4343 /// Nearly everywhere, inner must be non-null, however in places where
4344 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4345 pub inner: *mut nativeShutdown,
4346 /// Indicates that this is the only struct which contains the same pointer.
4348 /// Rust functions which take ownership of an object provided via an argument require
4349 /// this to be true and invalidate the object pointed to by inner.
4353 impl Drop for Shutdown {
4354 fn drop(&mut self) {
4355 if self.is_owned && !<*mut nativeShutdown>::is_null(self.inner) {
4356 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4360 /// Frees any resources used by the Shutdown, if is_owned is set and inner is non-NULL.
4362 pub extern "C" fn Shutdown_free(this_obj: Shutdown) { }
4364 /// Used only if an object of this type is returned as a trait impl by a method
4365 pub(crate) extern "C" fn Shutdown_free_void(this_ptr: *mut c_void) {
4366 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeShutdown) };
4370 pub(crate) fn get_native_ref(&self) -> &'static nativeShutdown {
4371 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4373 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeShutdown {
4374 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4376 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4377 pub(crate) fn take_inner(mut self) -> *mut nativeShutdown {
4378 assert!(self.is_owned);
4379 let ret = ObjOps::untweak_ptr(self.inner);
4380 self.inner = core::ptr::null_mut();
4386 pub extern "C" fn Shutdown_get_channel_id(this_ptr: &Shutdown) -> crate::lightning::ln::types::ChannelId {
4387 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4388 crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
4392 pub extern "C" fn Shutdown_set_channel_id(this_ptr: &mut Shutdown, mut val: crate::lightning::ln::types::ChannelId) {
4393 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
4395 /// The destination of this peer's funds on closing.
4397 /// Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.
4399 pub extern "C" fn Shutdown_get_scriptpubkey(this_ptr: &Shutdown) -> crate::c_types::derived::CVec_u8Z {
4400 let mut inner_val = &mut this_ptr.get_native_mut_ref().scriptpubkey;
4401 inner_val.as_bytes().to_vec().into()
4403 /// The destination of this peer's funds on closing.
4405 /// Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.
4407 pub extern "C" fn Shutdown_set_scriptpubkey(this_ptr: &mut Shutdown, mut val: crate::c_types::derived::CVec_u8Z) {
4408 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.scriptpubkey = ::bitcoin::blockdata::script::ScriptBuf::from(val.into_rust());
4410 /// Constructs a new Shutdown given each field
4413 pub extern "C" fn Shutdown_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut scriptpubkey_arg: crate::c_types::derived::CVec_u8Z) -> Shutdown {
4414 Shutdown { inner: ObjOps::heap_alloc(nativeShutdown {
4415 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
4416 scriptpubkey: ::bitcoin::blockdata::script::ScriptBuf::from(scriptpubkey_arg.into_rust()),
4417 }), is_owned: true }
4419 impl Clone for Shutdown {
4420 fn clone(&self) -> Self {
4422 inner: if <*mut nativeShutdown>::is_null(self.inner) { core::ptr::null_mut() } else {
4423 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4429 /// Used only if an object of this type is returned as a trait impl by a method
4430 pub(crate) extern "C" fn Shutdown_clone_void(this_ptr: *const c_void) -> *mut c_void {
4431 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeShutdown)).clone() })) as *mut c_void
4434 /// Creates a copy of the Shutdown
4435 pub extern "C" fn Shutdown_clone(orig: &Shutdown) -> Shutdown {
4438 /// Get a string which allows debug introspection of a Shutdown object
4439 pub extern "C" fn Shutdown_debug_str_void(o: *const c_void) -> Str {
4440 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::Shutdown }).into()}
4441 /// Generates a non-cryptographic 64-bit hash of the Shutdown.
4443 pub extern "C" fn Shutdown_hash(o: &Shutdown) -> u64 {
4444 if o.inner.is_null() { return 0; }
4445 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
4446 #[allow(deprecated)]
4447 let mut hasher = core::hash::SipHasher::new();
4448 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
4449 core::hash::Hasher::finish(&hasher)
4451 /// Checks if two Shutdowns contain equal inner contents.
4452 /// This ignores pointers and is_owned flags and looks at the values in fields.
4453 /// Two objects with NULL inner values will be considered "equal" here.
4455 pub extern "C" fn Shutdown_eq(a: &Shutdown, b: &Shutdown) -> bool {
4456 if a.inner == b.inner { return true; }
4457 if a.inner.is_null() || b.inner.is_null() { return false; }
4458 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4461 use lightning::ln::msgs::ClosingSignedFeeRange as nativeClosingSignedFeeRangeImport;
4462 pub(crate) type nativeClosingSignedFeeRange = nativeClosingSignedFeeRangeImport;
4464 /// The minimum and maximum fees which the sender is willing to place on the closing transaction.
4466 /// This is provided in [`ClosingSigned`] by both sides to indicate the fee range they are willing
4470 pub struct ClosingSignedFeeRange {
4471 /// A pointer to the opaque Rust object.
4473 /// Nearly everywhere, inner must be non-null, however in places where
4474 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4475 pub inner: *mut nativeClosingSignedFeeRange,
4476 /// Indicates that this is the only struct which contains the same pointer.
4478 /// Rust functions which take ownership of an object provided via an argument require
4479 /// this to be true and invalidate the object pointed to by inner.
4483 impl Drop for ClosingSignedFeeRange {
4484 fn drop(&mut self) {
4485 if self.is_owned && !<*mut nativeClosingSignedFeeRange>::is_null(self.inner) {
4486 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4490 /// Frees any resources used by the ClosingSignedFeeRange, if is_owned is set and inner is non-NULL.
4492 pub extern "C" fn ClosingSignedFeeRange_free(this_obj: ClosingSignedFeeRange) { }
4494 /// Used only if an object of this type is returned as a trait impl by a method
4495 pub(crate) extern "C" fn ClosingSignedFeeRange_free_void(this_ptr: *mut c_void) {
4496 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeClosingSignedFeeRange) };
4499 impl ClosingSignedFeeRange {
4500 pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSignedFeeRange {
4501 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4503 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSignedFeeRange {
4504 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4506 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4507 pub(crate) fn take_inner(mut self) -> *mut nativeClosingSignedFeeRange {
4508 assert!(self.is_owned);
4509 let ret = ObjOps::untweak_ptr(self.inner);
4510 self.inner = core::ptr::null_mut();
4514 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
4517 pub extern "C" fn ClosingSignedFeeRange_get_min_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
4518 let mut inner_val = &mut this_ptr.get_native_mut_ref().min_fee_satoshis;
4521 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
4524 pub extern "C" fn ClosingSignedFeeRange_set_min_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
4525 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_fee_satoshis = val;
4527 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
4530 pub extern "C" fn ClosingSignedFeeRange_get_max_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
4531 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_fee_satoshis;
4534 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
4537 pub extern "C" fn ClosingSignedFeeRange_set_max_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
4538 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_fee_satoshis = val;
4540 /// Constructs a new ClosingSignedFeeRange given each field
4543 pub extern "C" fn ClosingSignedFeeRange_new(mut min_fee_satoshis_arg: u64, mut max_fee_satoshis_arg: u64) -> ClosingSignedFeeRange {
4544 ClosingSignedFeeRange { inner: ObjOps::heap_alloc(nativeClosingSignedFeeRange {
4545 min_fee_satoshis: min_fee_satoshis_arg,
4546 max_fee_satoshis: max_fee_satoshis_arg,
4547 }), is_owned: true }
4549 impl Clone for ClosingSignedFeeRange {
4550 fn clone(&self) -> Self {
4552 inner: if <*mut nativeClosingSignedFeeRange>::is_null(self.inner) { core::ptr::null_mut() } else {
4553 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4559 /// Used only if an object of this type is returned as a trait impl by a method
4560 pub(crate) extern "C" fn ClosingSignedFeeRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
4561 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeClosingSignedFeeRange)).clone() })) as *mut c_void
4564 /// Creates a copy of the ClosingSignedFeeRange
4565 pub extern "C" fn ClosingSignedFeeRange_clone(orig: &ClosingSignedFeeRange) -> ClosingSignedFeeRange {
4568 /// Get a string which allows debug introspection of a ClosingSignedFeeRange object
4569 pub extern "C" fn ClosingSignedFeeRange_debug_str_void(o: *const c_void) -> Str {
4570 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ClosingSignedFeeRange }).into()}
4571 /// Generates a non-cryptographic 64-bit hash of the ClosingSignedFeeRange.
4573 pub extern "C" fn ClosingSignedFeeRange_hash(o: &ClosingSignedFeeRange) -> u64 {
4574 if o.inner.is_null() { return 0; }
4575 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
4576 #[allow(deprecated)]
4577 let mut hasher = core::hash::SipHasher::new();
4578 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
4579 core::hash::Hasher::finish(&hasher)
4581 /// Checks if two ClosingSignedFeeRanges contain equal inner contents.
4582 /// This ignores pointers and is_owned flags and looks at the values in fields.
4583 /// Two objects with NULL inner values will be considered "equal" here.
4585 pub extern "C" fn ClosingSignedFeeRange_eq(a: &ClosingSignedFeeRange, b: &ClosingSignedFeeRange) -> bool {
4586 if a.inner == b.inner { return true; }
4587 if a.inner.is_null() || b.inner.is_null() { return false; }
4588 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4591 use lightning::ln::msgs::ClosingSigned as nativeClosingSignedImport;
4592 pub(crate) type nativeClosingSigned = nativeClosingSignedImport;
4594 /// A [`closing_signed`] message to be sent to or received from a peer.
4596 /// [`closing_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-negotiation-closing_signed
4599 pub struct ClosingSigned {
4600 /// A pointer to the opaque Rust object.
4602 /// Nearly everywhere, inner must be non-null, however in places where
4603 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4604 pub inner: *mut nativeClosingSigned,
4605 /// Indicates that this is the only struct which contains the same pointer.
4607 /// Rust functions which take ownership of an object provided via an argument require
4608 /// this to be true and invalidate the object pointed to by inner.
4612 impl Drop for ClosingSigned {
4613 fn drop(&mut self) {
4614 if self.is_owned && !<*mut nativeClosingSigned>::is_null(self.inner) {
4615 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4619 /// Frees any resources used by the ClosingSigned, if is_owned is set and inner is non-NULL.
4621 pub extern "C" fn ClosingSigned_free(this_obj: ClosingSigned) { }
4623 /// Used only if an object of this type is returned as a trait impl by a method
4624 pub(crate) extern "C" fn ClosingSigned_free_void(this_ptr: *mut c_void) {
4625 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeClosingSigned) };
4628 impl ClosingSigned {
4629 pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSigned {
4630 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4632 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSigned {
4633 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4635 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4636 pub(crate) fn take_inner(mut self) -> *mut nativeClosingSigned {
4637 assert!(self.is_owned);
4638 let ret = ObjOps::untweak_ptr(self.inner);
4639 self.inner = core::ptr::null_mut();
4645 pub extern "C" fn ClosingSigned_get_channel_id(this_ptr: &ClosingSigned) -> crate::lightning::ln::types::ChannelId {
4646 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4647 crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
4651 pub extern "C" fn ClosingSigned_set_channel_id(this_ptr: &mut ClosingSigned, mut val: crate::lightning::ln::types::ChannelId) {
4652 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
4654 /// The proposed total fee for the closing transaction
4656 pub extern "C" fn ClosingSigned_get_fee_satoshis(this_ptr: &ClosingSigned) -> u64 {
4657 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_satoshis;
4660 /// The proposed total fee for the closing transaction
4662 pub extern "C" fn ClosingSigned_set_fee_satoshis(this_ptr: &mut ClosingSigned, mut val: u64) {
4663 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_satoshis = val;
4665 /// A signature on the closing transaction
4667 pub extern "C" fn ClosingSigned_get_signature(this_ptr: &ClosingSigned) -> crate::c_types::ECDSASignature {
4668 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
4669 crate::c_types::ECDSASignature::from_rust(&inner_val)
4671 /// A signature on the closing transaction
4673 pub extern "C" fn ClosingSigned_set_signature(this_ptr: &mut ClosingSigned, mut val: crate::c_types::ECDSASignature) {
4674 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
4676 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
4679 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
4681 pub extern "C" fn ClosingSigned_get_fee_range(this_ptr: &ClosingSigned) -> crate::lightning::ln::msgs::ClosingSignedFeeRange {
4682 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_range;
4683 let mut local_inner_val = crate::lightning::ln::msgs::ClosingSignedFeeRange { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::msgs::ClosingSignedFeeRange<>) as *mut _ }, is_owned: false };
4686 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
4689 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
4691 pub extern "C" fn ClosingSigned_set_fee_range(this_ptr: &mut ClosingSigned, mut val: crate::lightning::ln::msgs::ClosingSignedFeeRange) {
4692 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
4693 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_range = local_val;
4695 /// Constructs a new ClosingSigned given each field
4697 /// Note that fee_range_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
4700 pub extern "C" fn ClosingSigned_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut fee_satoshis_arg: u64, mut signature_arg: crate::c_types::ECDSASignature, mut fee_range_arg: crate::lightning::ln::msgs::ClosingSignedFeeRange) -> ClosingSigned {
4701 let mut local_fee_range_arg = if fee_range_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(fee_range_arg.take_inner()) } }) };
4702 ClosingSigned { inner: ObjOps::heap_alloc(nativeClosingSigned {
4703 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
4704 fee_satoshis: fee_satoshis_arg,
4705 signature: signature_arg.into_rust(),
4706 fee_range: local_fee_range_arg,
4707 }), is_owned: true }
4709 impl Clone for ClosingSigned {
4710 fn clone(&self) -> Self {
4712 inner: if <*mut nativeClosingSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
4713 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4719 /// Used only if an object of this type is returned as a trait impl by a method
4720 pub(crate) extern "C" fn ClosingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
4721 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeClosingSigned)).clone() })) as *mut c_void
4724 /// Creates a copy of the ClosingSigned
4725 pub extern "C" fn ClosingSigned_clone(orig: &ClosingSigned) -> ClosingSigned {
4728 /// Get a string which allows debug introspection of a ClosingSigned object
4729 pub extern "C" fn ClosingSigned_debug_str_void(o: *const c_void) -> Str {
4730 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ClosingSigned }).into()}
4731 /// Generates a non-cryptographic 64-bit hash of the ClosingSigned.
4733 pub extern "C" fn ClosingSigned_hash(o: &ClosingSigned) -> u64 {
4734 if o.inner.is_null() { return 0; }
4735 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
4736 #[allow(deprecated)]
4737 let mut hasher = core::hash::SipHasher::new();
4738 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
4739 core::hash::Hasher::finish(&hasher)
4741 /// Checks if two ClosingSigneds contain equal inner contents.
4742 /// This ignores pointers and is_owned flags and looks at the values in fields.
4743 /// Two objects with NULL inner values will be considered "equal" here.
4745 pub extern "C" fn ClosingSigned_eq(a: &ClosingSigned, b: &ClosingSigned) -> bool {
4746 if a.inner == b.inner { return true; }
4747 if a.inner.is_null() || b.inner.is_null() { return false; }
4748 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4751 use lightning::ln::msgs::UpdateAddHTLC as nativeUpdateAddHTLCImport;
4752 pub(crate) type nativeUpdateAddHTLC = nativeUpdateAddHTLCImport;
4754 /// An [`update_add_htlc`] message to be sent to or received from a peer.
4756 /// [`update_add_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#adding-an-htlc-update_add_htlc
4759 pub struct UpdateAddHTLC {
4760 /// A pointer to the opaque Rust object.
4762 /// Nearly everywhere, inner must be non-null, however in places where
4763 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4764 pub inner: *mut nativeUpdateAddHTLC,
4765 /// Indicates that this is the only struct which contains the same pointer.
4767 /// Rust functions which take ownership of an object provided via an argument require
4768 /// this to be true and invalidate the object pointed to by inner.
4772 impl Drop for UpdateAddHTLC {
4773 fn drop(&mut self) {
4774 if self.is_owned && !<*mut nativeUpdateAddHTLC>::is_null(self.inner) {
4775 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4779 /// Frees any resources used by the UpdateAddHTLC, if is_owned is set and inner is non-NULL.
4781 pub extern "C" fn UpdateAddHTLC_free(this_obj: UpdateAddHTLC) { }
4783 /// Used only if an object of this type is returned as a trait impl by a method
4784 pub(crate) extern "C" fn UpdateAddHTLC_free_void(this_ptr: *mut c_void) {
4785 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateAddHTLC) };
4788 impl UpdateAddHTLC {
4789 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateAddHTLC {
4790 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4792 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateAddHTLC {
4793 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4795 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4796 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateAddHTLC {
4797 assert!(self.is_owned);
4798 let ret = ObjOps::untweak_ptr(self.inner);
4799 self.inner = core::ptr::null_mut();
4805 pub extern "C" fn UpdateAddHTLC_get_channel_id(this_ptr: &UpdateAddHTLC) -> crate::lightning::ln::types::ChannelId {
4806 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4807 crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
4811 pub extern "C" fn UpdateAddHTLC_set_channel_id(this_ptr: &mut UpdateAddHTLC, mut val: crate::lightning::ln::types::ChannelId) {
4812 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
4816 pub extern "C" fn UpdateAddHTLC_get_htlc_id(this_ptr: &UpdateAddHTLC) -> u64 {
4817 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
4822 pub extern "C" fn UpdateAddHTLC_set_htlc_id(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
4823 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
4825 /// The HTLC value in milli-satoshi
4827 pub extern "C" fn UpdateAddHTLC_get_amount_msat(this_ptr: &UpdateAddHTLC) -> u64 {
4828 let mut inner_val = &mut this_ptr.get_native_mut_ref().amount_msat;
4831 /// The HTLC value in milli-satoshi
4833 pub extern "C" fn UpdateAddHTLC_set_amount_msat(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
4834 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.amount_msat = val;
4836 /// The payment hash, the pre-image of which controls HTLC redemption
4838 pub extern "C" fn UpdateAddHTLC_get_payment_hash(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
4839 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_hash;
4842 /// The payment hash, the pre-image of which controls HTLC redemption
4844 pub extern "C" fn UpdateAddHTLC_set_payment_hash(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4845 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_hash = ::lightning::ln::types::PaymentHash(val.data);
4847 /// The expiry height of the HTLC
4849 pub extern "C" fn UpdateAddHTLC_get_cltv_expiry(this_ptr: &UpdateAddHTLC) -> u32 {
4850 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry;
4853 /// The expiry height of the HTLC
4855 pub extern "C" fn UpdateAddHTLC_set_cltv_expiry(this_ptr: &mut UpdateAddHTLC, mut val: u32) {
4856 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry = val;
4858 /// The extra fee skimmed by the sender of this message. See
4859 /// [`ChannelConfig::accept_underpaying_htlcs`].
4861 /// [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
4863 pub extern "C" fn UpdateAddHTLC_get_skimmed_fee_msat(this_ptr: &UpdateAddHTLC) -> crate::c_types::derived::COption_u64Z {
4864 let mut inner_val = &mut this_ptr.get_native_mut_ref().skimmed_fee_msat;
4865 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) };
4868 /// The extra fee skimmed by the sender of this message. See
4869 /// [`ChannelConfig::accept_underpaying_htlcs`].
4871 /// [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
4873 pub extern "C" fn UpdateAddHTLC_set_skimmed_fee_msat(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::derived::COption_u64Z) {
4874 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
4875 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.skimmed_fee_msat = local_val;
4877 /// The onion routing packet with encrypted data for the next hop.
4879 pub extern "C" fn UpdateAddHTLC_get_onion_routing_packet(this_ptr: &UpdateAddHTLC) -> crate::lightning::ln::msgs::OnionPacket {
4880 let mut inner_val = &mut this_ptr.get_native_mut_ref().onion_routing_packet;
4881 crate::lightning::ln::msgs::OnionPacket { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::OnionPacket<>) as *mut _) }, is_owned: false }
4883 /// The onion routing packet with encrypted data for the next hop.
4885 pub extern "C" fn UpdateAddHTLC_set_onion_routing_packet(this_ptr: &mut UpdateAddHTLC, mut val: crate::lightning::ln::msgs::OnionPacket) {
4886 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.onion_routing_packet = *unsafe { Box::from_raw(val.take_inner()) };
4888 /// Provided if we are relaying or receiving a payment within a blinded path, to decrypt the onion
4889 /// routing packet and the recipient-provided encrypted payload within.
4891 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
4893 pub extern "C" fn UpdateAddHTLC_get_blinding_point(this_ptr: &UpdateAddHTLC) -> crate::c_types::PublicKey {
4894 let mut inner_val = &mut this_ptr.get_native_mut_ref().blinding_point;
4895 let mut local_inner_val = if inner_val.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(inner_val.unwrap())) } };
4898 /// Provided if we are relaying or receiving a payment within a blinded path, to decrypt the onion
4899 /// routing packet and the recipient-provided encrypted payload within.
4901 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
4903 pub extern "C" fn UpdateAddHTLC_set_blinding_point(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::PublicKey) {
4904 let mut local_val = if val.is_null() { None } else { Some( { val.into_rust() }) };
4905 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.blinding_point = local_val;
4907 /// Constructs a new UpdateAddHTLC given each field
4909 /// Note that blinding_point_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
4912 pub extern "C" fn UpdateAddHTLC_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut htlc_id_arg: u64, mut amount_msat_arg: u64, mut payment_hash_arg: crate::c_types::ThirtyTwoBytes, mut cltv_expiry_arg: u32, mut skimmed_fee_msat_arg: crate::c_types::derived::COption_u64Z, mut onion_routing_packet_arg: crate::lightning::ln::msgs::OnionPacket, mut blinding_point_arg: crate::c_types::PublicKey) -> UpdateAddHTLC {
4913 let mut local_skimmed_fee_msat_arg = if skimmed_fee_msat_arg.is_some() { Some( { skimmed_fee_msat_arg.take() }) } else { None };
4914 let mut local_blinding_point_arg = if blinding_point_arg.is_null() { None } else { Some( { blinding_point_arg.into_rust() }) };
4915 UpdateAddHTLC { inner: ObjOps::heap_alloc(nativeUpdateAddHTLC {
4916 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
4917 htlc_id: htlc_id_arg,
4918 amount_msat: amount_msat_arg,
4919 payment_hash: ::lightning::ln::types::PaymentHash(payment_hash_arg.data),
4920 cltv_expiry: cltv_expiry_arg,
4921 skimmed_fee_msat: local_skimmed_fee_msat_arg,
4922 onion_routing_packet: *unsafe { Box::from_raw(onion_routing_packet_arg.take_inner()) },
4923 blinding_point: local_blinding_point_arg,
4924 }), is_owned: true }
4926 impl Clone for UpdateAddHTLC {
4927 fn clone(&self) -> Self {
4929 inner: if <*mut nativeUpdateAddHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
4930 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4936 /// Used only if an object of this type is returned as a trait impl by a method
4937 pub(crate) extern "C" fn UpdateAddHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
4938 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUpdateAddHTLC)).clone() })) as *mut c_void
4941 /// Creates a copy of the UpdateAddHTLC
4942 pub extern "C" fn UpdateAddHTLC_clone(orig: &UpdateAddHTLC) -> UpdateAddHTLC {
4945 /// Get a string which allows debug introspection of a UpdateAddHTLC object
4946 pub extern "C" fn UpdateAddHTLC_debug_str_void(o: *const c_void) -> Str {
4947 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UpdateAddHTLC }).into()}
4948 /// Generates a non-cryptographic 64-bit hash of the UpdateAddHTLC.
4950 pub extern "C" fn UpdateAddHTLC_hash(o: &UpdateAddHTLC) -> u64 {
4951 if o.inner.is_null() { return 0; }
4952 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
4953 #[allow(deprecated)]
4954 let mut hasher = core::hash::SipHasher::new();
4955 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
4956 core::hash::Hasher::finish(&hasher)
4958 /// Checks if two UpdateAddHTLCs contain equal inner contents.
4959 /// This ignores pointers and is_owned flags and looks at the values in fields.
4960 /// Two objects with NULL inner values will be considered "equal" here.
4962 pub extern "C" fn UpdateAddHTLC_eq(a: &UpdateAddHTLC, b: &UpdateAddHTLC) -> bool {
4963 if a.inner == b.inner { return true; }
4964 if a.inner.is_null() || b.inner.is_null() { return false; }
4965 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4968 use lightning::ln::msgs::OnionMessage as nativeOnionMessageImport;
4969 pub(crate) type nativeOnionMessage = nativeOnionMessageImport;
4971 /// An onion message to be sent to or received from a peer.
4975 pub struct OnionMessage {
4976 /// A pointer to the opaque Rust object.
4978 /// Nearly everywhere, inner must be non-null, however in places where
4979 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4980 pub inner: *mut nativeOnionMessage,
4981 /// Indicates that this is the only struct which contains the same pointer.
4983 /// Rust functions which take ownership of an object provided via an argument require
4984 /// this to be true and invalidate the object pointed to by inner.
4988 impl Drop for OnionMessage {
4989 fn drop(&mut self) {
4990 if self.is_owned && !<*mut nativeOnionMessage>::is_null(self.inner) {
4991 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4995 /// Frees any resources used by the OnionMessage, if is_owned is set and inner is non-NULL.
4997 pub extern "C" fn OnionMessage_free(this_obj: OnionMessage) { }
4999 /// Used only if an object of this type is returned as a trait impl by a method
5000 pub(crate) extern "C" fn OnionMessage_free_void(this_ptr: *mut c_void) {
5001 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOnionMessage) };
5005 pub(crate) fn get_native_ref(&self) -> &'static nativeOnionMessage {
5006 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5008 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOnionMessage {
5009 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5011 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5012 pub(crate) fn take_inner(mut self) -> *mut nativeOnionMessage {
5013 assert!(self.is_owned);
5014 let ret = ObjOps::untweak_ptr(self.inner);
5015 self.inner = core::ptr::null_mut();
5019 /// Used in decrypting the onion packet's payload.
5021 pub extern "C" fn OnionMessage_get_blinding_point(this_ptr: &OnionMessage) -> crate::c_types::PublicKey {
5022 let mut inner_val = &mut this_ptr.get_native_mut_ref().blinding_point;
5023 crate::c_types::PublicKey::from_rust(&inner_val)
5025 /// Used in decrypting the onion packet's payload.
5027 pub extern "C" fn OnionMessage_set_blinding_point(this_ptr: &mut OnionMessage, mut val: crate::c_types::PublicKey) {
5028 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.blinding_point = val.into_rust();
5030 /// The full onion packet including hop data, pubkey, and hmac
5032 pub extern "C" fn OnionMessage_get_onion_routing_packet(this_ptr: &OnionMessage) -> crate::lightning::onion_message::packet::Packet {
5033 let mut inner_val = &mut this_ptr.get_native_mut_ref().onion_routing_packet;
5034 crate::lightning::onion_message::packet::Packet { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::onion_message::packet::Packet<>) as *mut _) }, is_owned: false }
5036 /// The full onion packet including hop data, pubkey, and hmac
5038 pub extern "C" fn OnionMessage_set_onion_routing_packet(this_ptr: &mut OnionMessage, mut val: crate::lightning::onion_message::packet::Packet) {
5039 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.onion_routing_packet = *unsafe { Box::from_raw(val.take_inner()) };
5041 /// Constructs a new OnionMessage given each field
5044 pub extern "C" fn OnionMessage_new(mut blinding_point_arg: crate::c_types::PublicKey, mut onion_routing_packet_arg: crate::lightning::onion_message::packet::Packet) -> OnionMessage {
5045 OnionMessage { inner: ObjOps::heap_alloc(nativeOnionMessage {
5046 blinding_point: blinding_point_arg.into_rust(),
5047 onion_routing_packet: *unsafe { Box::from_raw(onion_routing_packet_arg.take_inner()) },
5048 }), is_owned: true }
5050 impl Clone for OnionMessage {
5051 fn clone(&self) -> Self {
5053 inner: if <*mut nativeOnionMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
5054 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5060 /// Used only if an object of this type is returned as a trait impl by a method
5061 pub(crate) extern "C" fn OnionMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
5062 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOnionMessage)).clone() })) as *mut c_void
5065 /// Creates a copy of the OnionMessage
5066 pub extern "C" fn OnionMessage_clone(orig: &OnionMessage) -> OnionMessage {
5069 /// Get a string which allows debug introspection of a OnionMessage object
5070 pub extern "C" fn OnionMessage_debug_str_void(o: *const c_void) -> Str {
5071 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::OnionMessage }).into()}
5072 /// Generates a non-cryptographic 64-bit hash of the OnionMessage.
5074 pub extern "C" fn OnionMessage_hash(o: &OnionMessage) -> u64 {
5075 if o.inner.is_null() { return 0; }
5076 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
5077 #[allow(deprecated)]
5078 let mut hasher = core::hash::SipHasher::new();
5079 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
5080 core::hash::Hasher::finish(&hasher)
5082 /// Checks if two OnionMessages contain equal inner contents.
5083 /// This ignores pointers and is_owned flags and looks at the values in fields.
5084 /// Two objects with NULL inner values will be considered "equal" here.
5086 pub extern "C" fn OnionMessage_eq(a: &OnionMessage, b: &OnionMessage) -> bool {
5087 if a.inner == b.inner { return true; }
5088 if a.inner.is_null() || b.inner.is_null() { return false; }
5089 if a.get_native_ref() == b.get_native_ref() { true } else { false }
5092 use lightning::ln::msgs::UpdateFulfillHTLC as nativeUpdateFulfillHTLCImport;
5093 pub(crate) type nativeUpdateFulfillHTLC = nativeUpdateFulfillHTLCImport;
5095 /// An [`update_fulfill_htlc`] message to be sent to or received from a peer.
5097 /// [`update_fulfill_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#removing-an-htlc-update_fulfill_htlc-update_fail_htlc-and-update_fail_malformed_htlc
5100 pub struct UpdateFulfillHTLC {
5101 /// A pointer to the opaque Rust object.
5103 /// Nearly everywhere, inner must be non-null, however in places where
5104 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5105 pub inner: *mut nativeUpdateFulfillHTLC,
5106 /// Indicates that this is the only struct which contains the same pointer.
5108 /// Rust functions which take ownership of an object provided via an argument require
5109 /// this to be true and invalidate the object pointed to by inner.
5113 impl Drop for UpdateFulfillHTLC {
5114 fn drop(&mut self) {
5115 if self.is_owned && !<*mut nativeUpdateFulfillHTLC>::is_null(self.inner) {
5116 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5120 /// Frees any resources used by the UpdateFulfillHTLC, if is_owned is set and inner is non-NULL.
5122 pub extern "C" fn UpdateFulfillHTLC_free(this_obj: UpdateFulfillHTLC) { }
5124 /// Used only if an object of this type is returned as a trait impl by a method
5125 pub(crate) extern "C" fn UpdateFulfillHTLC_free_void(this_ptr: *mut c_void) {
5126 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFulfillHTLC) };
5129 impl UpdateFulfillHTLC {
5130 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFulfillHTLC {
5131 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5133 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFulfillHTLC {
5134 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5136 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5137 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFulfillHTLC {
5138 assert!(self.is_owned);
5139 let ret = ObjOps::untweak_ptr(self.inner);
5140 self.inner = core::ptr::null_mut();
5146 pub extern "C" fn UpdateFulfillHTLC_get_channel_id(this_ptr: &UpdateFulfillHTLC) -> crate::lightning::ln::types::ChannelId {
5147 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5148 crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
5152 pub extern "C" fn UpdateFulfillHTLC_set_channel_id(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::lightning::ln::types::ChannelId) {
5153 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
5157 pub extern "C" fn UpdateFulfillHTLC_get_htlc_id(this_ptr: &UpdateFulfillHTLC) -> u64 {
5158 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
5163 pub extern "C" fn UpdateFulfillHTLC_set_htlc_id(this_ptr: &mut UpdateFulfillHTLC, mut val: u64) {
5164 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
5166 /// The pre-image of the payment hash, allowing HTLC redemption
5168 pub extern "C" fn UpdateFulfillHTLC_get_payment_preimage(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
5169 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_preimage;
5172 /// The pre-image of the payment hash, allowing HTLC redemption
5174 pub extern "C" fn UpdateFulfillHTLC_set_payment_preimage(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
5175 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_preimage = ::lightning::ln::types::PaymentPreimage(val.data);
5177 /// Constructs a new UpdateFulfillHTLC given each field
5180 pub extern "C" fn UpdateFulfillHTLC_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut htlc_id_arg: u64, mut payment_preimage_arg: crate::c_types::ThirtyTwoBytes) -> UpdateFulfillHTLC {
5181 UpdateFulfillHTLC { inner: ObjOps::heap_alloc(nativeUpdateFulfillHTLC {
5182 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
5183 htlc_id: htlc_id_arg,
5184 payment_preimage: ::lightning::ln::types::PaymentPreimage(payment_preimage_arg.data),
5185 }), is_owned: true }
5187 impl Clone for UpdateFulfillHTLC {
5188 fn clone(&self) -> Self {
5190 inner: if <*mut nativeUpdateFulfillHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
5191 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5197 /// Used only if an object of this type is returned as a trait impl by a method
5198 pub(crate) extern "C" fn UpdateFulfillHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
5199 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUpdateFulfillHTLC)).clone() })) as *mut c_void
5202 /// Creates a copy of the UpdateFulfillHTLC
5203 pub extern "C" fn UpdateFulfillHTLC_clone(orig: &UpdateFulfillHTLC) -> UpdateFulfillHTLC {
5206 /// Get a string which allows debug introspection of a UpdateFulfillHTLC object
5207 pub extern "C" fn UpdateFulfillHTLC_debug_str_void(o: *const c_void) -> Str {
5208 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UpdateFulfillHTLC }).into()}
5209 /// Generates a non-cryptographic 64-bit hash of the UpdateFulfillHTLC.
5211 pub extern "C" fn UpdateFulfillHTLC_hash(o: &UpdateFulfillHTLC) -> u64 {
5212 if o.inner.is_null() { return 0; }
5213 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
5214 #[allow(deprecated)]
5215 let mut hasher = core::hash::SipHasher::new();
5216 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
5217 core::hash::Hasher::finish(&hasher)
5219 /// Checks if two UpdateFulfillHTLCs contain equal inner contents.
5220 /// This ignores pointers and is_owned flags and looks at the values in fields.
5221 /// Two objects with NULL inner values will be considered "equal" here.
5223 pub extern "C" fn UpdateFulfillHTLC_eq(a: &UpdateFulfillHTLC, b: &UpdateFulfillHTLC) -> bool {
5224 if a.inner == b.inner { return true; }
5225 if a.inner.is_null() || b.inner.is_null() { return false; }
5226 if a.get_native_ref() == b.get_native_ref() { true } else { false }
5229 use lightning::ln::msgs::UpdateFailHTLC as nativeUpdateFailHTLCImport;
5230 pub(crate) type nativeUpdateFailHTLC = nativeUpdateFailHTLCImport;
5232 /// An [`update_fail_htlc`] message to be sent to or received from a peer.
5234 /// [`update_fail_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#removing-an-htlc-update_fulfill_htlc-update_fail_htlc-and-update_fail_malformed_htlc
5237 pub struct UpdateFailHTLC {
5238 /// A pointer to the opaque Rust object.
5240 /// Nearly everywhere, inner must be non-null, however in places where
5241 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5242 pub inner: *mut nativeUpdateFailHTLC,
5243 /// Indicates that this is the only struct which contains the same pointer.
5245 /// Rust functions which take ownership of an object provided via an argument require
5246 /// this to be true and invalidate the object pointed to by inner.
5250 impl Drop for UpdateFailHTLC {
5251 fn drop(&mut self) {
5252 if self.is_owned && !<*mut nativeUpdateFailHTLC>::is_null(self.inner) {
5253 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5257 /// Frees any resources used by the UpdateFailHTLC, if is_owned is set and inner is non-NULL.
5259 pub extern "C" fn UpdateFailHTLC_free(this_obj: UpdateFailHTLC) { }
5261 /// Used only if an object of this type is returned as a trait impl by a method
5262 pub(crate) extern "C" fn UpdateFailHTLC_free_void(this_ptr: *mut c_void) {
5263 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFailHTLC) };
5266 impl UpdateFailHTLC {
5267 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailHTLC {
5268 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5270 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailHTLC {
5271 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5273 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5274 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailHTLC {
5275 assert!(self.is_owned);
5276 let ret = ObjOps::untweak_ptr(self.inner);
5277 self.inner = core::ptr::null_mut();
5283 pub extern "C" fn UpdateFailHTLC_get_channel_id(this_ptr: &UpdateFailHTLC) -> crate::lightning::ln::types::ChannelId {
5284 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5285 crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
5289 pub extern "C" fn UpdateFailHTLC_set_channel_id(this_ptr: &mut UpdateFailHTLC, mut val: crate::lightning::ln::types::ChannelId) {
5290 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
5294 pub extern "C" fn UpdateFailHTLC_get_htlc_id(this_ptr: &UpdateFailHTLC) -> u64 {
5295 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
5300 pub extern "C" fn UpdateFailHTLC_set_htlc_id(this_ptr: &mut UpdateFailHTLC, mut val: u64) {
5301 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
5303 impl Clone for UpdateFailHTLC {
5304 fn clone(&self) -> Self {
5306 inner: if <*mut nativeUpdateFailHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
5307 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5313 /// Used only if an object of this type is returned as a trait impl by a method
5314 pub(crate) extern "C" fn UpdateFailHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
5315 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUpdateFailHTLC)).clone() })) as *mut c_void
5318 /// Creates a copy of the UpdateFailHTLC
5319 pub extern "C" fn UpdateFailHTLC_clone(orig: &UpdateFailHTLC) -> UpdateFailHTLC {
5322 /// Get a string which allows debug introspection of a UpdateFailHTLC object
5323 pub extern "C" fn UpdateFailHTLC_debug_str_void(o: *const c_void) -> Str {
5324 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UpdateFailHTLC }).into()}
5325 /// Generates a non-cryptographic 64-bit hash of the UpdateFailHTLC.
5327 pub extern "C" fn UpdateFailHTLC_hash(o: &UpdateFailHTLC) -> u64 {
5328 if o.inner.is_null() { return 0; }
5329 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
5330 #[allow(deprecated)]
5331 let mut hasher = core::hash::SipHasher::new();
5332 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
5333 core::hash::Hasher::finish(&hasher)
5335 /// Checks if two UpdateFailHTLCs contain equal inner contents.
5336 /// This ignores pointers and is_owned flags and looks at the values in fields.
5337 /// Two objects with NULL inner values will be considered "equal" here.
5339 pub extern "C" fn UpdateFailHTLC_eq(a: &UpdateFailHTLC, b: &UpdateFailHTLC) -> bool {
5340 if a.inner == b.inner { return true; }
5341 if a.inner.is_null() || b.inner.is_null() { return false; }
5342 if a.get_native_ref() == b.get_native_ref() { true } else { false }
5345 use lightning::ln::msgs::UpdateFailMalformedHTLC as nativeUpdateFailMalformedHTLCImport;
5346 pub(crate) type nativeUpdateFailMalformedHTLC = nativeUpdateFailMalformedHTLCImport;
5348 /// An [`update_fail_malformed_htlc`] message to be sent to or received from a peer.
5350 /// [`update_fail_malformed_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#removing-an-htlc-update_fulfill_htlc-update_fail_htlc-and-update_fail_malformed_htlc
5353 pub struct UpdateFailMalformedHTLC {
5354 /// A pointer to the opaque Rust object.
5356 /// Nearly everywhere, inner must be non-null, however in places where
5357 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5358 pub inner: *mut nativeUpdateFailMalformedHTLC,
5359 /// Indicates that this is the only struct which contains the same pointer.
5361 /// Rust functions which take ownership of an object provided via an argument require
5362 /// this to be true and invalidate the object pointed to by inner.
5366 impl Drop for UpdateFailMalformedHTLC {
5367 fn drop(&mut self) {
5368 if self.is_owned && !<*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) {
5369 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5373 /// Frees any resources used by the UpdateFailMalformedHTLC, if is_owned is set and inner is non-NULL.
5375 pub extern "C" fn UpdateFailMalformedHTLC_free(this_obj: UpdateFailMalformedHTLC) { }
5377 /// Used only if an object of this type is returned as a trait impl by a method
5378 pub(crate) extern "C" fn UpdateFailMalformedHTLC_free_void(this_ptr: *mut c_void) {
5379 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFailMalformedHTLC) };
5382 impl UpdateFailMalformedHTLC {
5383 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailMalformedHTLC {
5384 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5386 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailMalformedHTLC {
5387 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5389 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5390 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailMalformedHTLC {
5391 assert!(self.is_owned);
5392 let ret = ObjOps::untweak_ptr(self.inner);
5393 self.inner = core::ptr::null_mut();
5399 pub extern "C" fn UpdateFailMalformedHTLC_get_channel_id(this_ptr: &UpdateFailMalformedHTLC) -> crate::lightning::ln::types::ChannelId {
5400 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5401 crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
5405 pub extern "C" fn UpdateFailMalformedHTLC_set_channel_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: crate::lightning::ln::types::ChannelId) {
5406 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
5410 pub extern "C" fn UpdateFailMalformedHTLC_get_htlc_id(this_ptr: &UpdateFailMalformedHTLC) -> u64 {
5411 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
5416 pub extern "C" fn UpdateFailMalformedHTLC_set_htlc_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u64) {
5417 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
5419 /// The failure code
5421 pub extern "C" fn UpdateFailMalformedHTLC_get_failure_code(this_ptr: &UpdateFailMalformedHTLC) -> u16 {
5422 let mut inner_val = &mut this_ptr.get_native_mut_ref().failure_code;
5425 /// The failure code
5427 pub extern "C" fn UpdateFailMalformedHTLC_set_failure_code(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u16) {
5428 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.failure_code = val;
5430 impl Clone for UpdateFailMalformedHTLC {
5431 fn clone(&self) -> Self {
5433 inner: if <*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
5434 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5440 /// Used only if an object of this type is returned as a trait impl by a method
5441 pub(crate) extern "C" fn UpdateFailMalformedHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
5442 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUpdateFailMalformedHTLC)).clone() })) as *mut c_void
5445 /// Creates a copy of the UpdateFailMalformedHTLC
5446 pub extern "C" fn UpdateFailMalformedHTLC_clone(orig: &UpdateFailMalformedHTLC) -> UpdateFailMalformedHTLC {
5449 /// Get a string which allows debug introspection of a UpdateFailMalformedHTLC object
5450 pub extern "C" fn UpdateFailMalformedHTLC_debug_str_void(o: *const c_void) -> Str {
5451 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UpdateFailMalformedHTLC }).into()}
5452 /// Generates a non-cryptographic 64-bit hash of the UpdateFailMalformedHTLC.
5454 pub extern "C" fn UpdateFailMalformedHTLC_hash(o: &UpdateFailMalformedHTLC) -> u64 {
5455 if o.inner.is_null() { return 0; }
5456 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
5457 #[allow(deprecated)]
5458 let mut hasher = core::hash::SipHasher::new();
5459 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
5460 core::hash::Hasher::finish(&hasher)
5462 /// Checks if two UpdateFailMalformedHTLCs contain equal inner contents.
5463 /// This ignores pointers and is_owned flags and looks at the values in fields.
5464 /// Two objects with NULL inner values will be considered "equal" here.
5466 pub extern "C" fn UpdateFailMalformedHTLC_eq(a: &UpdateFailMalformedHTLC, b: &UpdateFailMalformedHTLC) -> bool {
5467 if a.inner == b.inner { return true; }
5468 if a.inner.is_null() || b.inner.is_null() { return false; }
5469 if a.get_native_ref() == b.get_native_ref() { true } else { false }
5472 use lightning::ln::msgs::CommitmentSigned as nativeCommitmentSignedImport;
5473 pub(crate) type nativeCommitmentSigned = nativeCommitmentSignedImport;
5475 /// A [`commitment_signed`] message to be sent to or received from a peer.
5477 /// [`commitment_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#committing-updates-so-far-commitment_signed
5480 pub struct CommitmentSigned {
5481 /// A pointer to the opaque Rust object.
5483 /// Nearly everywhere, inner must be non-null, however in places where
5484 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5485 pub inner: *mut nativeCommitmentSigned,
5486 /// Indicates that this is the only struct which contains the same pointer.
5488 /// Rust functions which take ownership of an object provided via an argument require
5489 /// this to be true and invalidate the object pointed to by inner.
5493 impl Drop for CommitmentSigned {
5494 fn drop(&mut self) {
5495 if self.is_owned && !<*mut nativeCommitmentSigned>::is_null(self.inner) {
5496 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5500 /// Frees any resources used by the CommitmentSigned, if is_owned is set and inner is non-NULL.
5502 pub extern "C" fn CommitmentSigned_free(this_obj: CommitmentSigned) { }
5504 /// Used only if an object of this type is returned as a trait impl by a method
5505 pub(crate) extern "C" fn CommitmentSigned_free_void(this_ptr: *mut c_void) {
5506 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCommitmentSigned) };
5509 impl CommitmentSigned {
5510 pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentSigned {
5511 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5513 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentSigned {
5514 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5516 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5517 pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentSigned {
5518 assert!(self.is_owned);
5519 let ret = ObjOps::untweak_ptr(self.inner);
5520 self.inner = core::ptr::null_mut();
5526 pub extern "C" fn CommitmentSigned_get_channel_id(this_ptr: &CommitmentSigned) -> crate::lightning::ln::types::ChannelId {
5527 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5528 crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
5532 pub extern "C" fn CommitmentSigned_set_channel_id(this_ptr: &mut CommitmentSigned, mut val: crate::lightning::ln::types::ChannelId) {
5533 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
5535 /// A signature on the commitment transaction
5537 pub extern "C" fn CommitmentSigned_get_signature(this_ptr: &CommitmentSigned) -> crate::c_types::ECDSASignature {
5538 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
5539 crate::c_types::ECDSASignature::from_rust(&inner_val)
5541 /// A signature on the commitment transaction
5543 pub extern "C" fn CommitmentSigned_set_signature(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::ECDSASignature) {
5544 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
5546 /// Signatures on the HTLC transactions
5548 /// Returns a copy of the field.
5550 pub extern "C" fn CommitmentSigned_get_htlc_signatures(this_ptr: &CommitmentSigned) -> crate::c_types::derived::CVec_ECDSASignatureZ {
5551 let mut inner_val = this_ptr.get_native_mut_ref().htlc_signatures.clone();
5552 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { crate::c_types::ECDSASignature::from_rust(&item) }); };
5553 local_inner_val.into()
5555 /// Signatures on the HTLC transactions
5557 pub extern "C" fn CommitmentSigned_set_htlc_signatures(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::derived::CVec_ECDSASignatureZ) {
5558 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_rust() }); };
5559 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_signatures = local_val;
5561 /// Constructs a new CommitmentSigned given each field
5564 pub extern "C" fn CommitmentSigned_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut signature_arg: crate::c_types::ECDSASignature, mut htlc_signatures_arg: crate::c_types::derived::CVec_ECDSASignatureZ) -> CommitmentSigned {
5565 let mut local_htlc_signatures_arg = Vec::new(); for mut item in htlc_signatures_arg.into_rust().drain(..) { local_htlc_signatures_arg.push( { item.into_rust() }); };
5566 CommitmentSigned { inner: ObjOps::heap_alloc(nativeCommitmentSigned {
5567 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
5568 signature: signature_arg.into_rust(),
5569 htlc_signatures: local_htlc_signatures_arg,
5570 }), is_owned: true }
5572 impl Clone for CommitmentSigned {
5573 fn clone(&self) -> Self {
5575 inner: if <*mut nativeCommitmentSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
5576 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5582 /// Used only if an object of this type is returned as a trait impl by a method
5583 pub(crate) extern "C" fn CommitmentSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
5584 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeCommitmentSigned)).clone() })) as *mut c_void
5587 /// Creates a copy of the CommitmentSigned
5588 pub extern "C" fn CommitmentSigned_clone(orig: &CommitmentSigned) -> CommitmentSigned {
5591 /// Get a string which allows debug introspection of a CommitmentSigned object
5592 pub extern "C" fn CommitmentSigned_debug_str_void(o: *const c_void) -> Str {
5593 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::CommitmentSigned }).into()}
5594 /// Generates a non-cryptographic 64-bit hash of the CommitmentSigned.
5596 pub extern "C" fn CommitmentSigned_hash(o: &CommitmentSigned) -> u64 {
5597 if o.inner.is_null() { return 0; }
5598 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
5599 #[allow(deprecated)]
5600 let mut hasher = core::hash::SipHasher::new();
5601 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
5602 core::hash::Hasher::finish(&hasher)
5604 /// Checks if two CommitmentSigneds contain equal inner contents.
5605 /// This ignores pointers and is_owned flags and looks at the values in fields.
5606 /// Two objects with NULL inner values will be considered "equal" here.
5608 pub extern "C" fn CommitmentSigned_eq(a: &CommitmentSigned, b: &CommitmentSigned) -> bool {
5609 if a.inner == b.inner { return true; }
5610 if a.inner.is_null() || b.inner.is_null() { return false; }
5611 if a.get_native_ref() == b.get_native_ref() { true } else { false }
5614 use lightning::ln::msgs::RevokeAndACK as nativeRevokeAndACKImport;
5615 pub(crate) type nativeRevokeAndACK = nativeRevokeAndACKImport;
5617 /// A [`revoke_and_ack`] message to be sent to or received from a peer.
5619 /// [`revoke_and_ack`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#completing-the-transition-to-the-updated-state-revoke_and_ack
5622 pub struct RevokeAndACK {
5623 /// A pointer to the opaque Rust object.
5625 /// Nearly everywhere, inner must be non-null, however in places where
5626 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5627 pub inner: *mut nativeRevokeAndACK,
5628 /// Indicates that this is the only struct which contains the same pointer.
5630 /// Rust functions which take ownership of an object provided via an argument require
5631 /// this to be true and invalidate the object pointed to by inner.
5635 impl Drop for RevokeAndACK {
5636 fn drop(&mut self) {
5637 if self.is_owned && !<*mut nativeRevokeAndACK>::is_null(self.inner) {
5638 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5642 /// Frees any resources used by the RevokeAndACK, if is_owned is set and inner is non-NULL.
5644 pub extern "C" fn RevokeAndACK_free(this_obj: RevokeAndACK) { }
5646 /// Used only if an object of this type is returned as a trait impl by a method
5647 pub(crate) extern "C" fn RevokeAndACK_free_void(this_ptr: *mut c_void) {
5648 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRevokeAndACK) };
5652 pub(crate) fn get_native_ref(&self) -> &'static nativeRevokeAndACK {
5653 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5655 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRevokeAndACK {
5656 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5658 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5659 pub(crate) fn take_inner(mut self) -> *mut nativeRevokeAndACK {
5660 assert!(self.is_owned);
5661 let ret = ObjOps::untweak_ptr(self.inner);
5662 self.inner = core::ptr::null_mut();
5668 pub extern "C" fn RevokeAndACK_get_channel_id(this_ptr: &RevokeAndACK) -> crate::lightning::ln::types::ChannelId {
5669 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5670 crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
5674 pub extern "C" fn RevokeAndACK_set_channel_id(this_ptr: &mut RevokeAndACK, mut val: crate::lightning::ln::types::ChannelId) {
5675 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
5677 /// The secret corresponding to the per-commitment point
5679 pub extern "C" fn RevokeAndACK_get_per_commitment_secret(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
5680 let mut inner_val = &mut this_ptr.get_native_mut_ref().per_commitment_secret;
5683 /// The secret corresponding to the per-commitment point
5685 pub extern "C" fn RevokeAndACK_set_per_commitment_secret(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
5686 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.per_commitment_secret = val.data;
5688 /// The next sender-broadcast commitment transaction's per-commitment point
5690 pub extern "C" fn RevokeAndACK_get_next_per_commitment_point(this_ptr: &RevokeAndACK) -> crate::c_types::PublicKey {
5691 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
5692 crate::c_types::PublicKey::from_rust(&inner_val)
5694 /// The next sender-broadcast commitment transaction's per-commitment point
5696 pub extern "C" fn RevokeAndACK_set_next_per_commitment_point(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::PublicKey) {
5697 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
5699 /// Constructs a new RevokeAndACK given each field
5702 pub extern "C" fn RevokeAndACK_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut per_commitment_secret_arg: crate::c_types::ThirtyTwoBytes, mut next_per_commitment_point_arg: crate::c_types::PublicKey) -> RevokeAndACK {
5703 RevokeAndACK { inner: ObjOps::heap_alloc(nativeRevokeAndACK {
5704 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
5705 per_commitment_secret: per_commitment_secret_arg.data,
5706 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
5707 }), is_owned: true }
5709 impl Clone for RevokeAndACK {
5710 fn clone(&self) -> Self {
5712 inner: if <*mut nativeRevokeAndACK>::is_null(self.inner) { core::ptr::null_mut() } else {
5713 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5719 /// Used only if an object of this type is returned as a trait impl by a method
5720 pub(crate) extern "C" fn RevokeAndACK_clone_void(this_ptr: *const c_void) -> *mut c_void {
5721 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeRevokeAndACK)).clone() })) as *mut c_void
5724 /// Creates a copy of the RevokeAndACK
5725 pub extern "C" fn RevokeAndACK_clone(orig: &RevokeAndACK) -> RevokeAndACK {
5728 /// Get a string which allows debug introspection of a RevokeAndACK object
5729 pub extern "C" fn RevokeAndACK_debug_str_void(o: *const c_void) -> Str {
5730 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::RevokeAndACK }).into()}
5731 /// Generates a non-cryptographic 64-bit hash of the RevokeAndACK.
5733 pub extern "C" fn RevokeAndACK_hash(o: &RevokeAndACK) -> u64 {
5734 if o.inner.is_null() { return 0; }
5735 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
5736 #[allow(deprecated)]
5737 let mut hasher = core::hash::SipHasher::new();
5738 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
5739 core::hash::Hasher::finish(&hasher)
5741 /// Checks if two RevokeAndACKs contain equal inner contents.
5742 /// This ignores pointers and is_owned flags and looks at the values in fields.
5743 /// Two objects with NULL inner values will be considered "equal" here.
5745 pub extern "C" fn RevokeAndACK_eq(a: &RevokeAndACK, b: &RevokeAndACK) -> bool {
5746 if a.inner == b.inner { return true; }
5747 if a.inner.is_null() || b.inner.is_null() { return false; }
5748 if a.get_native_ref() == b.get_native_ref() { true } else { false }
5751 use lightning::ln::msgs::UpdateFee as nativeUpdateFeeImport;
5752 pub(crate) type nativeUpdateFee = nativeUpdateFeeImport;
5754 /// An [`update_fee`] message to be sent to or received from a peer
5756 /// [`update_fee`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#updating-fees-update_fee
5759 pub struct UpdateFee {
5760 /// A pointer to the opaque Rust object.
5762 /// Nearly everywhere, inner must be non-null, however in places where
5763 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5764 pub inner: *mut nativeUpdateFee,
5765 /// Indicates that this is the only struct which contains the same pointer.
5767 /// Rust functions which take ownership of an object provided via an argument require
5768 /// this to be true and invalidate the object pointed to by inner.
5772 impl Drop for UpdateFee {
5773 fn drop(&mut self) {
5774 if self.is_owned && !<*mut nativeUpdateFee>::is_null(self.inner) {
5775 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5779 /// Frees any resources used by the UpdateFee, if is_owned is set and inner is non-NULL.
5781 pub extern "C" fn UpdateFee_free(this_obj: UpdateFee) { }
5783 /// Used only if an object of this type is returned as a trait impl by a method
5784 pub(crate) extern "C" fn UpdateFee_free_void(this_ptr: *mut c_void) {
5785 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFee) };
5789 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFee {
5790 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5792 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFee {
5793 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5795 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5796 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFee {
5797 assert!(self.is_owned);
5798 let ret = ObjOps::untweak_ptr(self.inner);
5799 self.inner = core::ptr::null_mut();
5805 pub extern "C" fn UpdateFee_get_channel_id(this_ptr: &UpdateFee) -> crate::lightning::ln::types::ChannelId {
5806 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5807 crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
5811 pub extern "C" fn UpdateFee_set_channel_id(this_ptr: &mut UpdateFee, mut val: crate::lightning::ln::types::ChannelId) {
5812 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
5814 /// Fee rate per 1000-weight of the transaction
5816 pub extern "C" fn UpdateFee_get_feerate_per_kw(this_ptr: &UpdateFee) -> u32 {
5817 let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
5820 /// Fee rate per 1000-weight of the transaction
5822 pub extern "C" fn UpdateFee_set_feerate_per_kw(this_ptr: &mut UpdateFee, mut val: u32) {
5823 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
5825 /// Constructs a new UpdateFee given each field
5828 pub extern "C" fn UpdateFee_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut feerate_per_kw_arg: u32) -> UpdateFee {
5829 UpdateFee { inner: ObjOps::heap_alloc(nativeUpdateFee {
5830 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
5831 feerate_per_kw: feerate_per_kw_arg,
5832 }), is_owned: true }
5834 impl Clone for UpdateFee {
5835 fn clone(&self) -> Self {
5837 inner: if <*mut nativeUpdateFee>::is_null(self.inner) { core::ptr::null_mut() } else {
5838 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5844 /// Used only if an object of this type is returned as a trait impl by a method
5845 pub(crate) extern "C" fn UpdateFee_clone_void(this_ptr: *const c_void) -> *mut c_void {
5846 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUpdateFee)).clone() })) as *mut c_void
5849 /// Creates a copy of the UpdateFee
5850 pub extern "C" fn UpdateFee_clone(orig: &UpdateFee) -> UpdateFee {
5853 /// Get a string which allows debug introspection of a UpdateFee object
5854 pub extern "C" fn UpdateFee_debug_str_void(o: *const c_void) -> Str {
5855 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UpdateFee }).into()}
5856 /// Generates a non-cryptographic 64-bit hash of the UpdateFee.
5858 pub extern "C" fn UpdateFee_hash(o: &UpdateFee) -> u64 {
5859 if o.inner.is_null() { return 0; }
5860 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
5861 #[allow(deprecated)]
5862 let mut hasher = core::hash::SipHasher::new();
5863 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
5864 core::hash::Hasher::finish(&hasher)
5866 /// Checks if two UpdateFees contain equal inner contents.
5867 /// This ignores pointers and is_owned flags and looks at the values in fields.
5868 /// Two objects with NULL inner values will be considered "equal" here.
5870 pub extern "C" fn UpdateFee_eq(a: &UpdateFee, b: &UpdateFee) -> bool {
5871 if a.inner == b.inner { return true; }
5872 if a.inner.is_null() || b.inner.is_null() { return false; }
5873 if a.get_native_ref() == b.get_native_ref() { true } else { false }
5876 use lightning::ln::msgs::ChannelReestablish as nativeChannelReestablishImport;
5877 pub(crate) type nativeChannelReestablish = nativeChannelReestablishImport;
5879 /// A [`channel_reestablish`] message to be sent to or received from a peer.
5881 /// [`channel_reestablish`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#message-retransmission
5884 pub struct ChannelReestablish {
5885 /// A pointer to the opaque Rust object.
5887 /// Nearly everywhere, inner must be non-null, however in places where
5888 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5889 pub inner: *mut nativeChannelReestablish,
5890 /// Indicates that this is the only struct which contains the same pointer.
5892 /// Rust functions which take ownership of an object provided via an argument require
5893 /// this to be true and invalidate the object pointed to by inner.
5897 impl Drop for ChannelReestablish {
5898 fn drop(&mut self) {
5899 if self.is_owned && !<*mut nativeChannelReestablish>::is_null(self.inner) {
5900 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5904 /// Frees any resources used by the ChannelReestablish, if is_owned is set and inner is non-NULL.
5906 pub extern "C" fn ChannelReestablish_free(this_obj: ChannelReestablish) { }
5908 /// Used only if an object of this type is returned as a trait impl by a method
5909 pub(crate) extern "C" fn ChannelReestablish_free_void(this_ptr: *mut c_void) {
5910 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelReestablish) };
5913 impl ChannelReestablish {
5914 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelReestablish {
5915 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5917 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelReestablish {
5918 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5920 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5921 pub(crate) fn take_inner(mut self) -> *mut nativeChannelReestablish {
5922 assert!(self.is_owned);
5923 let ret = ObjOps::untweak_ptr(self.inner);
5924 self.inner = core::ptr::null_mut();
5930 pub extern "C" fn ChannelReestablish_get_channel_id(this_ptr: &ChannelReestablish) -> crate::lightning::ln::types::ChannelId {
5931 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5932 crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
5936 pub extern "C" fn ChannelReestablish_set_channel_id(this_ptr: &mut ChannelReestablish, mut val: crate::lightning::ln::types::ChannelId) {
5937 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
5939 /// The next commitment number for the sender
5941 pub extern "C" fn ChannelReestablish_get_next_local_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
5942 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_local_commitment_number;
5945 /// The next commitment number for the sender
5947 pub extern "C" fn ChannelReestablish_set_next_local_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
5948 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_local_commitment_number = val;
5950 /// The next commitment number for the recipient
5952 pub extern "C" fn ChannelReestablish_get_next_remote_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
5953 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_remote_commitment_number;
5956 /// The next commitment number for the recipient
5958 pub extern "C" fn ChannelReestablish_set_next_remote_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
5959 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_remote_commitment_number = val;
5961 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
5962 /// belonging to the recipient
5964 pub extern "C" fn ChannelReestablish_get_your_last_per_commitment_secret(this_ptr: &ChannelReestablish) -> *const [u8; 32] {
5965 let mut inner_val = &mut this_ptr.get_native_mut_ref().your_last_per_commitment_secret;
5968 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
5969 /// belonging to the recipient
5971 pub extern "C" fn ChannelReestablish_set_your_last_per_commitment_secret(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) {
5972 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.your_last_per_commitment_secret = val.data;
5974 /// The sender's per-commitment point for their current commitment transaction
5976 pub extern "C" fn ChannelReestablish_get_my_current_per_commitment_point(this_ptr: &ChannelReestablish) -> crate::c_types::PublicKey {
5977 let mut inner_val = &mut this_ptr.get_native_mut_ref().my_current_per_commitment_point;
5978 crate::c_types::PublicKey::from_rust(&inner_val)
5980 /// The sender's per-commitment point for their current commitment transaction
5982 pub extern "C" fn ChannelReestablish_set_my_current_per_commitment_point(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::PublicKey) {
5983 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.my_current_per_commitment_point = val.into_rust();
5985 /// The next funding transaction ID
5987 pub extern "C" fn ChannelReestablish_get_next_funding_txid(this_ptr: &ChannelReestablish) -> crate::c_types::derived::COption_ThirtyTwoBytesZ {
5988 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_funding_txid;
5989 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { crate::c_types::ThirtyTwoBytes { data: *(*inner_val.as_ref().unwrap()).clone().as_ref() } }) };
5992 /// The next funding transaction ID
5994 pub extern "C" fn ChannelReestablish_set_next_funding_txid(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::derived::COption_ThirtyTwoBytesZ) {
5995 let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::hash_types::Txid::from_slice(&{ val_opt.take() }.data[..]).unwrap() }})} };
5996 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_funding_txid = local_val;
5998 /// Constructs a new ChannelReestablish given each field
6001 pub extern "C" fn ChannelReestablish_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut next_local_commitment_number_arg: u64, mut next_remote_commitment_number_arg: u64, mut your_last_per_commitment_secret_arg: crate::c_types::ThirtyTwoBytes, mut my_current_per_commitment_point_arg: crate::c_types::PublicKey, mut next_funding_txid_arg: crate::c_types::derived::COption_ThirtyTwoBytesZ) -> ChannelReestablish {
6002 let mut local_next_funding_txid_arg = { /*next_funding_txid_arg*/ let next_funding_txid_arg_opt = next_funding_txid_arg; if next_funding_txid_arg_opt.is_none() { None } else { Some({ { ::bitcoin::hash_types::Txid::from_slice(&{ next_funding_txid_arg_opt.take() }.data[..]).unwrap() }})} };
6003 ChannelReestablish { inner: ObjOps::heap_alloc(nativeChannelReestablish {
6004 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
6005 next_local_commitment_number: next_local_commitment_number_arg,
6006 next_remote_commitment_number: next_remote_commitment_number_arg,
6007 your_last_per_commitment_secret: your_last_per_commitment_secret_arg.data,
6008 my_current_per_commitment_point: my_current_per_commitment_point_arg.into_rust(),
6009 next_funding_txid: local_next_funding_txid_arg,
6010 }), is_owned: true }
6012 impl Clone for ChannelReestablish {
6013 fn clone(&self) -> Self {
6015 inner: if <*mut nativeChannelReestablish>::is_null(self.inner) { core::ptr::null_mut() } else {
6016 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6022 /// Used only if an object of this type is returned as a trait impl by a method
6023 pub(crate) extern "C" fn ChannelReestablish_clone_void(this_ptr: *const c_void) -> *mut c_void {
6024 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelReestablish)).clone() })) as *mut c_void
6027 /// Creates a copy of the ChannelReestablish
6028 pub extern "C" fn ChannelReestablish_clone(orig: &ChannelReestablish) -> ChannelReestablish {
6031 /// Get a string which allows debug introspection of a ChannelReestablish object
6032 pub extern "C" fn ChannelReestablish_debug_str_void(o: *const c_void) -> Str {
6033 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ChannelReestablish }).into()}
6034 /// Generates a non-cryptographic 64-bit hash of the ChannelReestablish.
6036 pub extern "C" fn ChannelReestablish_hash(o: &ChannelReestablish) -> u64 {
6037 if o.inner.is_null() { return 0; }
6038 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
6039 #[allow(deprecated)]
6040 let mut hasher = core::hash::SipHasher::new();
6041 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
6042 core::hash::Hasher::finish(&hasher)
6044 /// Checks if two ChannelReestablishs contain equal inner contents.
6045 /// This ignores pointers and is_owned flags and looks at the values in fields.
6046 /// Two objects with NULL inner values will be considered "equal" here.
6048 pub extern "C" fn ChannelReestablish_eq(a: &ChannelReestablish, b: &ChannelReestablish) -> bool {
6049 if a.inner == b.inner { return true; }
6050 if a.inner.is_null() || b.inner.is_null() { return false; }
6051 if a.get_native_ref() == b.get_native_ref() { true } else { false }
6054 use lightning::ln::msgs::AnnouncementSignatures as nativeAnnouncementSignaturesImport;
6055 pub(crate) type nativeAnnouncementSignatures = nativeAnnouncementSignaturesImport;
6057 /// An [`announcement_signatures`] message to be sent to or received from a peer.
6059 /// [`announcement_signatures`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-announcement_signatures-message
6062 pub struct AnnouncementSignatures {
6063 /// A pointer to the opaque Rust object.
6065 /// Nearly everywhere, inner must be non-null, however in places where
6066 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6067 pub inner: *mut nativeAnnouncementSignatures,
6068 /// Indicates that this is the only struct which contains the same pointer.
6070 /// Rust functions which take ownership of an object provided via an argument require
6071 /// this to be true and invalidate the object pointed to by inner.
6075 impl Drop for AnnouncementSignatures {
6076 fn drop(&mut self) {
6077 if self.is_owned && !<*mut nativeAnnouncementSignatures>::is_null(self.inner) {
6078 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6082 /// Frees any resources used by the AnnouncementSignatures, if is_owned is set and inner is non-NULL.
6084 pub extern "C" fn AnnouncementSignatures_free(this_obj: AnnouncementSignatures) { }
6086 /// Used only if an object of this type is returned as a trait impl by a method
6087 pub(crate) extern "C" fn AnnouncementSignatures_free_void(this_ptr: *mut c_void) {
6088 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAnnouncementSignatures) };
6091 impl AnnouncementSignatures {
6092 pub(crate) fn get_native_ref(&self) -> &'static nativeAnnouncementSignatures {
6093 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6095 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAnnouncementSignatures {
6096 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6098 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6099 pub(crate) fn take_inner(mut self) -> *mut nativeAnnouncementSignatures {
6100 assert!(self.is_owned);
6101 let ret = ObjOps::untweak_ptr(self.inner);
6102 self.inner = core::ptr::null_mut();
6108 pub extern "C" fn AnnouncementSignatures_get_channel_id(this_ptr: &AnnouncementSignatures) -> crate::lightning::ln::types::ChannelId {
6109 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
6110 crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
6114 pub extern "C" fn AnnouncementSignatures_set_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: crate::lightning::ln::types::ChannelId) {
6115 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
6117 /// The short channel ID
6119 pub extern "C" fn AnnouncementSignatures_get_short_channel_id(this_ptr: &AnnouncementSignatures) -> u64 {
6120 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
6123 /// The short channel ID
6125 pub extern "C" fn AnnouncementSignatures_set_short_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: u64) {
6126 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
6128 /// A signature by the node key
6130 pub extern "C" fn AnnouncementSignatures_get_node_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::ECDSASignature {
6131 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature;
6132 crate::c_types::ECDSASignature::from_rust(&inner_val)
6134 /// A signature by the node key
6136 pub extern "C" fn AnnouncementSignatures_set_node_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ECDSASignature) {
6137 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature = val.into_rust();
6139 /// A signature by the funding key
6141 pub extern "C" fn AnnouncementSignatures_get_bitcoin_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::ECDSASignature {
6142 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature;
6143 crate::c_types::ECDSASignature::from_rust(&inner_val)
6145 /// A signature by the funding key
6147 pub extern "C" fn AnnouncementSignatures_set_bitcoin_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ECDSASignature) {
6148 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature = val.into_rust();
6150 /// Constructs a new AnnouncementSignatures given each field
6153 pub extern "C" fn AnnouncementSignatures_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut short_channel_id_arg: u64, mut node_signature_arg: crate::c_types::ECDSASignature, mut bitcoin_signature_arg: crate::c_types::ECDSASignature) -> AnnouncementSignatures {
6154 AnnouncementSignatures { inner: ObjOps::heap_alloc(nativeAnnouncementSignatures {
6155 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
6156 short_channel_id: short_channel_id_arg,
6157 node_signature: node_signature_arg.into_rust(),
6158 bitcoin_signature: bitcoin_signature_arg.into_rust(),
6159 }), is_owned: true }
6161 impl Clone for AnnouncementSignatures {
6162 fn clone(&self) -> Self {
6164 inner: if <*mut nativeAnnouncementSignatures>::is_null(self.inner) { core::ptr::null_mut() } else {
6165 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6171 /// Used only if an object of this type is returned as a trait impl by a method
6172 pub(crate) extern "C" fn AnnouncementSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
6173 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeAnnouncementSignatures)).clone() })) as *mut c_void
6176 /// Creates a copy of the AnnouncementSignatures
6177 pub extern "C" fn AnnouncementSignatures_clone(orig: &AnnouncementSignatures) -> AnnouncementSignatures {
6180 /// Get a string which allows debug introspection of a AnnouncementSignatures object
6181 pub extern "C" fn AnnouncementSignatures_debug_str_void(o: *const c_void) -> Str {
6182 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::AnnouncementSignatures }).into()}
6183 /// Generates a non-cryptographic 64-bit hash of the AnnouncementSignatures.
6185 pub extern "C" fn AnnouncementSignatures_hash(o: &AnnouncementSignatures) -> u64 {
6186 if o.inner.is_null() { return 0; }
6187 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
6188 #[allow(deprecated)]
6189 let mut hasher = core::hash::SipHasher::new();
6190 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
6191 core::hash::Hasher::finish(&hasher)
6193 /// Checks if two AnnouncementSignaturess contain equal inner contents.
6194 /// This ignores pointers and is_owned flags and looks at the values in fields.
6195 /// Two objects with NULL inner values will be considered "equal" here.
6197 pub extern "C" fn AnnouncementSignatures_eq(a: &AnnouncementSignatures, b: &AnnouncementSignatures) -> bool {
6198 if a.inner == b.inner { return true; }
6199 if a.inner.is_null() || b.inner.is_null() { return false; }
6200 if a.get_native_ref() == b.get_native_ref() { true } else { false }
6202 /// An address which can be used to connect to a remote peer.
6206 pub enum SocketAddress {
6207 /// An IPv4 address and port on which the peer is listening.
6209 /// The 4-byte IPv4 address
6210 addr: crate::c_types::FourBytes,
6211 /// The port on which the node is listening
6214 /// An IPv6 address and port on which the peer is listening.
6216 /// The 16-byte IPv6 address
6217 addr: crate::c_types::SixteenBytes,
6218 /// The port on which the node is listening
6221 /// An old-style Tor onion address/port on which the peer is listening.
6223 /// This field is deprecated and the Tor network generally no longer supports V2 Onion
6224 /// addresses. Thus, the details are not parsed here.
6226 crate::c_types::TwelveBytes),
6227 /// A new-style Tor onion address/port on which the peer is listening.
6229 /// To create the human-readable \"hostname\", concatenate the ED25519 pubkey, checksum, and version,
6230 /// wrap as base32 and append \".onion\".
6232 /// The ed25519 long-term public key of the peer
6233 ed25519_pubkey: crate::c_types::ThirtyTwoBytes,
6234 /// The checksum of the pubkey and version, as included in the onion address
6236 /// The version byte, as defined by the Tor Onion v3 spec.
6238 /// The port on which the node is listening
6241 /// A hostname/port on which the peer is listening.
6243 /// The hostname on which the node is listening.
6244 hostname: crate::lightning::util::ser::Hostname,
6245 /// The port on which the node is listening.
6249 use lightning::ln::msgs::SocketAddress as SocketAddressImport;
6250 pub(crate) type nativeSocketAddress = SocketAddressImport;
6252 impl SocketAddress {
6254 pub(crate) fn to_native(&self) -> nativeSocketAddress {
6256 SocketAddress::TcpIpV4 {ref addr, ref port, } => {
6257 let mut addr_nonref = Clone::clone(addr);
6258 let mut port_nonref = Clone::clone(port);
6259 nativeSocketAddress::TcpIpV4 {
6260 addr: addr_nonref.data,
6264 SocketAddress::TcpIpV6 {ref addr, ref port, } => {
6265 let mut addr_nonref = Clone::clone(addr);
6266 let mut port_nonref = Clone::clone(port);
6267 nativeSocketAddress::TcpIpV6 {
6268 addr: addr_nonref.data,
6272 SocketAddress::OnionV2 (ref a, ) => {
6273 let mut a_nonref = Clone::clone(a);
6274 nativeSocketAddress::OnionV2 (
6278 SocketAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
6279 let mut ed25519_pubkey_nonref = Clone::clone(ed25519_pubkey);
6280 let mut checksum_nonref = Clone::clone(checksum);
6281 let mut version_nonref = Clone::clone(version);
6282 let mut port_nonref = Clone::clone(port);
6283 nativeSocketAddress::OnionV3 {
6284 ed25519_pubkey: ed25519_pubkey_nonref.data,
6285 checksum: checksum_nonref,
6286 version: version_nonref,
6290 SocketAddress::Hostname {ref hostname, ref port, } => {
6291 let mut hostname_nonref = Clone::clone(hostname);
6292 let mut port_nonref = Clone::clone(port);
6293 nativeSocketAddress::Hostname {
6294 hostname: *unsafe { Box::from_raw(hostname_nonref.take_inner()) },
6301 pub(crate) fn into_native(self) -> nativeSocketAddress {
6303 SocketAddress::TcpIpV4 {mut addr, mut port, } => {
6304 nativeSocketAddress::TcpIpV4 {
6309 SocketAddress::TcpIpV6 {mut addr, mut port, } => {
6310 nativeSocketAddress::TcpIpV6 {
6315 SocketAddress::OnionV2 (mut a, ) => {
6316 nativeSocketAddress::OnionV2 (
6320 SocketAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
6321 nativeSocketAddress::OnionV3 {
6322 ed25519_pubkey: ed25519_pubkey.data,
6328 SocketAddress::Hostname {mut hostname, mut port, } => {
6329 nativeSocketAddress::Hostname {
6330 hostname: *unsafe { Box::from_raw(hostname.take_inner()) },
6337 pub(crate) fn from_native(native: &SocketAddressImport) -> Self {
6338 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeSocketAddress) };
6340 nativeSocketAddress::TcpIpV4 {ref addr, ref port, } => {
6341 let mut addr_nonref = Clone::clone(addr);
6342 let mut port_nonref = Clone::clone(port);
6343 SocketAddress::TcpIpV4 {
6344 addr: crate::c_types::FourBytes { data: addr_nonref },
6348 nativeSocketAddress::TcpIpV6 {ref addr, ref port, } => {
6349 let mut addr_nonref = Clone::clone(addr);
6350 let mut port_nonref = Clone::clone(port);
6351 SocketAddress::TcpIpV6 {
6352 addr: crate::c_types::SixteenBytes { data: addr_nonref },
6356 nativeSocketAddress::OnionV2 (ref a, ) => {
6357 let mut a_nonref = Clone::clone(a);
6358 SocketAddress::OnionV2 (
6359 crate::c_types::TwelveBytes { data: a_nonref },
6362 nativeSocketAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
6363 let mut ed25519_pubkey_nonref = Clone::clone(ed25519_pubkey);
6364 let mut checksum_nonref = Clone::clone(checksum);
6365 let mut version_nonref = Clone::clone(version);
6366 let mut port_nonref = Clone::clone(port);
6367 SocketAddress::OnionV3 {
6368 ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey_nonref },
6369 checksum: checksum_nonref,
6370 version: version_nonref,
6374 nativeSocketAddress::Hostname {ref hostname, ref port, } => {
6375 let mut hostname_nonref = Clone::clone(hostname);
6376 let mut port_nonref = Clone::clone(port);
6377 SocketAddress::Hostname {
6378 hostname: crate::lightning::util::ser::Hostname { inner: ObjOps::heap_alloc(hostname_nonref), is_owned: true },
6385 pub(crate) fn native_into(native: nativeSocketAddress) -> Self {
6387 nativeSocketAddress::TcpIpV4 {mut addr, mut port, } => {
6388 SocketAddress::TcpIpV4 {
6389 addr: crate::c_types::FourBytes { data: addr },
6393 nativeSocketAddress::TcpIpV6 {mut addr, mut port, } => {
6394 SocketAddress::TcpIpV6 {
6395 addr: crate::c_types::SixteenBytes { data: addr },
6399 nativeSocketAddress::OnionV2 (mut a, ) => {
6400 SocketAddress::OnionV2 (
6401 crate::c_types::TwelveBytes { data: a },
6404 nativeSocketAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
6405 SocketAddress::OnionV3 {
6406 ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey },
6412 nativeSocketAddress::Hostname {mut hostname, mut port, } => {
6413 SocketAddress::Hostname {
6414 hostname: crate::lightning::util::ser::Hostname { inner: ObjOps::heap_alloc(hostname), is_owned: true },
6421 /// Frees any resources used by the SocketAddress
6423 pub extern "C" fn SocketAddress_free(this_ptr: SocketAddress) { }
6424 /// Creates a copy of the SocketAddress
6426 pub extern "C" fn SocketAddress_clone(orig: &SocketAddress) -> SocketAddress {
6430 /// Used only if an object of this type is returned as a trait impl by a method
6431 pub(crate) extern "C" fn SocketAddress_clone_void(this_ptr: *const c_void) -> *mut c_void {
6432 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const SocketAddress)).clone() })) as *mut c_void
6435 /// Used only if an object of this type is returned as a trait impl by a method
6436 pub(crate) extern "C" fn SocketAddress_free_void(this_ptr: *mut c_void) {
6437 let _ = unsafe { Box::from_raw(this_ptr as *mut SocketAddress) };
6440 /// Utility method to constructs a new TcpIpV4-variant SocketAddress
6441 pub extern "C" fn SocketAddress_tcp_ip_v4(addr: crate::c_types::FourBytes, port: u16) -> SocketAddress {
6442 SocketAddress::TcpIpV4 {
6448 /// Utility method to constructs a new TcpIpV6-variant SocketAddress
6449 pub extern "C" fn SocketAddress_tcp_ip_v6(addr: crate::c_types::SixteenBytes, port: u16) -> SocketAddress {
6450 SocketAddress::TcpIpV6 {
6456 /// Utility method to constructs a new OnionV2-variant SocketAddress
6457 pub extern "C" fn SocketAddress_onion_v2(a: crate::c_types::TwelveBytes) -> SocketAddress {
6458 SocketAddress::OnionV2(a, )
6461 /// Utility method to constructs a new OnionV3-variant SocketAddress
6462 pub extern "C" fn SocketAddress_onion_v3(ed25519_pubkey: crate::c_types::ThirtyTwoBytes, checksum: u16, version: u8, port: u16) -> SocketAddress {
6463 SocketAddress::OnionV3 {
6471 /// Utility method to constructs a new Hostname-variant SocketAddress
6472 pub extern "C" fn SocketAddress_hostname(hostname: crate::lightning::util::ser::Hostname, port: u16) -> SocketAddress {
6473 SocketAddress::Hostname {
6478 /// Get a string which allows debug introspection of a SocketAddress object
6479 pub extern "C" fn SocketAddress_debug_str_void(o: *const c_void) -> Str {
6480 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::SocketAddress }).into()}
6481 /// Generates a non-cryptographic 64-bit hash of the SocketAddress.
6483 pub extern "C" fn SocketAddress_hash(o: &SocketAddress) -> u64 {
6484 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
6485 #[allow(deprecated)]
6486 let mut hasher = core::hash::SipHasher::new();
6487 core::hash::Hash::hash(&o.to_native(), &mut hasher);
6488 core::hash::Hasher::finish(&hasher)
6490 /// Checks if two SocketAddresss contain equal inner contents.
6491 /// This ignores pointers and is_owned flags and looks at the values in fields.
6493 pub extern "C" fn SocketAddress_eq(a: &SocketAddress, b: &SocketAddress) -> bool {
6494 if &a.to_native() == &b.to_native() { true } else { false }
6497 /// Serialize the SocketAddress object into a byte array which can be read by SocketAddress_read
6498 pub extern "C" fn SocketAddress_write(obj: &crate::lightning::ln::msgs::SocketAddress) -> crate::c_types::derived::CVec_u8Z {
6499 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
6502 pub(crate) extern "C" fn SocketAddress_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6503 SocketAddress_write(unsafe { &*(obj as *const SocketAddress) })
6506 /// Read a SocketAddress from a byte array, created by SocketAddress_write
6507 pub extern "C" fn SocketAddress_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SocketAddressDecodeErrorZ {
6508 let res: Result<lightning::ln::msgs::SocketAddress, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6509 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::SocketAddress::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
6512 /// [`SocketAddress`] error variants
6516 pub enum SocketAddressParseError {
6517 /// Socket address (IPv4/IPv6) parsing error
6519 /// Invalid input format
6523 /// Invalid onion v3 address
6526 use lightning::ln::msgs::SocketAddressParseError as SocketAddressParseErrorImport;
6527 pub(crate) type nativeSocketAddressParseError = SocketAddressParseErrorImport;
6529 impl SocketAddressParseError {
6531 pub(crate) fn to_native(&self) -> nativeSocketAddressParseError {
6533 SocketAddressParseError::SocketAddrParse => nativeSocketAddressParseError::SocketAddrParse,
6534 SocketAddressParseError::InvalidInput => nativeSocketAddressParseError::InvalidInput,
6535 SocketAddressParseError::InvalidPort => nativeSocketAddressParseError::InvalidPort,
6536 SocketAddressParseError::InvalidOnionV3 => nativeSocketAddressParseError::InvalidOnionV3,
6540 pub(crate) fn into_native(self) -> nativeSocketAddressParseError {
6542 SocketAddressParseError::SocketAddrParse => nativeSocketAddressParseError::SocketAddrParse,
6543 SocketAddressParseError::InvalidInput => nativeSocketAddressParseError::InvalidInput,
6544 SocketAddressParseError::InvalidPort => nativeSocketAddressParseError::InvalidPort,
6545 SocketAddressParseError::InvalidOnionV3 => nativeSocketAddressParseError::InvalidOnionV3,
6549 pub(crate) fn from_native(native: &SocketAddressParseErrorImport) -> Self {
6550 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeSocketAddressParseError) };
6552 nativeSocketAddressParseError::SocketAddrParse => SocketAddressParseError::SocketAddrParse,
6553 nativeSocketAddressParseError::InvalidInput => SocketAddressParseError::InvalidInput,
6554 nativeSocketAddressParseError::InvalidPort => SocketAddressParseError::InvalidPort,
6555 nativeSocketAddressParseError::InvalidOnionV3 => SocketAddressParseError::InvalidOnionV3,
6559 pub(crate) fn native_into(native: nativeSocketAddressParseError) -> Self {
6561 nativeSocketAddressParseError::SocketAddrParse => SocketAddressParseError::SocketAddrParse,
6562 nativeSocketAddressParseError::InvalidInput => SocketAddressParseError::InvalidInput,
6563 nativeSocketAddressParseError::InvalidPort => SocketAddressParseError::InvalidPort,
6564 nativeSocketAddressParseError::InvalidOnionV3 => SocketAddressParseError::InvalidOnionV3,
6568 /// Creates a copy of the SocketAddressParseError
6570 pub extern "C" fn SocketAddressParseError_clone(orig: &SocketAddressParseError) -> SocketAddressParseError {
6574 /// Used only if an object of this type is returned as a trait impl by a method
6575 pub(crate) extern "C" fn SocketAddressParseError_clone_void(this_ptr: *const c_void) -> *mut c_void {
6576 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const SocketAddressParseError)).clone() })) as *mut c_void
6579 /// Used only if an object of this type is returned as a trait impl by a method
6580 pub(crate) extern "C" fn SocketAddressParseError_free_void(this_ptr: *mut c_void) {
6581 let _ = unsafe { Box::from_raw(this_ptr as *mut SocketAddressParseError) };
6584 /// Utility method to constructs a new SocketAddrParse-variant SocketAddressParseError
6585 pub extern "C" fn SocketAddressParseError_socket_addr_parse() -> SocketAddressParseError {
6586 SocketAddressParseError::SocketAddrParse}
6588 /// Utility method to constructs a new InvalidInput-variant SocketAddressParseError
6589 pub extern "C" fn SocketAddressParseError_invalid_input() -> SocketAddressParseError {
6590 SocketAddressParseError::InvalidInput}
6592 /// Utility method to constructs a new InvalidPort-variant SocketAddressParseError
6593 pub extern "C" fn SocketAddressParseError_invalid_port() -> SocketAddressParseError {
6594 SocketAddressParseError::InvalidPort}
6596 /// Utility method to constructs a new InvalidOnionV3-variant SocketAddressParseError
6597 pub extern "C" fn SocketAddressParseError_invalid_onion_v3() -> SocketAddressParseError {
6598 SocketAddressParseError::InvalidOnionV3}
6599 /// Get a string which allows debug introspection of a SocketAddressParseError object
6600 pub extern "C" fn SocketAddressParseError_debug_str_void(o: *const c_void) -> Str {
6601 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::SocketAddressParseError }).into()}
6602 /// Generates a non-cryptographic 64-bit hash of the SocketAddressParseError.
6604 pub extern "C" fn SocketAddressParseError_hash(o: &SocketAddressParseError) -> u64 {
6605 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
6606 #[allow(deprecated)]
6607 let mut hasher = core::hash::SipHasher::new();
6608 core::hash::Hash::hash(&o.to_native(), &mut hasher);
6609 core::hash::Hasher::finish(&hasher)
6611 /// Checks if two SocketAddressParseErrors contain equal inner contents.
6612 /// This ignores pointers and is_owned flags and looks at the values in fields.
6614 pub extern "C" fn SocketAddressParseError_eq(a: &SocketAddressParseError, b: &SocketAddressParseError) -> bool {
6615 if &a.to_native() == &b.to_native() { true } else { false }
6617 /// Parses an OnionV3 host and port into a [`SocketAddress::OnionV3`].
6619 /// The host part must end with \".onion\".
6621 pub extern "C" fn parse_onion_address(mut host: crate::c_types::Str, mut port: u16) -> crate::c_types::derived::CResult_SocketAddressSocketAddressParseErrorZ {
6622 let mut ret = lightning::ln::msgs::parse_onion_address(host.into_str(), port);
6623 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() };
6628 /// Get the string representation of a SocketAddress object
6629 pub extern "C" fn SocketAddress_to_str(o: &crate::lightning::ln::msgs::SocketAddress) -> Str {
6630 alloc::format!("{}", &o.to_native()).into()
6633 /// Read a SocketAddress object from a string
6634 pub extern "C" fn SocketAddress_from_str(s: crate::c_types::Str) -> crate::c_types::derived::CResult_SocketAddressSocketAddressParseErrorZ {
6635 match lightning::ln::msgs::SocketAddress::from_str(s.into_str()) {
6637 crate::c_types::CResultTempl::ok(
6638 crate::lightning::ln::msgs::SocketAddress::native_into(r)
6642 crate::c_types::CResultTempl::err(
6643 crate::lightning::ln::msgs::SocketAddressParseError::native_into(e)
6648 /// Represents the set of gossip messages that require a signature from a node's identity key.
6652 pub enum UnsignedGossipMessage {
6653 /// An unsigned channel announcement.
6654 ChannelAnnouncement(
6655 crate::lightning::ln::msgs::UnsignedChannelAnnouncement),
6656 /// An unsigned channel update.
6658 crate::lightning::ln::msgs::UnsignedChannelUpdate),
6659 /// An unsigned node announcement.
6661 crate::lightning::ln::msgs::UnsignedNodeAnnouncement),
6663 use lightning::ln::msgs::UnsignedGossipMessage as UnsignedGossipMessageImport;
6664 pub(crate) type nativeUnsignedGossipMessage = UnsignedGossipMessageImport;
6666 impl UnsignedGossipMessage {
6668 pub(crate) fn to_native(&self) -> nativeUnsignedGossipMessage {
6670 UnsignedGossipMessage::ChannelAnnouncement (ref a, ) => {
6671 let mut a_nonref = Clone::clone(a);
6672 nativeUnsignedGossipMessage::ChannelAnnouncement (
6673 *unsafe { Box::from_raw(a_nonref.take_inner()) },
6676 UnsignedGossipMessage::ChannelUpdate (ref a, ) => {
6677 let mut a_nonref = Clone::clone(a);
6678 nativeUnsignedGossipMessage::ChannelUpdate (
6679 *unsafe { Box::from_raw(a_nonref.take_inner()) },
6682 UnsignedGossipMessage::NodeAnnouncement (ref a, ) => {
6683 let mut a_nonref = Clone::clone(a);
6684 nativeUnsignedGossipMessage::NodeAnnouncement (
6685 *unsafe { Box::from_raw(a_nonref.take_inner()) },
6691 pub(crate) fn into_native(self) -> nativeUnsignedGossipMessage {
6693 UnsignedGossipMessage::ChannelAnnouncement (mut a, ) => {
6694 nativeUnsignedGossipMessage::ChannelAnnouncement (
6695 *unsafe { Box::from_raw(a.take_inner()) },
6698 UnsignedGossipMessage::ChannelUpdate (mut a, ) => {
6699 nativeUnsignedGossipMessage::ChannelUpdate (
6700 *unsafe { Box::from_raw(a.take_inner()) },
6703 UnsignedGossipMessage::NodeAnnouncement (mut a, ) => {
6704 nativeUnsignedGossipMessage::NodeAnnouncement (
6705 *unsafe { Box::from_raw(a.take_inner()) },
6711 pub(crate) fn from_native(native: &UnsignedGossipMessageImport) -> Self {
6712 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeUnsignedGossipMessage) };
6714 nativeUnsignedGossipMessage::ChannelAnnouncement (ref a, ) => {
6715 let mut a_nonref = Clone::clone(a);
6716 UnsignedGossipMessage::ChannelAnnouncement (
6717 crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
6720 nativeUnsignedGossipMessage::ChannelUpdate (ref a, ) => {
6721 let mut a_nonref = Clone::clone(a);
6722 UnsignedGossipMessage::ChannelUpdate (
6723 crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
6726 nativeUnsignedGossipMessage::NodeAnnouncement (ref a, ) => {
6727 let mut a_nonref = Clone::clone(a);
6728 UnsignedGossipMessage::NodeAnnouncement (
6729 crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
6735 pub(crate) fn native_into(native: nativeUnsignedGossipMessage) -> Self {
6737 nativeUnsignedGossipMessage::ChannelAnnouncement (mut a, ) => {
6738 UnsignedGossipMessage::ChannelAnnouncement (
6739 crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(a), is_owned: true },
6742 nativeUnsignedGossipMessage::ChannelUpdate (mut a, ) => {
6743 UnsignedGossipMessage::ChannelUpdate (
6744 crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: ObjOps::heap_alloc(a), is_owned: true },
6747 nativeUnsignedGossipMessage::NodeAnnouncement (mut a, ) => {
6748 UnsignedGossipMessage::NodeAnnouncement (
6749 crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: ObjOps::heap_alloc(a), is_owned: true },
6755 /// Frees any resources used by the UnsignedGossipMessage
6757 pub extern "C" fn UnsignedGossipMessage_free(this_ptr: UnsignedGossipMessage) { }
6758 /// Creates a copy of the UnsignedGossipMessage
6760 pub extern "C" fn UnsignedGossipMessage_clone(orig: &UnsignedGossipMessage) -> UnsignedGossipMessage {
6764 /// Used only if an object of this type is returned as a trait impl by a method
6765 pub(crate) extern "C" fn UnsignedGossipMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
6766 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const UnsignedGossipMessage)).clone() })) as *mut c_void
6769 /// Used only if an object of this type is returned as a trait impl by a method
6770 pub(crate) extern "C" fn UnsignedGossipMessage_free_void(this_ptr: *mut c_void) {
6771 let _ = unsafe { Box::from_raw(this_ptr as *mut UnsignedGossipMessage) };
6774 /// Utility method to constructs a new ChannelAnnouncement-variant UnsignedGossipMessage
6775 pub extern "C" fn UnsignedGossipMessage_channel_announcement(a: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> UnsignedGossipMessage {
6776 UnsignedGossipMessage::ChannelAnnouncement(a, )
6779 /// Utility method to constructs a new ChannelUpdate-variant UnsignedGossipMessage
6780 pub extern "C" fn UnsignedGossipMessage_channel_update(a: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> UnsignedGossipMessage {
6781 UnsignedGossipMessage::ChannelUpdate(a, )
6784 /// Utility method to constructs a new NodeAnnouncement-variant UnsignedGossipMessage
6785 pub extern "C" fn UnsignedGossipMessage_node_announcement(a: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> UnsignedGossipMessage {
6786 UnsignedGossipMessage::NodeAnnouncement(a, )
6789 /// Serialize the UnsignedGossipMessage object into a byte array which can be read by UnsignedGossipMessage_read
6790 pub extern "C" fn UnsignedGossipMessage_write(obj: &crate::lightning::ln::msgs::UnsignedGossipMessage) -> crate::c_types::derived::CVec_u8Z {
6791 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
6794 pub(crate) extern "C" fn UnsignedGossipMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6795 UnsignedGossipMessage_write(unsafe { &*(obj as *const UnsignedGossipMessage) })
6798 use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport;
6799 pub(crate) type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport;
6801 /// The unsigned part of a [`node_announcement`] message.
6803 /// [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message
6806 pub struct UnsignedNodeAnnouncement {
6807 /// A pointer to the opaque Rust object.
6809 /// Nearly everywhere, inner must be non-null, however in places where
6810 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6811 pub inner: *mut nativeUnsignedNodeAnnouncement,
6812 /// Indicates that this is the only struct which contains the same pointer.
6814 /// Rust functions which take ownership of an object provided via an argument require
6815 /// this to be true and invalidate the object pointed to by inner.
6819 impl Drop for UnsignedNodeAnnouncement {
6820 fn drop(&mut self) {
6821 if self.is_owned && !<*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) {
6822 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6826 /// Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL.
6828 pub extern "C" fn UnsignedNodeAnnouncement_free(this_obj: UnsignedNodeAnnouncement) { }
6830 /// Used only if an object of this type is returned as a trait impl by a method
6831 pub(crate) extern "C" fn UnsignedNodeAnnouncement_free_void(this_ptr: *mut c_void) {
6832 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedNodeAnnouncement) };
6835 impl UnsignedNodeAnnouncement {
6836 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedNodeAnnouncement {
6837 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6839 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedNodeAnnouncement {
6840 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6842 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6843 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedNodeAnnouncement {
6844 assert!(self.is_owned);
6845 let ret = ObjOps::untweak_ptr(self.inner);
6846 self.inner = core::ptr::null_mut();
6850 /// The advertised features
6852 pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::ln::features::NodeFeatures {
6853 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
6854 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 }
6856 /// The advertised features
6858 pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::ln::features::NodeFeatures) {
6859 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
6861 /// A strictly monotonic announcement counter, with gaps allowed
6863 pub extern "C" fn UnsignedNodeAnnouncement_get_timestamp(this_ptr: &UnsignedNodeAnnouncement) -> u32 {
6864 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
6867 /// A strictly monotonic announcement counter, with gaps allowed
6869 pub extern "C" fn UnsignedNodeAnnouncement_set_timestamp(this_ptr: &mut UnsignedNodeAnnouncement, mut val: u32) {
6870 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
6872 /// The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back
6875 pub extern "C" fn UnsignedNodeAnnouncement_get_node_id(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::routing::gossip::NodeId {
6876 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id;
6877 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 }
6879 /// The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back
6882 pub extern "C" fn UnsignedNodeAnnouncement_set_node_id(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
6883 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id = *unsafe { Box::from_raw(val.take_inner()) };
6885 /// An RGB color for UI purposes
6887 pub extern "C" fn UnsignedNodeAnnouncement_get_rgb(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 3] {
6888 let mut inner_val = &mut this_ptr.get_native_mut_ref().rgb;
6891 /// An RGB color for UI purposes
6893 pub extern "C" fn UnsignedNodeAnnouncement_set_rgb(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThreeBytes) {
6894 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.rgb = val.data;
6896 /// An alias, for UI purposes.
6898 /// This should be sanitized before use. There is no guarantee of uniqueness.
6900 pub extern "C" fn UnsignedNodeAnnouncement_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::routing::gossip::NodeAlias {
6901 let mut inner_val = &mut this_ptr.get_native_mut_ref().alias;
6902 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 }
6904 /// An alias, for UI purposes.
6906 /// This should be sanitized before use. There is no guarantee of uniqueness.
6908 pub extern "C" fn UnsignedNodeAnnouncement_set_alias(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::routing::gossip::NodeAlias) {
6909 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.alias = *unsafe { Box::from_raw(val.take_inner()) };
6911 /// List of addresses on which this node is reachable
6913 /// Returns a copy of the field.
6915 pub extern "C" fn UnsignedNodeAnnouncement_get_addresses(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_SocketAddressZ {
6916 let mut inner_val = this_ptr.get_native_mut_ref().addresses.clone();
6917 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) }); };
6918 local_inner_val.into()
6920 /// List of addresses on which this node is reachable
6922 pub extern "C" fn UnsignedNodeAnnouncement_set_addresses(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_SocketAddressZ) {
6923 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
6924 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.addresses = local_val;
6926 /// Excess address data which was signed as a part of the message which we do not (yet) understand how
6929 /// This is stored to ensure forward-compatibility as new address types are added to the lightning gossip protocol.
6931 /// Returns a copy of the field.
6933 pub extern "C" fn UnsignedNodeAnnouncement_get_excess_address_data(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
6934 let mut inner_val = this_ptr.get_native_mut_ref().excess_address_data.clone();
6935 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
6936 local_inner_val.into()
6938 /// Excess address data which was signed as a part of the message which we do not (yet) understand how
6941 /// This is stored to ensure forward-compatibility as new address types are added to the lightning gossip protocol.
6943 pub extern "C" fn UnsignedNodeAnnouncement_set_excess_address_data(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_u8Z) {
6944 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
6945 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_address_data = local_val;
6947 /// Excess data which was signed as a part of the message which we do not (yet) understand how
6950 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
6952 /// Returns a copy of the field.
6954 pub extern "C" fn UnsignedNodeAnnouncement_get_excess_data(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
6955 let mut inner_val = this_ptr.get_native_mut_ref().excess_data.clone();
6956 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
6957 local_inner_val.into()
6959 /// Excess data which was signed as a part of the message which we do not (yet) understand how
6962 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
6964 pub extern "C" fn UnsignedNodeAnnouncement_set_excess_data(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_u8Z) {
6965 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
6966 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_data = local_val;
6968 /// Constructs a new UnsignedNodeAnnouncement given each field
6971 pub extern "C" fn UnsignedNodeAnnouncement_new(mut features_arg: crate::lightning::ln::features::NodeFeatures, mut timestamp_arg: u32, mut node_id_arg: crate::lightning::routing::gossip::NodeId, mut rgb_arg: crate::c_types::ThreeBytes, mut alias_arg: crate::lightning::routing::gossip::NodeAlias, mut addresses_arg: crate::c_types::derived::CVec_SocketAddressZ, mut excess_address_data_arg: crate::c_types::derived::CVec_u8Z, mut excess_data_arg: crate::c_types::derived::CVec_u8Z) -> UnsignedNodeAnnouncement {
6972 let mut local_addresses_arg = Vec::new(); for mut item in addresses_arg.into_rust().drain(..) { local_addresses_arg.push( { item.into_native() }); };
6973 let mut local_excess_address_data_arg = Vec::new(); for mut item in excess_address_data_arg.into_rust().drain(..) { local_excess_address_data_arg.push( { item }); };
6974 let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); };
6975 UnsignedNodeAnnouncement { inner: ObjOps::heap_alloc(nativeUnsignedNodeAnnouncement {
6976 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
6977 timestamp: timestamp_arg,
6978 node_id: *unsafe { Box::from_raw(node_id_arg.take_inner()) },
6980 alias: *unsafe { Box::from_raw(alias_arg.take_inner()) },
6981 addresses: local_addresses_arg,
6982 excess_address_data: local_excess_address_data_arg,
6983 excess_data: local_excess_data_arg,
6984 }), is_owned: true }
6986 impl Clone for UnsignedNodeAnnouncement {
6987 fn clone(&self) -> Self {
6989 inner: if <*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
6990 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6996 /// Used only if an object of this type is returned as a trait impl by a method
6997 pub(crate) extern "C" fn UnsignedNodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
6998 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUnsignedNodeAnnouncement)).clone() })) as *mut c_void
7001 /// Creates a copy of the UnsignedNodeAnnouncement
7002 pub extern "C" fn UnsignedNodeAnnouncement_clone(orig: &UnsignedNodeAnnouncement) -> UnsignedNodeAnnouncement {
7005 /// Get a string which allows debug introspection of a UnsignedNodeAnnouncement object
7006 pub extern "C" fn UnsignedNodeAnnouncement_debug_str_void(o: *const c_void) -> Str {
7007 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UnsignedNodeAnnouncement }).into()}
7008 /// Generates a non-cryptographic 64-bit hash of the UnsignedNodeAnnouncement.
7010 pub extern "C" fn UnsignedNodeAnnouncement_hash(o: &UnsignedNodeAnnouncement) -> u64 {
7011 if o.inner.is_null() { return 0; }
7012 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
7013 #[allow(deprecated)]
7014 let mut hasher = core::hash::SipHasher::new();
7015 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
7016 core::hash::Hasher::finish(&hasher)
7018 /// Checks if two UnsignedNodeAnnouncements contain equal inner contents.
7019 /// This ignores pointers and is_owned flags and looks at the values in fields.
7020 /// Two objects with NULL inner values will be considered "equal" here.
7022 pub extern "C" fn UnsignedNodeAnnouncement_eq(a: &UnsignedNodeAnnouncement, b: &UnsignedNodeAnnouncement) -> bool {
7023 if a.inner == b.inner { return true; }
7024 if a.inner.is_null() || b.inner.is_null() { return false; }
7025 if a.get_native_ref() == b.get_native_ref() { true } else { false }
7028 use lightning::ln::msgs::NodeAnnouncement as nativeNodeAnnouncementImport;
7029 pub(crate) type nativeNodeAnnouncement = nativeNodeAnnouncementImport;
7031 /// A [`node_announcement`] message to be sent to or received from a peer.
7033 /// [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message
7036 pub struct NodeAnnouncement {
7037 /// A pointer to the opaque Rust object.
7039 /// Nearly everywhere, inner must be non-null, however in places where
7040 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7041 pub inner: *mut nativeNodeAnnouncement,
7042 /// Indicates that this is the only struct which contains the same pointer.
7044 /// Rust functions which take ownership of an object provided via an argument require
7045 /// this to be true and invalidate the object pointed to by inner.
7049 impl Drop for NodeAnnouncement {
7050 fn drop(&mut self) {
7051 if self.is_owned && !<*mut nativeNodeAnnouncement>::is_null(self.inner) {
7052 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7056 /// Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL.
7058 pub extern "C" fn NodeAnnouncement_free(this_obj: NodeAnnouncement) { }
7060 /// Used only if an object of this type is returned as a trait impl by a method
7061 pub(crate) extern "C" fn NodeAnnouncement_free_void(this_ptr: *mut c_void) {
7062 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeNodeAnnouncement) };
7065 impl NodeAnnouncement {
7066 pub(crate) fn get_native_ref(&self) -> &'static nativeNodeAnnouncement {
7067 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7069 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeAnnouncement {
7070 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7072 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7073 pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncement {
7074 assert!(self.is_owned);
7075 let ret = ObjOps::untweak_ptr(self.inner);
7076 self.inner = core::ptr::null_mut();
7080 /// The signature by the node key
7082 pub extern "C" fn NodeAnnouncement_get_signature(this_ptr: &NodeAnnouncement) -> crate::c_types::ECDSASignature {
7083 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
7084 crate::c_types::ECDSASignature::from_rust(&inner_val)
7086 /// The signature by the node key
7088 pub extern "C" fn NodeAnnouncement_set_signature(this_ptr: &mut NodeAnnouncement, mut val: crate::c_types::ECDSASignature) {
7089 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
7091 /// The actual content of the announcement
7093 pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> crate::lightning::ln::msgs::UnsignedNodeAnnouncement {
7094 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
7095 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 }
7097 /// The actual content of the announcement
7099 pub extern "C" fn NodeAnnouncement_set_contents(this_ptr: &mut NodeAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) {
7100 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
7102 /// Constructs a new NodeAnnouncement given each field
7105 pub extern "C" fn NodeAnnouncement_new(mut signature_arg: crate::c_types::ECDSASignature, mut contents_arg: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> NodeAnnouncement {
7106 NodeAnnouncement { inner: ObjOps::heap_alloc(nativeNodeAnnouncement {
7107 signature: signature_arg.into_rust(),
7108 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
7109 }), is_owned: true }
7111 impl Clone for NodeAnnouncement {
7112 fn clone(&self) -> Self {
7114 inner: if <*mut nativeNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
7115 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7121 /// Used only if an object of this type is returned as a trait impl by a method
7122 pub(crate) extern "C" fn NodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
7123 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeNodeAnnouncement)).clone() })) as *mut c_void
7126 /// Creates a copy of the NodeAnnouncement
7127 pub extern "C" fn NodeAnnouncement_clone(orig: &NodeAnnouncement) -> NodeAnnouncement {
7130 /// Get a string which allows debug introspection of a NodeAnnouncement object
7131 pub extern "C" fn NodeAnnouncement_debug_str_void(o: *const c_void) -> Str {
7132 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::NodeAnnouncement }).into()}
7133 /// Generates a non-cryptographic 64-bit hash of the NodeAnnouncement.
7135 pub extern "C" fn NodeAnnouncement_hash(o: &NodeAnnouncement) -> u64 {
7136 if o.inner.is_null() { return 0; }
7137 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
7138 #[allow(deprecated)]
7139 let mut hasher = core::hash::SipHasher::new();
7140 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
7141 core::hash::Hasher::finish(&hasher)
7143 /// Checks if two NodeAnnouncements contain equal inner contents.
7144 /// This ignores pointers and is_owned flags and looks at the values in fields.
7145 /// Two objects with NULL inner values will be considered "equal" here.
7147 pub extern "C" fn NodeAnnouncement_eq(a: &NodeAnnouncement, b: &NodeAnnouncement) -> bool {
7148 if a.inner == b.inner { return true; }
7149 if a.inner.is_null() || b.inner.is_null() { return false; }
7150 if a.get_native_ref() == b.get_native_ref() { true } else { false }
7153 use lightning::ln::msgs::UnsignedChannelAnnouncement as nativeUnsignedChannelAnnouncementImport;
7154 pub(crate) type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport;
7156 /// The unsigned part of a [`channel_announcement`] message.
7158 /// [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message
7161 pub struct UnsignedChannelAnnouncement {
7162 /// A pointer to the opaque Rust object.
7164 /// Nearly everywhere, inner must be non-null, however in places where
7165 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7166 pub inner: *mut nativeUnsignedChannelAnnouncement,
7167 /// Indicates that this is the only struct which contains the same pointer.
7169 /// Rust functions which take ownership of an object provided via an argument require
7170 /// this to be true and invalidate the object pointed to by inner.
7174 impl Drop for UnsignedChannelAnnouncement {
7175 fn drop(&mut self) {
7176 if self.is_owned && !<*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) {
7177 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7181 /// Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL.
7183 pub extern "C" fn UnsignedChannelAnnouncement_free(this_obj: UnsignedChannelAnnouncement) { }
7185 /// Used only if an object of this type is returned as a trait impl by a method
7186 pub(crate) extern "C" fn UnsignedChannelAnnouncement_free_void(this_ptr: *mut c_void) {
7187 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedChannelAnnouncement) };
7190 impl UnsignedChannelAnnouncement {
7191 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelAnnouncement {
7192 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7194 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelAnnouncement {
7195 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7197 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7198 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelAnnouncement {
7199 assert!(self.is_owned);
7200 let ret = ObjOps::untweak_ptr(self.inner);
7201 self.inner = core::ptr::null_mut();
7205 /// The advertised channel features
7207 pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::ln::features::ChannelFeatures {
7208 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
7209 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 }
7211 /// The advertised channel features
7213 pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::ln::features::ChannelFeatures) {
7214 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
7216 /// The genesis hash of the blockchain where the channel is to be opened
7218 pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &UnsignedChannelAnnouncement) -> *const [u8; 32] {
7219 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
7222 /// The genesis hash of the blockchain where the channel is to be opened
7224 pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
7225 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
7227 /// The short channel ID
7229 pub extern "C" fn UnsignedChannelAnnouncement_get_short_channel_id(this_ptr: &UnsignedChannelAnnouncement) -> u64 {
7230 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
7233 /// The short channel ID
7235 pub extern "C" fn UnsignedChannelAnnouncement_set_short_channel_id(this_ptr: &mut UnsignedChannelAnnouncement, mut val: u64) {
7236 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
7238 /// One of the two `node_id`s which are endpoints of this channel
7240 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
7241 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_1;
7242 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 }
7244 /// One of the two `node_id`s which are endpoints of this channel
7246 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
7247 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_1 = *unsafe { Box::from_raw(val.take_inner()) };
7249 /// The other of the two `node_id`s which are endpoints of this channel
7251 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
7252 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_2;
7253 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 }
7255 /// The other of the two `node_id`s which are endpoints of this channel
7257 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
7258 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_2 = *unsafe { Box::from_raw(val.take_inner()) };
7260 /// The funding key for the first node
7262 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
7263 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_1;
7264 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 }
7266 /// The funding key for the first node
7268 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
7269 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_1 = *unsafe { Box::from_raw(val.take_inner()) };
7271 /// The funding key for the second node
7273 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
7274 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_2;
7275 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 }
7277 /// The funding key for the second node
7279 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
7280 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_2 = *unsafe { Box::from_raw(val.take_inner()) };
7282 /// Excess data which was signed as a part of the message which we do not (yet) understand how
7285 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
7287 /// Returns a copy of the field.
7289 pub extern "C" fn UnsignedChannelAnnouncement_get_excess_data(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
7290 let mut inner_val = this_ptr.get_native_mut_ref().excess_data.clone();
7291 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
7292 local_inner_val.into()
7294 /// Excess data which was signed as a part of the message which we do not (yet) understand how
7297 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
7299 pub extern "C" fn UnsignedChannelAnnouncement_set_excess_data(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::derived::CVec_u8Z) {
7300 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
7301 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_data = local_val;
7303 /// Constructs a new UnsignedChannelAnnouncement given each field
7306 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 {
7307 let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); };
7308 UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(nativeUnsignedChannelAnnouncement {
7309 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
7310 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
7311 short_channel_id: short_channel_id_arg,
7312 node_id_1: *unsafe { Box::from_raw(node_id_1_arg.take_inner()) },
7313 node_id_2: *unsafe { Box::from_raw(node_id_2_arg.take_inner()) },
7314 bitcoin_key_1: *unsafe { Box::from_raw(bitcoin_key_1_arg.take_inner()) },
7315 bitcoin_key_2: *unsafe { Box::from_raw(bitcoin_key_2_arg.take_inner()) },
7316 excess_data: local_excess_data_arg,
7317 }), is_owned: true }
7319 impl Clone for UnsignedChannelAnnouncement {
7320 fn clone(&self) -> Self {
7322 inner: if <*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
7323 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7329 /// Used only if an object of this type is returned as a trait impl by a method
7330 pub(crate) extern "C" fn UnsignedChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
7331 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUnsignedChannelAnnouncement)).clone() })) as *mut c_void
7334 /// Creates a copy of the UnsignedChannelAnnouncement
7335 pub extern "C" fn UnsignedChannelAnnouncement_clone(orig: &UnsignedChannelAnnouncement) -> UnsignedChannelAnnouncement {
7338 /// Get a string which allows debug introspection of a UnsignedChannelAnnouncement object
7339 pub extern "C" fn UnsignedChannelAnnouncement_debug_str_void(o: *const c_void) -> Str {
7340 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UnsignedChannelAnnouncement }).into()}
7341 /// Generates a non-cryptographic 64-bit hash of the UnsignedChannelAnnouncement.
7343 pub extern "C" fn UnsignedChannelAnnouncement_hash(o: &UnsignedChannelAnnouncement) -> u64 {
7344 if o.inner.is_null() { return 0; }
7345 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
7346 #[allow(deprecated)]
7347 let mut hasher = core::hash::SipHasher::new();
7348 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
7349 core::hash::Hasher::finish(&hasher)
7351 /// Checks if two UnsignedChannelAnnouncements contain equal inner contents.
7352 /// This ignores pointers and is_owned flags and looks at the values in fields.
7353 /// Two objects with NULL inner values will be considered "equal" here.
7355 pub extern "C" fn UnsignedChannelAnnouncement_eq(a: &UnsignedChannelAnnouncement, b: &UnsignedChannelAnnouncement) -> bool {
7356 if a.inner == b.inner { return true; }
7357 if a.inner.is_null() || b.inner.is_null() { return false; }
7358 if a.get_native_ref() == b.get_native_ref() { true } else { false }
7361 use lightning::ln::msgs::ChannelAnnouncement as nativeChannelAnnouncementImport;
7362 pub(crate) type nativeChannelAnnouncement = nativeChannelAnnouncementImport;
7364 /// A [`channel_announcement`] message to be sent to or received from a peer.
7366 /// [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message
7369 pub struct ChannelAnnouncement {
7370 /// A pointer to the opaque Rust object.
7372 /// Nearly everywhere, inner must be non-null, however in places where
7373 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7374 pub inner: *mut nativeChannelAnnouncement,
7375 /// Indicates that this is the only struct which contains the same pointer.
7377 /// Rust functions which take ownership of an object provided via an argument require
7378 /// this to be true and invalidate the object pointed to by inner.
7382 impl Drop for ChannelAnnouncement {
7383 fn drop(&mut self) {
7384 if self.is_owned && !<*mut nativeChannelAnnouncement>::is_null(self.inner) {
7385 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7389 /// Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL.
7391 pub extern "C" fn ChannelAnnouncement_free(this_obj: ChannelAnnouncement) { }
7393 /// Used only if an object of this type is returned as a trait impl by a method
7394 pub(crate) extern "C" fn ChannelAnnouncement_free_void(this_ptr: *mut c_void) {
7395 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelAnnouncement) };
7398 impl ChannelAnnouncement {
7399 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelAnnouncement {
7400 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7402 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelAnnouncement {
7403 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7405 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7406 pub(crate) fn take_inner(mut self) -> *mut nativeChannelAnnouncement {
7407 assert!(self.is_owned);
7408 let ret = ObjOps::untweak_ptr(self.inner);
7409 self.inner = core::ptr::null_mut();
7413 /// Authentication of the announcement by the first public node
7415 pub extern "C" fn ChannelAnnouncement_get_node_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
7416 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_1;
7417 crate::c_types::ECDSASignature::from_rust(&inner_val)
7419 /// Authentication of the announcement by the first public node
7421 pub extern "C" fn ChannelAnnouncement_set_node_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
7422 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_1 = val.into_rust();
7424 /// Authentication of the announcement by the second public node
7426 pub extern "C" fn ChannelAnnouncement_get_node_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
7427 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_2;
7428 crate::c_types::ECDSASignature::from_rust(&inner_val)
7430 /// Authentication of the announcement by the second public node
7432 pub extern "C" fn ChannelAnnouncement_set_node_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
7433 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_2 = val.into_rust();
7435 /// Proof of funding UTXO ownership by the first public node
7437 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
7438 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_1;
7439 crate::c_types::ECDSASignature::from_rust(&inner_val)
7441 /// Proof of funding UTXO ownership by the first public node
7443 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
7444 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_1 = val.into_rust();
7446 /// Proof of funding UTXO ownership by the second public node
7448 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
7449 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_2;
7450 crate::c_types::ECDSASignature::from_rust(&inner_val)
7452 /// Proof of funding UTXO ownership by the second public node
7454 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
7455 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_2 = val.into_rust();
7457 /// The actual announcement
7459 pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncement) -> crate::lightning::ln::msgs::UnsignedChannelAnnouncement {
7460 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
7461 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 }
7463 /// The actual announcement
7465 pub extern "C" fn ChannelAnnouncement_set_contents(this_ptr: &mut ChannelAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) {
7466 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
7468 /// Constructs a new ChannelAnnouncement given each field
7471 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 {
7472 ChannelAnnouncement { inner: ObjOps::heap_alloc(nativeChannelAnnouncement {
7473 node_signature_1: node_signature_1_arg.into_rust(),
7474 node_signature_2: node_signature_2_arg.into_rust(),
7475 bitcoin_signature_1: bitcoin_signature_1_arg.into_rust(),
7476 bitcoin_signature_2: bitcoin_signature_2_arg.into_rust(),
7477 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
7478 }), is_owned: true }
7480 impl Clone for ChannelAnnouncement {
7481 fn clone(&self) -> Self {
7483 inner: if <*mut nativeChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
7484 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7490 /// Used only if an object of this type is returned as a trait impl by a method
7491 pub(crate) extern "C" fn ChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
7492 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelAnnouncement)).clone() })) as *mut c_void
7495 /// Creates a copy of the ChannelAnnouncement
7496 pub extern "C" fn ChannelAnnouncement_clone(orig: &ChannelAnnouncement) -> ChannelAnnouncement {
7499 /// Get a string which allows debug introspection of a ChannelAnnouncement object
7500 pub extern "C" fn ChannelAnnouncement_debug_str_void(o: *const c_void) -> Str {
7501 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ChannelAnnouncement }).into()}
7502 /// Generates a non-cryptographic 64-bit hash of the ChannelAnnouncement.
7504 pub extern "C" fn ChannelAnnouncement_hash(o: &ChannelAnnouncement) -> u64 {
7505 if o.inner.is_null() { return 0; }
7506 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
7507 #[allow(deprecated)]
7508 let mut hasher = core::hash::SipHasher::new();
7509 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
7510 core::hash::Hasher::finish(&hasher)
7512 /// Checks if two ChannelAnnouncements contain equal inner contents.
7513 /// This ignores pointers and is_owned flags and looks at the values in fields.
7514 /// Two objects with NULL inner values will be considered "equal" here.
7516 pub extern "C" fn ChannelAnnouncement_eq(a: &ChannelAnnouncement, b: &ChannelAnnouncement) -> bool {
7517 if a.inner == b.inner { return true; }
7518 if a.inner.is_null() || b.inner.is_null() { return false; }
7519 if a.get_native_ref() == b.get_native_ref() { true } else { false }
7522 use lightning::ln::msgs::UnsignedChannelUpdate as nativeUnsignedChannelUpdateImport;
7523 pub(crate) type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport;
7525 /// The unsigned part of a [`channel_update`] message.
7527 /// [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
7530 pub struct UnsignedChannelUpdate {
7531 /// A pointer to the opaque Rust object.
7533 /// Nearly everywhere, inner must be non-null, however in places where
7534 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7535 pub inner: *mut nativeUnsignedChannelUpdate,
7536 /// Indicates that this is the only struct which contains the same pointer.
7538 /// Rust functions which take ownership of an object provided via an argument require
7539 /// this to be true and invalidate the object pointed to by inner.
7543 impl Drop for UnsignedChannelUpdate {
7544 fn drop(&mut self) {
7545 if self.is_owned && !<*mut nativeUnsignedChannelUpdate>::is_null(self.inner) {
7546 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7550 /// Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL.
7552 pub extern "C" fn UnsignedChannelUpdate_free(this_obj: UnsignedChannelUpdate) { }
7554 /// Used only if an object of this type is returned as a trait impl by a method
7555 pub(crate) extern "C" fn UnsignedChannelUpdate_free_void(this_ptr: *mut c_void) {
7556 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedChannelUpdate) };
7559 impl UnsignedChannelUpdate {
7560 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelUpdate {
7561 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7563 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelUpdate {
7564 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7566 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7567 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelUpdate {
7568 assert!(self.is_owned);
7569 let ret = ObjOps::untweak_ptr(self.inner);
7570 self.inner = core::ptr::null_mut();
7574 /// The genesis hash of the blockchain where the channel is to be opened
7576 pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChannelUpdate) -> *const [u8; 32] {
7577 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
7580 /// The genesis hash of the blockchain where the channel is to be opened
7582 pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::ThirtyTwoBytes) {
7583 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
7585 /// The short channel ID
7587 pub extern "C" fn UnsignedChannelUpdate_get_short_channel_id(this_ptr: &UnsignedChannelUpdate) -> u64 {
7588 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
7591 /// The short channel ID
7593 pub extern "C" fn UnsignedChannelUpdate_set_short_channel_id(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
7594 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
7596 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
7598 pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannelUpdate) -> u32 {
7599 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
7602 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
7604 pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
7605 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
7609 pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 {
7610 let mut inner_val = &mut this_ptr.get_native_mut_ref().flags;
7615 pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) {
7616 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.flags = val;
7618 /// The number of blocks such that if:
7619 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
7620 /// then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines
7621 /// the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a
7622 /// `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10,
7623 /// then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before
7624 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
7625 /// constructing the route.
7627 pub extern "C" fn UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr: &UnsignedChannelUpdate) -> u16 {
7628 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
7631 /// The number of blocks such that if:
7632 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
7633 /// then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines
7634 /// the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a
7635 /// `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10,
7636 /// then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before
7637 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
7638 /// constructing the route.
7640 pub extern "C" fn UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr: &mut UnsignedChannelUpdate, mut val: u16) {
7641 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
7643 /// The minimum HTLC size incoming to sender, in milli-satoshi
7645 pub extern "C" fn UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
7646 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
7649 /// The minimum HTLC size incoming to sender, in milli-satoshi
7651 pub extern "C" fn UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
7652 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
7654 /// The maximum HTLC value incoming to sender, in milli-satoshi.
7656 /// This used to be optional.
7658 pub extern "C" fn UnsignedChannelUpdate_get_htlc_maximum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
7659 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat;
7662 /// The maximum HTLC value incoming to sender, in milli-satoshi.
7664 /// This used to be optional.
7666 pub extern "C" fn UnsignedChannelUpdate_set_htlc_maximum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
7667 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = val;
7669 /// The base HTLC fee charged by sender, in milli-satoshi
7671 pub extern "C" fn UnsignedChannelUpdate_get_fee_base_msat(this_ptr: &UnsignedChannelUpdate) -> u32 {
7672 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat;
7675 /// The base HTLC fee charged by sender, in milli-satoshi
7677 pub extern "C" fn UnsignedChannelUpdate_set_fee_base_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
7678 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val;
7680 /// The amount to fee multiplier, in micro-satoshi
7682 pub extern "C" fn UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr: &UnsignedChannelUpdate) -> u32 {
7683 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths;
7686 /// The amount to fee multiplier, in micro-satoshi
7688 pub extern "C" fn UnsignedChannelUpdate_set_fee_proportional_millionths(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
7689 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val;
7691 /// Excess data which was signed as a part of the message which we do not (yet) understand how
7694 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
7696 /// Returns a copy of the field.
7698 pub extern "C" fn UnsignedChannelUpdate_get_excess_data(this_ptr: &UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
7699 let mut inner_val = this_ptr.get_native_mut_ref().excess_data.clone();
7700 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
7701 local_inner_val.into()
7703 /// Excess data which was signed as a part of the message which we do not (yet) understand how
7706 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
7708 pub extern "C" fn UnsignedChannelUpdate_set_excess_data(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::derived::CVec_u8Z) {
7709 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
7710 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_data = local_val;
7712 /// Constructs a new UnsignedChannelUpdate given each field
7715 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 {
7716 let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); };
7717 UnsignedChannelUpdate { inner: ObjOps::heap_alloc(nativeUnsignedChannelUpdate {
7718 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
7719 short_channel_id: short_channel_id_arg,
7720 timestamp: timestamp_arg,
7722 cltv_expiry_delta: cltv_expiry_delta_arg,
7723 htlc_minimum_msat: htlc_minimum_msat_arg,
7724 htlc_maximum_msat: htlc_maximum_msat_arg,
7725 fee_base_msat: fee_base_msat_arg,
7726 fee_proportional_millionths: fee_proportional_millionths_arg,
7727 excess_data: local_excess_data_arg,
7728 }), is_owned: true }
7730 impl Clone for UnsignedChannelUpdate {
7731 fn clone(&self) -> Self {
7733 inner: if <*mut nativeUnsignedChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
7734 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7740 /// Used only if an object of this type is returned as a trait impl by a method
7741 pub(crate) extern "C" fn UnsignedChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
7742 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUnsignedChannelUpdate)).clone() })) as *mut c_void
7745 /// Creates a copy of the UnsignedChannelUpdate
7746 pub extern "C" fn UnsignedChannelUpdate_clone(orig: &UnsignedChannelUpdate) -> UnsignedChannelUpdate {
7749 /// Get a string which allows debug introspection of a UnsignedChannelUpdate object
7750 pub extern "C" fn UnsignedChannelUpdate_debug_str_void(o: *const c_void) -> Str {
7751 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UnsignedChannelUpdate }).into()}
7752 /// Generates a non-cryptographic 64-bit hash of the UnsignedChannelUpdate.
7754 pub extern "C" fn UnsignedChannelUpdate_hash(o: &UnsignedChannelUpdate) -> u64 {
7755 if o.inner.is_null() { return 0; }
7756 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
7757 #[allow(deprecated)]
7758 let mut hasher = core::hash::SipHasher::new();
7759 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
7760 core::hash::Hasher::finish(&hasher)
7762 /// Checks if two UnsignedChannelUpdates contain equal inner contents.
7763 /// This ignores pointers and is_owned flags and looks at the values in fields.
7764 /// Two objects with NULL inner values will be considered "equal" here.
7766 pub extern "C" fn UnsignedChannelUpdate_eq(a: &UnsignedChannelUpdate, b: &UnsignedChannelUpdate) -> bool {
7767 if a.inner == b.inner { return true; }
7768 if a.inner.is_null() || b.inner.is_null() { return false; }
7769 if a.get_native_ref() == b.get_native_ref() { true } else { false }
7772 use lightning::ln::msgs::ChannelUpdate as nativeChannelUpdateImport;
7773 pub(crate) type nativeChannelUpdate = nativeChannelUpdateImport;
7775 /// A [`channel_update`] message to be sent to or received from a peer.
7777 /// [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
7780 pub struct ChannelUpdate {
7781 /// A pointer to the opaque Rust object.
7783 /// Nearly everywhere, inner must be non-null, however in places where
7784 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7785 pub inner: *mut nativeChannelUpdate,
7786 /// Indicates that this is the only struct which contains the same pointer.
7788 /// Rust functions which take ownership of an object provided via an argument require
7789 /// this to be true and invalidate the object pointed to by inner.
7793 impl Drop for ChannelUpdate {
7794 fn drop(&mut self) {
7795 if self.is_owned && !<*mut nativeChannelUpdate>::is_null(self.inner) {
7796 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7800 /// Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL.
7802 pub extern "C" fn ChannelUpdate_free(this_obj: ChannelUpdate) { }
7804 /// Used only if an object of this type is returned as a trait impl by a method
7805 pub(crate) extern "C" fn ChannelUpdate_free_void(this_ptr: *mut c_void) {
7806 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelUpdate) };
7809 impl ChannelUpdate {
7810 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelUpdate {
7811 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7813 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelUpdate {
7814 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7816 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7817 pub(crate) fn take_inner(mut self) -> *mut nativeChannelUpdate {
7818 assert!(self.is_owned);
7819 let ret = ObjOps::untweak_ptr(self.inner);
7820 self.inner = core::ptr::null_mut();
7824 /// A signature of the channel update
7826 pub extern "C" fn ChannelUpdate_get_signature(this_ptr: &ChannelUpdate) -> crate::c_types::ECDSASignature {
7827 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
7828 crate::c_types::ECDSASignature::from_rust(&inner_val)
7830 /// A signature of the channel update
7832 pub extern "C" fn ChannelUpdate_set_signature(this_ptr: &mut ChannelUpdate, mut val: crate::c_types::ECDSASignature) {
7833 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
7835 /// The actual channel update
7837 pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate::lightning::ln::msgs::UnsignedChannelUpdate {
7838 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
7839 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 }
7841 /// The actual channel update
7843 pub extern "C" fn ChannelUpdate_set_contents(this_ptr: &mut ChannelUpdate, mut val: crate::lightning::ln::msgs::UnsignedChannelUpdate) {
7844 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
7846 /// Constructs a new ChannelUpdate given each field
7849 pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::ECDSASignature, mut contents_arg: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> ChannelUpdate {
7850 ChannelUpdate { inner: ObjOps::heap_alloc(nativeChannelUpdate {
7851 signature: signature_arg.into_rust(),
7852 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
7853 }), is_owned: true }
7855 impl Clone for ChannelUpdate {
7856 fn clone(&self) -> Self {
7858 inner: if <*mut nativeChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
7859 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7865 /// Used only if an object of this type is returned as a trait impl by a method
7866 pub(crate) extern "C" fn ChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
7867 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelUpdate)).clone() })) as *mut c_void
7870 /// Creates a copy of the ChannelUpdate
7871 pub extern "C" fn ChannelUpdate_clone(orig: &ChannelUpdate) -> ChannelUpdate {
7874 /// Get a string which allows debug introspection of a ChannelUpdate object
7875 pub extern "C" fn ChannelUpdate_debug_str_void(o: *const c_void) -> Str {
7876 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ChannelUpdate }).into()}
7877 /// Generates a non-cryptographic 64-bit hash of the ChannelUpdate.
7879 pub extern "C" fn ChannelUpdate_hash(o: &ChannelUpdate) -> u64 {
7880 if o.inner.is_null() { return 0; }
7881 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
7882 #[allow(deprecated)]
7883 let mut hasher = core::hash::SipHasher::new();
7884 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
7885 core::hash::Hasher::finish(&hasher)
7887 /// Checks if two ChannelUpdates contain equal inner contents.
7888 /// This ignores pointers and is_owned flags and looks at the values in fields.
7889 /// Two objects with NULL inner values will be considered "equal" here.
7891 pub extern "C" fn ChannelUpdate_eq(a: &ChannelUpdate, b: &ChannelUpdate) -> bool {
7892 if a.inner == b.inner { return true; }
7893 if a.inner.is_null() || b.inner.is_null() { return false; }
7894 if a.get_native_ref() == b.get_native_ref() { true } else { false }
7897 use lightning::ln::msgs::QueryChannelRange as nativeQueryChannelRangeImport;
7898 pub(crate) type nativeQueryChannelRange = nativeQueryChannelRangeImport;
7900 /// A [`query_channel_range`] message is used to query a peer for channel
7901 /// UTXOs in a range of blocks. The recipient of a query makes a best
7902 /// effort to reply to the query using one or more [`ReplyChannelRange`]
7905 /// [`query_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages
7908 pub struct QueryChannelRange {
7909 /// A pointer to the opaque Rust object.
7911 /// Nearly everywhere, inner must be non-null, however in places where
7912 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7913 pub inner: *mut nativeQueryChannelRange,
7914 /// Indicates that this is the only struct which contains the same pointer.
7916 /// Rust functions which take ownership of an object provided via an argument require
7917 /// this to be true and invalidate the object pointed to by inner.
7921 impl Drop for QueryChannelRange {
7922 fn drop(&mut self) {
7923 if self.is_owned && !<*mut nativeQueryChannelRange>::is_null(self.inner) {
7924 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7928 /// Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL.
7930 pub extern "C" fn QueryChannelRange_free(this_obj: QueryChannelRange) { }
7932 /// Used only if an object of this type is returned as a trait impl by a method
7933 pub(crate) extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) {
7934 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeQueryChannelRange) };
7937 impl QueryChannelRange {
7938 pub(crate) fn get_native_ref(&self) -> &'static nativeQueryChannelRange {
7939 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7941 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryChannelRange {
7942 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7944 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7945 pub(crate) fn take_inner(mut self) -> *mut nativeQueryChannelRange {
7946 assert!(self.is_owned);
7947 let ret = ObjOps::untweak_ptr(self.inner);
7948 self.inner = core::ptr::null_mut();
7952 /// The genesis hash of the blockchain being queried
7954 pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *const [u8; 32] {
7955 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
7958 /// The genesis hash of the blockchain being queried
7960 pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
7961 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
7963 /// The height of the first block for the channel UTXOs being queried
7965 pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 {
7966 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
7969 /// The height of the first block for the channel UTXOs being queried
7971 pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChannelRange, mut val: u32) {
7972 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
7974 /// The number of blocks to include in the query results
7976 pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 {
7977 let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
7980 /// The number of blocks to include in the query results
7982 pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryChannelRange, mut val: u32) {
7983 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
7985 /// Constructs a new QueryChannelRange given each field
7988 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 {
7989 QueryChannelRange { inner: ObjOps::heap_alloc(nativeQueryChannelRange {
7990 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
7991 first_blocknum: first_blocknum_arg,
7992 number_of_blocks: number_of_blocks_arg,
7993 }), is_owned: true }
7995 impl Clone for QueryChannelRange {
7996 fn clone(&self) -> Self {
7998 inner: if <*mut nativeQueryChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
7999 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
8005 /// Used only if an object of this type is returned as a trait impl by a method
8006 pub(crate) extern "C" fn QueryChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
8007 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeQueryChannelRange)).clone() })) as *mut c_void
8010 /// Creates a copy of the QueryChannelRange
8011 pub extern "C" fn QueryChannelRange_clone(orig: &QueryChannelRange) -> QueryChannelRange {
8014 /// Get a string which allows debug introspection of a QueryChannelRange object
8015 pub extern "C" fn QueryChannelRange_debug_str_void(o: *const c_void) -> Str {
8016 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::QueryChannelRange }).into()}
8017 /// Generates a non-cryptographic 64-bit hash of the QueryChannelRange.
8019 pub extern "C" fn QueryChannelRange_hash(o: &QueryChannelRange) -> u64 {
8020 if o.inner.is_null() { return 0; }
8021 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
8022 #[allow(deprecated)]
8023 let mut hasher = core::hash::SipHasher::new();
8024 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
8025 core::hash::Hasher::finish(&hasher)
8027 /// Checks if two QueryChannelRanges contain equal inner contents.
8028 /// This ignores pointers and is_owned flags and looks at the values in fields.
8029 /// Two objects with NULL inner values will be considered "equal" here.
8031 pub extern "C" fn QueryChannelRange_eq(a: &QueryChannelRange, b: &QueryChannelRange) -> bool {
8032 if a.inner == b.inner { return true; }
8033 if a.inner.is_null() || b.inner.is_null() { return false; }
8034 if a.get_native_ref() == b.get_native_ref() { true } else { false }
8037 use lightning::ln::msgs::ReplyChannelRange as nativeReplyChannelRangeImport;
8038 pub(crate) type nativeReplyChannelRange = nativeReplyChannelRangeImport;
8040 /// A [`reply_channel_range`] message is a reply to a [`QueryChannelRange`]
8043 /// Multiple `reply_channel_range` messages can be sent in reply
8044 /// to a single [`QueryChannelRange`] message. The query recipient makes a
8045 /// best effort to respond based on their local network view which may
8046 /// not be a perfect view of the network. The `short_channel_id`s in the
8047 /// reply are encoded. We only support `encoding_type=0` uncompressed
8048 /// serialization and do not support `encoding_type=1` zlib serialization.
8050 /// [`reply_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages
8053 pub struct ReplyChannelRange {
8054 /// A pointer to the opaque Rust object.
8056 /// Nearly everywhere, inner must be non-null, however in places where
8057 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
8058 pub inner: *mut nativeReplyChannelRange,
8059 /// Indicates that this is the only struct which contains the same pointer.
8061 /// Rust functions which take ownership of an object provided via an argument require
8062 /// this to be true and invalidate the object pointed to by inner.
8066 impl Drop for ReplyChannelRange {
8067 fn drop(&mut self) {
8068 if self.is_owned && !<*mut nativeReplyChannelRange>::is_null(self.inner) {
8069 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
8073 /// Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL.
8075 pub extern "C" fn ReplyChannelRange_free(this_obj: ReplyChannelRange) { }
8077 /// Used only if an object of this type is returned as a trait impl by a method
8078 pub(crate) extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) {
8079 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeReplyChannelRange) };
8082 impl ReplyChannelRange {
8083 pub(crate) fn get_native_ref(&self) -> &'static nativeReplyChannelRange {
8084 unsafe { &*ObjOps::untweak_ptr(self.inner) }
8086 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyChannelRange {
8087 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
8089 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
8090 pub(crate) fn take_inner(mut self) -> *mut nativeReplyChannelRange {
8091 assert!(self.is_owned);
8092 let ret = ObjOps::untweak_ptr(self.inner);
8093 self.inner = core::ptr::null_mut();
8097 /// The genesis hash of the blockchain being queried
8099 pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *const [u8; 32] {
8100 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
8103 /// The genesis hash of the blockchain being queried
8105 pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
8106 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
8108 /// The height of the first block in the range of the reply
8110 pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 {
8111 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
8114 /// The height of the first block in the range of the reply
8116 pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChannelRange, mut val: u32) {
8117 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
8119 /// The number of blocks included in the range of the reply
8121 pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 {
8122 let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
8125 /// The number of blocks included in the range of the reply
8127 pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyChannelRange, mut val: u32) {
8128 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
8130 /// True when this is the final reply for a query
8132 pub extern "C" fn ReplyChannelRange_get_sync_complete(this_ptr: &ReplyChannelRange) -> bool {
8133 let mut inner_val = &mut this_ptr.get_native_mut_ref().sync_complete;
8136 /// True when this is the final reply for a query
8138 pub extern "C" fn ReplyChannelRange_set_sync_complete(this_ptr: &mut ReplyChannelRange, mut val: bool) {
8139 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sync_complete = val;
8141 /// The `short_channel_id`s in the channel range
8143 /// Returns a copy of the field.
8145 pub extern "C" fn ReplyChannelRange_get_short_channel_ids(this_ptr: &ReplyChannelRange) -> crate::c_types::derived::CVec_u64Z {
8146 let mut inner_val = this_ptr.get_native_mut_ref().short_channel_ids.clone();
8147 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
8148 local_inner_val.into()
8150 /// The `short_channel_id`s in the channel range
8152 pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::derived::CVec_u64Z) {
8153 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
8154 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
8156 /// Constructs a new ReplyChannelRange given each field
8159 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 {
8160 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 }); };
8161 ReplyChannelRange { inner: ObjOps::heap_alloc(nativeReplyChannelRange {
8162 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
8163 first_blocknum: first_blocknum_arg,
8164 number_of_blocks: number_of_blocks_arg,
8165 sync_complete: sync_complete_arg,
8166 short_channel_ids: local_short_channel_ids_arg,
8167 }), is_owned: true }
8169 impl Clone for ReplyChannelRange {
8170 fn clone(&self) -> Self {
8172 inner: if <*mut nativeReplyChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
8173 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
8179 /// Used only if an object of this type is returned as a trait impl by a method
8180 pub(crate) extern "C" fn ReplyChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
8181 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeReplyChannelRange)).clone() })) as *mut c_void
8184 /// Creates a copy of the ReplyChannelRange
8185 pub extern "C" fn ReplyChannelRange_clone(orig: &ReplyChannelRange) -> ReplyChannelRange {
8188 /// Get a string which allows debug introspection of a ReplyChannelRange object
8189 pub extern "C" fn ReplyChannelRange_debug_str_void(o: *const c_void) -> Str {
8190 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ReplyChannelRange }).into()}
8191 /// Generates a non-cryptographic 64-bit hash of the ReplyChannelRange.
8193 pub extern "C" fn ReplyChannelRange_hash(o: &ReplyChannelRange) -> u64 {
8194 if o.inner.is_null() { return 0; }
8195 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
8196 #[allow(deprecated)]
8197 let mut hasher = core::hash::SipHasher::new();
8198 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
8199 core::hash::Hasher::finish(&hasher)
8201 /// Checks if two ReplyChannelRanges contain equal inner contents.
8202 /// This ignores pointers and is_owned flags and looks at the values in fields.
8203 /// Two objects with NULL inner values will be considered "equal" here.
8205 pub extern "C" fn ReplyChannelRange_eq(a: &ReplyChannelRange, b: &ReplyChannelRange) -> bool {
8206 if a.inner == b.inner { return true; }
8207 if a.inner.is_null() || b.inner.is_null() { return false; }
8208 if a.get_native_ref() == b.get_native_ref() { true } else { false }
8211 use lightning::ln::msgs::QueryShortChannelIds as nativeQueryShortChannelIdsImport;
8212 pub(crate) type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport;
8214 /// A [`query_short_channel_ids`] message is used to query a peer for
8215 /// routing gossip messages related to one or more `short_channel_id`s.
8217 /// The query recipient will reply with the latest, if available,
8218 /// [`ChannelAnnouncement`], [`ChannelUpdate`] and [`NodeAnnouncement`] messages
8219 /// it maintains for the requested `short_channel_id`s followed by a
8220 /// [`ReplyShortChannelIdsEnd`] message. The `short_channel_id`s sent in
8221 /// this query are encoded. We only support `encoding_type=0` uncompressed
8222 /// serialization and do not support `encoding_type=1` zlib serialization.
8224 /// [`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
8227 pub struct QueryShortChannelIds {
8228 /// A pointer to the opaque Rust object.
8230 /// Nearly everywhere, inner must be non-null, however in places where
8231 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
8232 pub inner: *mut nativeQueryShortChannelIds,
8233 /// Indicates that this is the only struct which contains the same pointer.
8235 /// Rust functions which take ownership of an object provided via an argument require
8236 /// this to be true and invalidate the object pointed to by inner.
8240 impl Drop for QueryShortChannelIds {
8241 fn drop(&mut self) {
8242 if self.is_owned && !<*mut nativeQueryShortChannelIds>::is_null(self.inner) {
8243 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
8247 /// Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL.
8249 pub extern "C" fn QueryShortChannelIds_free(this_obj: QueryShortChannelIds) { }
8251 /// Used only if an object of this type is returned as a trait impl by a method
8252 pub(crate) extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) {
8253 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeQueryShortChannelIds) };
8256 impl QueryShortChannelIds {
8257 pub(crate) fn get_native_ref(&self) -> &'static nativeQueryShortChannelIds {
8258 unsafe { &*ObjOps::untweak_ptr(self.inner) }
8260 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryShortChannelIds {
8261 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
8263 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
8264 pub(crate) fn take_inner(mut self) -> *mut nativeQueryShortChannelIds {
8265 assert!(self.is_owned);
8266 let ret = ObjOps::untweak_ptr(self.inner);
8267 self.inner = core::ptr::null_mut();
8271 /// The genesis hash of the blockchain being queried
8273 pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *const [u8; 32] {
8274 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
8277 /// The genesis hash of the blockchain being queried
8279 pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::ThirtyTwoBytes) {
8280 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
8282 /// The short_channel_ids that are being queried
8284 /// Returns a copy of the field.
8286 pub extern "C" fn QueryShortChannelIds_get_short_channel_ids(this_ptr: &QueryShortChannelIds) -> crate::c_types::derived::CVec_u64Z {
8287 let mut inner_val = this_ptr.get_native_mut_ref().short_channel_ids.clone();
8288 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
8289 local_inner_val.into()
8291 /// The short_channel_ids that are being queried
8293 pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::derived::CVec_u64Z) {
8294 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
8295 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
8297 /// Constructs a new QueryShortChannelIds given each field
8300 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 {
8301 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 }); };
8302 QueryShortChannelIds { inner: ObjOps::heap_alloc(nativeQueryShortChannelIds {
8303 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
8304 short_channel_ids: local_short_channel_ids_arg,
8305 }), is_owned: true }
8307 impl Clone for QueryShortChannelIds {
8308 fn clone(&self) -> Self {
8310 inner: if <*mut nativeQueryShortChannelIds>::is_null(self.inner) { core::ptr::null_mut() } else {
8311 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
8317 /// Used only if an object of this type is returned as a trait impl by a method
8318 pub(crate) extern "C" fn QueryShortChannelIds_clone_void(this_ptr: *const c_void) -> *mut c_void {
8319 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeQueryShortChannelIds)).clone() })) as *mut c_void
8322 /// Creates a copy of the QueryShortChannelIds
8323 pub extern "C" fn QueryShortChannelIds_clone(orig: &QueryShortChannelIds) -> QueryShortChannelIds {
8326 /// Get a string which allows debug introspection of a QueryShortChannelIds object
8327 pub extern "C" fn QueryShortChannelIds_debug_str_void(o: *const c_void) -> Str {
8328 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::QueryShortChannelIds }).into()}
8329 /// Generates a non-cryptographic 64-bit hash of the QueryShortChannelIds.
8331 pub extern "C" fn QueryShortChannelIds_hash(o: &QueryShortChannelIds) -> u64 {
8332 if o.inner.is_null() { return 0; }
8333 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
8334 #[allow(deprecated)]
8335 let mut hasher = core::hash::SipHasher::new();
8336 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
8337 core::hash::Hasher::finish(&hasher)
8339 /// Checks if two QueryShortChannelIdss contain equal inner contents.
8340 /// This ignores pointers and is_owned flags and looks at the values in fields.
8341 /// Two objects with NULL inner values will be considered "equal" here.
8343 pub extern "C" fn QueryShortChannelIds_eq(a: &QueryShortChannelIds, b: &QueryShortChannelIds) -> bool {
8344 if a.inner == b.inner { return true; }
8345 if a.inner.is_null() || b.inner.is_null() { return false; }
8346 if a.get_native_ref() == b.get_native_ref() { true } else { false }
8349 use lightning::ln::msgs::ReplyShortChannelIdsEnd as nativeReplyShortChannelIdsEndImport;
8350 pub(crate) type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport;
8352 /// A [`reply_short_channel_ids_end`] message is sent as a reply to a
8353 /// message. The query recipient makes a best
8354 /// effort to respond based on their local network view which may not be
8355 /// a perfect view of the network.
8357 /// [`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
8360 pub struct ReplyShortChannelIdsEnd {
8361 /// A pointer to the opaque Rust object.
8363 /// Nearly everywhere, inner must be non-null, however in places where
8364 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
8365 pub inner: *mut nativeReplyShortChannelIdsEnd,
8366 /// Indicates that this is the only struct which contains the same pointer.
8368 /// Rust functions which take ownership of an object provided via an argument require
8369 /// this to be true and invalidate the object pointed to by inner.
8373 impl Drop for ReplyShortChannelIdsEnd {
8374 fn drop(&mut self) {
8375 if self.is_owned && !<*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) {
8376 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
8380 /// Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL.
8382 pub extern "C" fn ReplyShortChannelIdsEnd_free(this_obj: ReplyShortChannelIdsEnd) { }
8384 /// Used only if an object of this type is returned as a trait impl by a method
8385 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) {
8386 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeReplyShortChannelIdsEnd) };
8389 impl ReplyShortChannelIdsEnd {
8390 pub(crate) fn get_native_ref(&self) -> &'static nativeReplyShortChannelIdsEnd {
8391 unsafe { &*ObjOps::untweak_ptr(self.inner) }
8393 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyShortChannelIdsEnd {
8394 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
8396 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
8397 pub(crate) fn take_inner(mut self) -> *mut nativeReplyShortChannelIdsEnd {
8398 assert!(self.is_owned);
8399 let ret = ObjOps::untweak_ptr(self.inner);
8400 self.inner = core::ptr::null_mut();
8404 /// The genesis hash of the blockchain that was queried
8406 pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *const [u8; 32] {
8407 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
8410 /// The genesis hash of the blockchain that was queried
8412 pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) {
8413 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
8415 /// Indicates if the query recipient maintains up-to-date channel
8416 /// information for the `chain_hash`
8418 pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool {
8419 let mut inner_val = &mut this_ptr.get_native_mut_ref().full_information;
8422 /// Indicates if the query recipient maintains up-to-date channel
8423 /// information for the `chain_hash`
8425 pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: bool) {
8426 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.full_information = val;
8428 /// Constructs a new ReplyShortChannelIdsEnd given each field
8431 pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd {
8432 ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(nativeReplyShortChannelIdsEnd {
8433 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
8434 full_information: full_information_arg,
8435 }), is_owned: true }
8437 impl Clone for ReplyShortChannelIdsEnd {
8438 fn clone(&self) -> Self {
8440 inner: if <*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) { core::ptr::null_mut() } else {
8441 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
8447 /// Used only if an object of this type is returned as a trait impl by a method
8448 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_void) -> *mut c_void {
8449 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeReplyShortChannelIdsEnd)).clone() })) as *mut c_void
8452 /// Creates a copy of the ReplyShortChannelIdsEnd
8453 pub extern "C" fn ReplyShortChannelIdsEnd_clone(orig: &ReplyShortChannelIdsEnd) -> ReplyShortChannelIdsEnd {
8456 /// Get a string which allows debug introspection of a ReplyShortChannelIdsEnd object
8457 pub extern "C" fn ReplyShortChannelIdsEnd_debug_str_void(o: *const c_void) -> Str {
8458 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ReplyShortChannelIdsEnd }).into()}
8459 /// Generates a non-cryptographic 64-bit hash of the ReplyShortChannelIdsEnd.
8461 pub extern "C" fn ReplyShortChannelIdsEnd_hash(o: &ReplyShortChannelIdsEnd) -> u64 {
8462 if o.inner.is_null() { return 0; }
8463 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
8464 #[allow(deprecated)]
8465 let mut hasher = core::hash::SipHasher::new();
8466 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
8467 core::hash::Hasher::finish(&hasher)
8469 /// Checks if two ReplyShortChannelIdsEnds contain equal inner contents.
8470 /// This ignores pointers and is_owned flags and looks at the values in fields.
8471 /// Two objects with NULL inner values will be considered "equal" here.
8473 pub extern "C" fn ReplyShortChannelIdsEnd_eq(a: &ReplyShortChannelIdsEnd, b: &ReplyShortChannelIdsEnd) -> bool {
8474 if a.inner == b.inner { return true; }
8475 if a.inner.is_null() || b.inner.is_null() { return false; }
8476 if a.get_native_ref() == b.get_native_ref() { true } else { false }
8479 use lightning::ln::msgs::GossipTimestampFilter as nativeGossipTimestampFilterImport;
8480 pub(crate) type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport;
8482 /// A [`gossip_timestamp_filter`] message is used by a node to request
8483 /// gossip relay for messages in the requested time range when the
8484 /// `gossip_queries` feature has been negotiated.
8486 /// [`gossip_timestamp_filter`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-gossip_timestamp_filter-message
8489 pub struct GossipTimestampFilter {
8490 /// A pointer to the opaque Rust object.
8492 /// Nearly everywhere, inner must be non-null, however in places where
8493 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
8494 pub inner: *mut nativeGossipTimestampFilter,
8495 /// Indicates that this is the only struct which contains the same pointer.
8497 /// Rust functions which take ownership of an object provided via an argument require
8498 /// this to be true and invalidate the object pointed to by inner.
8502 impl Drop for GossipTimestampFilter {
8503 fn drop(&mut self) {
8504 if self.is_owned && !<*mut nativeGossipTimestampFilter>::is_null(self.inner) {
8505 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
8509 /// Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL.
8511 pub extern "C" fn GossipTimestampFilter_free(this_obj: GossipTimestampFilter) { }
8513 /// Used only if an object of this type is returned as a trait impl by a method
8514 pub(crate) extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) {
8515 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeGossipTimestampFilter) };
8518 impl GossipTimestampFilter {
8519 pub(crate) fn get_native_ref(&self) -> &'static nativeGossipTimestampFilter {
8520 unsafe { &*ObjOps::untweak_ptr(self.inner) }
8522 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeGossipTimestampFilter {
8523 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
8525 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
8526 pub(crate) fn take_inner(mut self) -> *mut nativeGossipTimestampFilter {
8527 assert!(self.is_owned);
8528 let ret = ObjOps::untweak_ptr(self.inner);
8529 self.inner = core::ptr::null_mut();
8533 /// The genesis hash of the blockchain for channel and node information
8535 pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *const [u8; 32] {
8536 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
8539 /// The genesis hash of the blockchain for channel and node information
8541 pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) {
8542 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
8544 /// The starting unix timestamp
8546 pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 {
8547 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_timestamp;
8550 /// The starting unix timestamp
8552 pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
8553 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_timestamp = val;
8555 /// The range of information in seconds
8557 pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 {
8558 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp_range;
8561 /// The range of information in seconds
8563 pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
8564 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp_range = val;
8566 /// Constructs a new GossipTimestampFilter given each field
8569 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 {
8570 GossipTimestampFilter { inner: ObjOps::heap_alloc(nativeGossipTimestampFilter {
8571 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
8572 first_timestamp: first_timestamp_arg,
8573 timestamp_range: timestamp_range_arg,
8574 }), is_owned: true }
8576 impl Clone for GossipTimestampFilter {
8577 fn clone(&self) -> Self {
8579 inner: if <*mut nativeGossipTimestampFilter>::is_null(self.inner) { core::ptr::null_mut() } else {
8580 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
8586 /// Used only if an object of this type is returned as a trait impl by a method
8587 pub(crate) extern "C" fn GossipTimestampFilter_clone_void(this_ptr: *const c_void) -> *mut c_void {
8588 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeGossipTimestampFilter)).clone() })) as *mut c_void
8591 /// Creates a copy of the GossipTimestampFilter
8592 pub extern "C" fn GossipTimestampFilter_clone(orig: &GossipTimestampFilter) -> GossipTimestampFilter {
8595 /// Get a string which allows debug introspection of a GossipTimestampFilter object
8596 pub extern "C" fn GossipTimestampFilter_debug_str_void(o: *const c_void) -> Str {
8597 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::GossipTimestampFilter }).into()}
8598 /// Generates a non-cryptographic 64-bit hash of the GossipTimestampFilter.
8600 pub extern "C" fn GossipTimestampFilter_hash(o: &GossipTimestampFilter) -> u64 {
8601 if o.inner.is_null() { return 0; }
8602 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
8603 #[allow(deprecated)]
8604 let mut hasher = core::hash::SipHasher::new();
8605 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
8606 core::hash::Hasher::finish(&hasher)
8608 /// Checks if two GossipTimestampFilters contain equal inner contents.
8609 /// This ignores pointers and is_owned flags and looks at the values in fields.
8610 /// Two objects with NULL inner values will be considered "equal" here.
8612 pub extern "C" fn GossipTimestampFilter_eq(a: &GossipTimestampFilter, b: &GossipTimestampFilter) -> bool {
8613 if a.inner == b.inner { return true; }
8614 if a.inner.is_null() || b.inner.is_null() { return false; }
8615 if a.get_native_ref() == b.get_native_ref() { true } else { false }
8617 /// Used to put an error message in a [`LightningError`].
8621 pub enum ErrorAction {
8622 /// The peer took some action which made us think they were useless. Disconnect them.
8624 /// An error message which we should make an effort to send before we disconnect.
8626 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
8627 msg: crate::lightning::ln::msgs::ErrorMessage,
8629 /// The peer did something incorrect. Tell them without closing any channels and disconnect them.
8630 DisconnectPeerWithWarning {
8631 /// A warning message which we should make an effort to send before we disconnect.
8632 msg: crate::lightning::ln::msgs::WarningMessage,
8634 /// The peer did something harmless that we weren't able to process, just log and ignore
8636 /// The peer did something harmless that we weren't able to meaningfully process.
8637 /// If the error is logged, log it at the given level.
8639 crate::lightning::util::logger::Level),
8640 /// The peer provided us with a gossip message which we'd already seen. In most cases this
8641 /// should be ignored, but it may result in the message being forwarded if it is a duplicate of
8642 /// our own channel announcements.
8643 IgnoreDuplicateGossip,
8644 /// The peer did something incorrect. Tell them.
8646 /// The message to send.
8647 msg: crate::lightning::ln::msgs::ErrorMessage,
8649 /// The peer did something incorrect. Tell them without closing any channels.
8650 SendWarningMessage {
8651 /// The message to send.
8652 msg: crate::lightning::ln::msgs::WarningMessage,
8653 /// The peer may have done something harmless that we weren't able to meaningfully process,
8654 /// though we should still tell them about it.
8655 /// If this event is logged, log it at the given level.
8656 log_level: crate::lightning::util::logger::Level,
8659 use lightning::ln::msgs::ErrorAction as ErrorActionImport;
8660 pub(crate) type nativeErrorAction = ErrorActionImport;
8664 pub(crate) fn to_native(&self) -> nativeErrorAction {
8666 ErrorAction::DisconnectPeer {ref msg, } => {
8667 let mut msg_nonref = Clone::clone(msg);
8668 let mut local_msg_nonref = if msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg_nonref.take_inner()) } }) };
8669 nativeErrorAction::DisconnectPeer {
8670 msg: local_msg_nonref,
8673 ErrorAction::DisconnectPeerWithWarning {ref msg, } => {
8674 let mut msg_nonref = Clone::clone(msg);
8675 nativeErrorAction::DisconnectPeerWithWarning {
8676 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
8679 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
8680 ErrorAction::IgnoreAndLog (ref a, ) => {
8681 let mut a_nonref = Clone::clone(a);
8682 nativeErrorAction::IgnoreAndLog (
8683 a_nonref.into_native(),
8686 ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
8687 ErrorAction::SendErrorMessage {ref msg, } => {
8688 let mut msg_nonref = Clone::clone(msg);
8689 nativeErrorAction::SendErrorMessage {
8690 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
8693 ErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
8694 let mut msg_nonref = Clone::clone(msg);
8695 let mut log_level_nonref = Clone::clone(log_level);
8696 nativeErrorAction::SendWarningMessage {
8697 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
8698 log_level: log_level_nonref.into_native(),
8704 pub(crate) fn into_native(self) -> nativeErrorAction {
8706 ErrorAction::DisconnectPeer {mut msg, } => {
8707 let mut local_msg = if msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg.take_inner()) } }) };
8708 nativeErrorAction::DisconnectPeer {
8712 ErrorAction::DisconnectPeerWithWarning {mut msg, } => {
8713 nativeErrorAction::DisconnectPeerWithWarning {
8714 msg: *unsafe { Box::from_raw(msg.take_inner()) },
8717 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
8718 ErrorAction::IgnoreAndLog (mut a, ) => {
8719 nativeErrorAction::IgnoreAndLog (
8723 ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
8724 ErrorAction::SendErrorMessage {mut msg, } => {
8725 nativeErrorAction::SendErrorMessage {
8726 msg: *unsafe { Box::from_raw(msg.take_inner()) },
8729 ErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
8730 nativeErrorAction::SendWarningMessage {
8731 msg: *unsafe { Box::from_raw(msg.take_inner()) },
8732 log_level: log_level.into_native(),
8738 pub(crate) fn from_native(native: &ErrorActionImport) -> Self {
8739 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeErrorAction) };
8741 nativeErrorAction::DisconnectPeer {ref msg, } => {
8742 let mut msg_nonref = Clone::clone(msg);
8743 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 };
8744 ErrorAction::DisconnectPeer {
8745 msg: local_msg_nonref,
8748 nativeErrorAction::DisconnectPeerWithWarning {ref msg, } => {
8749 let mut msg_nonref = Clone::clone(msg);
8750 ErrorAction::DisconnectPeerWithWarning {
8751 msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
8754 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
8755 nativeErrorAction::IgnoreAndLog (ref a, ) => {
8756 let mut a_nonref = Clone::clone(a);
8757 ErrorAction::IgnoreAndLog (
8758 crate::lightning::util::logger::Level::native_into(a_nonref),
8761 nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
8762 nativeErrorAction::SendErrorMessage {ref msg, } => {
8763 let mut msg_nonref = Clone::clone(msg);
8764 ErrorAction::SendErrorMessage {
8765 msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
8768 nativeErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
8769 let mut msg_nonref = Clone::clone(msg);
8770 let mut log_level_nonref = Clone::clone(log_level);
8771 ErrorAction::SendWarningMessage {
8772 msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
8773 log_level: crate::lightning::util::logger::Level::native_into(log_level_nonref),
8779 pub(crate) fn native_into(native: nativeErrorAction) -> Self {
8781 nativeErrorAction::DisconnectPeer {mut msg, } => {
8782 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 };
8783 ErrorAction::DisconnectPeer {
8787 nativeErrorAction::DisconnectPeerWithWarning {mut msg, } => {
8788 ErrorAction::DisconnectPeerWithWarning {
8789 msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
8792 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
8793 nativeErrorAction::IgnoreAndLog (mut a, ) => {
8794 ErrorAction::IgnoreAndLog (
8795 crate::lightning::util::logger::Level::native_into(a),
8798 nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
8799 nativeErrorAction::SendErrorMessage {mut msg, } => {
8800 ErrorAction::SendErrorMessage {
8801 msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
8804 nativeErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
8805 ErrorAction::SendWarningMessage {
8806 msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
8807 log_level: crate::lightning::util::logger::Level::native_into(log_level),
8813 /// Frees any resources used by the ErrorAction
8815 pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { }
8816 /// Creates a copy of the ErrorAction
8818 pub extern "C" fn ErrorAction_clone(orig: &ErrorAction) -> ErrorAction {
8822 /// Used only if an object of this type is returned as a trait impl by a method
8823 pub(crate) extern "C" fn ErrorAction_clone_void(this_ptr: *const c_void) -> *mut c_void {
8824 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const ErrorAction)).clone() })) as *mut c_void
8827 /// Used only if an object of this type is returned as a trait impl by a method
8828 pub(crate) extern "C" fn ErrorAction_free_void(this_ptr: *mut c_void) {
8829 let _ = unsafe { Box::from_raw(this_ptr as *mut ErrorAction) };
8832 /// Utility method to constructs a new DisconnectPeer-variant ErrorAction
8833 pub extern "C" fn ErrorAction_disconnect_peer(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
8834 ErrorAction::DisconnectPeer {
8839 /// Utility method to constructs a new DisconnectPeerWithWarning-variant ErrorAction
8840 pub extern "C" fn ErrorAction_disconnect_peer_with_warning(msg: crate::lightning::ln::msgs::WarningMessage) -> ErrorAction {
8841 ErrorAction::DisconnectPeerWithWarning {
8846 /// Utility method to constructs a new IgnoreError-variant ErrorAction
8847 pub extern "C" fn ErrorAction_ignore_error() -> ErrorAction {
8848 ErrorAction::IgnoreError}
8850 /// Utility method to constructs a new IgnoreAndLog-variant ErrorAction
8851 pub extern "C" fn ErrorAction_ignore_and_log(a: crate::lightning::util::logger::Level) -> ErrorAction {
8852 ErrorAction::IgnoreAndLog(a, )
8855 /// Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction
8856 pub extern "C" fn ErrorAction_ignore_duplicate_gossip() -> ErrorAction {
8857 ErrorAction::IgnoreDuplicateGossip}
8859 /// Utility method to constructs a new SendErrorMessage-variant ErrorAction
8860 pub extern "C" fn ErrorAction_send_error_message(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
8861 ErrorAction::SendErrorMessage {
8866 /// Utility method to constructs a new SendWarningMessage-variant ErrorAction
8867 pub extern "C" fn ErrorAction_send_warning_message(msg: crate::lightning::ln::msgs::WarningMessage, log_level: crate::lightning::util::logger::Level) -> ErrorAction {
8868 ErrorAction::SendWarningMessage {
8873 /// Get a string which allows debug introspection of a ErrorAction object
8874 pub extern "C" fn ErrorAction_debug_str_void(o: *const c_void) -> Str {
8875 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ErrorAction }).into()}
8876 /// Generates a non-cryptographic 64-bit hash of the ErrorAction.
8878 pub extern "C" fn ErrorAction_hash(o: &ErrorAction) -> u64 {
8879 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
8880 #[allow(deprecated)]
8881 let mut hasher = core::hash::SipHasher::new();
8882 core::hash::Hash::hash(&o.to_native(), &mut hasher);
8883 core::hash::Hasher::finish(&hasher)
8886 use lightning::ln::msgs::LightningError as nativeLightningErrorImport;
8887 pub(crate) type nativeLightningError = nativeLightningErrorImport;
8889 /// An Err type for failure to process messages.
8892 pub struct LightningError {
8893 /// A pointer to the opaque Rust object.
8895 /// Nearly everywhere, inner must be non-null, however in places where
8896 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
8897 pub inner: *mut nativeLightningError,
8898 /// Indicates that this is the only struct which contains the same pointer.
8900 /// Rust functions which take ownership of an object provided via an argument require
8901 /// this to be true and invalidate the object pointed to by inner.
8905 impl Drop for LightningError {
8906 fn drop(&mut self) {
8907 if self.is_owned && !<*mut nativeLightningError>::is_null(self.inner) {
8908 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
8912 /// Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL.
8914 pub extern "C" fn LightningError_free(this_obj: LightningError) { }
8916 /// Used only if an object of this type is returned as a trait impl by a method
8917 pub(crate) extern "C" fn LightningError_free_void(this_ptr: *mut c_void) {
8918 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLightningError) };
8921 impl LightningError {
8922 pub(crate) fn get_native_ref(&self) -> &'static nativeLightningError {
8923 unsafe { &*ObjOps::untweak_ptr(self.inner) }
8925 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLightningError {
8926 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
8928 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
8929 pub(crate) fn take_inner(mut self) -> *mut nativeLightningError {
8930 assert!(self.is_owned);
8931 let ret = ObjOps::untweak_ptr(self.inner);
8932 self.inner = core::ptr::null_mut();
8936 /// A human-readable message describing the error
8938 pub extern "C" fn LightningError_get_err(this_ptr: &LightningError) -> crate::c_types::Str {
8939 let mut inner_val = &mut this_ptr.get_native_mut_ref().err;
8940 inner_val.as_str().into()
8942 /// A human-readable message describing the error
8944 pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: crate::c_types::Str) {
8945 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.err = val.into_string();
8947 /// The action which should be taken against the offending peer.
8949 pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate::lightning::ln::msgs::ErrorAction {
8950 let mut inner_val = &mut this_ptr.get_native_mut_ref().action;
8951 crate::lightning::ln::msgs::ErrorAction::from_native(inner_val)
8953 /// The action which should be taken against the offending peer.
8955 pub extern "C" fn LightningError_set_action(this_ptr: &mut LightningError, mut val: crate::lightning::ln::msgs::ErrorAction) {
8956 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.action = val.into_native();
8958 /// Constructs a new LightningError given each field
8961 pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::Str, mut action_arg: crate::lightning::ln::msgs::ErrorAction) -> LightningError {
8962 LightningError { inner: ObjOps::heap_alloc(nativeLightningError {
8963 err: err_arg.into_string(),
8964 action: action_arg.into_native(),
8965 }), is_owned: true }
8967 impl Clone for LightningError {
8968 fn clone(&self) -> Self {
8970 inner: if <*mut nativeLightningError>::is_null(self.inner) { core::ptr::null_mut() } else {
8971 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
8977 /// Used only if an object of this type is returned as a trait impl by a method
8978 pub(crate) extern "C" fn LightningError_clone_void(this_ptr: *const c_void) -> *mut c_void {
8979 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeLightningError)).clone() })) as *mut c_void
8982 /// Creates a copy of the LightningError
8983 pub extern "C" fn LightningError_clone(orig: &LightningError) -> LightningError {
8986 /// Get a string which allows debug introspection of a LightningError object
8987 pub extern "C" fn LightningError_debug_str_void(o: *const c_void) -> Str {
8988 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::LightningError }).into()}
8990 use lightning::ln::msgs::CommitmentUpdate as nativeCommitmentUpdateImport;
8991 pub(crate) type nativeCommitmentUpdate = nativeCommitmentUpdateImport;
8993 /// Struct used to return values from [`RevokeAndACK`] messages, containing a bunch of commitment
8994 /// transaction updates if they were pending.
8997 pub struct CommitmentUpdate {
8998 /// A pointer to the opaque Rust object.
9000 /// Nearly everywhere, inner must be non-null, however in places where
9001 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
9002 pub inner: *mut nativeCommitmentUpdate,
9003 /// Indicates that this is the only struct which contains the same pointer.
9005 /// Rust functions which take ownership of an object provided via an argument require
9006 /// this to be true and invalidate the object pointed to by inner.
9010 impl Drop for CommitmentUpdate {
9011 fn drop(&mut self) {
9012 if self.is_owned && !<*mut nativeCommitmentUpdate>::is_null(self.inner) {
9013 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
9017 /// Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL.
9019 pub extern "C" fn CommitmentUpdate_free(this_obj: CommitmentUpdate) { }
9021 /// Used only if an object of this type is returned as a trait impl by a method
9022 pub(crate) extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) {
9023 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCommitmentUpdate) };
9026 impl CommitmentUpdate {
9027 pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentUpdate {
9028 unsafe { &*ObjOps::untweak_ptr(self.inner) }
9030 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentUpdate {
9031 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
9033 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
9034 pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentUpdate {
9035 assert!(self.is_owned);
9036 let ret = ObjOps::untweak_ptr(self.inner);
9037 self.inner = core::ptr::null_mut();
9041 /// `update_add_htlc` messages which should be sent
9043 pub extern "C" fn CommitmentUpdate_get_update_add_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateAddHTLCZ {
9044 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_add_htlcs;
9045 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 } }); };
9046 local_inner_val.into()
9048 /// `update_add_htlc` messages which should be sent
9050 pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) {
9051 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
9052 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_add_htlcs = local_val;
9054 /// `update_fulfill_htlc` messages which should be sent
9056 pub extern "C" fn CommitmentUpdate_get_update_fulfill_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFulfillHTLCZ {
9057 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fulfill_htlcs;
9058 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 } }); };
9059 local_inner_val.into()
9061 /// `update_fulfill_htlc` messages which should be sent
9063 pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) {
9064 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
9065 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fulfill_htlcs = local_val;
9067 /// `update_fail_htlc` messages which should be sent
9069 pub extern "C" fn CommitmentUpdate_get_update_fail_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailHTLCZ {
9070 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_htlcs;
9071 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 } }); };
9072 local_inner_val.into()
9074 /// `update_fail_htlc` messages which should be sent
9076 pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) {
9077 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
9078 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_htlcs = local_val;
9080 /// `update_fail_malformed_htlc` messages which should be sent
9082 pub extern "C" fn CommitmentUpdate_get_update_fail_malformed_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ {
9083 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_malformed_htlcs;
9084 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 } }); };
9085 local_inner_val.into()
9087 /// `update_fail_malformed_htlc` messages which should be sent
9089 pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) {
9090 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
9091 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_malformed_htlcs = local_val;
9093 /// An `update_fee` message which should be sent
9095 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
9097 pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::UpdateFee {
9098 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fee;
9099 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 };
9102 /// An `update_fee` message which should be sent
9104 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
9106 pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::UpdateFee) {
9107 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
9108 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fee = local_val;
9110 /// A `commitment_signed` message which should be sent
9112 pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::CommitmentSigned {
9113 let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_signed;
9114 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 }
9116 /// A `commitment_signed` message which should be sent
9118 pub extern "C" fn CommitmentUpdate_set_commitment_signed(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::CommitmentSigned) {
9119 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_signed = *unsafe { Box::from_raw(val.take_inner()) };
9121 /// Constructs a new CommitmentUpdate given each field
9123 /// Note that update_fee_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
9126 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 {
9127 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()) } }); };
9128 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()) } }); };
9129 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()) } }); };
9130 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()) } }); };
9131 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()) } }) };
9132 CommitmentUpdate { inner: ObjOps::heap_alloc(nativeCommitmentUpdate {
9133 update_add_htlcs: local_update_add_htlcs_arg,
9134 update_fulfill_htlcs: local_update_fulfill_htlcs_arg,
9135 update_fail_htlcs: local_update_fail_htlcs_arg,
9136 update_fail_malformed_htlcs: local_update_fail_malformed_htlcs_arg,
9137 update_fee: local_update_fee_arg,
9138 commitment_signed: *unsafe { Box::from_raw(commitment_signed_arg.take_inner()) },
9139 }), is_owned: true }
9141 impl Clone for CommitmentUpdate {
9142 fn clone(&self) -> Self {
9144 inner: if <*mut nativeCommitmentUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
9145 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
9151 /// Used only if an object of this type is returned as a trait impl by a method
9152 pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
9153 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeCommitmentUpdate)).clone() })) as *mut c_void
9156 /// Creates a copy of the CommitmentUpdate
9157 pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentUpdate {
9160 /// Get a string which allows debug introspection of a CommitmentUpdate object
9161 pub extern "C" fn CommitmentUpdate_debug_str_void(o: *const c_void) -> Str {
9162 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::CommitmentUpdate }).into()}
9163 /// Generates a non-cryptographic 64-bit hash of the CommitmentUpdate.
9165 pub extern "C" fn CommitmentUpdate_hash(o: &CommitmentUpdate) -> u64 {
9166 if o.inner.is_null() { return 0; }
9167 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
9168 #[allow(deprecated)]
9169 let mut hasher = core::hash::SipHasher::new();
9170 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
9171 core::hash::Hasher::finish(&hasher)
9173 /// Checks if two CommitmentUpdates contain equal inner contents.
9174 /// This ignores pointers and is_owned flags and looks at the values in fields.
9175 /// Two objects with NULL inner values will be considered "equal" here.
9177 pub extern "C" fn CommitmentUpdate_eq(a: &CommitmentUpdate, b: &CommitmentUpdate) -> bool {
9178 if a.inner == b.inner { return true; }
9179 if a.inner.is_null() || b.inner.is_null() { return false; }
9180 if a.get_native_ref() == b.get_native_ref() { true } else { false }
9182 /// A trait to describe an object which can receive channel messages.
9184 /// Messages MAY be called in parallel when they originate from different `their_node_ids`, however
9185 /// they MUST NOT be called in parallel when the two calls have the same `their_node_id`.
9187 pub struct ChannelMessageHandler {
9188 /// An opaque pointer which is passed to your function implementations as an argument.
9189 /// This has no meaning in the LDK, and can be NULL or any other value.
9190 pub this_arg: *mut c_void,
9191 /// Handle an incoming `open_channel` message from the given peer.
9192 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),
9193 /// Handle an incoming `open_channel2` message from the given peer.
9194 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),
9195 /// Handle an incoming `accept_channel` message from the given peer.
9196 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),
9197 /// Handle an incoming `accept_channel2` message from the given peer.
9198 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),
9199 /// Handle an incoming `funding_created` message from the given peer.
9200 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),
9201 /// Handle an incoming `funding_signed` message from the given peer.
9202 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),
9203 /// Handle an incoming `channel_ready` message from the given peer.
9204 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),
9205 /// Handle an incoming `shutdown` message from the given peer.
9206 pub handle_shutdown: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Shutdown),
9207 /// Handle an incoming `closing_signed` message from the given peer.
9208 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),
9209 /// Handle an incoming `stfu` message from the given peer.
9210 pub handle_stfu: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Stfu),
9211 /// Handle an incoming `tx_add_input message` from the given peer.
9212 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),
9213 /// Handle an incoming `tx_add_output` message from the given peer.
9214 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),
9215 /// Handle an incoming `tx_remove_input` message from the given peer.
9216 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),
9217 /// Handle an incoming `tx_remove_output` message from the given peer.
9218 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),
9219 /// Handle an incoming `tx_complete message` from the given peer.
9220 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),
9221 /// Handle an incoming `tx_signatures` message from the given peer.
9222 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),
9223 /// Handle an incoming `tx_init_rbf` message from the given peer.
9224 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),
9225 /// Handle an incoming `tx_ack_rbf` message from the given peer.
9226 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),
9227 /// Handle an incoming `tx_abort message` from the given peer.
9228 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),
9229 /// Handle an incoming `update_add_htlc` message from the given peer.
9230 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),
9231 /// Handle an incoming `update_fulfill_htlc` message from the given peer.
9232 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),
9233 /// Handle an incoming `update_fail_htlc` message from the given peer.
9234 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),
9235 /// Handle an incoming `update_fail_malformed_htlc` message from the given peer.
9236 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),
9237 /// Handle an incoming `commitment_signed` message from the given peer.
9238 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),
9239 /// Handle an incoming `revoke_and_ack` message from the given peer.
9240 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),
9241 /// Handle an incoming `update_fee` message from the given peer.
9242 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),
9243 /// Handle an incoming `announcement_signatures` message from the given peer.
9244 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),
9245 /// Indicates a connection to the peer failed/an existing connection was lost.
9246 pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey),
9247 /// Handle a peer reconnecting, possibly generating `channel_reestablish` message(s).
9249 /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
9250 /// with us. Implementors should be somewhat conservative about doing so, however, as other
9251 /// message handlers may still wish to communicate with this peer.
9252 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,
9253 /// Handle an incoming `channel_reestablish` message from the given peer.
9254 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),
9255 /// Handle an incoming `channel_update` message from the given peer.
9256 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),
9257 /// Handle an incoming `error` message from the given peer.
9258 pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ErrorMessage),
9259 /// Gets the node feature flags which this handler itself supports. All available handlers are
9260 /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
9261 /// which are broadcasted in our [`NodeAnnouncement`] message.
9262 pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
9263 /// Gets the init feature flags which should be sent to the given peer. All available handlers
9264 /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
9265 /// which are sent in our [`Init`] message.
9267 /// Note that this method is called before [`Self::peer_connected`].
9268 pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
9269 /// Gets the chain hashes for this `ChannelMessageHandler` indicating which chains it supports.
9271 /// If it's `None`, then no particular network chain hash compatibility will be enforced when
9272 /// connecting to peers.
9273 pub get_chain_hashes: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ,
9274 /// Implementation of MessageSendEventsProvider for this object.
9275 pub MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider,
9276 /// Frees any resources associated with this object given its this_arg pointer.
9277 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
9278 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
9280 unsafe impl Send for ChannelMessageHandler {}
9281 unsafe impl Sync for ChannelMessageHandler {}
9283 pub(crate) fn ChannelMessageHandler_clone_fields(orig: &ChannelMessageHandler) -> ChannelMessageHandler {
9284 ChannelMessageHandler {
9285 this_arg: orig.this_arg,
9286 handle_open_channel: Clone::clone(&orig.handle_open_channel),
9287 handle_open_channel_v2: Clone::clone(&orig.handle_open_channel_v2),
9288 handle_accept_channel: Clone::clone(&orig.handle_accept_channel),
9289 handle_accept_channel_v2: Clone::clone(&orig.handle_accept_channel_v2),
9290 handle_funding_created: Clone::clone(&orig.handle_funding_created),
9291 handle_funding_signed: Clone::clone(&orig.handle_funding_signed),
9292 handle_channel_ready: Clone::clone(&orig.handle_channel_ready),
9293 handle_shutdown: Clone::clone(&orig.handle_shutdown),
9294 handle_closing_signed: Clone::clone(&orig.handle_closing_signed),
9295 handle_stfu: Clone::clone(&orig.handle_stfu),
9296 handle_tx_add_input: Clone::clone(&orig.handle_tx_add_input),
9297 handle_tx_add_output: Clone::clone(&orig.handle_tx_add_output),
9298 handle_tx_remove_input: Clone::clone(&orig.handle_tx_remove_input),
9299 handle_tx_remove_output: Clone::clone(&orig.handle_tx_remove_output),
9300 handle_tx_complete: Clone::clone(&orig.handle_tx_complete),
9301 handle_tx_signatures: Clone::clone(&orig.handle_tx_signatures),
9302 handle_tx_init_rbf: Clone::clone(&orig.handle_tx_init_rbf),
9303 handle_tx_ack_rbf: Clone::clone(&orig.handle_tx_ack_rbf),
9304 handle_tx_abort: Clone::clone(&orig.handle_tx_abort),
9305 handle_update_add_htlc: Clone::clone(&orig.handle_update_add_htlc),
9306 handle_update_fulfill_htlc: Clone::clone(&orig.handle_update_fulfill_htlc),
9307 handle_update_fail_htlc: Clone::clone(&orig.handle_update_fail_htlc),
9308 handle_update_fail_malformed_htlc: Clone::clone(&orig.handle_update_fail_malformed_htlc),
9309 handle_commitment_signed: Clone::clone(&orig.handle_commitment_signed),
9310 handle_revoke_and_ack: Clone::clone(&orig.handle_revoke_and_ack),
9311 handle_update_fee: Clone::clone(&orig.handle_update_fee),
9312 handle_announcement_signatures: Clone::clone(&orig.handle_announcement_signatures),
9313 peer_disconnected: Clone::clone(&orig.peer_disconnected),
9314 peer_connected: Clone::clone(&orig.peer_connected),
9315 handle_channel_reestablish: Clone::clone(&orig.handle_channel_reestablish),
9316 handle_channel_update: Clone::clone(&orig.handle_channel_update),
9317 handle_error: Clone::clone(&orig.handle_error),
9318 provided_node_features: Clone::clone(&orig.provided_node_features),
9319 provided_init_features: Clone::clone(&orig.provided_init_features),
9320 get_chain_hashes: Clone::clone(&orig.get_chain_hashes),
9321 MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
9322 free: Clone::clone(&orig.free),
9325 impl lightning::events::MessageSendEventsProvider for ChannelMessageHandler {
9326 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::events::MessageSendEvent> {
9327 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
9328 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
9333 use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler;
9334 impl rustChannelMessageHandler for ChannelMessageHandler {
9335 fn handle_open_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OpenChannel) {
9336 (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 })
9338 fn handle_open_channel_v2(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OpenChannelV2) {
9339 (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 })
9341 fn handle_accept_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AcceptChannel) {
9342 (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 })
9344 fn handle_accept_channel_v2(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AcceptChannelV2) {
9345 (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 })
9347 fn handle_funding_created(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingCreated) {
9348 (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 })
9350 fn handle_funding_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingSigned) {
9351 (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 })
9353 fn handle_channel_ready(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReady) {
9354 (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 })
9356 fn handle_shutdown(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Shutdown) {
9357 (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 })
9359 fn handle_closing_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ClosingSigned) {
9360 (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 })
9362 fn handle_stfu(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Stfu) {
9363 (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 })
9365 fn handle_tx_add_input(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAddInput) {
9366 (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 })
9368 fn handle_tx_add_output(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAddOutput) {
9369 (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 })
9371 fn handle_tx_remove_input(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxRemoveInput) {
9372 (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 })
9374 fn handle_tx_remove_output(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxRemoveOutput) {
9375 (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 })
9377 fn handle_tx_complete(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxComplete) {
9378 (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 })
9380 fn handle_tx_signatures(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxSignatures) {
9381 (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 })
9383 fn handle_tx_init_rbf(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxInitRbf) {
9384 (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 })
9386 fn handle_tx_ack_rbf(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAckRbf) {
9387 (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 })
9389 fn handle_tx_abort(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAbort) {
9390 (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 })
9392 fn handle_update_add_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateAddHTLC) {
9393 (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 })
9395 fn handle_update_fulfill_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFulfillHTLC) {
9396 (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 })
9398 fn handle_update_fail_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailHTLC) {
9399 (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 })
9401 fn handle_update_fail_malformed_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) {
9402 (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 })
9404 fn handle_commitment_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::CommitmentSigned) {
9405 (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 })
9407 fn handle_revoke_and_ack(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::RevokeAndACK) {
9408 (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 })
9410 fn handle_update_fee(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFee) {
9411 (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 })
9413 fn handle_announcement_signatures(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AnnouncementSignatures) {
9414 (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 })
9416 fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) {
9417 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id))
9419 fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
9420 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);
9421 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)) })*/ })};
9424 fn handle_channel_reestablish(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReestablish) {
9425 (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 })
9427 fn handle_channel_update(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelUpdate) {
9428 (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 })
9430 fn handle_error(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ErrorMessage) {
9431 (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 })
9433 fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
9434 let mut ret = (self.provided_node_features)(self.this_arg);
9435 *unsafe { Box::from_raw(ret.take_inner()) }
9437 fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
9438 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
9439 *unsafe { Box::from_raw(ret.take_inner()) }
9441 fn get_chain_hashes(&self) -> Option<Vec<bitcoin::blockdata::constants::ChainHash>> {
9442 let mut ret = (self.get_chain_hashes)(self.this_arg);
9443 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 }})} };
9448 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
9449 // directly as a Deref trait in higher-level structs:
9450 impl core::ops::Deref for ChannelMessageHandler {
9452 fn deref(&self) -> &Self {
9456 impl core::ops::DerefMut for ChannelMessageHandler {
9457 fn deref_mut(&mut self) -> &mut Self {
9461 /// Calls the free function if one is set
9463 pub extern "C" fn ChannelMessageHandler_free(this_ptr: ChannelMessageHandler) { }
9464 impl Drop for ChannelMessageHandler {
9465 fn drop(&mut self) {
9466 if let Some(f) = self.free {
9471 /// A trait to describe an object which can receive routing messages.
9473 /// # Implementor DoS Warnings
9475 /// For messages enabled with the `gossip_queries` feature there are potential DoS vectors when
9476 /// handling inbound queries. Implementors using an on-disk network graph should be aware of
9477 /// repeated disk I/O for queries accessing different parts of the network graph.
9479 pub struct RoutingMessageHandler {
9480 /// An opaque pointer which is passed to your function implementations as an argument.
9481 /// This has no meaning in the LDK, and can be NULL or any other value.
9482 pub this_arg: *mut c_void,
9483 /// Handle an incoming `node_announcement` message, returning `true` if it should be forwarded on,
9484 /// `false` or returning an `Err` otherwise.
9485 pub handle_node_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
9486 /// Handle a `channel_announcement` message, returning `true` if it should be forwarded on, `false`
9487 /// or returning an `Err` otherwise.
9488 pub handle_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
9489 /// Handle an incoming `channel_update` message, returning true if it should be forwarded on,
9490 /// `false` or returning an `Err` otherwise.
9491 pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ,
9492 /// Gets channel announcements and updates required to dump our routing table to a remote node,
9493 /// starting at the `short_channel_id` indicated by `starting_point` and including announcements
9494 /// for a single channel.
9495 pub get_next_channel_announcement: extern "C" fn (this_arg: *const c_void, starting_point: u64) -> crate::c_types::derived::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ,
9496 /// Gets a node announcement required to dump our routing table to a remote node, starting at
9497 /// the node *after* the provided pubkey and including up to one announcement immediately
9498 /// higher (as defined by `<PublicKey as Ord>::cmp`) than `starting_point`.
9499 /// If `None` is provided for `starting_point`, we start at the first node.
9501 /// Note that starting_point (or a relevant inner pointer) may be NULL or all-0s to represent None
9502 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
9503 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,
9504 /// Called when a connection is established with a peer. This can be used to
9505 /// perform routing table synchronization using a strategy defined by the
9508 /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
9509 /// with us. Implementors should be somewhat conservative about doing so, however, as other
9510 /// message handlers may still wish to communicate with this peer.
9511 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,
9512 /// Handles the reply of a query we initiated to learn about channels
9513 /// for a given range of blocks. We can expect to receive one or more
9514 /// replies to a single query.
9515 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,
9516 /// Handles the reply of a query we initiated asking for routing gossip
9517 /// messages for a list of channels. We should receive this message when
9518 /// a node has completed its best effort to send us the pertaining routing
9519 /// gossip messages.
9520 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,
9521 /// Handles when a peer asks us to send a list of `short_channel_id`s
9522 /// for the requested range of blocks.
9523 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,
9524 /// Handles when a peer asks us to send routing gossip messages for a
9525 /// list of `short_channel_id`s.
9526 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,
9527 /// Indicates that there are a large number of [`ChannelAnnouncement`] (or other) messages
9528 /// pending some async action. While there is no guarantee of the rate of future messages, the
9529 /// caller should seek to reduce the rate of new gossip messages handled, especially
9530 /// [`ChannelAnnouncement`]s.
9531 pub processing_queue_high: extern "C" fn (this_arg: *const c_void) -> bool,
9532 /// Gets the node feature flags which this handler itself supports. All available handlers are
9533 /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
9534 /// which are broadcasted in our [`NodeAnnouncement`] message.
9535 pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
9536 /// Gets the init feature flags which should be sent to the given peer. All available handlers
9537 /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
9538 /// which are sent in our [`Init`] message.
9540 /// Note that this method is called before [`Self::peer_connected`].
9541 pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
9542 /// Implementation of MessageSendEventsProvider for this object.
9543 pub MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider,
9544 /// Frees any resources associated with this object given its this_arg pointer.
9545 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
9546 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
9548 unsafe impl Send for RoutingMessageHandler {}
9549 unsafe impl Sync for RoutingMessageHandler {}
9551 pub(crate) fn RoutingMessageHandler_clone_fields(orig: &RoutingMessageHandler) -> RoutingMessageHandler {
9552 RoutingMessageHandler {
9553 this_arg: orig.this_arg,
9554 handle_node_announcement: Clone::clone(&orig.handle_node_announcement),
9555 handle_channel_announcement: Clone::clone(&orig.handle_channel_announcement),
9556 handle_channel_update: Clone::clone(&orig.handle_channel_update),
9557 get_next_channel_announcement: Clone::clone(&orig.get_next_channel_announcement),
9558 get_next_node_announcement: Clone::clone(&orig.get_next_node_announcement),
9559 peer_connected: Clone::clone(&orig.peer_connected),
9560 handle_reply_channel_range: Clone::clone(&orig.handle_reply_channel_range),
9561 handle_reply_short_channel_ids_end: Clone::clone(&orig.handle_reply_short_channel_ids_end),
9562 handle_query_channel_range: Clone::clone(&orig.handle_query_channel_range),
9563 handle_query_short_channel_ids: Clone::clone(&orig.handle_query_short_channel_ids),
9564 processing_queue_high: Clone::clone(&orig.processing_queue_high),
9565 provided_node_features: Clone::clone(&orig.provided_node_features),
9566 provided_init_features: Clone::clone(&orig.provided_init_features),
9567 MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
9568 free: Clone::clone(&orig.free),
9571 impl lightning::events::MessageSendEventsProvider for RoutingMessageHandler {
9572 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::events::MessageSendEvent> {
9573 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
9574 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
9579 use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler;
9580 impl rustRoutingMessageHandler for RoutingMessageHandler {
9581 fn handle_node_announcement(&self, mut msg: &lightning::ln::msgs::NodeAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
9582 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 });
9583 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()) } })};
9586 fn handle_channel_announcement(&self, mut msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
9587 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 });
9588 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
9591 fn handle_channel_update(&self, mut msg: &lightning::ln::msgs::ChannelUpdate) -> Result<bool, lightning::ln::msgs::LightningError> {
9592 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 });
9593 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
9596 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>)> {
9597 let mut ret = (self.get_next_channel_announcement)(self.this_arg, starting_point);
9598 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 };
9601 fn get_next_node_announcement(&self, mut starting_point: Option<&lightning::routing::gossip::NodeId>) -> Option<lightning::ln::msgs::NodeAnnouncement> {
9602 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 };
9603 let mut ret = (self.get_next_node_announcement)(self.this_arg, local_starting_point);
9604 let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) };
9607 fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
9608 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);
9609 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)) })*/ })};
9612 fn handle_reply_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::ReplyChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
9613 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 });
9614 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
9617 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> {
9618 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 });
9619 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
9622 fn handle_query_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::QueryChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
9623 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 });
9624 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
9627 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> {
9628 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 });
9629 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
9632 fn processing_queue_high(&self) -> bool {
9633 let mut ret = (self.processing_queue_high)(self.this_arg);
9636 fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
9637 let mut ret = (self.provided_node_features)(self.this_arg);
9638 *unsafe { Box::from_raw(ret.take_inner()) }
9640 fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
9641 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
9642 *unsafe { Box::from_raw(ret.take_inner()) }
9646 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
9647 // directly as a Deref trait in higher-level structs:
9648 impl core::ops::Deref for RoutingMessageHandler {
9650 fn deref(&self) -> &Self {
9654 impl core::ops::DerefMut for RoutingMessageHandler {
9655 fn deref_mut(&mut self) -> &mut Self {
9659 /// Calls the free function if one is set
9661 pub extern "C" fn RoutingMessageHandler_free(this_ptr: RoutingMessageHandler) { }
9662 impl Drop for RoutingMessageHandler {
9663 fn drop(&mut self) {
9664 if let Some(f) = self.free {
9669 /// A handler for received [`OnionMessage`]s and for providing generated ones to send.
9671 pub struct OnionMessageHandler {
9672 /// An opaque pointer which is passed to your function implementations as an argument.
9673 /// This has no meaning in the LDK, and can be NULL or any other value.
9674 pub this_arg: *mut c_void,
9675 /// Because much of the lightning network does not yet support forwarding onion messages, we
9676 /// may need to directly connect to a node which will forward a message for us. In such a case,
9677 /// this method will return the set of nodes which need connection by node_id and the
9678 /// corresponding socket addresses where they may accept incoming connections.
9680 /// Thus, this method should be polled regularly to detect messages await such a direct
9682 pub get_and_clear_connections_needed: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ,
9683 /// Handle an incoming `onion_message` message from the given peer.
9684 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),
9685 /// Returns the next pending onion message for the peer with the given node id.
9687 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
9688 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,
9689 /// Called when a connection is established with a peer. Can be used to track which peers
9690 /// advertise onion message support and are online.
9692 /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
9693 /// with us. Implementors should be somewhat conservative about doing so, however, as other
9694 /// message handlers may still wish to communicate with this peer.
9695 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,
9696 /// Indicates a connection to the peer failed/an existing connection was lost. Allows handlers to
9697 /// drop and refuse to forward onion messages to this peer.
9698 pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey),
9699 /// Performs actions that should happen roughly every ten seconds after startup. Allows handlers
9700 /// to drop any buffered onion messages intended for prospective peers.
9701 pub timer_tick_occurred: extern "C" fn (this_arg: *const c_void),
9702 /// Gets the node feature flags which this handler itself supports. All available handlers are
9703 /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
9704 /// which are broadcasted in our [`NodeAnnouncement`] message.
9705 pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
9706 /// Gets the init feature flags which should be sent to the given peer. All available handlers
9707 /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
9708 /// which are sent in our [`Init`] message.
9710 /// Note that this method is called before [`Self::peer_connected`].
9711 pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
9712 /// Frees any resources associated with this object given its this_arg pointer.
9713 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
9714 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
9716 unsafe impl Send for OnionMessageHandler {}
9717 unsafe impl Sync for OnionMessageHandler {}
9719 pub(crate) fn OnionMessageHandler_clone_fields(orig: &OnionMessageHandler) -> OnionMessageHandler {
9720 OnionMessageHandler {
9721 this_arg: orig.this_arg,
9722 get_and_clear_connections_needed: Clone::clone(&orig.get_and_clear_connections_needed),
9723 handle_onion_message: Clone::clone(&orig.handle_onion_message),
9724 next_onion_message_for_peer: Clone::clone(&orig.next_onion_message_for_peer),
9725 peer_connected: Clone::clone(&orig.peer_connected),
9726 peer_disconnected: Clone::clone(&orig.peer_disconnected),
9727 timer_tick_occurred: Clone::clone(&orig.timer_tick_occurred),
9728 provided_node_features: Clone::clone(&orig.provided_node_features),
9729 provided_init_features: Clone::clone(&orig.provided_init_features),
9730 free: Clone::clone(&orig.free),
9734 use lightning::ln::msgs::OnionMessageHandler as rustOnionMessageHandler;
9735 impl rustOnionMessageHandler for OnionMessageHandler {
9736 fn get_and_clear_connections_needed(&self) -> Vec<(bitcoin::secp256k1::PublicKey, Vec<lightning::ln::msgs::SocketAddress>)> {
9737 let mut ret = (self.get_and_clear_connections_needed)(self.this_arg);
9738 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 }); };
9741 fn handle_onion_message(&self, mut peer_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OnionMessage) {
9742 (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 })
9744 fn next_onion_message_for_peer(&self, mut peer_node_id: bitcoin::secp256k1::PublicKey) -> Option<lightning::ln::msgs::OnionMessage> {
9745 let mut ret = (self.next_onion_message_for_peer)(self.this_arg, crate::c_types::PublicKey::from_rust(&peer_node_id));
9746 let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) };
9749 fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
9750 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);
9751 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)) })*/ })};
9754 fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) {
9755 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id))
9757 fn timer_tick_occurred(&self) {
9758 (self.timer_tick_occurred)(self.this_arg)
9760 fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
9761 let mut ret = (self.provided_node_features)(self.this_arg);
9762 *unsafe { Box::from_raw(ret.take_inner()) }
9764 fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
9765 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
9766 *unsafe { Box::from_raw(ret.take_inner()) }
9770 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
9771 // directly as a Deref trait in higher-level structs:
9772 impl core::ops::Deref for OnionMessageHandler {
9774 fn deref(&self) -> &Self {
9778 impl core::ops::DerefMut for OnionMessageHandler {
9779 fn deref_mut(&mut self) -> &mut Self {
9783 /// Calls the free function if one is set
9785 pub extern "C" fn OnionMessageHandler_free(this_ptr: OnionMessageHandler) { }
9786 impl Drop for OnionMessageHandler {
9787 fn drop(&mut self) {
9788 if let Some(f) = self.free {
9794 use lightning::ln::msgs::FinalOnionHopData as nativeFinalOnionHopDataImport;
9795 pub(crate) type nativeFinalOnionHopData = nativeFinalOnionHopDataImport;
9797 /// Information communicated in the onion to the recipient for multi-part tracking and proof that
9798 /// the payment is associated with an invoice.
9801 pub struct FinalOnionHopData {
9802 /// A pointer to the opaque Rust object.
9804 /// Nearly everywhere, inner must be non-null, however in places where
9805 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
9806 pub inner: *mut nativeFinalOnionHopData,
9807 /// Indicates that this is the only struct which contains the same pointer.
9809 /// Rust functions which take ownership of an object provided via an argument require
9810 /// this to be true and invalidate the object pointed to by inner.
9814 impl Drop for FinalOnionHopData {
9815 fn drop(&mut self) {
9816 if self.is_owned && !<*mut nativeFinalOnionHopData>::is_null(self.inner) {
9817 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
9821 /// Frees any resources used by the FinalOnionHopData, if is_owned is set and inner is non-NULL.
9823 pub extern "C" fn FinalOnionHopData_free(this_obj: FinalOnionHopData) { }
9825 /// Used only if an object of this type is returned as a trait impl by a method
9826 pub(crate) extern "C" fn FinalOnionHopData_free_void(this_ptr: *mut c_void) {
9827 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeFinalOnionHopData) };
9830 impl FinalOnionHopData {
9831 pub(crate) fn get_native_ref(&self) -> &'static nativeFinalOnionHopData {
9832 unsafe { &*ObjOps::untweak_ptr(self.inner) }
9834 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFinalOnionHopData {
9835 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
9837 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
9838 pub(crate) fn take_inner(mut self) -> *mut nativeFinalOnionHopData {
9839 assert!(self.is_owned);
9840 let ret = ObjOps::untweak_ptr(self.inner);
9841 self.inner = core::ptr::null_mut();
9845 /// When sending a multi-part payment, this secret is used to identify a payment across HTLCs.
9846 /// Because it is generated by the recipient and included in the invoice, it also provides
9847 /// proof to the recipient that the payment was sent by someone with the generated invoice.
9849 pub extern "C" fn FinalOnionHopData_get_payment_secret(this_ptr: &FinalOnionHopData) -> *const [u8; 32] {
9850 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_secret;
9853 /// When sending a multi-part payment, this secret is used to identify a payment across HTLCs.
9854 /// Because it is generated by the recipient and included in the invoice, it also provides
9855 /// proof to the recipient that the payment was sent by someone with the generated invoice.
9857 pub extern "C" fn FinalOnionHopData_set_payment_secret(this_ptr: &mut FinalOnionHopData, mut val: crate::c_types::ThirtyTwoBytes) {
9858 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_secret = ::lightning::ln::types::PaymentSecret(val.data);
9860 /// The intended total amount that this payment is for.
9862 /// Message serialization may panic if this value is more than 21 million Bitcoin.
9864 pub extern "C" fn FinalOnionHopData_get_total_msat(this_ptr: &FinalOnionHopData) -> u64 {
9865 let mut inner_val = &mut this_ptr.get_native_mut_ref().total_msat;
9868 /// The intended total amount that this payment is for.
9870 /// Message serialization may panic if this value is more than 21 million Bitcoin.
9872 pub extern "C" fn FinalOnionHopData_set_total_msat(this_ptr: &mut FinalOnionHopData, mut val: u64) {
9873 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.total_msat = val;
9875 /// Constructs a new FinalOnionHopData given each field
9878 pub extern "C" fn FinalOnionHopData_new(mut payment_secret_arg: crate::c_types::ThirtyTwoBytes, mut total_msat_arg: u64) -> FinalOnionHopData {
9879 FinalOnionHopData { inner: ObjOps::heap_alloc(nativeFinalOnionHopData {
9880 payment_secret: ::lightning::ln::types::PaymentSecret(payment_secret_arg.data),
9881 total_msat: total_msat_arg,
9882 }), is_owned: true }
9884 impl Clone for FinalOnionHopData {
9885 fn clone(&self) -> Self {
9887 inner: if <*mut nativeFinalOnionHopData>::is_null(self.inner) { core::ptr::null_mut() } else {
9888 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
9894 /// Used only if an object of this type is returned as a trait impl by a method
9895 pub(crate) extern "C" fn FinalOnionHopData_clone_void(this_ptr: *const c_void) -> *mut c_void {
9896 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeFinalOnionHopData)).clone() })) as *mut c_void
9899 /// Creates a copy of the FinalOnionHopData
9900 pub extern "C" fn FinalOnionHopData_clone(orig: &FinalOnionHopData) -> FinalOnionHopData {
9903 mod fuzzy_internal_msgs {
9905 use alloc::str::FromStr;
9906 use alloc::string::String;
9907 use core::ffi::c_void;
9908 use core::convert::Infallible;
9909 use bitcoin::hashes::Hash;
9910 use crate::c_types::*;
9911 #[cfg(feature="no-std")]
9912 use alloc::{vec::Vec, boxed::Box};
9916 use lightning::ln::msgs::OnionPacket as nativeOnionPacketImport;
9917 pub(crate) type nativeOnionPacket = nativeOnionPacketImport;
9919 /// BOLT 4 onion packet including hop data for the next peer.
9922 pub struct OnionPacket {
9923 /// A pointer to the opaque Rust object.
9925 /// Nearly everywhere, inner must be non-null, however in places where
9926 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
9927 pub inner: *mut nativeOnionPacket,
9928 /// Indicates that this is the only struct which contains the same pointer.
9930 /// Rust functions which take ownership of an object provided via an argument require
9931 /// this to be true and invalidate the object pointed to by inner.
9935 impl Drop for OnionPacket {
9936 fn drop(&mut self) {
9937 if self.is_owned && !<*mut nativeOnionPacket>::is_null(self.inner) {
9938 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
9942 /// Frees any resources used by the OnionPacket, if is_owned is set and inner is non-NULL.
9944 pub extern "C" fn OnionPacket_free(this_obj: OnionPacket) { }
9946 /// Used only if an object of this type is returned as a trait impl by a method
9947 pub(crate) extern "C" fn OnionPacket_free_void(this_ptr: *mut c_void) {
9948 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOnionPacket) };
9952 pub(crate) fn get_native_ref(&self) -> &'static nativeOnionPacket {
9953 unsafe { &*ObjOps::untweak_ptr(self.inner) }
9955 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOnionPacket {
9956 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
9958 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
9959 pub(crate) fn take_inner(mut self) -> *mut nativeOnionPacket {
9960 assert!(self.is_owned);
9961 let ret = ObjOps::untweak_ptr(self.inner);
9962 self.inner = core::ptr::null_mut();
9966 /// BOLT 4 version number.
9968 pub extern "C" fn OnionPacket_get_version(this_ptr: &OnionPacket) -> u8 {
9969 let mut inner_val = &mut this_ptr.get_native_mut_ref().version;
9972 /// BOLT 4 version number.
9974 pub extern "C" fn OnionPacket_set_version(this_ptr: &mut OnionPacket, mut val: u8) {
9975 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.version = val;
9977 /// In order to ensure we always return an error on onion decode in compliance with [BOLT
9978 /// #4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md), we have to
9979 /// deserialize `OnionPacket`s contained in [`UpdateAddHTLC`] messages even if the ephemeral
9980 /// public key (here) is bogus, so we hold a [`Result`] instead of a [`PublicKey`] as we'd
9983 /// Returns a copy of the field.
9985 pub extern "C" fn OnionPacket_get_public_key(this_ptr: &OnionPacket) -> crate::c_types::derived::CResult_PublicKeySecp256k1ErrorZ {
9986 let mut inner_val = this_ptr.get_native_mut_ref().public_key.clone();
9987 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() };
9990 /// In order to ensure we always return an error on onion decode in compliance with [BOLT
9991 /// #4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md), we have to
9992 /// deserialize `OnionPacket`s contained in [`UpdateAddHTLC`] messages even if the ephemeral
9993 /// public key (here) is bogus, so we hold a [`Result`] instead of a [`PublicKey`] as we'd
9996 pub extern "C" fn OnionPacket_set_public_key(this_ptr: &mut OnionPacket, mut val: crate::c_types::derived::CResult_PublicKeySecp256k1ErrorZ) {
9997 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() })};
9998 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.public_key = local_val;
10000 /// HMAC to verify the integrity of hop_data.
10002 pub extern "C" fn OnionPacket_get_hmac(this_ptr: &OnionPacket) -> *const [u8; 32] {
10003 let mut inner_val = &mut this_ptr.get_native_mut_ref().hmac;
10006 /// HMAC to verify the integrity of hop_data.
10008 pub extern "C" fn OnionPacket_set_hmac(this_ptr: &mut OnionPacket, mut val: crate::c_types::ThirtyTwoBytes) {
10009 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.hmac = val.data;
10011 impl Clone for OnionPacket {
10012 fn clone(&self) -> Self {
10014 inner: if <*mut nativeOnionPacket>::is_null(self.inner) { core::ptr::null_mut() } else {
10015 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
10021 /// Used only if an object of this type is returned as a trait impl by a method
10022 pub(crate) extern "C" fn OnionPacket_clone_void(this_ptr: *const c_void) -> *mut c_void {
10023 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOnionPacket)).clone() })) as *mut c_void
10026 /// Creates a copy of the OnionPacket
10027 pub extern "C" fn OnionPacket_clone(orig: &OnionPacket) -> OnionPacket {
10030 /// Generates a non-cryptographic 64-bit hash of the OnionPacket.
10032 pub extern "C" fn OnionPacket_hash(o: &OnionPacket) -> u64 {
10033 if o.inner.is_null() { return 0; }
10034 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
10035 #[allow(deprecated)]
10036 let mut hasher = core::hash::SipHasher::new();
10037 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
10038 core::hash::Hasher::finish(&hasher)
10040 /// Checks if two OnionPackets contain equal inner contents.
10041 /// This ignores pointers and is_owned flags and looks at the values in fields.
10042 /// Two objects with NULL inner values will be considered "equal" here.
10044 pub extern "C" fn OnionPacket_eq(a: &OnionPacket, b: &OnionPacket) -> bool {
10045 if a.inner == b.inner { return true; }
10046 if a.inner.is_null() || b.inner.is_null() { return false; }
10047 if a.get_native_ref() == b.get_native_ref() { true } else { false }
10049 /// Get a string which allows debug introspection of a OnionPacket object
10050 pub extern "C" fn OnionPacket_debug_str_void(o: *const c_void) -> Str {
10051 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::OnionPacket }).into()}
10053 use lightning::ln::msgs::TrampolineOnionPacket as nativeTrampolineOnionPacketImport;
10054 pub(crate) type nativeTrampolineOnionPacket = nativeTrampolineOnionPacketImport;
10056 /// BOLT 4 onion packet including hop data for the next peer.
10059 pub struct TrampolineOnionPacket {
10060 /// A pointer to the opaque Rust object.
10062 /// Nearly everywhere, inner must be non-null, however in places where
10063 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
10064 pub inner: *mut nativeTrampolineOnionPacket,
10065 /// Indicates that this is the only struct which contains the same pointer.
10067 /// Rust functions which take ownership of an object provided via an argument require
10068 /// this to be true and invalidate the object pointed to by inner.
10069 pub is_owned: bool,
10072 impl Drop for TrampolineOnionPacket {
10073 fn drop(&mut self) {
10074 if self.is_owned && !<*mut nativeTrampolineOnionPacket>::is_null(self.inner) {
10075 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
10079 /// Frees any resources used by the TrampolineOnionPacket, if is_owned is set and inner is non-NULL.
10081 pub extern "C" fn TrampolineOnionPacket_free(this_obj: TrampolineOnionPacket) { }
10083 /// Used only if an object of this type is returned as a trait impl by a method
10084 pub(crate) extern "C" fn TrampolineOnionPacket_free_void(this_ptr: *mut c_void) {
10085 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTrampolineOnionPacket) };
10088 impl TrampolineOnionPacket {
10089 pub(crate) fn get_native_ref(&self) -> &'static nativeTrampolineOnionPacket {
10090 unsafe { &*ObjOps::untweak_ptr(self.inner) }
10092 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTrampolineOnionPacket {
10093 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
10095 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
10096 pub(crate) fn take_inner(mut self) -> *mut nativeTrampolineOnionPacket {
10097 assert!(self.is_owned);
10098 let ret = ObjOps::untweak_ptr(self.inner);
10099 self.inner = core::ptr::null_mut();
10103 /// Bolt 04 version number
10105 pub extern "C" fn TrampolineOnionPacket_get_version(this_ptr: &TrampolineOnionPacket) -> u8 {
10106 let mut inner_val = &mut this_ptr.get_native_mut_ref().version;
10109 /// Bolt 04 version number
10111 pub extern "C" fn TrampolineOnionPacket_set_version(this_ptr: &mut TrampolineOnionPacket, mut val: u8) {
10112 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.version = val;
10114 /// A random sepc256k1 point, used to build the ECDH shared secret to decrypt hop_data
10116 pub extern "C" fn TrampolineOnionPacket_get_public_key(this_ptr: &TrampolineOnionPacket) -> crate::c_types::PublicKey {
10117 let mut inner_val = &mut this_ptr.get_native_mut_ref().public_key;
10118 crate::c_types::PublicKey::from_rust(&inner_val)
10120 /// A random sepc256k1 point, used to build the ECDH shared secret to decrypt hop_data
10122 pub extern "C" fn TrampolineOnionPacket_set_public_key(this_ptr: &mut TrampolineOnionPacket, mut val: crate::c_types::PublicKey) {
10123 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.public_key = val.into_rust();
10125 /// Encrypted payload for the next hop
10127 /// Returns a copy of the field.
10129 pub extern "C" fn TrampolineOnionPacket_get_hop_data(this_ptr: &TrampolineOnionPacket) -> crate::c_types::derived::CVec_u8Z {
10130 let mut inner_val = this_ptr.get_native_mut_ref().hop_data.clone();
10131 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
10132 local_inner_val.into()
10134 /// Encrypted payload for the next hop
10136 pub extern "C" fn TrampolineOnionPacket_set_hop_data(this_ptr: &mut TrampolineOnionPacket, mut val: crate::c_types::derived::CVec_u8Z) {
10137 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
10138 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.hop_data = local_val;
10140 /// HMAC to verify the integrity of hop_data
10142 pub extern "C" fn TrampolineOnionPacket_get_hmac(this_ptr: &TrampolineOnionPacket) -> *const [u8; 32] {
10143 let mut inner_val = &mut this_ptr.get_native_mut_ref().hmac;
10146 /// HMAC to verify the integrity of hop_data
10148 pub extern "C" fn TrampolineOnionPacket_set_hmac(this_ptr: &mut TrampolineOnionPacket, mut val: crate::c_types::ThirtyTwoBytes) {
10149 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.hmac = val.data;
10151 /// Constructs a new TrampolineOnionPacket given each field
10154 pub extern "C" fn TrampolineOnionPacket_new(mut version_arg: u8, mut public_key_arg: crate::c_types::PublicKey, mut hop_data_arg: crate::c_types::derived::CVec_u8Z, mut hmac_arg: crate::c_types::ThirtyTwoBytes) -> TrampolineOnionPacket {
10155 let mut local_hop_data_arg = Vec::new(); for mut item in hop_data_arg.into_rust().drain(..) { local_hop_data_arg.push( { item }); };
10156 TrampolineOnionPacket { inner: ObjOps::heap_alloc(nativeTrampolineOnionPacket {
10157 version: version_arg,
10158 public_key: public_key_arg.into_rust(),
10159 hop_data: local_hop_data_arg,
10160 hmac: hmac_arg.data,
10161 }), is_owned: true }
10163 impl Clone for TrampolineOnionPacket {
10164 fn clone(&self) -> Self {
10166 inner: if <*mut nativeTrampolineOnionPacket>::is_null(self.inner) { core::ptr::null_mut() } else {
10167 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
10173 /// Used only if an object of this type is returned as a trait impl by a method
10174 pub(crate) extern "C" fn TrampolineOnionPacket_clone_void(this_ptr: *const c_void) -> *mut c_void {
10175 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTrampolineOnionPacket)).clone() })) as *mut c_void
10178 /// Creates a copy of the TrampolineOnionPacket
10179 pub extern "C" fn TrampolineOnionPacket_clone(orig: &TrampolineOnionPacket) -> TrampolineOnionPacket {
10182 /// Generates a non-cryptographic 64-bit hash of the TrampolineOnionPacket.
10184 pub extern "C" fn TrampolineOnionPacket_hash(o: &TrampolineOnionPacket) -> u64 {
10185 if o.inner.is_null() { return 0; }
10186 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
10187 #[allow(deprecated)]
10188 let mut hasher = core::hash::SipHasher::new();
10189 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
10190 core::hash::Hasher::finish(&hasher)
10192 /// Checks if two TrampolineOnionPackets contain equal inner contents.
10193 /// This ignores pointers and is_owned flags and looks at the values in fields.
10194 /// Two objects with NULL inner values will be considered "equal" here.
10196 pub extern "C" fn TrampolineOnionPacket_eq(a: &TrampolineOnionPacket, b: &TrampolineOnionPacket) -> bool {
10197 if a.inner == b.inner { return true; }
10198 if a.inner.is_null() || b.inner.is_null() { return false; }
10199 if a.get_native_ref() == b.get_native_ref() { true } else { false }
10202 /// Serialize the TrampolineOnionPacket object into a byte array which can be read by TrampolineOnionPacket_read
10203 pub extern "C" fn TrampolineOnionPacket_write(obj: &crate::lightning::ln::msgs::TrampolineOnionPacket) -> crate::c_types::derived::CVec_u8Z {
10204 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10207 pub(crate) extern "C" fn TrampolineOnionPacket_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10208 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTrampolineOnionPacket) })
10210 /// Get a string which allows debug introspection of a TrampolineOnionPacket object
10211 pub extern "C" fn TrampolineOnionPacket_debug_str_void(o: *const c_void) -> Str {
10212 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TrampolineOnionPacket }).into()}
10214 /// Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read
10215 pub extern "C" fn AcceptChannel_write(obj: &crate::lightning::ln::msgs::AcceptChannel) -> crate::c_types::derived::CVec_u8Z {
10216 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10219 pub(crate) extern "C" fn AcceptChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10220 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannel) })
10223 /// Read a AcceptChannel from a byte array, created by AcceptChannel_write
10224 pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelDecodeErrorZ {
10225 let res: Result<lightning::ln::msgs::AcceptChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10226 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() };
10230 /// Serialize the AcceptChannelV2 object into a byte array which can be read by AcceptChannelV2_read
10231 pub extern "C" fn AcceptChannelV2_write(obj: &crate::lightning::ln::msgs::AcceptChannelV2) -> crate::c_types::derived::CVec_u8Z {
10232 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10235 pub(crate) extern "C" fn AcceptChannelV2_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10236 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannelV2) })
10239 /// Read a AcceptChannelV2 from a byte array, created by AcceptChannelV2_write
10240 pub extern "C" fn AcceptChannelV2_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelV2DecodeErrorZ {
10241 let res: Result<lightning::ln::msgs::AcceptChannelV2, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10242 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() };
10246 /// Serialize the Stfu object into a byte array which can be read by Stfu_read
10247 pub extern "C" fn Stfu_write(obj: &crate::lightning::ln::msgs::Stfu) -> crate::c_types::derived::CVec_u8Z {
10248 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10251 pub(crate) extern "C" fn Stfu_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10252 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeStfu) })
10255 /// Read a Stfu from a byte array, created by Stfu_write
10256 pub extern "C" fn Stfu_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_StfuDecodeErrorZ {
10257 let res: Result<lightning::ln::msgs::Stfu, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10258 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() };
10262 /// Serialize the Splice object into a byte array which can be read by Splice_read
10263 pub extern "C" fn Splice_write(obj: &crate::lightning::ln::msgs::Splice) -> crate::c_types::derived::CVec_u8Z {
10264 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10267 pub(crate) extern "C" fn Splice_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10268 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeSplice) })
10271 /// Read a Splice from a byte array, created by Splice_write
10272 pub extern "C" fn Splice_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SpliceDecodeErrorZ {
10273 let res: Result<lightning::ln::msgs::Splice, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10274 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() };
10278 /// Serialize the SpliceAck object into a byte array which can be read by SpliceAck_read
10279 pub extern "C" fn SpliceAck_write(obj: &crate::lightning::ln::msgs::SpliceAck) -> crate::c_types::derived::CVec_u8Z {
10280 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10283 pub(crate) extern "C" fn SpliceAck_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10284 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeSpliceAck) })
10287 /// Read a SpliceAck from a byte array, created by SpliceAck_write
10288 pub extern "C" fn SpliceAck_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SpliceAckDecodeErrorZ {
10289 let res: Result<lightning::ln::msgs::SpliceAck, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10290 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() };
10294 /// Serialize the SpliceLocked object into a byte array which can be read by SpliceLocked_read
10295 pub extern "C" fn SpliceLocked_write(obj: &crate::lightning::ln::msgs::SpliceLocked) -> crate::c_types::derived::CVec_u8Z {
10296 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10299 pub(crate) extern "C" fn SpliceLocked_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10300 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeSpliceLocked) })
10303 /// Read a SpliceLocked from a byte array, created by SpliceLocked_write
10304 pub extern "C" fn SpliceLocked_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SpliceLockedDecodeErrorZ {
10305 let res: Result<lightning::ln::msgs::SpliceLocked, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10306 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() };
10310 /// Serialize the TxAddInput object into a byte array which can be read by TxAddInput_read
10311 pub extern "C" fn TxAddInput_write(obj: &crate::lightning::ln::msgs::TxAddInput) -> crate::c_types::derived::CVec_u8Z {
10312 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10315 pub(crate) extern "C" fn TxAddInput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10316 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAddInput) })
10319 /// Read a TxAddInput from a byte array, created by TxAddInput_write
10320 pub extern "C" fn TxAddInput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAddInputDecodeErrorZ {
10321 let res: Result<lightning::ln::msgs::TxAddInput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10322 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() };
10326 /// Serialize the TxAddOutput object into a byte array which can be read by TxAddOutput_read
10327 pub extern "C" fn TxAddOutput_write(obj: &crate::lightning::ln::msgs::TxAddOutput) -> crate::c_types::derived::CVec_u8Z {
10328 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10331 pub(crate) extern "C" fn TxAddOutput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10332 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAddOutput) })
10335 /// Read a TxAddOutput from a byte array, created by TxAddOutput_write
10336 pub extern "C" fn TxAddOutput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAddOutputDecodeErrorZ {
10337 let res: Result<lightning::ln::msgs::TxAddOutput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10338 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() };
10342 /// Serialize the TxRemoveInput object into a byte array which can be read by TxRemoveInput_read
10343 pub extern "C" fn TxRemoveInput_write(obj: &crate::lightning::ln::msgs::TxRemoveInput) -> crate::c_types::derived::CVec_u8Z {
10344 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10347 pub(crate) extern "C" fn TxRemoveInput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10348 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxRemoveInput) })
10351 /// Read a TxRemoveInput from a byte array, created by TxRemoveInput_write
10352 pub extern "C" fn TxRemoveInput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxRemoveInputDecodeErrorZ {
10353 let res: Result<lightning::ln::msgs::TxRemoveInput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10354 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() };
10358 /// Serialize the TxRemoveOutput object into a byte array which can be read by TxRemoveOutput_read
10359 pub extern "C" fn TxRemoveOutput_write(obj: &crate::lightning::ln::msgs::TxRemoveOutput) -> crate::c_types::derived::CVec_u8Z {
10360 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10363 pub(crate) extern "C" fn TxRemoveOutput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10364 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxRemoveOutput) })
10367 /// Read a TxRemoveOutput from a byte array, created by TxRemoveOutput_write
10368 pub extern "C" fn TxRemoveOutput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxRemoveOutputDecodeErrorZ {
10369 let res: Result<lightning::ln::msgs::TxRemoveOutput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10370 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() };
10374 /// Serialize the TxComplete object into a byte array which can be read by TxComplete_read
10375 pub extern "C" fn TxComplete_write(obj: &crate::lightning::ln::msgs::TxComplete) -> crate::c_types::derived::CVec_u8Z {
10376 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10379 pub(crate) extern "C" fn TxComplete_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10380 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxComplete) })
10383 /// Read a TxComplete from a byte array, created by TxComplete_write
10384 pub extern "C" fn TxComplete_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxCompleteDecodeErrorZ {
10385 let res: Result<lightning::ln::msgs::TxComplete, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10386 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() };
10390 /// Serialize the TxSignatures object into a byte array which can be read by TxSignatures_read
10391 pub extern "C" fn TxSignatures_write(obj: &crate::lightning::ln::msgs::TxSignatures) -> crate::c_types::derived::CVec_u8Z {
10392 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10395 pub(crate) extern "C" fn TxSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10396 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxSignatures) })
10399 /// Read a TxSignatures from a byte array, created by TxSignatures_write
10400 pub extern "C" fn TxSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxSignaturesDecodeErrorZ {
10401 let res: Result<lightning::ln::msgs::TxSignatures, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10402 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() };
10406 /// Serialize the TxInitRbf object into a byte array which can be read by TxInitRbf_read
10407 pub extern "C" fn TxInitRbf_write(obj: &crate::lightning::ln::msgs::TxInitRbf) -> crate::c_types::derived::CVec_u8Z {
10408 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10411 pub(crate) extern "C" fn TxInitRbf_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10412 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxInitRbf) })
10415 /// Read a TxInitRbf from a byte array, created by TxInitRbf_write
10416 pub extern "C" fn TxInitRbf_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxInitRbfDecodeErrorZ {
10417 let res: Result<lightning::ln::msgs::TxInitRbf, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10418 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() };
10422 /// Serialize the TxAckRbf object into a byte array which can be read by TxAckRbf_read
10423 pub extern "C" fn TxAckRbf_write(obj: &crate::lightning::ln::msgs::TxAckRbf) -> crate::c_types::derived::CVec_u8Z {
10424 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10427 pub(crate) extern "C" fn TxAckRbf_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10428 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAckRbf) })
10431 /// Read a TxAckRbf from a byte array, created by TxAckRbf_write
10432 pub extern "C" fn TxAckRbf_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAckRbfDecodeErrorZ {
10433 let res: Result<lightning::ln::msgs::TxAckRbf, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10434 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() };
10438 /// Serialize the TxAbort object into a byte array which can be read by TxAbort_read
10439 pub extern "C" fn TxAbort_write(obj: &crate::lightning::ln::msgs::TxAbort) -> crate::c_types::derived::CVec_u8Z {
10440 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10443 pub(crate) extern "C" fn TxAbort_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10444 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAbort) })
10447 /// Read a TxAbort from a byte array, created by TxAbort_write
10448 pub extern "C" fn TxAbort_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAbortDecodeErrorZ {
10449 let res: Result<lightning::ln::msgs::TxAbort, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10450 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() };
10454 /// Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read
10455 pub extern "C" fn AnnouncementSignatures_write(obj: &crate::lightning::ln::msgs::AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z {
10456 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10459 pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10460 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAnnouncementSignatures) })
10463 /// Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write
10464 pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AnnouncementSignaturesDecodeErrorZ {
10465 let res: Result<lightning::ln::msgs::AnnouncementSignatures, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10466 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() };
10470 /// Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read
10471 pub extern "C" fn ChannelReestablish_write(obj: &crate::lightning::ln::msgs::ChannelReestablish) -> crate::c_types::derived::CVec_u8Z {
10472 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10475 pub(crate) extern "C" fn ChannelReestablish_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10476 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReestablish) })
10479 /// Read a ChannelReestablish from a byte array, created by ChannelReestablish_write
10480 pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReestablishDecodeErrorZ {
10481 let res: Result<lightning::ln::msgs::ChannelReestablish, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10482 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() };
10486 /// Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read
10487 pub extern "C" fn ClosingSigned_write(obj: &crate::lightning::ln::msgs::ClosingSigned) -> crate::c_types::derived::CVec_u8Z {
10488 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10491 pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10492 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSigned) })
10495 /// Read a ClosingSigned from a byte array, created by ClosingSigned_write
10496 pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedDecodeErrorZ {
10497 let res: Result<lightning::ln::msgs::ClosingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10498 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() };
10502 /// Serialize the ClosingSignedFeeRange object into a byte array which can be read by ClosingSignedFeeRange_read
10503 pub extern "C" fn ClosingSignedFeeRange_write(obj: &crate::lightning::ln::msgs::ClosingSignedFeeRange) -> crate::c_types::derived::CVec_u8Z {
10504 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10507 pub(crate) extern "C" fn ClosingSignedFeeRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10508 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSignedFeeRange) })
10511 /// Read a ClosingSignedFeeRange from a byte array, created by ClosingSignedFeeRange_write
10512 pub extern "C" fn ClosingSignedFeeRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedFeeRangeDecodeErrorZ {
10513 let res: Result<lightning::ln::msgs::ClosingSignedFeeRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10514 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() };
10518 /// Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read
10519 pub extern "C" fn CommitmentSigned_write(obj: &crate::lightning::ln::msgs::CommitmentSigned) -> crate::c_types::derived::CVec_u8Z {
10520 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10523 pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10524 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentSigned) })
10527 /// Read a CommitmentSigned from a byte array, created by CommitmentSigned_write
10528 pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CommitmentSignedDecodeErrorZ {
10529 let res: Result<lightning::ln::msgs::CommitmentSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10530 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() };
10534 /// Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read
10535 pub extern "C" fn FundingCreated_write(obj: &crate::lightning::ln::msgs::FundingCreated) -> crate::c_types::derived::CVec_u8Z {
10536 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10539 pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10540 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingCreated) })
10543 /// Read a FundingCreated from a byte array, created by FundingCreated_write
10544 pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingCreatedDecodeErrorZ {
10545 let res: Result<lightning::ln::msgs::FundingCreated, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10546 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() };
10550 /// Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read
10551 pub extern "C" fn FundingSigned_write(obj: &crate::lightning::ln::msgs::FundingSigned) -> crate::c_types::derived::CVec_u8Z {
10552 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10555 pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10556 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingSigned) })
10559 /// Read a FundingSigned from a byte array, created by FundingSigned_write
10560 pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingSignedDecodeErrorZ {
10561 let res: Result<lightning::ln::msgs::FundingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10562 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() };
10566 /// Serialize the ChannelReady object into a byte array which can be read by ChannelReady_read
10567 pub extern "C" fn ChannelReady_write(obj: &crate::lightning::ln::msgs::ChannelReady) -> crate::c_types::derived::CVec_u8Z {
10568 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10571 pub(crate) extern "C" fn ChannelReady_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10572 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReady) })
10575 /// Read a ChannelReady from a byte array, created by ChannelReady_write
10576 pub extern "C" fn ChannelReady_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReadyDecodeErrorZ {
10577 let res: Result<lightning::ln::msgs::ChannelReady, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10578 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() };
10582 /// Serialize the Init object into a byte array which can be read by Init_read
10583 pub extern "C" fn Init_write(obj: &crate::lightning::ln::msgs::Init) -> crate::c_types::derived::CVec_u8Z {
10584 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10587 pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10588 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInit) })
10591 /// Read a Init from a byte array, created by Init_write
10592 pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitDecodeErrorZ {
10593 let res: Result<lightning::ln::msgs::Init, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10594 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() };
10598 /// Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read
10599 pub extern "C" fn OpenChannel_write(obj: &crate::lightning::ln::msgs::OpenChannel) -> crate::c_types::derived::CVec_u8Z {
10600 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10603 pub(crate) extern "C" fn OpenChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10604 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannel) })
10607 /// Read a OpenChannel from a byte array, created by OpenChannel_write
10608 pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelDecodeErrorZ {
10609 let res: Result<lightning::ln::msgs::OpenChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10610 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() };
10614 /// Serialize the OpenChannelV2 object into a byte array which can be read by OpenChannelV2_read
10615 pub extern "C" fn OpenChannelV2_write(obj: &crate::lightning::ln::msgs::OpenChannelV2) -> crate::c_types::derived::CVec_u8Z {
10616 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10619 pub(crate) extern "C" fn OpenChannelV2_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10620 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannelV2) })
10623 /// Read a OpenChannelV2 from a byte array, created by OpenChannelV2_write
10624 pub extern "C" fn OpenChannelV2_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelV2DecodeErrorZ {
10625 let res: Result<lightning::ln::msgs::OpenChannelV2, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10626 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() };
10630 /// Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read
10631 pub extern "C" fn RevokeAndACK_write(obj: &crate::lightning::ln::msgs::RevokeAndACK) -> crate::c_types::derived::CVec_u8Z {
10632 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10635 pub(crate) extern "C" fn RevokeAndACK_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10636 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevokeAndACK) })
10639 /// Read a RevokeAndACK from a byte array, created by RevokeAndACK_write
10640 pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RevokeAndACKDecodeErrorZ {
10641 let res: Result<lightning::ln::msgs::RevokeAndACK, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10642 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() };
10646 /// Serialize the Shutdown object into a byte array which can be read by Shutdown_read
10647 pub extern "C" fn Shutdown_write(obj: &crate::lightning::ln::msgs::Shutdown) -> crate::c_types::derived::CVec_u8Z {
10648 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10651 pub(crate) extern "C" fn Shutdown_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10652 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeShutdown) })
10655 /// Read a Shutdown from a byte array, created by Shutdown_write
10656 pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ShutdownDecodeErrorZ {
10657 let res: Result<lightning::ln::msgs::Shutdown, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10658 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() };
10662 /// Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read
10663 pub extern "C" fn UpdateFailHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFailHTLC) -> crate::c_types::derived::CVec_u8Z {
10664 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10667 pub(crate) extern "C" fn UpdateFailHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10668 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailHTLC) })
10671 /// Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write
10672 pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailHTLCDecodeErrorZ {
10673 let res: Result<lightning::ln::msgs::UpdateFailHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10674 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() };
10678 /// Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read
10679 pub extern "C" fn UpdateFailMalformedHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFailMalformedHTLC) -> crate::c_types::derived::CVec_u8Z {
10680 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10683 pub(crate) extern "C" fn UpdateFailMalformedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10684 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailMalformedHTLC) })
10687 /// Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write
10688 pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailMalformedHTLCDecodeErrorZ {
10689 let res: Result<lightning::ln::msgs::UpdateFailMalformedHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10690 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() };
10694 /// Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read
10695 pub extern "C" fn UpdateFee_write(obj: &crate::lightning::ln::msgs::UpdateFee) -> crate::c_types::derived::CVec_u8Z {
10696 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10699 pub(crate) extern "C" fn UpdateFee_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10700 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFee) })
10703 /// Read a UpdateFee from a byte array, created by UpdateFee_write
10704 pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFeeDecodeErrorZ {
10705 let res: Result<lightning::ln::msgs::UpdateFee, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10706 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() };
10710 /// Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read
10711 pub extern "C" fn UpdateFulfillHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFulfillHTLC) -> crate::c_types::derived::CVec_u8Z {
10712 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10715 pub(crate) extern "C" fn UpdateFulfillHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10716 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFulfillHTLC) })
10719 /// Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write
10720 pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFulfillHTLCDecodeErrorZ {
10721 let res: Result<lightning::ln::msgs::UpdateFulfillHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10722 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() };
10726 /// Serialize the OnionPacket object into a byte array which can be read by OnionPacket_read
10727 pub extern "C" fn OnionPacket_write(obj: &crate::lightning::ln::msgs::OnionPacket) -> crate::c_types::derived::CVec_u8Z {
10728 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10731 pub(crate) extern "C" fn OnionPacket_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10732 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOnionPacket) })
10735 /// Read a OnionPacket from a byte array, created by OnionPacket_write
10736 pub extern "C" fn OnionPacket_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OnionPacketDecodeErrorZ {
10737 let res: Result<lightning::ln::msgs::OnionPacket, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10738 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() };
10742 /// Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read
10743 pub extern "C" fn UpdateAddHTLC_write(obj: &crate::lightning::ln::msgs::UpdateAddHTLC) -> crate::c_types::derived::CVec_u8Z {
10744 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10747 pub(crate) extern "C" fn UpdateAddHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10748 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateAddHTLC) })
10751 /// Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write
10752 pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateAddHTLCDecodeErrorZ {
10753 let res: Result<lightning::ln::msgs::UpdateAddHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10754 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() };
10758 /// Read a OnionMessage from a byte array, created by OnionMessage_write
10759 pub extern "C" fn OnionMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OnionMessageDecodeErrorZ {
10760 let res: Result<lightning::ln::msgs::OnionMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10761 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() };
10765 /// Serialize the OnionMessage object into a byte array which can be read by OnionMessage_read
10766 pub extern "C" fn OnionMessage_write(obj: &crate::lightning::ln::msgs::OnionMessage) -> crate::c_types::derived::CVec_u8Z {
10767 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10770 pub(crate) extern "C" fn OnionMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10771 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOnionMessage) })
10774 /// Serialize the FinalOnionHopData object into a byte array which can be read by FinalOnionHopData_read
10775 pub extern "C" fn FinalOnionHopData_write(obj: &crate::lightning::ln::msgs::FinalOnionHopData) -> crate::c_types::derived::CVec_u8Z {
10776 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10779 pub(crate) extern "C" fn FinalOnionHopData_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10780 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFinalOnionHopData) })
10783 /// Read a FinalOnionHopData from a byte array, created by FinalOnionHopData_write
10784 pub extern "C" fn FinalOnionHopData_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FinalOnionHopDataDecodeErrorZ {
10785 let res: Result<lightning::ln::msgs::FinalOnionHopData, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10786 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() };
10790 /// Serialize the Ping object into a byte array which can be read by Ping_read
10791 pub extern "C" fn Ping_write(obj: &crate::lightning::ln::msgs::Ping) -> crate::c_types::derived::CVec_u8Z {
10792 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10795 pub(crate) extern "C" fn Ping_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10796 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePing) })
10799 /// Read a Ping from a byte array, created by Ping_write
10800 pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PingDecodeErrorZ {
10801 let res: Result<lightning::ln::msgs::Ping, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10802 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() };
10806 /// Serialize the Pong object into a byte array which can be read by Pong_read
10807 pub extern "C" fn Pong_write(obj: &crate::lightning::ln::msgs::Pong) -> crate::c_types::derived::CVec_u8Z {
10808 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10811 pub(crate) extern "C" fn Pong_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10812 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePong) })
10815 /// Read a Pong from a byte array, created by Pong_write
10816 pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PongDecodeErrorZ {
10817 let res: Result<lightning::ln::msgs::Pong, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10818 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() };
10822 /// Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read
10823 pub extern "C" fn UnsignedChannelAnnouncement_write(obj: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
10824 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10827 pub(crate) extern "C" fn UnsignedChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10828 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelAnnouncement) })
10831 /// Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write
10832 pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelAnnouncementDecodeErrorZ {
10833 let res: Result<lightning::ln::msgs::UnsignedChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10834 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() };
10838 /// Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read
10839 pub extern "C" fn ChannelAnnouncement_write(obj: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
10840 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10843 pub(crate) extern "C" fn ChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10844 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelAnnouncement) })
10847 /// Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write
10848 pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelAnnouncementDecodeErrorZ {
10849 let res: Result<lightning::ln::msgs::ChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10850 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() };
10854 /// Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read
10855 pub extern "C" fn UnsignedChannelUpdate_write(obj: &crate::lightning::ln::msgs::UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
10856 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10859 pub(crate) extern "C" fn UnsignedChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10860 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelUpdate) })
10863 /// Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write
10864 pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelUpdateDecodeErrorZ {
10865 let res: Result<lightning::ln::msgs::UnsignedChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10866 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() };
10870 /// Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read
10871 pub extern "C" fn ChannelUpdate_write(obj: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
10872 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10875 pub(crate) extern "C" fn ChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10876 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdate) })
10879 /// Read a ChannelUpdate from a byte array, created by ChannelUpdate_write
10880 pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelUpdateDecodeErrorZ {
10881 let res: Result<lightning::ln::msgs::ChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10882 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() };
10886 /// Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read
10887 pub extern "C" fn ErrorMessage_write(obj: &crate::lightning::ln::msgs::ErrorMessage) -> crate::c_types::derived::CVec_u8Z {
10888 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10891 pub(crate) extern "C" fn ErrorMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10892 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeErrorMessage) })
10895 /// Read a ErrorMessage from a byte array, created by ErrorMessage_write
10896 pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ErrorMessageDecodeErrorZ {
10897 let res: Result<lightning::ln::msgs::ErrorMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10898 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() };
10902 /// Serialize the WarningMessage object into a byte array which can be read by WarningMessage_read
10903 pub extern "C" fn WarningMessage_write(obj: &crate::lightning::ln::msgs::WarningMessage) -> crate::c_types::derived::CVec_u8Z {
10904 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10907 pub(crate) extern "C" fn WarningMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10908 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeWarningMessage) })
10911 /// Read a WarningMessage from a byte array, created by WarningMessage_write
10912 pub extern "C" fn WarningMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_WarningMessageDecodeErrorZ {
10913 let res: Result<lightning::ln::msgs::WarningMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10914 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() };
10918 /// Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read
10919 pub extern "C" fn UnsignedNodeAnnouncement_write(obj: &crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
10920 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10923 pub(crate) extern "C" fn UnsignedNodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10924 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedNodeAnnouncement) })
10927 /// Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write
10928 pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedNodeAnnouncementDecodeErrorZ {
10929 let res: Result<lightning::ln::msgs::UnsignedNodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10930 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() };
10934 /// Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read
10935 pub extern "C" fn NodeAnnouncement_write(obj: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
10936 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10939 pub(crate) extern "C" fn NodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10940 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncement) })
10943 /// Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write
10944 pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementDecodeErrorZ {
10945 let res: Result<lightning::ln::msgs::NodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10946 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() };
10950 /// Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write
10951 pub extern "C" fn QueryShortChannelIds_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryShortChannelIdsDecodeErrorZ {
10952 let res: Result<lightning::ln::msgs::QueryShortChannelIds, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10953 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() };
10957 /// Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read
10958 pub extern "C" fn QueryShortChannelIds_write(obj: &crate::lightning::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CVec_u8Z {
10959 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10962 pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10963 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) })
10966 /// Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read
10967 pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z {
10968 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10971 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10972 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) })
10975 /// Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write
10976 pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyShortChannelIdsEndDecodeErrorZ {
10977 let res: Result<lightning::ln::msgs::ReplyShortChannelIdsEnd, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10978 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() };
10981 /// Calculates the overflow safe ending block height for the query.
10983 /// Overflow returns `0xffffffff`, otherwise returns `first_blocknum + number_of_blocks`.
10986 pub extern "C" fn QueryChannelRange_end_blocknum(this_arg: &crate::lightning::ln::msgs::QueryChannelRange) -> u32 {
10987 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.end_blocknum();
10992 /// Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read
10993 pub extern "C" fn QueryChannelRange_write(obj: &crate::lightning::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CVec_u8Z {
10994 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10997 pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10998 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) })
11001 /// Read a QueryChannelRange from a byte array, created by QueryChannelRange_write
11002 pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ {
11003 let res: Result<lightning::ln::msgs::QueryChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
11004 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() };
11008 /// Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write
11009 pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyChannelRangeDecodeErrorZ {
11010 let res: Result<lightning::ln::msgs::ReplyChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
11011 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() };
11015 /// Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read
11016 pub extern "C" fn ReplyChannelRange_write(obj: &crate::lightning::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CVec_u8Z {
11017 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
11020 pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
11021 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) })
11024 /// Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read
11025 pub extern "C" fn GossipTimestampFilter_write(obj: &crate::lightning::ln::msgs::GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z {
11026 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
11029 pub(crate) extern "C" fn GossipTimestampFilter_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
11030 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeGossipTimestampFilter) })
11033 /// Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write
11034 pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_GossipTimestampFilterDecodeErrorZ {
11035 let res: Result<lightning::ln::msgs::GossipTimestampFilter, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
11036 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() };