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 }
6618 /// Get the string representation of a SocketAddressParseError object
6619 pub extern "C" fn SocketAddressParseError_to_str(o: &crate::lightning::ln::msgs::SocketAddressParseError) -> Str {
6620 alloc::format!("{}", &o.to_native()).into()
6622 /// Parses an OnionV3 host and port into a [`SocketAddress::OnionV3`].
6624 /// The host part must end with \".onion\".
6626 pub extern "C" fn parse_onion_address(mut host: crate::c_types::Str, mut port: u16) -> crate::c_types::derived::CResult_SocketAddressSocketAddressParseErrorZ {
6627 let mut ret = lightning::ln::msgs::parse_onion_address(host.into_str(), port);
6628 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::SocketAddress::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::SocketAddressParseError::native_into(e) }).into() };
6633 /// Get the string representation of a SocketAddress object
6634 pub extern "C" fn SocketAddress_to_str(o: &crate::lightning::ln::msgs::SocketAddress) -> Str {
6635 alloc::format!("{}", &o.to_native()).into()
6638 /// Read a SocketAddress object from a string
6639 pub extern "C" fn SocketAddress_from_str(s: crate::c_types::Str) -> crate::c_types::derived::CResult_SocketAddressSocketAddressParseErrorZ {
6640 match lightning::ln::msgs::SocketAddress::from_str(s.into_str()) {
6642 crate::c_types::CResultTempl::ok(
6643 crate::lightning::ln::msgs::SocketAddress::native_into(r)
6647 crate::c_types::CResultTempl::err(
6648 crate::lightning::ln::msgs::SocketAddressParseError::native_into(e)
6653 /// Represents the set of gossip messages that require a signature from a node's identity key.
6657 pub enum UnsignedGossipMessage {
6658 /// An unsigned channel announcement.
6659 ChannelAnnouncement(
6660 crate::lightning::ln::msgs::UnsignedChannelAnnouncement),
6661 /// An unsigned channel update.
6663 crate::lightning::ln::msgs::UnsignedChannelUpdate),
6664 /// An unsigned node announcement.
6666 crate::lightning::ln::msgs::UnsignedNodeAnnouncement),
6668 use lightning::ln::msgs::UnsignedGossipMessage as UnsignedGossipMessageImport;
6669 pub(crate) type nativeUnsignedGossipMessage = UnsignedGossipMessageImport;
6671 impl UnsignedGossipMessage {
6673 pub(crate) fn to_native(&self) -> nativeUnsignedGossipMessage {
6675 UnsignedGossipMessage::ChannelAnnouncement (ref a, ) => {
6676 let mut a_nonref = Clone::clone(a);
6677 nativeUnsignedGossipMessage::ChannelAnnouncement (
6678 *unsafe { Box::from_raw(a_nonref.take_inner()) },
6681 UnsignedGossipMessage::ChannelUpdate (ref a, ) => {
6682 let mut a_nonref = Clone::clone(a);
6683 nativeUnsignedGossipMessage::ChannelUpdate (
6684 *unsafe { Box::from_raw(a_nonref.take_inner()) },
6687 UnsignedGossipMessage::NodeAnnouncement (ref a, ) => {
6688 let mut a_nonref = Clone::clone(a);
6689 nativeUnsignedGossipMessage::NodeAnnouncement (
6690 *unsafe { Box::from_raw(a_nonref.take_inner()) },
6696 pub(crate) fn into_native(self) -> nativeUnsignedGossipMessage {
6698 UnsignedGossipMessage::ChannelAnnouncement (mut a, ) => {
6699 nativeUnsignedGossipMessage::ChannelAnnouncement (
6700 *unsafe { Box::from_raw(a.take_inner()) },
6703 UnsignedGossipMessage::ChannelUpdate (mut a, ) => {
6704 nativeUnsignedGossipMessage::ChannelUpdate (
6705 *unsafe { Box::from_raw(a.take_inner()) },
6708 UnsignedGossipMessage::NodeAnnouncement (mut a, ) => {
6709 nativeUnsignedGossipMessage::NodeAnnouncement (
6710 *unsafe { Box::from_raw(a.take_inner()) },
6716 pub(crate) fn from_native(native: &UnsignedGossipMessageImport) -> Self {
6717 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeUnsignedGossipMessage) };
6719 nativeUnsignedGossipMessage::ChannelAnnouncement (ref a, ) => {
6720 let mut a_nonref = Clone::clone(a);
6721 UnsignedGossipMessage::ChannelAnnouncement (
6722 crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
6725 nativeUnsignedGossipMessage::ChannelUpdate (ref a, ) => {
6726 let mut a_nonref = Clone::clone(a);
6727 UnsignedGossipMessage::ChannelUpdate (
6728 crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
6731 nativeUnsignedGossipMessage::NodeAnnouncement (ref a, ) => {
6732 let mut a_nonref = Clone::clone(a);
6733 UnsignedGossipMessage::NodeAnnouncement (
6734 crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
6740 pub(crate) fn native_into(native: nativeUnsignedGossipMessage) -> Self {
6742 nativeUnsignedGossipMessage::ChannelAnnouncement (mut a, ) => {
6743 UnsignedGossipMessage::ChannelAnnouncement (
6744 crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(a), is_owned: true },
6747 nativeUnsignedGossipMessage::ChannelUpdate (mut a, ) => {
6748 UnsignedGossipMessage::ChannelUpdate (
6749 crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: ObjOps::heap_alloc(a), is_owned: true },
6752 nativeUnsignedGossipMessage::NodeAnnouncement (mut a, ) => {
6753 UnsignedGossipMessage::NodeAnnouncement (
6754 crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: ObjOps::heap_alloc(a), is_owned: true },
6760 /// Frees any resources used by the UnsignedGossipMessage
6762 pub extern "C" fn UnsignedGossipMessage_free(this_ptr: UnsignedGossipMessage) { }
6763 /// Creates a copy of the UnsignedGossipMessage
6765 pub extern "C" fn UnsignedGossipMessage_clone(orig: &UnsignedGossipMessage) -> UnsignedGossipMessage {
6769 /// Used only if an object of this type is returned as a trait impl by a method
6770 pub(crate) extern "C" fn UnsignedGossipMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
6771 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const UnsignedGossipMessage)).clone() })) as *mut c_void
6774 /// Used only if an object of this type is returned as a trait impl by a method
6775 pub(crate) extern "C" fn UnsignedGossipMessage_free_void(this_ptr: *mut c_void) {
6776 let _ = unsafe { Box::from_raw(this_ptr as *mut UnsignedGossipMessage) };
6779 /// Utility method to constructs a new ChannelAnnouncement-variant UnsignedGossipMessage
6780 pub extern "C" fn UnsignedGossipMessage_channel_announcement(a: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> UnsignedGossipMessage {
6781 UnsignedGossipMessage::ChannelAnnouncement(a, )
6784 /// Utility method to constructs a new ChannelUpdate-variant UnsignedGossipMessage
6785 pub extern "C" fn UnsignedGossipMessage_channel_update(a: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> UnsignedGossipMessage {
6786 UnsignedGossipMessage::ChannelUpdate(a, )
6789 /// Utility method to constructs a new NodeAnnouncement-variant UnsignedGossipMessage
6790 pub extern "C" fn UnsignedGossipMessage_node_announcement(a: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> UnsignedGossipMessage {
6791 UnsignedGossipMessage::NodeAnnouncement(a, )
6794 /// Serialize the UnsignedGossipMessage object into a byte array which can be read by UnsignedGossipMessage_read
6795 pub extern "C" fn UnsignedGossipMessage_write(obj: &crate::lightning::ln::msgs::UnsignedGossipMessage) -> crate::c_types::derived::CVec_u8Z {
6796 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
6799 pub(crate) extern "C" fn UnsignedGossipMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6800 UnsignedGossipMessage_write(unsafe { &*(obj as *const UnsignedGossipMessage) })
6803 use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport;
6804 pub(crate) type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport;
6806 /// The unsigned part of a [`node_announcement`] message.
6808 /// [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message
6811 pub struct UnsignedNodeAnnouncement {
6812 /// A pointer to the opaque Rust object.
6814 /// Nearly everywhere, inner must be non-null, however in places where
6815 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6816 pub inner: *mut nativeUnsignedNodeAnnouncement,
6817 /// Indicates that this is the only struct which contains the same pointer.
6819 /// Rust functions which take ownership of an object provided via an argument require
6820 /// this to be true and invalidate the object pointed to by inner.
6824 impl Drop for UnsignedNodeAnnouncement {
6825 fn drop(&mut self) {
6826 if self.is_owned && !<*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) {
6827 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6831 /// Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL.
6833 pub extern "C" fn UnsignedNodeAnnouncement_free(this_obj: UnsignedNodeAnnouncement) { }
6835 /// Used only if an object of this type is returned as a trait impl by a method
6836 pub(crate) extern "C" fn UnsignedNodeAnnouncement_free_void(this_ptr: *mut c_void) {
6837 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedNodeAnnouncement) };
6840 impl UnsignedNodeAnnouncement {
6841 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedNodeAnnouncement {
6842 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6844 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedNodeAnnouncement {
6845 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6847 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6848 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedNodeAnnouncement {
6849 assert!(self.is_owned);
6850 let ret = ObjOps::untweak_ptr(self.inner);
6851 self.inner = core::ptr::null_mut();
6855 /// The advertised features
6857 pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::ln::features::NodeFeatures {
6858 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
6859 crate::lightning::ln::features::NodeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::NodeFeatures<>) as *mut _) }, is_owned: false }
6861 /// The advertised features
6863 pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::ln::features::NodeFeatures) {
6864 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
6866 /// A strictly monotonic announcement counter, with gaps allowed
6868 pub extern "C" fn UnsignedNodeAnnouncement_get_timestamp(this_ptr: &UnsignedNodeAnnouncement) -> u32 {
6869 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
6872 /// A strictly monotonic announcement counter, with gaps allowed
6874 pub extern "C" fn UnsignedNodeAnnouncement_set_timestamp(this_ptr: &mut UnsignedNodeAnnouncement, mut val: u32) {
6875 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
6877 /// The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back
6880 pub extern "C" fn UnsignedNodeAnnouncement_get_node_id(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::routing::gossip::NodeId {
6881 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id;
6882 crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false }
6884 /// The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back
6887 pub extern "C" fn UnsignedNodeAnnouncement_set_node_id(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
6888 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id = *unsafe { Box::from_raw(val.take_inner()) };
6890 /// An RGB color for UI purposes
6892 pub extern "C" fn UnsignedNodeAnnouncement_get_rgb(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 3] {
6893 let mut inner_val = &mut this_ptr.get_native_mut_ref().rgb;
6896 /// An RGB color for UI purposes
6898 pub extern "C" fn UnsignedNodeAnnouncement_set_rgb(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThreeBytes) {
6899 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.rgb = val.data;
6901 /// An alias, for UI purposes.
6903 /// This should be sanitized before use. There is no guarantee of uniqueness.
6905 pub extern "C" fn UnsignedNodeAnnouncement_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::routing::gossip::NodeAlias {
6906 let mut inner_val = &mut this_ptr.get_native_mut_ref().alias;
6907 crate::lightning::routing::gossip::NodeAlias { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeAlias<>) as *mut _) }, is_owned: false }
6909 /// An alias, for UI purposes.
6911 /// This should be sanitized before use. There is no guarantee of uniqueness.
6913 pub extern "C" fn UnsignedNodeAnnouncement_set_alias(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::routing::gossip::NodeAlias) {
6914 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.alias = *unsafe { Box::from_raw(val.take_inner()) };
6916 /// List of addresses on which this node is reachable
6918 /// Returns a copy of the field.
6920 pub extern "C" fn UnsignedNodeAnnouncement_get_addresses(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_SocketAddressZ {
6921 let mut inner_val = this_ptr.get_native_mut_ref().addresses.clone();
6922 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { crate::lightning::ln::msgs::SocketAddress::native_into(item) }); };
6923 local_inner_val.into()
6925 /// List of addresses on which this node is reachable
6927 pub extern "C" fn UnsignedNodeAnnouncement_set_addresses(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_SocketAddressZ) {
6928 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
6929 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.addresses = local_val;
6931 /// Excess address data which was signed as a part of the message which we do not (yet) understand how
6934 /// This is stored to ensure forward-compatibility as new address types are added to the lightning gossip protocol.
6936 /// Returns a copy of the field.
6938 pub extern "C" fn UnsignedNodeAnnouncement_get_excess_address_data(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
6939 let mut inner_val = this_ptr.get_native_mut_ref().excess_address_data.clone();
6940 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
6941 local_inner_val.into()
6943 /// Excess address data which was signed as a part of the message which we do not (yet) understand how
6946 /// This is stored to ensure forward-compatibility as new address types are added to the lightning gossip protocol.
6948 pub extern "C" fn UnsignedNodeAnnouncement_set_excess_address_data(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_u8Z) {
6949 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
6950 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_address_data = local_val;
6952 /// Excess data which was signed as a part of the message which we do not (yet) understand how
6955 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
6957 /// Returns a copy of the field.
6959 pub extern "C" fn UnsignedNodeAnnouncement_get_excess_data(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
6960 let mut inner_val = this_ptr.get_native_mut_ref().excess_data.clone();
6961 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
6962 local_inner_val.into()
6964 /// Excess data which was signed as a part of the message which we do not (yet) understand how
6967 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
6969 pub extern "C" fn UnsignedNodeAnnouncement_set_excess_data(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_u8Z) {
6970 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
6971 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_data = local_val;
6973 /// Constructs a new UnsignedNodeAnnouncement given each field
6976 pub extern "C" fn UnsignedNodeAnnouncement_new(mut features_arg: crate::lightning::ln::features::NodeFeatures, mut timestamp_arg: u32, mut node_id_arg: crate::lightning::routing::gossip::NodeId, mut rgb_arg: crate::c_types::ThreeBytes, mut alias_arg: crate::lightning::routing::gossip::NodeAlias, mut addresses_arg: crate::c_types::derived::CVec_SocketAddressZ, mut excess_address_data_arg: crate::c_types::derived::CVec_u8Z, mut excess_data_arg: crate::c_types::derived::CVec_u8Z) -> UnsignedNodeAnnouncement {
6977 let mut local_addresses_arg = Vec::new(); for mut item in addresses_arg.into_rust().drain(..) { local_addresses_arg.push( { item.into_native() }); };
6978 let mut local_excess_address_data_arg = Vec::new(); for mut item in excess_address_data_arg.into_rust().drain(..) { local_excess_address_data_arg.push( { item }); };
6979 let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); };
6980 UnsignedNodeAnnouncement { inner: ObjOps::heap_alloc(nativeUnsignedNodeAnnouncement {
6981 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
6982 timestamp: timestamp_arg,
6983 node_id: *unsafe { Box::from_raw(node_id_arg.take_inner()) },
6985 alias: *unsafe { Box::from_raw(alias_arg.take_inner()) },
6986 addresses: local_addresses_arg,
6987 excess_address_data: local_excess_address_data_arg,
6988 excess_data: local_excess_data_arg,
6989 }), is_owned: true }
6991 impl Clone for UnsignedNodeAnnouncement {
6992 fn clone(&self) -> Self {
6994 inner: if <*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
6995 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7001 /// Used only if an object of this type is returned as a trait impl by a method
7002 pub(crate) extern "C" fn UnsignedNodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
7003 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUnsignedNodeAnnouncement)).clone() })) as *mut c_void
7006 /// Creates a copy of the UnsignedNodeAnnouncement
7007 pub extern "C" fn UnsignedNodeAnnouncement_clone(orig: &UnsignedNodeAnnouncement) -> UnsignedNodeAnnouncement {
7010 /// Get a string which allows debug introspection of a UnsignedNodeAnnouncement object
7011 pub extern "C" fn UnsignedNodeAnnouncement_debug_str_void(o: *const c_void) -> Str {
7012 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UnsignedNodeAnnouncement }).into()}
7013 /// Generates a non-cryptographic 64-bit hash of the UnsignedNodeAnnouncement.
7015 pub extern "C" fn UnsignedNodeAnnouncement_hash(o: &UnsignedNodeAnnouncement) -> u64 {
7016 if o.inner.is_null() { return 0; }
7017 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
7018 #[allow(deprecated)]
7019 let mut hasher = core::hash::SipHasher::new();
7020 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
7021 core::hash::Hasher::finish(&hasher)
7023 /// Checks if two UnsignedNodeAnnouncements contain equal inner contents.
7024 /// This ignores pointers and is_owned flags and looks at the values in fields.
7025 /// Two objects with NULL inner values will be considered "equal" here.
7027 pub extern "C" fn UnsignedNodeAnnouncement_eq(a: &UnsignedNodeAnnouncement, b: &UnsignedNodeAnnouncement) -> bool {
7028 if a.inner == b.inner { return true; }
7029 if a.inner.is_null() || b.inner.is_null() { return false; }
7030 if a.get_native_ref() == b.get_native_ref() { true } else { false }
7033 use lightning::ln::msgs::NodeAnnouncement as nativeNodeAnnouncementImport;
7034 pub(crate) type nativeNodeAnnouncement = nativeNodeAnnouncementImport;
7036 /// A [`node_announcement`] message to be sent to or received from a peer.
7038 /// [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message
7041 pub struct NodeAnnouncement {
7042 /// A pointer to the opaque Rust object.
7044 /// Nearly everywhere, inner must be non-null, however in places where
7045 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7046 pub inner: *mut nativeNodeAnnouncement,
7047 /// Indicates that this is the only struct which contains the same pointer.
7049 /// Rust functions which take ownership of an object provided via an argument require
7050 /// this to be true and invalidate the object pointed to by inner.
7054 impl Drop for NodeAnnouncement {
7055 fn drop(&mut self) {
7056 if self.is_owned && !<*mut nativeNodeAnnouncement>::is_null(self.inner) {
7057 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7061 /// Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL.
7063 pub extern "C" fn NodeAnnouncement_free(this_obj: NodeAnnouncement) { }
7065 /// Used only if an object of this type is returned as a trait impl by a method
7066 pub(crate) extern "C" fn NodeAnnouncement_free_void(this_ptr: *mut c_void) {
7067 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeNodeAnnouncement) };
7070 impl NodeAnnouncement {
7071 pub(crate) fn get_native_ref(&self) -> &'static nativeNodeAnnouncement {
7072 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7074 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeAnnouncement {
7075 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7077 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7078 pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncement {
7079 assert!(self.is_owned);
7080 let ret = ObjOps::untweak_ptr(self.inner);
7081 self.inner = core::ptr::null_mut();
7085 /// The signature by the node key
7087 pub extern "C" fn NodeAnnouncement_get_signature(this_ptr: &NodeAnnouncement) -> crate::c_types::ECDSASignature {
7088 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
7089 crate::c_types::ECDSASignature::from_rust(&inner_val)
7091 /// The signature by the node key
7093 pub extern "C" fn NodeAnnouncement_set_signature(this_ptr: &mut NodeAnnouncement, mut val: crate::c_types::ECDSASignature) {
7094 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
7096 /// The actual content of the announcement
7098 pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> crate::lightning::ln::msgs::UnsignedNodeAnnouncement {
7099 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
7100 crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::UnsignedNodeAnnouncement<>) as *mut _) }, is_owned: false }
7102 /// The actual content of the announcement
7104 pub extern "C" fn NodeAnnouncement_set_contents(this_ptr: &mut NodeAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) {
7105 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
7107 /// Constructs a new NodeAnnouncement given each field
7110 pub extern "C" fn NodeAnnouncement_new(mut signature_arg: crate::c_types::ECDSASignature, mut contents_arg: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> NodeAnnouncement {
7111 NodeAnnouncement { inner: ObjOps::heap_alloc(nativeNodeAnnouncement {
7112 signature: signature_arg.into_rust(),
7113 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
7114 }), is_owned: true }
7116 impl Clone for NodeAnnouncement {
7117 fn clone(&self) -> Self {
7119 inner: if <*mut nativeNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
7120 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7126 /// Used only if an object of this type is returned as a trait impl by a method
7127 pub(crate) extern "C" fn NodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
7128 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeNodeAnnouncement)).clone() })) as *mut c_void
7131 /// Creates a copy of the NodeAnnouncement
7132 pub extern "C" fn NodeAnnouncement_clone(orig: &NodeAnnouncement) -> NodeAnnouncement {
7135 /// Get a string which allows debug introspection of a NodeAnnouncement object
7136 pub extern "C" fn NodeAnnouncement_debug_str_void(o: *const c_void) -> Str {
7137 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::NodeAnnouncement }).into()}
7138 /// Generates a non-cryptographic 64-bit hash of the NodeAnnouncement.
7140 pub extern "C" fn NodeAnnouncement_hash(o: &NodeAnnouncement) -> u64 {
7141 if o.inner.is_null() { return 0; }
7142 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
7143 #[allow(deprecated)]
7144 let mut hasher = core::hash::SipHasher::new();
7145 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
7146 core::hash::Hasher::finish(&hasher)
7148 /// Checks if two NodeAnnouncements contain equal inner contents.
7149 /// This ignores pointers and is_owned flags and looks at the values in fields.
7150 /// Two objects with NULL inner values will be considered "equal" here.
7152 pub extern "C" fn NodeAnnouncement_eq(a: &NodeAnnouncement, b: &NodeAnnouncement) -> bool {
7153 if a.inner == b.inner { return true; }
7154 if a.inner.is_null() || b.inner.is_null() { return false; }
7155 if a.get_native_ref() == b.get_native_ref() { true } else { false }
7158 use lightning::ln::msgs::UnsignedChannelAnnouncement as nativeUnsignedChannelAnnouncementImport;
7159 pub(crate) type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport;
7161 /// The unsigned part of a [`channel_announcement`] message.
7163 /// [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message
7166 pub struct UnsignedChannelAnnouncement {
7167 /// A pointer to the opaque Rust object.
7169 /// Nearly everywhere, inner must be non-null, however in places where
7170 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7171 pub inner: *mut nativeUnsignedChannelAnnouncement,
7172 /// Indicates that this is the only struct which contains the same pointer.
7174 /// Rust functions which take ownership of an object provided via an argument require
7175 /// this to be true and invalidate the object pointed to by inner.
7179 impl Drop for UnsignedChannelAnnouncement {
7180 fn drop(&mut self) {
7181 if self.is_owned && !<*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) {
7182 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7186 /// Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL.
7188 pub extern "C" fn UnsignedChannelAnnouncement_free(this_obj: UnsignedChannelAnnouncement) { }
7190 /// Used only if an object of this type is returned as a trait impl by a method
7191 pub(crate) extern "C" fn UnsignedChannelAnnouncement_free_void(this_ptr: *mut c_void) {
7192 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedChannelAnnouncement) };
7195 impl UnsignedChannelAnnouncement {
7196 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelAnnouncement {
7197 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7199 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelAnnouncement {
7200 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7202 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7203 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelAnnouncement {
7204 assert!(self.is_owned);
7205 let ret = ObjOps::untweak_ptr(self.inner);
7206 self.inner = core::ptr::null_mut();
7210 /// The advertised channel features
7212 pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::ln::features::ChannelFeatures {
7213 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
7214 crate::lightning::ln::features::ChannelFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::ChannelFeatures<>) as *mut _) }, is_owned: false }
7216 /// The advertised channel features
7218 pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::ln::features::ChannelFeatures) {
7219 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
7221 /// The genesis hash of the blockchain where the channel is to be opened
7223 pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &UnsignedChannelAnnouncement) -> *const [u8; 32] {
7224 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
7227 /// The genesis hash of the blockchain where the channel is to be opened
7229 pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
7230 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
7232 /// The short channel ID
7234 pub extern "C" fn UnsignedChannelAnnouncement_get_short_channel_id(this_ptr: &UnsignedChannelAnnouncement) -> u64 {
7235 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
7238 /// The short channel ID
7240 pub extern "C" fn UnsignedChannelAnnouncement_set_short_channel_id(this_ptr: &mut UnsignedChannelAnnouncement, mut val: u64) {
7241 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
7243 /// One of the two `node_id`s which are endpoints of this channel
7245 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
7246 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_1;
7247 crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false }
7249 /// One of the two `node_id`s which are endpoints of this channel
7251 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
7252 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_1 = *unsafe { Box::from_raw(val.take_inner()) };
7254 /// The other of the two `node_id`s which are endpoints of this channel
7256 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
7257 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_2;
7258 crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false }
7260 /// The other of the two `node_id`s which are endpoints of this channel
7262 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
7263 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_2 = *unsafe { Box::from_raw(val.take_inner()) };
7265 /// The funding key for the first node
7267 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
7268 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_1;
7269 crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false }
7271 /// The funding key for the first node
7273 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
7274 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_1 = *unsafe { Box::from_raw(val.take_inner()) };
7276 /// The funding key for the second node
7278 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
7279 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_2;
7280 crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false }
7282 /// The funding key for the second node
7284 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
7285 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_2 = *unsafe { Box::from_raw(val.take_inner()) };
7287 /// Excess data which was signed as a part of the message which we do not (yet) understand how
7290 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
7292 /// Returns a copy of the field.
7294 pub extern "C" fn UnsignedChannelAnnouncement_get_excess_data(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
7295 let mut inner_val = this_ptr.get_native_mut_ref().excess_data.clone();
7296 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
7297 local_inner_val.into()
7299 /// Excess data which was signed as a part of the message which we do not (yet) understand how
7302 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
7304 pub extern "C" fn UnsignedChannelAnnouncement_set_excess_data(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::derived::CVec_u8Z) {
7305 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
7306 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_data = local_val;
7308 /// Constructs a new UnsignedChannelAnnouncement given each field
7311 pub extern "C" fn UnsignedChannelAnnouncement_new(mut features_arg: crate::lightning::ln::features::ChannelFeatures, mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_id_arg: u64, mut node_id_1_arg: crate::lightning::routing::gossip::NodeId, mut node_id_2_arg: crate::lightning::routing::gossip::NodeId, mut bitcoin_key_1_arg: crate::lightning::routing::gossip::NodeId, mut bitcoin_key_2_arg: crate::lightning::routing::gossip::NodeId, mut excess_data_arg: crate::c_types::derived::CVec_u8Z) -> UnsignedChannelAnnouncement {
7312 let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); };
7313 UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(nativeUnsignedChannelAnnouncement {
7314 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
7315 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
7316 short_channel_id: short_channel_id_arg,
7317 node_id_1: *unsafe { Box::from_raw(node_id_1_arg.take_inner()) },
7318 node_id_2: *unsafe { Box::from_raw(node_id_2_arg.take_inner()) },
7319 bitcoin_key_1: *unsafe { Box::from_raw(bitcoin_key_1_arg.take_inner()) },
7320 bitcoin_key_2: *unsafe { Box::from_raw(bitcoin_key_2_arg.take_inner()) },
7321 excess_data: local_excess_data_arg,
7322 }), is_owned: true }
7324 impl Clone for UnsignedChannelAnnouncement {
7325 fn clone(&self) -> Self {
7327 inner: if <*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
7328 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7334 /// Used only if an object of this type is returned as a trait impl by a method
7335 pub(crate) extern "C" fn UnsignedChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
7336 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUnsignedChannelAnnouncement)).clone() })) as *mut c_void
7339 /// Creates a copy of the UnsignedChannelAnnouncement
7340 pub extern "C" fn UnsignedChannelAnnouncement_clone(orig: &UnsignedChannelAnnouncement) -> UnsignedChannelAnnouncement {
7343 /// Get a string which allows debug introspection of a UnsignedChannelAnnouncement object
7344 pub extern "C" fn UnsignedChannelAnnouncement_debug_str_void(o: *const c_void) -> Str {
7345 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UnsignedChannelAnnouncement }).into()}
7346 /// Generates a non-cryptographic 64-bit hash of the UnsignedChannelAnnouncement.
7348 pub extern "C" fn UnsignedChannelAnnouncement_hash(o: &UnsignedChannelAnnouncement) -> u64 {
7349 if o.inner.is_null() { return 0; }
7350 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
7351 #[allow(deprecated)]
7352 let mut hasher = core::hash::SipHasher::new();
7353 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
7354 core::hash::Hasher::finish(&hasher)
7356 /// Checks if two UnsignedChannelAnnouncements contain equal inner contents.
7357 /// This ignores pointers and is_owned flags and looks at the values in fields.
7358 /// Two objects with NULL inner values will be considered "equal" here.
7360 pub extern "C" fn UnsignedChannelAnnouncement_eq(a: &UnsignedChannelAnnouncement, b: &UnsignedChannelAnnouncement) -> bool {
7361 if a.inner == b.inner { return true; }
7362 if a.inner.is_null() || b.inner.is_null() { return false; }
7363 if a.get_native_ref() == b.get_native_ref() { true } else { false }
7366 use lightning::ln::msgs::ChannelAnnouncement as nativeChannelAnnouncementImport;
7367 pub(crate) type nativeChannelAnnouncement = nativeChannelAnnouncementImport;
7369 /// A [`channel_announcement`] message to be sent to or received from a peer.
7371 /// [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message
7374 pub struct ChannelAnnouncement {
7375 /// A pointer to the opaque Rust object.
7377 /// Nearly everywhere, inner must be non-null, however in places where
7378 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7379 pub inner: *mut nativeChannelAnnouncement,
7380 /// Indicates that this is the only struct which contains the same pointer.
7382 /// Rust functions which take ownership of an object provided via an argument require
7383 /// this to be true and invalidate the object pointed to by inner.
7387 impl Drop for ChannelAnnouncement {
7388 fn drop(&mut self) {
7389 if self.is_owned && !<*mut nativeChannelAnnouncement>::is_null(self.inner) {
7390 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7394 /// Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL.
7396 pub extern "C" fn ChannelAnnouncement_free(this_obj: ChannelAnnouncement) { }
7398 /// Used only if an object of this type is returned as a trait impl by a method
7399 pub(crate) extern "C" fn ChannelAnnouncement_free_void(this_ptr: *mut c_void) {
7400 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelAnnouncement) };
7403 impl ChannelAnnouncement {
7404 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelAnnouncement {
7405 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7407 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelAnnouncement {
7408 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7410 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7411 pub(crate) fn take_inner(mut self) -> *mut nativeChannelAnnouncement {
7412 assert!(self.is_owned);
7413 let ret = ObjOps::untweak_ptr(self.inner);
7414 self.inner = core::ptr::null_mut();
7418 /// Authentication of the announcement by the first public node
7420 pub extern "C" fn ChannelAnnouncement_get_node_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
7421 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_1;
7422 crate::c_types::ECDSASignature::from_rust(&inner_val)
7424 /// Authentication of the announcement by the first public node
7426 pub extern "C" fn ChannelAnnouncement_set_node_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
7427 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_1 = val.into_rust();
7429 /// Authentication of the announcement by the second public node
7431 pub extern "C" fn ChannelAnnouncement_get_node_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
7432 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_2;
7433 crate::c_types::ECDSASignature::from_rust(&inner_val)
7435 /// Authentication of the announcement by the second public node
7437 pub extern "C" fn ChannelAnnouncement_set_node_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
7438 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_2 = val.into_rust();
7440 /// Proof of funding UTXO ownership by the first public node
7442 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
7443 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_1;
7444 crate::c_types::ECDSASignature::from_rust(&inner_val)
7446 /// Proof of funding UTXO ownership by the first public node
7448 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
7449 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_1 = val.into_rust();
7451 /// Proof of funding UTXO ownership by the second public node
7453 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
7454 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_2;
7455 crate::c_types::ECDSASignature::from_rust(&inner_val)
7457 /// Proof of funding UTXO ownership by the second public node
7459 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
7460 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_2 = val.into_rust();
7462 /// The actual announcement
7464 pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncement) -> crate::lightning::ln::msgs::UnsignedChannelAnnouncement {
7465 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
7466 crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::UnsignedChannelAnnouncement<>) as *mut _) }, is_owned: false }
7468 /// The actual announcement
7470 pub extern "C" fn ChannelAnnouncement_set_contents(this_ptr: &mut ChannelAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) {
7471 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
7473 /// Constructs a new ChannelAnnouncement given each field
7476 pub extern "C" fn ChannelAnnouncement_new(mut node_signature_1_arg: crate::c_types::ECDSASignature, mut node_signature_2_arg: crate::c_types::ECDSASignature, mut bitcoin_signature_1_arg: crate::c_types::ECDSASignature, mut bitcoin_signature_2_arg: crate::c_types::ECDSASignature, mut contents_arg: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> ChannelAnnouncement {
7477 ChannelAnnouncement { inner: ObjOps::heap_alloc(nativeChannelAnnouncement {
7478 node_signature_1: node_signature_1_arg.into_rust(),
7479 node_signature_2: node_signature_2_arg.into_rust(),
7480 bitcoin_signature_1: bitcoin_signature_1_arg.into_rust(),
7481 bitcoin_signature_2: bitcoin_signature_2_arg.into_rust(),
7482 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
7483 }), is_owned: true }
7485 impl Clone for ChannelAnnouncement {
7486 fn clone(&self) -> Self {
7488 inner: if <*mut nativeChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
7489 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7495 /// Used only if an object of this type is returned as a trait impl by a method
7496 pub(crate) extern "C" fn ChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
7497 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelAnnouncement)).clone() })) as *mut c_void
7500 /// Creates a copy of the ChannelAnnouncement
7501 pub extern "C" fn ChannelAnnouncement_clone(orig: &ChannelAnnouncement) -> ChannelAnnouncement {
7504 /// Get a string which allows debug introspection of a ChannelAnnouncement object
7505 pub extern "C" fn ChannelAnnouncement_debug_str_void(o: *const c_void) -> Str {
7506 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ChannelAnnouncement }).into()}
7507 /// Generates a non-cryptographic 64-bit hash of the ChannelAnnouncement.
7509 pub extern "C" fn ChannelAnnouncement_hash(o: &ChannelAnnouncement) -> u64 {
7510 if o.inner.is_null() { return 0; }
7511 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
7512 #[allow(deprecated)]
7513 let mut hasher = core::hash::SipHasher::new();
7514 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
7515 core::hash::Hasher::finish(&hasher)
7517 /// Checks if two ChannelAnnouncements contain equal inner contents.
7518 /// This ignores pointers and is_owned flags and looks at the values in fields.
7519 /// Two objects with NULL inner values will be considered "equal" here.
7521 pub extern "C" fn ChannelAnnouncement_eq(a: &ChannelAnnouncement, b: &ChannelAnnouncement) -> bool {
7522 if a.inner == b.inner { return true; }
7523 if a.inner.is_null() || b.inner.is_null() { return false; }
7524 if a.get_native_ref() == b.get_native_ref() { true } else { false }
7527 use lightning::ln::msgs::UnsignedChannelUpdate as nativeUnsignedChannelUpdateImport;
7528 pub(crate) type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport;
7530 /// The unsigned part of a [`channel_update`] message.
7532 /// [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
7535 pub struct UnsignedChannelUpdate {
7536 /// A pointer to the opaque Rust object.
7538 /// Nearly everywhere, inner must be non-null, however in places where
7539 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7540 pub inner: *mut nativeUnsignedChannelUpdate,
7541 /// Indicates that this is the only struct which contains the same pointer.
7543 /// Rust functions which take ownership of an object provided via an argument require
7544 /// this to be true and invalidate the object pointed to by inner.
7548 impl Drop for UnsignedChannelUpdate {
7549 fn drop(&mut self) {
7550 if self.is_owned && !<*mut nativeUnsignedChannelUpdate>::is_null(self.inner) {
7551 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7555 /// Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL.
7557 pub extern "C" fn UnsignedChannelUpdate_free(this_obj: UnsignedChannelUpdate) { }
7559 /// Used only if an object of this type is returned as a trait impl by a method
7560 pub(crate) extern "C" fn UnsignedChannelUpdate_free_void(this_ptr: *mut c_void) {
7561 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedChannelUpdate) };
7564 impl UnsignedChannelUpdate {
7565 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelUpdate {
7566 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7568 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelUpdate {
7569 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7571 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7572 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelUpdate {
7573 assert!(self.is_owned);
7574 let ret = ObjOps::untweak_ptr(self.inner);
7575 self.inner = core::ptr::null_mut();
7579 /// The genesis hash of the blockchain where the channel is to be opened
7581 pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChannelUpdate) -> *const [u8; 32] {
7582 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
7585 /// The genesis hash of the blockchain where the channel is to be opened
7587 pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::ThirtyTwoBytes) {
7588 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
7590 /// The short channel ID
7592 pub extern "C" fn UnsignedChannelUpdate_get_short_channel_id(this_ptr: &UnsignedChannelUpdate) -> u64 {
7593 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
7596 /// The short channel ID
7598 pub extern "C" fn UnsignedChannelUpdate_set_short_channel_id(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
7599 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
7601 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
7603 pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannelUpdate) -> u32 {
7604 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
7607 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
7609 pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
7610 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
7614 pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 {
7615 let mut inner_val = &mut this_ptr.get_native_mut_ref().flags;
7620 pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) {
7621 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.flags = val;
7623 /// The number of blocks such that if:
7624 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
7625 /// then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines
7626 /// the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a
7627 /// `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10,
7628 /// then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before
7629 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
7630 /// constructing the route.
7632 pub extern "C" fn UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr: &UnsignedChannelUpdate) -> u16 {
7633 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
7636 /// The number of blocks such that if:
7637 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
7638 /// then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines
7639 /// the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a
7640 /// `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10,
7641 /// then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before
7642 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
7643 /// constructing the route.
7645 pub extern "C" fn UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr: &mut UnsignedChannelUpdate, mut val: u16) {
7646 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
7648 /// The minimum HTLC size incoming to sender, in milli-satoshi
7650 pub extern "C" fn UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
7651 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
7654 /// The minimum HTLC size incoming to sender, in milli-satoshi
7656 pub extern "C" fn UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
7657 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
7659 /// The maximum HTLC value incoming to sender, in milli-satoshi.
7661 /// This used to be optional.
7663 pub extern "C" fn UnsignedChannelUpdate_get_htlc_maximum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
7664 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat;
7667 /// The maximum HTLC value incoming to sender, in milli-satoshi.
7669 /// This used to be optional.
7671 pub extern "C" fn UnsignedChannelUpdate_set_htlc_maximum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
7672 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = val;
7674 /// The base HTLC fee charged by sender, in milli-satoshi
7676 pub extern "C" fn UnsignedChannelUpdate_get_fee_base_msat(this_ptr: &UnsignedChannelUpdate) -> u32 {
7677 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat;
7680 /// The base HTLC fee charged by sender, in milli-satoshi
7682 pub extern "C" fn UnsignedChannelUpdate_set_fee_base_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
7683 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val;
7685 /// The amount to fee multiplier, in micro-satoshi
7687 pub extern "C" fn UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr: &UnsignedChannelUpdate) -> u32 {
7688 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths;
7691 /// The amount to fee multiplier, in micro-satoshi
7693 pub extern "C" fn UnsignedChannelUpdate_set_fee_proportional_millionths(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
7694 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val;
7696 /// Excess data which was signed as a part of the message which we do not (yet) understand how
7699 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
7701 /// Returns a copy of the field.
7703 pub extern "C" fn UnsignedChannelUpdate_get_excess_data(this_ptr: &UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
7704 let mut inner_val = this_ptr.get_native_mut_ref().excess_data.clone();
7705 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
7706 local_inner_val.into()
7708 /// Excess data which was signed as a part of the message which we do not (yet) understand how
7711 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
7713 pub extern "C" fn UnsignedChannelUpdate_set_excess_data(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::derived::CVec_u8Z) {
7714 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
7715 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_data = local_val;
7717 /// Constructs a new UnsignedChannelUpdate given each field
7720 pub extern "C" fn UnsignedChannelUpdate_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_id_arg: u64, mut timestamp_arg: u32, mut flags_arg: u8, mut cltv_expiry_delta_arg: u16, mut htlc_minimum_msat_arg: u64, mut htlc_maximum_msat_arg: u64, mut fee_base_msat_arg: u32, mut fee_proportional_millionths_arg: u32, mut excess_data_arg: crate::c_types::derived::CVec_u8Z) -> UnsignedChannelUpdate {
7721 let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); };
7722 UnsignedChannelUpdate { inner: ObjOps::heap_alloc(nativeUnsignedChannelUpdate {
7723 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
7724 short_channel_id: short_channel_id_arg,
7725 timestamp: timestamp_arg,
7727 cltv_expiry_delta: cltv_expiry_delta_arg,
7728 htlc_minimum_msat: htlc_minimum_msat_arg,
7729 htlc_maximum_msat: htlc_maximum_msat_arg,
7730 fee_base_msat: fee_base_msat_arg,
7731 fee_proportional_millionths: fee_proportional_millionths_arg,
7732 excess_data: local_excess_data_arg,
7733 }), is_owned: true }
7735 impl Clone for UnsignedChannelUpdate {
7736 fn clone(&self) -> Self {
7738 inner: if <*mut nativeUnsignedChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
7739 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7745 /// Used only if an object of this type is returned as a trait impl by a method
7746 pub(crate) extern "C" fn UnsignedChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
7747 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUnsignedChannelUpdate)).clone() })) as *mut c_void
7750 /// Creates a copy of the UnsignedChannelUpdate
7751 pub extern "C" fn UnsignedChannelUpdate_clone(orig: &UnsignedChannelUpdate) -> UnsignedChannelUpdate {
7754 /// Get a string which allows debug introspection of a UnsignedChannelUpdate object
7755 pub extern "C" fn UnsignedChannelUpdate_debug_str_void(o: *const c_void) -> Str {
7756 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UnsignedChannelUpdate }).into()}
7757 /// Generates a non-cryptographic 64-bit hash of the UnsignedChannelUpdate.
7759 pub extern "C" fn UnsignedChannelUpdate_hash(o: &UnsignedChannelUpdate) -> u64 {
7760 if o.inner.is_null() { return 0; }
7761 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
7762 #[allow(deprecated)]
7763 let mut hasher = core::hash::SipHasher::new();
7764 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
7765 core::hash::Hasher::finish(&hasher)
7767 /// Checks if two UnsignedChannelUpdates contain equal inner contents.
7768 /// This ignores pointers and is_owned flags and looks at the values in fields.
7769 /// Two objects with NULL inner values will be considered "equal" here.
7771 pub extern "C" fn UnsignedChannelUpdate_eq(a: &UnsignedChannelUpdate, b: &UnsignedChannelUpdate) -> bool {
7772 if a.inner == b.inner { return true; }
7773 if a.inner.is_null() || b.inner.is_null() { return false; }
7774 if a.get_native_ref() == b.get_native_ref() { true } else { false }
7777 use lightning::ln::msgs::ChannelUpdate as nativeChannelUpdateImport;
7778 pub(crate) type nativeChannelUpdate = nativeChannelUpdateImport;
7780 /// A [`channel_update`] message to be sent to or received from a peer.
7782 /// [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
7785 pub struct ChannelUpdate {
7786 /// A pointer to the opaque Rust object.
7788 /// Nearly everywhere, inner must be non-null, however in places where
7789 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7790 pub inner: *mut nativeChannelUpdate,
7791 /// Indicates that this is the only struct which contains the same pointer.
7793 /// Rust functions which take ownership of an object provided via an argument require
7794 /// this to be true and invalidate the object pointed to by inner.
7798 impl Drop for ChannelUpdate {
7799 fn drop(&mut self) {
7800 if self.is_owned && !<*mut nativeChannelUpdate>::is_null(self.inner) {
7801 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7805 /// Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL.
7807 pub extern "C" fn ChannelUpdate_free(this_obj: ChannelUpdate) { }
7809 /// Used only if an object of this type is returned as a trait impl by a method
7810 pub(crate) extern "C" fn ChannelUpdate_free_void(this_ptr: *mut c_void) {
7811 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelUpdate) };
7814 impl ChannelUpdate {
7815 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelUpdate {
7816 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7818 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelUpdate {
7819 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7821 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7822 pub(crate) fn take_inner(mut self) -> *mut nativeChannelUpdate {
7823 assert!(self.is_owned);
7824 let ret = ObjOps::untweak_ptr(self.inner);
7825 self.inner = core::ptr::null_mut();
7829 /// A signature of the channel update
7831 pub extern "C" fn ChannelUpdate_get_signature(this_ptr: &ChannelUpdate) -> crate::c_types::ECDSASignature {
7832 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
7833 crate::c_types::ECDSASignature::from_rust(&inner_val)
7835 /// A signature of the channel update
7837 pub extern "C" fn ChannelUpdate_set_signature(this_ptr: &mut ChannelUpdate, mut val: crate::c_types::ECDSASignature) {
7838 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
7840 /// The actual channel update
7842 pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate::lightning::ln::msgs::UnsignedChannelUpdate {
7843 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
7844 crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::UnsignedChannelUpdate<>) as *mut _) }, is_owned: false }
7846 /// The actual channel update
7848 pub extern "C" fn ChannelUpdate_set_contents(this_ptr: &mut ChannelUpdate, mut val: crate::lightning::ln::msgs::UnsignedChannelUpdate) {
7849 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
7851 /// Constructs a new ChannelUpdate given each field
7854 pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::ECDSASignature, mut contents_arg: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> ChannelUpdate {
7855 ChannelUpdate { inner: ObjOps::heap_alloc(nativeChannelUpdate {
7856 signature: signature_arg.into_rust(),
7857 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
7858 }), is_owned: true }
7860 impl Clone for ChannelUpdate {
7861 fn clone(&self) -> Self {
7863 inner: if <*mut nativeChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
7864 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7870 /// Used only if an object of this type is returned as a trait impl by a method
7871 pub(crate) extern "C" fn ChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
7872 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelUpdate)).clone() })) as *mut c_void
7875 /// Creates a copy of the ChannelUpdate
7876 pub extern "C" fn ChannelUpdate_clone(orig: &ChannelUpdate) -> ChannelUpdate {
7879 /// Get a string which allows debug introspection of a ChannelUpdate object
7880 pub extern "C" fn ChannelUpdate_debug_str_void(o: *const c_void) -> Str {
7881 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ChannelUpdate }).into()}
7882 /// Generates a non-cryptographic 64-bit hash of the ChannelUpdate.
7884 pub extern "C" fn ChannelUpdate_hash(o: &ChannelUpdate) -> u64 {
7885 if o.inner.is_null() { return 0; }
7886 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
7887 #[allow(deprecated)]
7888 let mut hasher = core::hash::SipHasher::new();
7889 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
7890 core::hash::Hasher::finish(&hasher)
7892 /// Checks if two ChannelUpdates contain equal inner contents.
7893 /// This ignores pointers and is_owned flags and looks at the values in fields.
7894 /// Two objects with NULL inner values will be considered "equal" here.
7896 pub extern "C" fn ChannelUpdate_eq(a: &ChannelUpdate, b: &ChannelUpdate) -> bool {
7897 if a.inner == b.inner { return true; }
7898 if a.inner.is_null() || b.inner.is_null() { return false; }
7899 if a.get_native_ref() == b.get_native_ref() { true } else { false }
7902 use lightning::ln::msgs::QueryChannelRange as nativeQueryChannelRangeImport;
7903 pub(crate) type nativeQueryChannelRange = nativeQueryChannelRangeImport;
7905 /// A [`query_channel_range`] message is used to query a peer for channel
7906 /// UTXOs in a range of blocks. The recipient of a query makes a best
7907 /// effort to reply to the query using one or more [`ReplyChannelRange`]
7910 /// [`query_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages
7913 pub struct QueryChannelRange {
7914 /// A pointer to the opaque Rust object.
7916 /// Nearly everywhere, inner must be non-null, however in places where
7917 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7918 pub inner: *mut nativeQueryChannelRange,
7919 /// Indicates that this is the only struct which contains the same pointer.
7921 /// Rust functions which take ownership of an object provided via an argument require
7922 /// this to be true and invalidate the object pointed to by inner.
7926 impl Drop for QueryChannelRange {
7927 fn drop(&mut self) {
7928 if self.is_owned && !<*mut nativeQueryChannelRange>::is_null(self.inner) {
7929 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7933 /// Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL.
7935 pub extern "C" fn QueryChannelRange_free(this_obj: QueryChannelRange) { }
7937 /// Used only if an object of this type is returned as a trait impl by a method
7938 pub(crate) extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) {
7939 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeQueryChannelRange) };
7942 impl QueryChannelRange {
7943 pub(crate) fn get_native_ref(&self) -> &'static nativeQueryChannelRange {
7944 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7946 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryChannelRange {
7947 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7949 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7950 pub(crate) fn take_inner(mut self) -> *mut nativeQueryChannelRange {
7951 assert!(self.is_owned);
7952 let ret = ObjOps::untweak_ptr(self.inner);
7953 self.inner = core::ptr::null_mut();
7957 /// The genesis hash of the blockchain being queried
7959 pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *const [u8; 32] {
7960 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
7963 /// The genesis hash of the blockchain being queried
7965 pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
7966 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
7968 /// The height of the first block for the channel UTXOs being queried
7970 pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 {
7971 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
7974 /// The height of the first block for the channel UTXOs being queried
7976 pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChannelRange, mut val: u32) {
7977 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
7979 /// The number of blocks to include in the query results
7981 pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 {
7982 let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
7985 /// The number of blocks to include in the query results
7987 pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryChannelRange, mut val: u32) {
7988 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
7990 /// Constructs a new QueryChannelRange given each field
7993 pub extern "C" fn QueryChannelRange_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut first_blocknum_arg: u32, mut number_of_blocks_arg: u32) -> QueryChannelRange {
7994 QueryChannelRange { inner: ObjOps::heap_alloc(nativeQueryChannelRange {
7995 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
7996 first_blocknum: first_blocknum_arg,
7997 number_of_blocks: number_of_blocks_arg,
7998 }), is_owned: true }
8000 impl Clone for QueryChannelRange {
8001 fn clone(&self) -> Self {
8003 inner: if <*mut nativeQueryChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
8004 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
8010 /// Used only if an object of this type is returned as a trait impl by a method
8011 pub(crate) extern "C" fn QueryChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
8012 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeQueryChannelRange)).clone() })) as *mut c_void
8015 /// Creates a copy of the QueryChannelRange
8016 pub extern "C" fn QueryChannelRange_clone(orig: &QueryChannelRange) -> QueryChannelRange {
8019 /// Get a string which allows debug introspection of a QueryChannelRange object
8020 pub extern "C" fn QueryChannelRange_debug_str_void(o: *const c_void) -> Str {
8021 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::QueryChannelRange }).into()}
8022 /// Generates a non-cryptographic 64-bit hash of the QueryChannelRange.
8024 pub extern "C" fn QueryChannelRange_hash(o: &QueryChannelRange) -> u64 {
8025 if o.inner.is_null() { return 0; }
8026 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
8027 #[allow(deprecated)]
8028 let mut hasher = core::hash::SipHasher::new();
8029 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
8030 core::hash::Hasher::finish(&hasher)
8032 /// Checks if two QueryChannelRanges contain equal inner contents.
8033 /// This ignores pointers and is_owned flags and looks at the values in fields.
8034 /// Two objects with NULL inner values will be considered "equal" here.
8036 pub extern "C" fn QueryChannelRange_eq(a: &QueryChannelRange, b: &QueryChannelRange) -> bool {
8037 if a.inner == b.inner { return true; }
8038 if a.inner.is_null() || b.inner.is_null() { return false; }
8039 if a.get_native_ref() == b.get_native_ref() { true } else { false }
8042 use lightning::ln::msgs::ReplyChannelRange as nativeReplyChannelRangeImport;
8043 pub(crate) type nativeReplyChannelRange = nativeReplyChannelRangeImport;
8045 /// A [`reply_channel_range`] message is a reply to a [`QueryChannelRange`]
8048 /// Multiple `reply_channel_range` messages can be sent in reply
8049 /// to a single [`QueryChannelRange`] message. The query recipient makes a
8050 /// best effort to respond based on their local network view which may
8051 /// not be a perfect view of the network. The `short_channel_id`s in the
8052 /// reply are encoded. We only support `encoding_type=0` uncompressed
8053 /// serialization and do not support `encoding_type=1` zlib serialization.
8055 /// [`reply_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages
8058 pub struct ReplyChannelRange {
8059 /// A pointer to the opaque Rust object.
8061 /// Nearly everywhere, inner must be non-null, however in places where
8062 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
8063 pub inner: *mut nativeReplyChannelRange,
8064 /// Indicates that this is the only struct which contains the same pointer.
8066 /// Rust functions which take ownership of an object provided via an argument require
8067 /// this to be true and invalidate the object pointed to by inner.
8071 impl Drop for ReplyChannelRange {
8072 fn drop(&mut self) {
8073 if self.is_owned && !<*mut nativeReplyChannelRange>::is_null(self.inner) {
8074 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
8078 /// Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL.
8080 pub extern "C" fn ReplyChannelRange_free(this_obj: ReplyChannelRange) { }
8082 /// Used only if an object of this type is returned as a trait impl by a method
8083 pub(crate) extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) {
8084 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeReplyChannelRange) };
8087 impl ReplyChannelRange {
8088 pub(crate) fn get_native_ref(&self) -> &'static nativeReplyChannelRange {
8089 unsafe { &*ObjOps::untweak_ptr(self.inner) }
8091 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyChannelRange {
8092 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
8094 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
8095 pub(crate) fn take_inner(mut self) -> *mut nativeReplyChannelRange {
8096 assert!(self.is_owned);
8097 let ret = ObjOps::untweak_ptr(self.inner);
8098 self.inner = core::ptr::null_mut();
8102 /// The genesis hash of the blockchain being queried
8104 pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *const [u8; 32] {
8105 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
8108 /// The genesis hash of the blockchain being queried
8110 pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
8111 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
8113 /// The height of the first block in the range of the reply
8115 pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 {
8116 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
8119 /// The height of the first block in the range of the reply
8121 pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChannelRange, mut val: u32) {
8122 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
8124 /// The number of blocks included in the range of the reply
8126 pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 {
8127 let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
8130 /// The number of blocks included in the range of the reply
8132 pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyChannelRange, mut val: u32) {
8133 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
8135 /// True when this is the final reply for a query
8137 pub extern "C" fn ReplyChannelRange_get_sync_complete(this_ptr: &ReplyChannelRange) -> bool {
8138 let mut inner_val = &mut this_ptr.get_native_mut_ref().sync_complete;
8141 /// True when this is the final reply for a query
8143 pub extern "C" fn ReplyChannelRange_set_sync_complete(this_ptr: &mut ReplyChannelRange, mut val: bool) {
8144 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sync_complete = val;
8146 /// The `short_channel_id`s in the channel range
8148 /// Returns a copy of the field.
8150 pub extern "C" fn ReplyChannelRange_get_short_channel_ids(this_ptr: &ReplyChannelRange) -> crate::c_types::derived::CVec_u64Z {
8151 let mut inner_val = this_ptr.get_native_mut_ref().short_channel_ids.clone();
8152 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
8153 local_inner_val.into()
8155 /// The `short_channel_id`s in the channel range
8157 pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::derived::CVec_u64Z) {
8158 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
8159 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
8161 /// Constructs a new ReplyChannelRange given each field
8164 pub extern "C" fn ReplyChannelRange_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut first_blocknum_arg: u32, mut number_of_blocks_arg: u32, mut sync_complete_arg: bool, mut short_channel_ids_arg: crate::c_types::derived::CVec_u64Z) -> ReplyChannelRange {
8165 let mut local_short_channel_ids_arg = Vec::new(); for mut item in short_channel_ids_arg.into_rust().drain(..) { local_short_channel_ids_arg.push( { item }); };
8166 ReplyChannelRange { inner: ObjOps::heap_alloc(nativeReplyChannelRange {
8167 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
8168 first_blocknum: first_blocknum_arg,
8169 number_of_blocks: number_of_blocks_arg,
8170 sync_complete: sync_complete_arg,
8171 short_channel_ids: local_short_channel_ids_arg,
8172 }), is_owned: true }
8174 impl Clone for ReplyChannelRange {
8175 fn clone(&self) -> Self {
8177 inner: if <*mut nativeReplyChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
8178 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
8184 /// Used only if an object of this type is returned as a trait impl by a method
8185 pub(crate) extern "C" fn ReplyChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
8186 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeReplyChannelRange)).clone() })) as *mut c_void
8189 /// Creates a copy of the ReplyChannelRange
8190 pub extern "C" fn ReplyChannelRange_clone(orig: &ReplyChannelRange) -> ReplyChannelRange {
8193 /// Get a string which allows debug introspection of a ReplyChannelRange object
8194 pub extern "C" fn ReplyChannelRange_debug_str_void(o: *const c_void) -> Str {
8195 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ReplyChannelRange }).into()}
8196 /// Generates a non-cryptographic 64-bit hash of the ReplyChannelRange.
8198 pub extern "C" fn ReplyChannelRange_hash(o: &ReplyChannelRange) -> u64 {
8199 if o.inner.is_null() { return 0; }
8200 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
8201 #[allow(deprecated)]
8202 let mut hasher = core::hash::SipHasher::new();
8203 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
8204 core::hash::Hasher::finish(&hasher)
8206 /// Checks if two ReplyChannelRanges contain equal inner contents.
8207 /// This ignores pointers and is_owned flags and looks at the values in fields.
8208 /// Two objects with NULL inner values will be considered "equal" here.
8210 pub extern "C" fn ReplyChannelRange_eq(a: &ReplyChannelRange, b: &ReplyChannelRange) -> bool {
8211 if a.inner == b.inner { return true; }
8212 if a.inner.is_null() || b.inner.is_null() { return false; }
8213 if a.get_native_ref() == b.get_native_ref() { true } else { false }
8216 use lightning::ln::msgs::QueryShortChannelIds as nativeQueryShortChannelIdsImport;
8217 pub(crate) type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport;
8219 /// A [`query_short_channel_ids`] message is used to query a peer for
8220 /// routing gossip messages related to one or more `short_channel_id`s.
8222 /// The query recipient will reply with the latest, if available,
8223 /// [`ChannelAnnouncement`], [`ChannelUpdate`] and [`NodeAnnouncement`] messages
8224 /// it maintains for the requested `short_channel_id`s followed by a
8225 /// [`ReplyShortChannelIdsEnd`] message. The `short_channel_id`s sent in
8226 /// this query are encoded. We only support `encoding_type=0` uncompressed
8227 /// serialization and do not support `encoding_type=1` zlib serialization.
8229 /// [`query_short_channel_ids`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_short_channel_idsreply_short_channel_ids_end-messages
8232 pub struct QueryShortChannelIds {
8233 /// A pointer to the opaque Rust object.
8235 /// Nearly everywhere, inner must be non-null, however in places where
8236 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
8237 pub inner: *mut nativeQueryShortChannelIds,
8238 /// Indicates that this is the only struct which contains the same pointer.
8240 /// Rust functions which take ownership of an object provided via an argument require
8241 /// this to be true and invalidate the object pointed to by inner.
8245 impl Drop for QueryShortChannelIds {
8246 fn drop(&mut self) {
8247 if self.is_owned && !<*mut nativeQueryShortChannelIds>::is_null(self.inner) {
8248 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
8252 /// Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL.
8254 pub extern "C" fn QueryShortChannelIds_free(this_obj: QueryShortChannelIds) { }
8256 /// Used only if an object of this type is returned as a trait impl by a method
8257 pub(crate) extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) {
8258 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeQueryShortChannelIds) };
8261 impl QueryShortChannelIds {
8262 pub(crate) fn get_native_ref(&self) -> &'static nativeQueryShortChannelIds {
8263 unsafe { &*ObjOps::untweak_ptr(self.inner) }
8265 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryShortChannelIds {
8266 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
8268 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
8269 pub(crate) fn take_inner(mut self) -> *mut nativeQueryShortChannelIds {
8270 assert!(self.is_owned);
8271 let ret = ObjOps::untweak_ptr(self.inner);
8272 self.inner = core::ptr::null_mut();
8276 /// The genesis hash of the blockchain being queried
8278 pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *const [u8; 32] {
8279 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
8282 /// The genesis hash of the blockchain being queried
8284 pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::ThirtyTwoBytes) {
8285 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
8287 /// The short_channel_ids that are being queried
8289 /// Returns a copy of the field.
8291 pub extern "C" fn QueryShortChannelIds_get_short_channel_ids(this_ptr: &QueryShortChannelIds) -> crate::c_types::derived::CVec_u64Z {
8292 let mut inner_val = this_ptr.get_native_mut_ref().short_channel_ids.clone();
8293 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
8294 local_inner_val.into()
8296 /// The short_channel_ids that are being queried
8298 pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::derived::CVec_u64Z) {
8299 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
8300 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
8302 /// Constructs a new QueryShortChannelIds given each field
8305 pub extern "C" fn QueryShortChannelIds_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_ids_arg: crate::c_types::derived::CVec_u64Z) -> QueryShortChannelIds {
8306 let mut local_short_channel_ids_arg = Vec::new(); for mut item in short_channel_ids_arg.into_rust().drain(..) { local_short_channel_ids_arg.push( { item }); };
8307 QueryShortChannelIds { inner: ObjOps::heap_alloc(nativeQueryShortChannelIds {
8308 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
8309 short_channel_ids: local_short_channel_ids_arg,
8310 }), is_owned: true }
8312 impl Clone for QueryShortChannelIds {
8313 fn clone(&self) -> Self {
8315 inner: if <*mut nativeQueryShortChannelIds>::is_null(self.inner) { core::ptr::null_mut() } else {
8316 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
8322 /// Used only if an object of this type is returned as a trait impl by a method
8323 pub(crate) extern "C" fn QueryShortChannelIds_clone_void(this_ptr: *const c_void) -> *mut c_void {
8324 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeQueryShortChannelIds)).clone() })) as *mut c_void
8327 /// Creates a copy of the QueryShortChannelIds
8328 pub extern "C" fn QueryShortChannelIds_clone(orig: &QueryShortChannelIds) -> QueryShortChannelIds {
8331 /// Get a string which allows debug introspection of a QueryShortChannelIds object
8332 pub extern "C" fn QueryShortChannelIds_debug_str_void(o: *const c_void) -> Str {
8333 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::QueryShortChannelIds }).into()}
8334 /// Generates a non-cryptographic 64-bit hash of the QueryShortChannelIds.
8336 pub extern "C" fn QueryShortChannelIds_hash(o: &QueryShortChannelIds) -> u64 {
8337 if o.inner.is_null() { return 0; }
8338 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
8339 #[allow(deprecated)]
8340 let mut hasher = core::hash::SipHasher::new();
8341 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
8342 core::hash::Hasher::finish(&hasher)
8344 /// Checks if two QueryShortChannelIdss contain equal inner contents.
8345 /// This ignores pointers and is_owned flags and looks at the values in fields.
8346 /// Two objects with NULL inner values will be considered "equal" here.
8348 pub extern "C" fn QueryShortChannelIds_eq(a: &QueryShortChannelIds, b: &QueryShortChannelIds) -> bool {
8349 if a.inner == b.inner { return true; }
8350 if a.inner.is_null() || b.inner.is_null() { return false; }
8351 if a.get_native_ref() == b.get_native_ref() { true } else { false }
8354 use lightning::ln::msgs::ReplyShortChannelIdsEnd as nativeReplyShortChannelIdsEndImport;
8355 pub(crate) type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport;
8357 /// A [`reply_short_channel_ids_end`] message is sent as a reply to a
8358 /// message. The query recipient makes a best
8359 /// effort to respond based on their local network view which may not be
8360 /// a perfect view of the network.
8362 /// [`reply_short_channel_ids_end`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_short_channel_idsreply_short_channel_ids_end-messages
8365 pub struct ReplyShortChannelIdsEnd {
8366 /// A pointer to the opaque Rust object.
8368 /// Nearly everywhere, inner must be non-null, however in places where
8369 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
8370 pub inner: *mut nativeReplyShortChannelIdsEnd,
8371 /// Indicates that this is the only struct which contains the same pointer.
8373 /// Rust functions which take ownership of an object provided via an argument require
8374 /// this to be true and invalidate the object pointed to by inner.
8378 impl Drop for ReplyShortChannelIdsEnd {
8379 fn drop(&mut self) {
8380 if self.is_owned && !<*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) {
8381 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
8385 /// Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL.
8387 pub extern "C" fn ReplyShortChannelIdsEnd_free(this_obj: ReplyShortChannelIdsEnd) { }
8389 /// Used only if an object of this type is returned as a trait impl by a method
8390 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) {
8391 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeReplyShortChannelIdsEnd) };
8394 impl ReplyShortChannelIdsEnd {
8395 pub(crate) fn get_native_ref(&self) -> &'static nativeReplyShortChannelIdsEnd {
8396 unsafe { &*ObjOps::untweak_ptr(self.inner) }
8398 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyShortChannelIdsEnd {
8399 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
8401 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
8402 pub(crate) fn take_inner(mut self) -> *mut nativeReplyShortChannelIdsEnd {
8403 assert!(self.is_owned);
8404 let ret = ObjOps::untweak_ptr(self.inner);
8405 self.inner = core::ptr::null_mut();
8409 /// The genesis hash of the blockchain that was queried
8411 pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *const [u8; 32] {
8412 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
8415 /// The genesis hash of the blockchain that was queried
8417 pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) {
8418 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
8420 /// Indicates if the query recipient maintains up-to-date channel
8421 /// information for the `chain_hash`
8423 pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool {
8424 let mut inner_val = &mut this_ptr.get_native_mut_ref().full_information;
8427 /// Indicates if the query recipient maintains up-to-date channel
8428 /// information for the `chain_hash`
8430 pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: bool) {
8431 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.full_information = val;
8433 /// Constructs a new ReplyShortChannelIdsEnd given each field
8436 pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd {
8437 ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(nativeReplyShortChannelIdsEnd {
8438 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
8439 full_information: full_information_arg,
8440 }), is_owned: true }
8442 impl Clone for ReplyShortChannelIdsEnd {
8443 fn clone(&self) -> Self {
8445 inner: if <*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) { core::ptr::null_mut() } else {
8446 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
8452 /// Used only if an object of this type is returned as a trait impl by a method
8453 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_void) -> *mut c_void {
8454 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeReplyShortChannelIdsEnd)).clone() })) as *mut c_void
8457 /// Creates a copy of the ReplyShortChannelIdsEnd
8458 pub extern "C" fn ReplyShortChannelIdsEnd_clone(orig: &ReplyShortChannelIdsEnd) -> ReplyShortChannelIdsEnd {
8461 /// Get a string which allows debug introspection of a ReplyShortChannelIdsEnd object
8462 pub extern "C" fn ReplyShortChannelIdsEnd_debug_str_void(o: *const c_void) -> Str {
8463 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ReplyShortChannelIdsEnd }).into()}
8464 /// Generates a non-cryptographic 64-bit hash of the ReplyShortChannelIdsEnd.
8466 pub extern "C" fn ReplyShortChannelIdsEnd_hash(o: &ReplyShortChannelIdsEnd) -> u64 {
8467 if o.inner.is_null() { return 0; }
8468 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
8469 #[allow(deprecated)]
8470 let mut hasher = core::hash::SipHasher::new();
8471 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
8472 core::hash::Hasher::finish(&hasher)
8474 /// Checks if two ReplyShortChannelIdsEnds contain equal inner contents.
8475 /// This ignores pointers and is_owned flags and looks at the values in fields.
8476 /// Two objects with NULL inner values will be considered "equal" here.
8478 pub extern "C" fn ReplyShortChannelIdsEnd_eq(a: &ReplyShortChannelIdsEnd, b: &ReplyShortChannelIdsEnd) -> bool {
8479 if a.inner == b.inner { return true; }
8480 if a.inner.is_null() || b.inner.is_null() { return false; }
8481 if a.get_native_ref() == b.get_native_ref() { true } else { false }
8484 use lightning::ln::msgs::GossipTimestampFilter as nativeGossipTimestampFilterImport;
8485 pub(crate) type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport;
8487 /// A [`gossip_timestamp_filter`] message is used by a node to request
8488 /// gossip relay for messages in the requested time range when the
8489 /// `gossip_queries` feature has been negotiated.
8491 /// [`gossip_timestamp_filter`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-gossip_timestamp_filter-message
8494 pub struct GossipTimestampFilter {
8495 /// A pointer to the opaque Rust object.
8497 /// Nearly everywhere, inner must be non-null, however in places where
8498 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
8499 pub inner: *mut nativeGossipTimestampFilter,
8500 /// Indicates that this is the only struct which contains the same pointer.
8502 /// Rust functions which take ownership of an object provided via an argument require
8503 /// this to be true and invalidate the object pointed to by inner.
8507 impl Drop for GossipTimestampFilter {
8508 fn drop(&mut self) {
8509 if self.is_owned && !<*mut nativeGossipTimestampFilter>::is_null(self.inner) {
8510 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
8514 /// Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL.
8516 pub extern "C" fn GossipTimestampFilter_free(this_obj: GossipTimestampFilter) { }
8518 /// Used only if an object of this type is returned as a trait impl by a method
8519 pub(crate) extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) {
8520 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeGossipTimestampFilter) };
8523 impl GossipTimestampFilter {
8524 pub(crate) fn get_native_ref(&self) -> &'static nativeGossipTimestampFilter {
8525 unsafe { &*ObjOps::untweak_ptr(self.inner) }
8527 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeGossipTimestampFilter {
8528 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
8530 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
8531 pub(crate) fn take_inner(mut self) -> *mut nativeGossipTimestampFilter {
8532 assert!(self.is_owned);
8533 let ret = ObjOps::untweak_ptr(self.inner);
8534 self.inner = core::ptr::null_mut();
8538 /// The genesis hash of the blockchain for channel and node information
8540 pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *const [u8; 32] {
8541 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
8544 /// The genesis hash of the blockchain for channel and node information
8546 pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) {
8547 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data);
8549 /// The starting unix timestamp
8551 pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 {
8552 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_timestamp;
8555 /// The starting unix timestamp
8557 pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
8558 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_timestamp = val;
8560 /// The range of information in seconds
8562 pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 {
8563 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp_range;
8566 /// The range of information in seconds
8568 pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
8569 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp_range = val;
8571 /// Constructs a new GossipTimestampFilter given each field
8574 pub extern "C" fn GossipTimestampFilter_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut first_timestamp_arg: u32, mut timestamp_range_arg: u32) -> GossipTimestampFilter {
8575 GossipTimestampFilter { inner: ObjOps::heap_alloc(nativeGossipTimestampFilter {
8576 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data),
8577 first_timestamp: first_timestamp_arg,
8578 timestamp_range: timestamp_range_arg,
8579 }), is_owned: true }
8581 impl Clone for GossipTimestampFilter {
8582 fn clone(&self) -> Self {
8584 inner: if <*mut nativeGossipTimestampFilter>::is_null(self.inner) { core::ptr::null_mut() } else {
8585 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
8591 /// Used only if an object of this type is returned as a trait impl by a method
8592 pub(crate) extern "C" fn GossipTimestampFilter_clone_void(this_ptr: *const c_void) -> *mut c_void {
8593 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeGossipTimestampFilter)).clone() })) as *mut c_void
8596 /// Creates a copy of the GossipTimestampFilter
8597 pub extern "C" fn GossipTimestampFilter_clone(orig: &GossipTimestampFilter) -> GossipTimestampFilter {
8600 /// Get a string which allows debug introspection of a GossipTimestampFilter object
8601 pub extern "C" fn GossipTimestampFilter_debug_str_void(o: *const c_void) -> Str {
8602 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::GossipTimestampFilter }).into()}
8603 /// Generates a non-cryptographic 64-bit hash of the GossipTimestampFilter.
8605 pub extern "C" fn GossipTimestampFilter_hash(o: &GossipTimestampFilter) -> u64 {
8606 if o.inner.is_null() { return 0; }
8607 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
8608 #[allow(deprecated)]
8609 let mut hasher = core::hash::SipHasher::new();
8610 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
8611 core::hash::Hasher::finish(&hasher)
8613 /// Checks if two GossipTimestampFilters contain equal inner contents.
8614 /// This ignores pointers and is_owned flags and looks at the values in fields.
8615 /// Two objects with NULL inner values will be considered "equal" here.
8617 pub extern "C" fn GossipTimestampFilter_eq(a: &GossipTimestampFilter, b: &GossipTimestampFilter) -> bool {
8618 if a.inner == b.inner { return true; }
8619 if a.inner.is_null() || b.inner.is_null() { return false; }
8620 if a.get_native_ref() == b.get_native_ref() { true } else { false }
8622 /// Used to put an error message in a [`LightningError`].
8626 pub enum ErrorAction {
8627 /// The peer took some action which made us think they were useless. Disconnect them.
8629 /// An error message which we should make an effort to send before we disconnect.
8631 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
8632 msg: crate::lightning::ln::msgs::ErrorMessage,
8634 /// The peer did something incorrect. Tell them without closing any channels and disconnect them.
8635 DisconnectPeerWithWarning {
8636 /// A warning message which we should make an effort to send before we disconnect.
8637 msg: crate::lightning::ln::msgs::WarningMessage,
8639 /// The peer did something harmless that we weren't able to process, just log and ignore
8641 /// The peer did something harmless that we weren't able to meaningfully process.
8642 /// If the error is logged, log it at the given level.
8644 crate::lightning::util::logger::Level),
8645 /// The peer provided us with a gossip message which we'd already seen. In most cases this
8646 /// should be ignored, but it may result in the message being forwarded if it is a duplicate of
8647 /// our own channel announcements.
8648 IgnoreDuplicateGossip,
8649 /// The peer did something incorrect. Tell them.
8651 /// The message to send.
8652 msg: crate::lightning::ln::msgs::ErrorMessage,
8654 /// The peer did something incorrect. Tell them without closing any channels.
8655 SendWarningMessage {
8656 /// The message to send.
8657 msg: crate::lightning::ln::msgs::WarningMessage,
8658 /// The peer may have done something harmless that we weren't able to meaningfully process,
8659 /// though we should still tell them about it.
8660 /// If this event is logged, log it at the given level.
8661 log_level: crate::lightning::util::logger::Level,
8664 use lightning::ln::msgs::ErrorAction as ErrorActionImport;
8665 pub(crate) type nativeErrorAction = ErrorActionImport;
8669 pub(crate) fn to_native(&self) -> nativeErrorAction {
8671 ErrorAction::DisconnectPeer {ref msg, } => {
8672 let mut msg_nonref = Clone::clone(msg);
8673 let mut local_msg_nonref = if msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg_nonref.take_inner()) } }) };
8674 nativeErrorAction::DisconnectPeer {
8675 msg: local_msg_nonref,
8678 ErrorAction::DisconnectPeerWithWarning {ref msg, } => {
8679 let mut msg_nonref = Clone::clone(msg);
8680 nativeErrorAction::DisconnectPeerWithWarning {
8681 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
8684 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
8685 ErrorAction::IgnoreAndLog (ref a, ) => {
8686 let mut a_nonref = Clone::clone(a);
8687 nativeErrorAction::IgnoreAndLog (
8688 a_nonref.into_native(),
8691 ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
8692 ErrorAction::SendErrorMessage {ref msg, } => {
8693 let mut msg_nonref = Clone::clone(msg);
8694 nativeErrorAction::SendErrorMessage {
8695 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
8698 ErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
8699 let mut msg_nonref = Clone::clone(msg);
8700 let mut log_level_nonref = Clone::clone(log_level);
8701 nativeErrorAction::SendWarningMessage {
8702 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
8703 log_level: log_level_nonref.into_native(),
8709 pub(crate) fn into_native(self) -> nativeErrorAction {
8711 ErrorAction::DisconnectPeer {mut msg, } => {
8712 let mut local_msg = if msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg.take_inner()) } }) };
8713 nativeErrorAction::DisconnectPeer {
8717 ErrorAction::DisconnectPeerWithWarning {mut msg, } => {
8718 nativeErrorAction::DisconnectPeerWithWarning {
8719 msg: *unsafe { Box::from_raw(msg.take_inner()) },
8722 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
8723 ErrorAction::IgnoreAndLog (mut a, ) => {
8724 nativeErrorAction::IgnoreAndLog (
8728 ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
8729 ErrorAction::SendErrorMessage {mut msg, } => {
8730 nativeErrorAction::SendErrorMessage {
8731 msg: *unsafe { Box::from_raw(msg.take_inner()) },
8734 ErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
8735 nativeErrorAction::SendWarningMessage {
8736 msg: *unsafe { Box::from_raw(msg.take_inner()) },
8737 log_level: log_level.into_native(),
8743 pub(crate) fn from_native(native: &ErrorActionImport) -> Self {
8744 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeErrorAction) };
8746 nativeErrorAction::DisconnectPeer {ref msg, } => {
8747 let mut msg_nonref = Clone::clone(msg);
8748 let mut local_msg_nonref = crate::lightning::ln::msgs::ErrorMessage { inner: if msg_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((msg_nonref.unwrap())) } }, is_owned: true };
8749 ErrorAction::DisconnectPeer {
8750 msg: local_msg_nonref,
8753 nativeErrorAction::DisconnectPeerWithWarning {ref msg, } => {
8754 let mut msg_nonref = Clone::clone(msg);
8755 ErrorAction::DisconnectPeerWithWarning {
8756 msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
8759 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
8760 nativeErrorAction::IgnoreAndLog (ref a, ) => {
8761 let mut a_nonref = Clone::clone(a);
8762 ErrorAction::IgnoreAndLog (
8763 crate::lightning::util::logger::Level::native_into(a_nonref),
8766 nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
8767 nativeErrorAction::SendErrorMessage {ref msg, } => {
8768 let mut msg_nonref = Clone::clone(msg);
8769 ErrorAction::SendErrorMessage {
8770 msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
8773 nativeErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
8774 let mut msg_nonref = Clone::clone(msg);
8775 let mut log_level_nonref = Clone::clone(log_level);
8776 ErrorAction::SendWarningMessage {
8777 msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
8778 log_level: crate::lightning::util::logger::Level::native_into(log_level_nonref),
8784 pub(crate) fn native_into(native: nativeErrorAction) -> Self {
8786 nativeErrorAction::DisconnectPeer {mut msg, } => {
8787 let mut local_msg = crate::lightning::ln::msgs::ErrorMessage { inner: if msg.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((msg.unwrap())) } }, is_owned: true };
8788 ErrorAction::DisconnectPeer {
8792 nativeErrorAction::DisconnectPeerWithWarning {mut msg, } => {
8793 ErrorAction::DisconnectPeerWithWarning {
8794 msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
8797 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
8798 nativeErrorAction::IgnoreAndLog (mut a, ) => {
8799 ErrorAction::IgnoreAndLog (
8800 crate::lightning::util::logger::Level::native_into(a),
8803 nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
8804 nativeErrorAction::SendErrorMessage {mut msg, } => {
8805 ErrorAction::SendErrorMessage {
8806 msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
8809 nativeErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
8810 ErrorAction::SendWarningMessage {
8811 msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
8812 log_level: crate::lightning::util::logger::Level::native_into(log_level),
8818 /// Frees any resources used by the ErrorAction
8820 pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { }
8821 /// Creates a copy of the ErrorAction
8823 pub extern "C" fn ErrorAction_clone(orig: &ErrorAction) -> ErrorAction {
8827 /// Used only if an object of this type is returned as a trait impl by a method
8828 pub(crate) extern "C" fn ErrorAction_clone_void(this_ptr: *const c_void) -> *mut c_void {
8829 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const ErrorAction)).clone() })) as *mut c_void
8832 /// Used only if an object of this type is returned as a trait impl by a method
8833 pub(crate) extern "C" fn ErrorAction_free_void(this_ptr: *mut c_void) {
8834 let _ = unsafe { Box::from_raw(this_ptr as *mut ErrorAction) };
8837 /// Utility method to constructs a new DisconnectPeer-variant ErrorAction
8838 pub extern "C" fn ErrorAction_disconnect_peer(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
8839 ErrorAction::DisconnectPeer {
8844 /// Utility method to constructs a new DisconnectPeerWithWarning-variant ErrorAction
8845 pub extern "C" fn ErrorAction_disconnect_peer_with_warning(msg: crate::lightning::ln::msgs::WarningMessage) -> ErrorAction {
8846 ErrorAction::DisconnectPeerWithWarning {
8851 /// Utility method to constructs a new IgnoreError-variant ErrorAction
8852 pub extern "C" fn ErrorAction_ignore_error() -> ErrorAction {
8853 ErrorAction::IgnoreError}
8855 /// Utility method to constructs a new IgnoreAndLog-variant ErrorAction
8856 pub extern "C" fn ErrorAction_ignore_and_log(a: crate::lightning::util::logger::Level) -> ErrorAction {
8857 ErrorAction::IgnoreAndLog(a, )
8860 /// Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction
8861 pub extern "C" fn ErrorAction_ignore_duplicate_gossip() -> ErrorAction {
8862 ErrorAction::IgnoreDuplicateGossip}
8864 /// Utility method to constructs a new SendErrorMessage-variant ErrorAction
8865 pub extern "C" fn ErrorAction_send_error_message(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
8866 ErrorAction::SendErrorMessage {
8871 /// Utility method to constructs a new SendWarningMessage-variant ErrorAction
8872 pub extern "C" fn ErrorAction_send_warning_message(msg: crate::lightning::ln::msgs::WarningMessage, log_level: crate::lightning::util::logger::Level) -> ErrorAction {
8873 ErrorAction::SendWarningMessage {
8878 /// Get a string which allows debug introspection of a ErrorAction object
8879 pub extern "C" fn ErrorAction_debug_str_void(o: *const c_void) -> Str {
8880 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ErrorAction }).into()}
8881 /// Generates a non-cryptographic 64-bit hash of the ErrorAction.
8883 pub extern "C" fn ErrorAction_hash(o: &ErrorAction) -> u64 {
8884 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
8885 #[allow(deprecated)]
8886 let mut hasher = core::hash::SipHasher::new();
8887 core::hash::Hash::hash(&o.to_native(), &mut hasher);
8888 core::hash::Hasher::finish(&hasher)
8891 use lightning::ln::msgs::LightningError as nativeLightningErrorImport;
8892 pub(crate) type nativeLightningError = nativeLightningErrorImport;
8894 /// An Err type for failure to process messages.
8897 pub struct LightningError {
8898 /// A pointer to the opaque Rust object.
8900 /// Nearly everywhere, inner must be non-null, however in places where
8901 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
8902 pub inner: *mut nativeLightningError,
8903 /// Indicates that this is the only struct which contains the same pointer.
8905 /// Rust functions which take ownership of an object provided via an argument require
8906 /// this to be true and invalidate the object pointed to by inner.
8910 impl Drop for LightningError {
8911 fn drop(&mut self) {
8912 if self.is_owned && !<*mut nativeLightningError>::is_null(self.inner) {
8913 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
8917 /// Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL.
8919 pub extern "C" fn LightningError_free(this_obj: LightningError) { }
8921 /// Used only if an object of this type is returned as a trait impl by a method
8922 pub(crate) extern "C" fn LightningError_free_void(this_ptr: *mut c_void) {
8923 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLightningError) };
8926 impl LightningError {
8927 pub(crate) fn get_native_ref(&self) -> &'static nativeLightningError {
8928 unsafe { &*ObjOps::untweak_ptr(self.inner) }
8930 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLightningError {
8931 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
8933 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
8934 pub(crate) fn take_inner(mut self) -> *mut nativeLightningError {
8935 assert!(self.is_owned);
8936 let ret = ObjOps::untweak_ptr(self.inner);
8937 self.inner = core::ptr::null_mut();
8941 /// A human-readable message describing the error
8943 pub extern "C" fn LightningError_get_err(this_ptr: &LightningError) -> crate::c_types::Str {
8944 let mut inner_val = &mut this_ptr.get_native_mut_ref().err;
8945 inner_val.as_str().into()
8947 /// A human-readable message describing the error
8949 pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: crate::c_types::Str) {
8950 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.err = val.into_string();
8952 /// The action which should be taken against the offending peer.
8954 pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate::lightning::ln::msgs::ErrorAction {
8955 let mut inner_val = &mut this_ptr.get_native_mut_ref().action;
8956 crate::lightning::ln::msgs::ErrorAction::from_native(inner_val)
8958 /// The action which should be taken against the offending peer.
8960 pub extern "C" fn LightningError_set_action(this_ptr: &mut LightningError, mut val: crate::lightning::ln::msgs::ErrorAction) {
8961 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.action = val.into_native();
8963 /// Constructs a new LightningError given each field
8966 pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::Str, mut action_arg: crate::lightning::ln::msgs::ErrorAction) -> LightningError {
8967 LightningError { inner: ObjOps::heap_alloc(nativeLightningError {
8968 err: err_arg.into_string(),
8969 action: action_arg.into_native(),
8970 }), is_owned: true }
8972 impl Clone for LightningError {
8973 fn clone(&self) -> Self {
8975 inner: if <*mut nativeLightningError>::is_null(self.inner) { core::ptr::null_mut() } else {
8976 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
8982 /// Used only if an object of this type is returned as a trait impl by a method
8983 pub(crate) extern "C" fn LightningError_clone_void(this_ptr: *const c_void) -> *mut c_void {
8984 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeLightningError)).clone() })) as *mut c_void
8987 /// Creates a copy of the LightningError
8988 pub extern "C" fn LightningError_clone(orig: &LightningError) -> LightningError {
8991 /// Get a string which allows debug introspection of a LightningError object
8992 pub extern "C" fn LightningError_debug_str_void(o: *const c_void) -> Str {
8993 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::LightningError }).into()}
8995 use lightning::ln::msgs::CommitmentUpdate as nativeCommitmentUpdateImport;
8996 pub(crate) type nativeCommitmentUpdate = nativeCommitmentUpdateImport;
8998 /// Struct used to return values from [`RevokeAndACK`] messages, containing a bunch of commitment
8999 /// transaction updates if they were pending.
9002 pub struct CommitmentUpdate {
9003 /// A pointer to the opaque Rust object.
9005 /// Nearly everywhere, inner must be non-null, however in places where
9006 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
9007 pub inner: *mut nativeCommitmentUpdate,
9008 /// Indicates that this is the only struct which contains the same pointer.
9010 /// Rust functions which take ownership of an object provided via an argument require
9011 /// this to be true and invalidate the object pointed to by inner.
9015 impl Drop for CommitmentUpdate {
9016 fn drop(&mut self) {
9017 if self.is_owned && !<*mut nativeCommitmentUpdate>::is_null(self.inner) {
9018 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
9022 /// Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL.
9024 pub extern "C" fn CommitmentUpdate_free(this_obj: CommitmentUpdate) { }
9026 /// Used only if an object of this type is returned as a trait impl by a method
9027 pub(crate) extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) {
9028 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCommitmentUpdate) };
9031 impl CommitmentUpdate {
9032 pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentUpdate {
9033 unsafe { &*ObjOps::untweak_ptr(self.inner) }
9035 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentUpdate {
9036 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
9038 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
9039 pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentUpdate {
9040 assert!(self.is_owned);
9041 let ret = ObjOps::untweak_ptr(self.inner);
9042 self.inner = core::ptr::null_mut();
9046 /// `update_add_htlc` messages which should be sent
9048 pub extern "C" fn CommitmentUpdate_get_update_add_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateAddHTLCZ {
9049 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_add_htlcs;
9050 let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::ln::msgs::UpdateAddHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::ln::msgs::UpdateAddHTLC<>) as *mut _) }, is_owned: false } }); };
9051 local_inner_val.into()
9053 /// `update_add_htlc` messages which should be sent
9055 pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) {
9056 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
9057 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_add_htlcs = local_val;
9059 /// `update_fulfill_htlc` messages which should be sent
9061 pub extern "C" fn CommitmentUpdate_get_update_fulfill_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFulfillHTLCZ {
9062 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fulfill_htlcs;
9063 let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::ln::msgs::UpdateFulfillHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::ln::msgs::UpdateFulfillHTLC<>) as *mut _) }, is_owned: false } }); };
9064 local_inner_val.into()
9066 /// `update_fulfill_htlc` messages which should be sent
9068 pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) {
9069 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
9070 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fulfill_htlcs = local_val;
9072 /// `update_fail_htlc` messages which should be sent
9074 pub extern "C" fn CommitmentUpdate_get_update_fail_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailHTLCZ {
9075 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_htlcs;
9076 let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::ln::msgs::UpdateFailHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::ln::msgs::UpdateFailHTLC<>) as *mut _) }, is_owned: false } }); };
9077 local_inner_val.into()
9079 /// `update_fail_htlc` messages which should be sent
9081 pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) {
9082 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
9083 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_htlcs = local_val;
9085 /// `update_fail_malformed_htlc` messages which should be sent
9087 pub extern "C" fn CommitmentUpdate_get_update_fail_malformed_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ {
9088 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_malformed_htlcs;
9089 let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::ln::msgs::UpdateFailMalformedHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::ln::msgs::UpdateFailMalformedHTLC<>) as *mut _) }, is_owned: false } }); };
9090 local_inner_val.into()
9092 /// `update_fail_malformed_htlc` messages which should be sent
9094 pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) {
9095 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
9096 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_malformed_htlcs = local_val;
9098 /// An `update_fee` message which should be sent
9100 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
9102 pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::UpdateFee {
9103 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fee;
9104 let mut local_inner_val = crate::lightning::ln::msgs::UpdateFee { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::msgs::UpdateFee<>) as *mut _ }, is_owned: false };
9107 /// An `update_fee` message which should be sent
9109 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
9111 pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::UpdateFee) {
9112 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
9113 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fee = local_val;
9115 /// A `commitment_signed` message which should be sent
9117 pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::CommitmentSigned {
9118 let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_signed;
9119 crate::lightning::ln::msgs::CommitmentSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::CommitmentSigned<>) as *mut _) }, is_owned: false }
9121 /// A `commitment_signed` message which should be sent
9123 pub extern "C" fn CommitmentUpdate_set_commitment_signed(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::CommitmentSigned) {
9124 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_signed = *unsafe { Box::from_raw(val.take_inner()) };
9126 /// Constructs a new CommitmentUpdate given each field
9128 /// Note that update_fee_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
9131 pub extern "C" fn CommitmentUpdate_new(mut update_add_htlcs_arg: crate::c_types::derived::CVec_UpdateAddHTLCZ, mut update_fulfill_htlcs_arg: crate::c_types::derived::CVec_UpdateFulfillHTLCZ, mut update_fail_htlcs_arg: crate::c_types::derived::CVec_UpdateFailHTLCZ, mut update_fail_malformed_htlcs_arg: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ, mut update_fee_arg: crate::lightning::ln::msgs::UpdateFee, mut commitment_signed_arg: crate::lightning::ln::msgs::CommitmentSigned) -> CommitmentUpdate {
9132 let mut local_update_add_htlcs_arg = Vec::new(); for mut item in update_add_htlcs_arg.into_rust().drain(..) { local_update_add_htlcs_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
9133 let mut local_update_fulfill_htlcs_arg = Vec::new(); for mut item in update_fulfill_htlcs_arg.into_rust().drain(..) { local_update_fulfill_htlcs_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
9134 let mut local_update_fail_htlcs_arg = Vec::new(); for mut item in update_fail_htlcs_arg.into_rust().drain(..) { local_update_fail_htlcs_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
9135 let mut local_update_fail_malformed_htlcs_arg = Vec::new(); for mut item in update_fail_malformed_htlcs_arg.into_rust().drain(..) { local_update_fail_malformed_htlcs_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
9136 let mut local_update_fee_arg = if update_fee_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(update_fee_arg.take_inner()) } }) };
9137 CommitmentUpdate { inner: ObjOps::heap_alloc(nativeCommitmentUpdate {
9138 update_add_htlcs: local_update_add_htlcs_arg,
9139 update_fulfill_htlcs: local_update_fulfill_htlcs_arg,
9140 update_fail_htlcs: local_update_fail_htlcs_arg,
9141 update_fail_malformed_htlcs: local_update_fail_malformed_htlcs_arg,
9142 update_fee: local_update_fee_arg,
9143 commitment_signed: *unsafe { Box::from_raw(commitment_signed_arg.take_inner()) },
9144 }), is_owned: true }
9146 impl Clone for CommitmentUpdate {
9147 fn clone(&self) -> Self {
9149 inner: if <*mut nativeCommitmentUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
9150 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
9156 /// Used only if an object of this type is returned as a trait impl by a method
9157 pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
9158 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeCommitmentUpdate)).clone() })) as *mut c_void
9161 /// Creates a copy of the CommitmentUpdate
9162 pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentUpdate {
9165 /// Get a string which allows debug introspection of a CommitmentUpdate object
9166 pub extern "C" fn CommitmentUpdate_debug_str_void(o: *const c_void) -> Str {
9167 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::CommitmentUpdate }).into()}
9168 /// Generates a non-cryptographic 64-bit hash of the CommitmentUpdate.
9170 pub extern "C" fn CommitmentUpdate_hash(o: &CommitmentUpdate) -> u64 {
9171 if o.inner.is_null() { return 0; }
9172 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
9173 #[allow(deprecated)]
9174 let mut hasher = core::hash::SipHasher::new();
9175 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
9176 core::hash::Hasher::finish(&hasher)
9178 /// Checks if two CommitmentUpdates contain equal inner contents.
9179 /// This ignores pointers and is_owned flags and looks at the values in fields.
9180 /// Two objects with NULL inner values will be considered "equal" here.
9182 pub extern "C" fn CommitmentUpdate_eq(a: &CommitmentUpdate, b: &CommitmentUpdate) -> bool {
9183 if a.inner == b.inner { return true; }
9184 if a.inner.is_null() || b.inner.is_null() { return false; }
9185 if a.get_native_ref() == b.get_native_ref() { true } else { false }
9187 /// A trait to describe an object which can receive channel messages.
9189 /// Messages MAY be called in parallel when they originate from different `their_node_ids`, however
9190 /// they MUST NOT be called in parallel when the two calls have the same `their_node_id`.
9192 pub struct ChannelMessageHandler {
9193 /// An opaque pointer which is passed to your function implementations as an argument.
9194 /// This has no meaning in the LDK, and can be NULL or any other value.
9195 pub this_arg: *mut c_void,
9196 /// Handle an incoming `open_channel` message from the given peer.
9197 pub handle_open_channel: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OpenChannel),
9198 /// Handle an incoming `open_channel2` message from the given peer.
9199 pub handle_open_channel_v2: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OpenChannelV2),
9200 /// Handle an incoming `accept_channel` message from the given peer.
9201 pub handle_accept_channel: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AcceptChannel),
9202 /// Handle an incoming `accept_channel2` message from the given peer.
9203 pub handle_accept_channel_v2: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AcceptChannelV2),
9204 /// Handle an incoming `funding_created` message from the given peer.
9205 pub handle_funding_created: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::FundingCreated),
9206 /// Handle an incoming `funding_signed` message from the given peer.
9207 pub handle_funding_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::FundingSigned),
9208 /// Handle an incoming `channel_ready` message from the given peer.
9209 pub handle_channel_ready: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelReady),
9210 /// Handle an incoming `shutdown` message from the given peer.
9211 pub handle_shutdown: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Shutdown),
9212 /// Handle an incoming `closing_signed` message from the given peer.
9213 pub handle_closing_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ClosingSigned),
9214 /// Handle an incoming `stfu` message from the given peer.
9215 pub handle_stfu: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Stfu),
9216 /// Handle an incoming `tx_add_input message` from the given peer.
9217 pub handle_tx_add_input: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAddInput),
9218 /// Handle an incoming `tx_add_output` message from the given peer.
9219 pub handle_tx_add_output: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAddOutput),
9220 /// Handle an incoming `tx_remove_input` message from the given peer.
9221 pub handle_tx_remove_input: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxRemoveInput),
9222 /// Handle an incoming `tx_remove_output` message from the given peer.
9223 pub handle_tx_remove_output: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxRemoveOutput),
9224 /// Handle an incoming `tx_complete message` from the given peer.
9225 pub handle_tx_complete: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxComplete),
9226 /// Handle an incoming `tx_signatures` message from the given peer.
9227 pub handle_tx_signatures: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxSignatures),
9228 /// Handle an incoming `tx_init_rbf` message from the given peer.
9229 pub handle_tx_init_rbf: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxInitRbf),
9230 /// Handle an incoming `tx_ack_rbf` message from the given peer.
9231 pub handle_tx_ack_rbf: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAckRbf),
9232 /// Handle an incoming `tx_abort message` from the given peer.
9233 pub handle_tx_abort: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAbort),
9234 /// Handle an incoming `update_add_htlc` message from the given peer.
9235 pub handle_update_add_htlc: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateAddHTLC),
9236 /// Handle an incoming `update_fulfill_htlc` message from the given peer.
9237 pub handle_update_fulfill_htlc: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFulfillHTLC),
9238 /// Handle an incoming `update_fail_htlc` message from the given peer.
9239 pub handle_update_fail_htlc: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFailHTLC),
9240 /// Handle an incoming `update_fail_malformed_htlc` message from the given peer.
9241 pub handle_update_fail_malformed_htlc: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFailMalformedHTLC),
9242 /// Handle an incoming `commitment_signed` message from the given peer.
9243 pub handle_commitment_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::CommitmentSigned),
9244 /// Handle an incoming `revoke_and_ack` message from the given peer.
9245 pub handle_revoke_and_ack: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::RevokeAndACK),
9246 /// Handle an incoming `update_fee` message from the given peer.
9247 pub handle_update_fee: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFee),
9248 /// Handle an incoming `announcement_signatures` message from the given peer.
9249 pub handle_announcement_signatures: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AnnouncementSignatures),
9250 /// Indicates a connection to the peer failed/an existing connection was lost.
9251 pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey),
9252 /// Handle a peer reconnecting, possibly generating `channel_reestablish` message(s).
9254 /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
9255 /// with us. Implementors should be somewhat conservative about doing so, however, as other
9256 /// message handlers may still wish to communicate with this peer.
9257 pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Init, inbound: bool) -> crate::c_types::derived::CResult_NoneNoneZ,
9258 /// Handle an incoming `channel_reestablish` message from the given peer.
9259 pub handle_channel_reestablish: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelReestablish),
9260 /// Handle an incoming `channel_update` message from the given peer.
9261 pub handle_channel_update: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelUpdate),
9262 /// Handle an incoming `error` message from the given peer.
9263 pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ErrorMessage),
9264 /// Gets the node feature flags which this handler itself supports. All available handlers are
9265 /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
9266 /// which are broadcasted in our [`NodeAnnouncement`] message.
9267 pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
9268 /// Gets the init feature flags which should be sent to the given peer. All available handlers
9269 /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
9270 /// which are sent in our [`Init`] message.
9272 /// Note that this method is called before [`Self::peer_connected`].
9273 pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
9274 /// Gets the chain hashes for this `ChannelMessageHandler` indicating which chains it supports.
9276 /// If it's `None`, then no particular network chain hash compatibility will be enforced when
9277 /// connecting to peers.
9278 pub get_chain_hashes: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ,
9279 /// Implementation of MessageSendEventsProvider for this object.
9280 pub MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider,
9281 /// Frees any resources associated with this object given its this_arg pointer.
9282 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
9283 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
9285 unsafe impl Send for ChannelMessageHandler {}
9286 unsafe impl Sync for ChannelMessageHandler {}
9288 pub(crate) fn ChannelMessageHandler_clone_fields(orig: &ChannelMessageHandler) -> ChannelMessageHandler {
9289 ChannelMessageHandler {
9290 this_arg: orig.this_arg,
9291 handle_open_channel: Clone::clone(&orig.handle_open_channel),
9292 handle_open_channel_v2: Clone::clone(&orig.handle_open_channel_v2),
9293 handle_accept_channel: Clone::clone(&orig.handle_accept_channel),
9294 handle_accept_channel_v2: Clone::clone(&orig.handle_accept_channel_v2),
9295 handle_funding_created: Clone::clone(&orig.handle_funding_created),
9296 handle_funding_signed: Clone::clone(&orig.handle_funding_signed),
9297 handle_channel_ready: Clone::clone(&orig.handle_channel_ready),
9298 handle_shutdown: Clone::clone(&orig.handle_shutdown),
9299 handle_closing_signed: Clone::clone(&orig.handle_closing_signed),
9300 handle_stfu: Clone::clone(&orig.handle_stfu),
9301 handle_tx_add_input: Clone::clone(&orig.handle_tx_add_input),
9302 handle_tx_add_output: Clone::clone(&orig.handle_tx_add_output),
9303 handle_tx_remove_input: Clone::clone(&orig.handle_tx_remove_input),
9304 handle_tx_remove_output: Clone::clone(&orig.handle_tx_remove_output),
9305 handle_tx_complete: Clone::clone(&orig.handle_tx_complete),
9306 handle_tx_signatures: Clone::clone(&orig.handle_tx_signatures),
9307 handle_tx_init_rbf: Clone::clone(&orig.handle_tx_init_rbf),
9308 handle_tx_ack_rbf: Clone::clone(&orig.handle_tx_ack_rbf),
9309 handle_tx_abort: Clone::clone(&orig.handle_tx_abort),
9310 handle_update_add_htlc: Clone::clone(&orig.handle_update_add_htlc),
9311 handle_update_fulfill_htlc: Clone::clone(&orig.handle_update_fulfill_htlc),
9312 handle_update_fail_htlc: Clone::clone(&orig.handle_update_fail_htlc),
9313 handle_update_fail_malformed_htlc: Clone::clone(&orig.handle_update_fail_malformed_htlc),
9314 handle_commitment_signed: Clone::clone(&orig.handle_commitment_signed),
9315 handle_revoke_and_ack: Clone::clone(&orig.handle_revoke_and_ack),
9316 handle_update_fee: Clone::clone(&orig.handle_update_fee),
9317 handle_announcement_signatures: Clone::clone(&orig.handle_announcement_signatures),
9318 peer_disconnected: Clone::clone(&orig.peer_disconnected),
9319 peer_connected: Clone::clone(&orig.peer_connected),
9320 handle_channel_reestablish: Clone::clone(&orig.handle_channel_reestablish),
9321 handle_channel_update: Clone::clone(&orig.handle_channel_update),
9322 handle_error: Clone::clone(&orig.handle_error),
9323 provided_node_features: Clone::clone(&orig.provided_node_features),
9324 provided_init_features: Clone::clone(&orig.provided_init_features),
9325 get_chain_hashes: Clone::clone(&orig.get_chain_hashes),
9326 MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
9327 free: Clone::clone(&orig.free),
9330 impl lightning::events::MessageSendEventsProvider for ChannelMessageHandler {
9331 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::events::MessageSendEvent> {
9332 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
9333 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
9338 use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler;
9339 impl rustChannelMessageHandler for ChannelMessageHandler {
9340 fn handle_open_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OpenChannel) {
9341 (self.handle_open_channel)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::OpenChannel { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::OpenChannel<>) as *mut _) }, is_owned: false })
9343 fn handle_open_channel_v2(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OpenChannelV2) {
9344 (self.handle_open_channel_v2)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::OpenChannelV2 { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::OpenChannelV2<>) as *mut _) }, is_owned: false })
9346 fn handle_accept_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AcceptChannel) {
9347 (self.handle_accept_channel)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::AcceptChannel { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::AcceptChannel<>) as *mut _) }, is_owned: false })
9349 fn handle_accept_channel_v2(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AcceptChannelV2) {
9350 (self.handle_accept_channel_v2)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::AcceptChannelV2 { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::AcceptChannelV2<>) as *mut _) }, is_owned: false })
9352 fn handle_funding_created(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingCreated) {
9353 (self.handle_funding_created)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::FundingCreated { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::FundingCreated<>) as *mut _) }, is_owned: false })
9355 fn handle_funding_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingSigned) {
9356 (self.handle_funding_signed)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::FundingSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::FundingSigned<>) as *mut _) }, is_owned: false })
9358 fn handle_channel_ready(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReady) {
9359 (self.handle_channel_ready)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ChannelReady { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelReady<>) as *mut _) }, is_owned: false })
9361 fn handle_shutdown(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Shutdown) {
9362 (self.handle_shutdown)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Shutdown { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::Shutdown<>) as *mut _) }, is_owned: false })
9364 fn handle_closing_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ClosingSigned) {
9365 (self.handle_closing_signed)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ClosingSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ClosingSigned<>) as *mut _) }, is_owned: false })
9367 fn handle_stfu(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Stfu) {
9368 (self.handle_stfu)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Stfu { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::Stfu<>) as *mut _) }, is_owned: false })
9370 fn handle_tx_add_input(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAddInput) {
9371 (self.handle_tx_add_input)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAddInput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAddInput<>) as *mut _) }, is_owned: false })
9373 fn handle_tx_add_output(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAddOutput) {
9374 (self.handle_tx_add_output)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAddOutput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAddOutput<>) as *mut _) }, is_owned: false })
9376 fn handle_tx_remove_input(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxRemoveInput) {
9377 (self.handle_tx_remove_input)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxRemoveInput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxRemoveInput<>) as *mut _) }, is_owned: false })
9379 fn handle_tx_remove_output(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxRemoveOutput) {
9380 (self.handle_tx_remove_output)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxRemoveOutput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxRemoveOutput<>) as *mut _) }, is_owned: false })
9382 fn handle_tx_complete(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxComplete) {
9383 (self.handle_tx_complete)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxComplete { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxComplete<>) as *mut _) }, is_owned: false })
9385 fn handle_tx_signatures(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxSignatures) {
9386 (self.handle_tx_signatures)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxSignatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxSignatures<>) as *mut _) }, is_owned: false })
9388 fn handle_tx_init_rbf(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxInitRbf) {
9389 (self.handle_tx_init_rbf)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxInitRbf { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxInitRbf<>) as *mut _) }, is_owned: false })
9391 fn handle_tx_ack_rbf(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAckRbf) {
9392 (self.handle_tx_ack_rbf)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAckRbf { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAckRbf<>) as *mut _) }, is_owned: false })
9394 fn handle_tx_abort(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAbort) {
9395 (self.handle_tx_abort)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAbort { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAbort<>) as *mut _) }, is_owned: false })
9397 fn handle_update_add_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateAddHTLC) {
9398 (self.handle_update_add_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateAddHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateAddHTLC<>) as *mut _) }, is_owned: false })
9400 fn handle_update_fulfill_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFulfillHTLC) {
9401 (self.handle_update_fulfill_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFulfillHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateFulfillHTLC<>) as *mut _) }, is_owned: false })
9403 fn handle_update_fail_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailHTLC) {
9404 (self.handle_update_fail_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFailHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateFailHTLC<>) as *mut _) }, is_owned: false })
9406 fn handle_update_fail_malformed_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) {
9407 (self.handle_update_fail_malformed_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFailMalformedHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateFailMalformedHTLC<>) as *mut _) }, is_owned: false })
9409 fn handle_commitment_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::CommitmentSigned) {
9410 (self.handle_commitment_signed)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::CommitmentSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::CommitmentSigned<>) as *mut _) }, is_owned: false })
9412 fn handle_revoke_and_ack(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::RevokeAndACK) {
9413 (self.handle_revoke_and_ack)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::RevokeAndACK { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::RevokeAndACK<>) as *mut _) }, is_owned: false })
9415 fn handle_update_fee(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFee) {
9416 (self.handle_update_fee)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFee { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateFee<>) as *mut _) }, is_owned: false })
9418 fn handle_announcement_signatures(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AnnouncementSignatures) {
9419 (self.handle_announcement_signatures)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::AnnouncementSignatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::AnnouncementSignatures<>) as *mut _) }, is_owned: false })
9421 fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) {
9422 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id))
9424 fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
9425 let mut ret = (self.peer_connected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::Init<>) as *mut _) }, is_owned: false }, inbound);
9426 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
9429 fn handle_channel_reestablish(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReestablish) {
9430 (self.handle_channel_reestablish)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ChannelReestablish { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelReestablish<>) as *mut _) }, is_owned: false })
9432 fn handle_channel_update(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelUpdate) {
9433 (self.handle_channel_update)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ChannelUpdate { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelUpdate<>) as *mut _) }, is_owned: false })
9435 fn handle_error(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ErrorMessage) {
9436 (self.handle_error)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ErrorMessage { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ErrorMessage<>) as *mut _) }, is_owned: false })
9438 fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
9439 let mut ret = (self.provided_node_features)(self.this_arg);
9440 *unsafe { Box::from_raw(ret.take_inner()) }
9442 fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
9443 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
9444 *unsafe { Box::from_raw(ret.take_inner()) }
9446 fn get_chain_hashes(&self) -> Option<Vec<bitcoin::blockdata::constants::ChainHash>> {
9447 let mut ret = (self.get_chain_hashes)(self.this_arg);
9448 let mut local_ret = { /*ret*/ let ret_opt = ret; if ret_opt.is_none() { None } else { Some({ { let mut local_ret_0 = Vec::new(); for mut item in { ret_opt.take() }.into_rust().drain(..) { local_ret_0.push( { ::bitcoin::blockdata::constants::ChainHash::from(&item.data) }); }; local_ret_0 }})} };
9453 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
9454 // directly as a Deref trait in higher-level structs:
9455 impl core::ops::Deref for ChannelMessageHandler {
9457 fn deref(&self) -> &Self {
9461 impl core::ops::DerefMut for ChannelMessageHandler {
9462 fn deref_mut(&mut self) -> &mut Self {
9466 /// Calls the free function if one is set
9468 pub extern "C" fn ChannelMessageHandler_free(this_ptr: ChannelMessageHandler) { }
9469 impl Drop for ChannelMessageHandler {
9470 fn drop(&mut self) {
9471 if let Some(f) = self.free {
9476 /// A trait to describe an object which can receive routing messages.
9478 /// # Implementor DoS Warnings
9480 /// For messages enabled with the `gossip_queries` feature there are potential DoS vectors when
9481 /// handling inbound queries. Implementors using an on-disk network graph should be aware of
9482 /// repeated disk I/O for queries accessing different parts of the network graph.
9484 pub struct RoutingMessageHandler {
9485 /// An opaque pointer which is passed to your function implementations as an argument.
9486 /// This has no meaning in the LDK, and can be NULL or any other value.
9487 pub this_arg: *mut c_void,
9488 /// Handle an incoming `node_announcement` message, returning `true` if it should be forwarded on,
9489 /// `false` or returning an `Err` otherwise.
9490 pub handle_node_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
9491 /// Handle a `channel_announcement` message, returning `true` if it should be forwarded on, `false`
9492 /// or returning an `Err` otherwise.
9493 pub handle_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
9494 /// Handle an incoming `channel_update` message, returning true if it should be forwarded on,
9495 /// `false` or returning an `Err` otherwise.
9496 pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ,
9497 /// Gets channel announcements and updates required to dump our routing table to a remote node,
9498 /// starting at the `short_channel_id` indicated by `starting_point` and including announcements
9499 /// for a single channel.
9500 pub get_next_channel_announcement: extern "C" fn (this_arg: *const c_void, starting_point: u64) -> crate::c_types::derived::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ,
9501 /// Gets a node announcement required to dump our routing table to a remote node, starting at
9502 /// the node *after* the provided pubkey and including up to one announcement immediately
9503 /// higher (as defined by `<PublicKey as Ord>::cmp`) than `starting_point`.
9504 /// If `None` is provided for `starting_point`, we start at the first node.
9506 /// Note that starting_point (or a relevant inner pointer) may be NULL or all-0s to represent None
9507 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
9508 pub get_next_node_announcement: extern "C" fn (this_arg: *const c_void, starting_point: crate::lightning::routing::gossip::NodeId) -> crate::lightning::ln::msgs::NodeAnnouncement,
9509 /// Called when a connection is established with a peer. This can be used to
9510 /// perform routing table synchronization using a strategy defined by the
9513 /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
9514 /// with us. Implementors should be somewhat conservative about doing so, however, as other
9515 /// message handlers may still wish to communicate with this peer.
9516 pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, init: &crate::lightning::ln::msgs::Init, inbound: bool) -> crate::c_types::derived::CResult_NoneNoneZ,
9517 /// Handles the reply of a query we initiated to learn about channels
9518 /// for a given range of blocks. We can expect to receive one or more
9519 /// replies to a single query.
9520 pub handle_reply_channel_range: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ,
9521 /// Handles the reply of a query we initiated asking for routing gossip
9522 /// messages for a list of channels. We should receive this message when
9523 /// a node has completed its best effort to send us the pertaining routing
9524 /// gossip messages.
9525 pub handle_reply_short_channel_ids_end: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CResult_NoneLightningErrorZ,
9526 /// Handles when a peer asks us to send a list of `short_channel_id`s
9527 /// for the requested range of blocks.
9528 pub handle_query_channel_range: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ,
9529 /// Handles when a peer asks us to send routing gossip messages for a
9530 /// list of `short_channel_id`s.
9531 pub handle_query_short_channel_ids: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CResult_NoneLightningErrorZ,
9532 /// Indicates that there are a large number of [`ChannelAnnouncement`] (or other) messages
9533 /// pending some async action. While there is no guarantee of the rate of future messages, the
9534 /// caller should seek to reduce the rate of new gossip messages handled, especially
9535 /// [`ChannelAnnouncement`]s.
9536 pub processing_queue_high: extern "C" fn (this_arg: *const c_void) -> bool,
9537 /// Gets the node feature flags which this handler itself supports. All available handlers are
9538 /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
9539 /// which are broadcasted in our [`NodeAnnouncement`] message.
9540 pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
9541 /// Gets the init feature flags which should be sent to the given peer. All available handlers
9542 /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
9543 /// which are sent in our [`Init`] message.
9545 /// Note that this method is called before [`Self::peer_connected`].
9546 pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
9547 /// Implementation of MessageSendEventsProvider for this object.
9548 pub MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider,
9549 /// Frees any resources associated with this object given its this_arg pointer.
9550 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
9551 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
9553 unsafe impl Send for RoutingMessageHandler {}
9554 unsafe impl Sync for RoutingMessageHandler {}
9556 pub(crate) fn RoutingMessageHandler_clone_fields(orig: &RoutingMessageHandler) -> RoutingMessageHandler {
9557 RoutingMessageHandler {
9558 this_arg: orig.this_arg,
9559 handle_node_announcement: Clone::clone(&orig.handle_node_announcement),
9560 handle_channel_announcement: Clone::clone(&orig.handle_channel_announcement),
9561 handle_channel_update: Clone::clone(&orig.handle_channel_update),
9562 get_next_channel_announcement: Clone::clone(&orig.get_next_channel_announcement),
9563 get_next_node_announcement: Clone::clone(&orig.get_next_node_announcement),
9564 peer_connected: Clone::clone(&orig.peer_connected),
9565 handle_reply_channel_range: Clone::clone(&orig.handle_reply_channel_range),
9566 handle_reply_short_channel_ids_end: Clone::clone(&orig.handle_reply_short_channel_ids_end),
9567 handle_query_channel_range: Clone::clone(&orig.handle_query_channel_range),
9568 handle_query_short_channel_ids: Clone::clone(&orig.handle_query_short_channel_ids),
9569 processing_queue_high: Clone::clone(&orig.processing_queue_high),
9570 provided_node_features: Clone::clone(&orig.provided_node_features),
9571 provided_init_features: Clone::clone(&orig.provided_init_features),
9572 MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
9573 free: Clone::clone(&orig.free),
9576 impl lightning::events::MessageSendEventsProvider for RoutingMessageHandler {
9577 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::events::MessageSendEvent> {
9578 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
9579 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
9584 use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler;
9585 impl rustRoutingMessageHandler for RoutingMessageHandler {
9586 fn handle_node_announcement(&self, mut msg: &lightning::ln::msgs::NodeAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
9587 let mut ret = (self.handle_node_announcement)(self.this_arg, &crate::lightning::ln::msgs::NodeAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::NodeAnnouncement<>) as *mut _) }, is_owned: false });
9588 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
9591 fn handle_channel_announcement(&self, mut msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
9592 let mut ret = (self.handle_channel_announcement)(self.this_arg, &crate::lightning::ln::msgs::ChannelAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelAnnouncement<>) as *mut _) }, is_owned: false });
9593 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
9596 fn handle_channel_update(&self, mut msg: &lightning::ln::msgs::ChannelUpdate) -> Result<bool, lightning::ln::msgs::LightningError> {
9597 let mut ret = (self.handle_channel_update)(self.this_arg, &crate::lightning::ln::msgs::ChannelUpdate { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelUpdate<>) as *mut _) }, is_owned: false });
9598 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
9601 fn get_next_channel_announcement(&self, mut starting_point: u64) -> Option<(lightning::ln::msgs::ChannelAnnouncement, Option<lightning::ln::msgs::ChannelUpdate>, Option<lightning::ln::msgs::ChannelUpdate>)> {
9602 let mut ret = (self.get_next_channel_announcement)(self.this_arg, starting_point);
9603 let mut local_ret = if ret.is_some() { Some( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = ret.take().to_rust(); let mut local_orig_ret_0_1 = if orig_ret_0_1.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(orig_ret_0_1.take_inner()) } }) }; let mut local_orig_ret_0_2 = if orig_ret_0_2.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(orig_ret_0_2.take_inner()) } }) }; let mut local_ret_0 = (*unsafe { Box::from_raw(orig_ret_0_0.take_inner()) }, local_orig_ret_0_1, local_orig_ret_0_2); local_ret_0 }) } else { None };
9606 fn get_next_node_announcement(&self, mut starting_point: Option<&lightning::routing::gossip::NodeId>) -> Option<lightning::ln::msgs::NodeAnnouncement> {
9607 let mut local_starting_point = crate::lightning::routing::gossip::NodeId { inner: unsafe { (if starting_point.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (starting_point.unwrap()) }) } as *const lightning::routing::gossip::NodeId<>) as *mut _ }, is_owned: false };
9608 let mut ret = (self.get_next_node_announcement)(self.this_arg, local_starting_point);
9609 let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) };
9612 fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
9613 let mut ret = (self.peer_connected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { ObjOps::nonnull_ptr_to_inner((init as *const lightning::ln::msgs::Init<>) as *mut _) }, is_owned: false }, inbound);
9614 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
9617 fn handle_reply_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::ReplyChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
9618 let mut ret = (self.handle_reply_channel_range)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::msgs::ReplyChannelRange { inner: ObjOps::heap_alloc(msg), is_owned: true });
9619 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
9622 fn handle_reply_short_channel_ids_end(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::ReplyShortChannelIdsEnd) -> Result<(), lightning::ln::msgs::LightningError> {
9623 let mut ret = (self.handle_reply_short_channel_ids_end)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::msgs::ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(msg), is_owned: true });
9624 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
9627 fn handle_query_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::QueryChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
9628 let mut ret = (self.handle_query_channel_range)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::msgs::QueryChannelRange { inner: ObjOps::heap_alloc(msg), is_owned: true });
9629 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
9632 fn handle_query_short_channel_ids(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::QueryShortChannelIds) -> Result<(), lightning::ln::msgs::LightningError> {
9633 let mut ret = (self.handle_query_short_channel_ids)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::msgs::QueryShortChannelIds { inner: ObjOps::heap_alloc(msg), is_owned: true });
9634 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
9637 fn processing_queue_high(&self) -> bool {
9638 let mut ret = (self.processing_queue_high)(self.this_arg);
9641 fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
9642 let mut ret = (self.provided_node_features)(self.this_arg);
9643 *unsafe { Box::from_raw(ret.take_inner()) }
9645 fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
9646 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
9647 *unsafe { Box::from_raw(ret.take_inner()) }
9651 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
9652 // directly as a Deref trait in higher-level structs:
9653 impl core::ops::Deref for RoutingMessageHandler {
9655 fn deref(&self) -> &Self {
9659 impl core::ops::DerefMut for RoutingMessageHandler {
9660 fn deref_mut(&mut self) -> &mut Self {
9664 /// Calls the free function if one is set
9666 pub extern "C" fn RoutingMessageHandler_free(this_ptr: RoutingMessageHandler) { }
9667 impl Drop for RoutingMessageHandler {
9668 fn drop(&mut self) {
9669 if let Some(f) = self.free {
9674 /// A handler for received [`OnionMessage`]s and for providing generated ones to send.
9676 pub struct OnionMessageHandler {
9677 /// An opaque pointer which is passed to your function implementations as an argument.
9678 /// This has no meaning in the LDK, and can be NULL or any other value.
9679 pub this_arg: *mut c_void,
9680 /// Because much of the lightning network does not yet support forwarding onion messages, we
9681 /// may need to directly connect to a node which will forward a message for us. In such a case,
9682 /// this method will return the set of nodes which need connection by node_id and the
9683 /// corresponding socket addresses where they may accept incoming connections.
9685 /// Thus, this method should be polled regularly to detect messages await such a direct
9687 pub get_and_clear_connections_needed: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ,
9688 /// Handle an incoming `onion_message` message from the given peer.
9689 pub handle_onion_message: extern "C" fn (this_arg: *const c_void, peer_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OnionMessage),
9690 /// Returns the next pending onion message for the peer with the given node id.
9692 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
9693 pub next_onion_message_for_peer: extern "C" fn (this_arg: *const c_void, peer_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::msgs::OnionMessage,
9694 /// Called when a connection is established with a peer. Can be used to track which peers
9695 /// advertise onion message support and are online.
9697 /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
9698 /// with us. Implementors should be somewhat conservative about doing so, however, as other
9699 /// message handlers may still wish to communicate with this peer.
9700 pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, init: &crate::lightning::ln::msgs::Init, inbound: bool) -> crate::c_types::derived::CResult_NoneNoneZ,
9701 /// Indicates a connection to the peer failed/an existing connection was lost. Allows handlers to
9702 /// drop and refuse to forward onion messages to this peer.
9703 pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey),
9704 /// Performs actions that should happen roughly every ten seconds after startup. Allows handlers
9705 /// to drop any buffered onion messages intended for prospective peers.
9706 pub timer_tick_occurred: extern "C" fn (this_arg: *const c_void),
9707 /// Gets the node feature flags which this handler itself supports. All available handlers are
9708 /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
9709 /// which are broadcasted in our [`NodeAnnouncement`] message.
9710 pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
9711 /// Gets the init feature flags which should be sent to the given peer. All available handlers
9712 /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
9713 /// which are sent in our [`Init`] message.
9715 /// Note that this method is called before [`Self::peer_connected`].
9716 pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
9717 /// Frees any resources associated with this object given its this_arg pointer.
9718 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
9719 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
9721 unsafe impl Send for OnionMessageHandler {}
9722 unsafe impl Sync for OnionMessageHandler {}
9724 pub(crate) fn OnionMessageHandler_clone_fields(orig: &OnionMessageHandler) -> OnionMessageHandler {
9725 OnionMessageHandler {
9726 this_arg: orig.this_arg,
9727 get_and_clear_connections_needed: Clone::clone(&orig.get_and_clear_connections_needed),
9728 handle_onion_message: Clone::clone(&orig.handle_onion_message),
9729 next_onion_message_for_peer: Clone::clone(&orig.next_onion_message_for_peer),
9730 peer_connected: Clone::clone(&orig.peer_connected),
9731 peer_disconnected: Clone::clone(&orig.peer_disconnected),
9732 timer_tick_occurred: Clone::clone(&orig.timer_tick_occurred),
9733 provided_node_features: Clone::clone(&orig.provided_node_features),
9734 provided_init_features: Clone::clone(&orig.provided_init_features),
9735 free: Clone::clone(&orig.free),
9739 use lightning::ln::msgs::OnionMessageHandler as rustOnionMessageHandler;
9740 impl rustOnionMessageHandler for OnionMessageHandler {
9741 fn get_and_clear_connections_needed(&self) -> Vec<(bitcoin::secp256k1::PublicKey, Vec<lightning::ln::msgs::SocketAddress>)> {
9742 let mut ret = (self.get_and_clear_connections_needed)(self.this_arg);
9743 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item.to_rust(); let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.into_rust().drain(..) { local_orig_ret_0_1.push( { item.into_native() }); }; let mut local_ret_0 = (orig_ret_0_0.into_rust(), local_orig_ret_0_1); local_ret_0 }); };
9746 fn handle_onion_message(&self, mut peer_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OnionMessage) {
9747 (self.handle_onion_message)(self.this_arg, crate::c_types::PublicKey::from_rust(&peer_node_id), &crate::lightning::ln::msgs::OnionMessage { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::OnionMessage<>) as *mut _) }, is_owned: false })
9749 fn next_onion_message_for_peer(&self, mut peer_node_id: bitcoin::secp256k1::PublicKey) -> Option<lightning::ln::msgs::OnionMessage> {
9750 let mut ret = (self.next_onion_message_for_peer)(self.this_arg, crate::c_types::PublicKey::from_rust(&peer_node_id));
9751 let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) };
9754 fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
9755 let mut ret = (self.peer_connected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { ObjOps::nonnull_ptr_to_inner((init as *const lightning::ln::msgs::Init<>) as *mut _) }, is_owned: false }, inbound);
9756 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
9759 fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) {
9760 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id))
9762 fn timer_tick_occurred(&self) {
9763 (self.timer_tick_occurred)(self.this_arg)
9765 fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
9766 let mut ret = (self.provided_node_features)(self.this_arg);
9767 *unsafe { Box::from_raw(ret.take_inner()) }
9769 fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
9770 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
9771 *unsafe { Box::from_raw(ret.take_inner()) }
9775 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
9776 // directly as a Deref trait in higher-level structs:
9777 impl core::ops::Deref for OnionMessageHandler {
9779 fn deref(&self) -> &Self {
9783 impl core::ops::DerefMut for OnionMessageHandler {
9784 fn deref_mut(&mut self) -> &mut Self {
9788 /// Calls the free function if one is set
9790 pub extern "C" fn OnionMessageHandler_free(this_ptr: OnionMessageHandler) { }
9791 impl Drop for OnionMessageHandler {
9792 fn drop(&mut self) {
9793 if let Some(f) = self.free {
9799 use lightning::ln::msgs::FinalOnionHopData as nativeFinalOnionHopDataImport;
9800 pub(crate) type nativeFinalOnionHopData = nativeFinalOnionHopDataImport;
9802 /// Information communicated in the onion to the recipient for multi-part tracking and proof that
9803 /// the payment is associated with an invoice.
9806 pub struct FinalOnionHopData {
9807 /// A pointer to the opaque Rust object.
9809 /// Nearly everywhere, inner must be non-null, however in places where
9810 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
9811 pub inner: *mut nativeFinalOnionHopData,
9812 /// Indicates that this is the only struct which contains the same pointer.
9814 /// Rust functions which take ownership of an object provided via an argument require
9815 /// this to be true and invalidate the object pointed to by inner.
9819 impl Drop for FinalOnionHopData {
9820 fn drop(&mut self) {
9821 if self.is_owned && !<*mut nativeFinalOnionHopData>::is_null(self.inner) {
9822 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
9826 /// Frees any resources used by the FinalOnionHopData, if is_owned is set and inner is non-NULL.
9828 pub extern "C" fn FinalOnionHopData_free(this_obj: FinalOnionHopData) { }
9830 /// Used only if an object of this type is returned as a trait impl by a method
9831 pub(crate) extern "C" fn FinalOnionHopData_free_void(this_ptr: *mut c_void) {
9832 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeFinalOnionHopData) };
9835 impl FinalOnionHopData {
9836 pub(crate) fn get_native_ref(&self) -> &'static nativeFinalOnionHopData {
9837 unsafe { &*ObjOps::untweak_ptr(self.inner) }
9839 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFinalOnionHopData {
9840 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
9842 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
9843 pub(crate) fn take_inner(mut self) -> *mut nativeFinalOnionHopData {
9844 assert!(self.is_owned);
9845 let ret = ObjOps::untweak_ptr(self.inner);
9846 self.inner = core::ptr::null_mut();
9850 /// When sending a multi-part payment, this secret is used to identify a payment across HTLCs.
9851 /// Because it is generated by the recipient and included in the invoice, it also provides
9852 /// proof to the recipient that the payment was sent by someone with the generated invoice.
9854 pub extern "C" fn FinalOnionHopData_get_payment_secret(this_ptr: &FinalOnionHopData) -> *const [u8; 32] {
9855 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_secret;
9858 /// When sending a multi-part payment, this secret is used to identify a payment across HTLCs.
9859 /// Because it is generated by the recipient and included in the invoice, it also provides
9860 /// proof to the recipient that the payment was sent by someone with the generated invoice.
9862 pub extern "C" fn FinalOnionHopData_set_payment_secret(this_ptr: &mut FinalOnionHopData, mut val: crate::c_types::ThirtyTwoBytes) {
9863 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_secret = ::lightning::ln::types::PaymentSecret(val.data);
9865 /// The intended total amount that this payment is for.
9867 /// Message serialization may panic if this value is more than 21 million Bitcoin.
9869 pub extern "C" fn FinalOnionHopData_get_total_msat(this_ptr: &FinalOnionHopData) -> u64 {
9870 let mut inner_val = &mut this_ptr.get_native_mut_ref().total_msat;
9873 /// The intended total amount that this payment is for.
9875 /// Message serialization may panic if this value is more than 21 million Bitcoin.
9877 pub extern "C" fn FinalOnionHopData_set_total_msat(this_ptr: &mut FinalOnionHopData, mut val: u64) {
9878 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.total_msat = val;
9880 /// Constructs a new FinalOnionHopData given each field
9883 pub extern "C" fn FinalOnionHopData_new(mut payment_secret_arg: crate::c_types::ThirtyTwoBytes, mut total_msat_arg: u64) -> FinalOnionHopData {
9884 FinalOnionHopData { inner: ObjOps::heap_alloc(nativeFinalOnionHopData {
9885 payment_secret: ::lightning::ln::types::PaymentSecret(payment_secret_arg.data),
9886 total_msat: total_msat_arg,
9887 }), is_owned: true }
9889 impl Clone for FinalOnionHopData {
9890 fn clone(&self) -> Self {
9892 inner: if <*mut nativeFinalOnionHopData>::is_null(self.inner) { core::ptr::null_mut() } else {
9893 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
9899 /// Used only if an object of this type is returned as a trait impl by a method
9900 pub(crate) extern "C" fn FinalOnionHopData_clone_void(this_ptr: *const c_void) -> *mut c_void {
9901 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeFinalOnionHopData)).clone() })) as *mut c_void
9904 /// Creates a copy of the FinalOnionHopData
9905 pub extern "C" fn FinalOnionHopData_clone(orig: &FinalOnionHopData) -> FinalOnionHopData {
9908 mod fuzzy_internal_msgs {
9910 use alloc::str::FromStr;
9911 use alloc::string::String;
9912 use core::ffi::c_void;
9913 use core::convert::Infallible;
9914 use bitcoin::hashes::Hash;
9915 use crate::c_types::*;
9916 #[cfg(feature="no-std")]
9917 use alloc::{vec::Vec, boxed::Box};
9921 use lightning::ln::msgs::OnionPacket as nativeOnionPacketImport;
9922 pub(crate) type nativeOnionPacket = nativeOnionPacketImport;
9924 /// BOLT 4 onion packet including hop data for the next peer.
9927 pub struct OnionPacket {
9928 /// A pointer to the opaque Rust object.
9930 /// Nearly everywhere, inner must be non-null, however in places where
9931 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
9932 pub inner: *mut nativeOnionPacket,
9933 /// Indicates that this is the only struct which contains the same pointer.
9935 /// Rust functions which take ownership of an object provided via an argument require
9936 /// this to be true and invalidate the object pointed to by inner.
9940 impl Drop for OnionPacket {
9941 fn drop(&mut self) {
9942 if self.is_owned && !<*mut nativeOnionPacket>::is_null(self.inner) {
9943 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
9947 /// Frees any resources used by the OnionPacket, if is_owned is set and inner is non-NULL.
9949 pub extern "C" fn OnionPacket_free(this_obj: OnionPacket) { }
9951 /// Used only if an object of this type is returned as a trait impl by a method
9952 pub(crate) extern "C" fn OnionPacket_free_void(this_ptr: *mut c_void) {
9953 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOnionPacket) };
9957 pub(crate) fn get_native_ref(&self) -> &'static nativeOnionPacket {
9958 unsafe { &*ObjOps::untweak_ptr(self.inner) }
9960 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOnionPacket {
9961 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
9963 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
9964 pub(crate) fn take_inner(mut self) -> *mut nativeOnionPacket {
9965 assert!(self.is_owned);
9966 let ret = ObjOps::untweak_ptr(self.inner);
9967 self.inner = core::ptr::null_mut();
9971 /// BOLT 4 version number.
9973 pub extern "C" fn OnionPacket_get_version(this_ptr: &OnionPacket) -> u8 {
9974 let mut inner_val = &mut this_ptr.get_native_mut_ref().version;
9977 /// BOLT 4 version number.
9979 pub extern "C" fn OnionPacket_set_version(this_ptr: &mut OnionPacket, mut val: u8) {
9980 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.version = val;
9982 /// In order to ensure we always return an error on onion decode in compliance with [BOLT
9983 /// #4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md), we have to
9984 /// deserialize `OnionPacket`s contained in [`UpdateAddHTLC`] messages even if the ephemeral
9985 /// public key (here) is bogus, so we hold a [`Result`] instead of a [`PublicKey`] as we'd
9988 /// Returns a copy of the field.
9990 pub extern "C" fn OnionPacket_get_public_key(this_ptr: &OnionPacket) -> crate::c_types::derived::CResult_PublicKeySecp256k1ErrorZ {
9991 let mut inner_val = this_ptr.get_native_mut_ref().public_key.clone();
9992 let mut local_inner_val = match inner_val { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::PublicKey::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }).into() };
9995 /// In order to ensure we always return an error on onion decode in compliance with [BOLT
9996 /// #4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md), we have to
9997 /// deserialize `OnionPacket`s contained in [`UpdateAddHTLC`] messages even if the ephemeral
9998 /// public key (here) is bogus, so we hold a [`Result`] instead of a [`PublicKey`] as we'd
10001 pub extern "C" fn OnionPacket_set_public_key(this_ptr: &mut OnionPacket, mut val: crate::c_types::derived::CResult_PublicKeySecp256k1ErrorZ) {
10002 let mut local_val = match val.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut val.contents.result)) }).into_rust() }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut val.contents.err)) }).into_rust() })};
10003 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.public_key = local_val;
10005 /// HMAC to verify the integrity of hop_data.
10007 pub extern "C" fn OnionPacket_get_hmac(this_ptr: &OnionPacket) -> *const [u8; 32] {
10008 let mut inner_val = &mut this_ptr.get_native_mut_ref().hmac;
10011 /// HMAC to verify the integrity of hop_data.
10013 pub extern "C" fn OnionPacket_set_hmac(this_ptr: &mut OnionPacket, mut val: crate::c_types::ThirtyTwoBytes) {
10014 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.hmac = val.data;
10016 impl Clone for OnionPacket {
10017 fn clone(&self) -> Self {
10019 inner: if <*mut nativeOnionPacket>::is_null(self.inner) { core::ptr::null_mut() } else {
10020 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
10026 /// Used only if an object of this type is returned as a trait impl by a method
10027 pub(crate) extern "C" fn OnionPacket_clone_void(this_ptr: *const c_void) -> *mut c_void {
10028 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOnionPacket)).clone() })) as *mut c_void
10031 /// Creates a copy of the OnionPacket
10032 pub extern "C" fn OnionPacket_clone(orig: &OnionPacket) -> OnionPacket {
10035 /// Generates a non-cryptographic 64-bit hash of the OnionPacket.
10037 pub extern "C" fn OnionPacket_hash(o: &OnionPacket) -> u64 {
10038 if o.inner.is_null() { return 0; }
10039 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
10040 #[allow(deprecated)]
10041 let mut hasher = core::hash::SipHasher::new();
10042 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
10043 core::hash::Hasher::finish(&hasher)
10045 /// Checks if two OnionPackets contain equal inner contents.
10046 /// This ignores pointers and is_owned flags and looks at the values in fields.
10047 /// Two objects with NULL inner values will be considered "equal" here.
10049 pub extern "C" fn OnionPacket_eq(a: &OnionPacket, b: &OnionPacket) -> bool {
10050 if a.inner == b.inner { return true; }
10051 if a.inner.is_null() || b.inner.is_null() { return false; }
10052 if a.get_native_ref() == b.get_native_ref() { true } else { false }
10054 /// Get a string which allows debug introspection of a OnionPacket object
10055 pub extern "C" fn OnionPacket_debug_str_void(o: *const c_void) -> Str {
10056 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::OnionPacket }).into()}
10058 use lightning::ln::msgs::TrampolineOnionPacket as nativeTrampolineOnionPacketImport;
10059 pub(crate) type nativeTrampolineOnionPacket = nativeTrampolineOnionPacketImport;
10061 /// BOLT 4 onion packet including hop data for the next peer.
10064 pub struct TrampolineOnionPacket {
10065 /// A pointer to the opaque Rust object.
10067 /// Nearly everywhere, inner must be non-null, however in places where
10068 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
10069 pub inner: *mut nativeTrampolineOnionPacket,
10070 /// Indicates that this is the only struct which contains the same pointer.
10072 /// Rust functions which take ownership of an object provided via an argument require
10073 /// this to be true and invalidate the object pointed to by inner.
10074 pub is_owned: bool,
10077 impl Drop for TrampolineOnionPacket {
10078 fn drop(&mut self) {
10079 if self.is_owned && !<*mut nativeTrampolineOnionPacket>::is_null(self.inner) {
10080 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
10084 /// Frees any resources used by the TrampolineOnionPacket, if is_owned is set and inner is non-NULL.
10086 pub extern "C" fn TrampolineOnionPacket_free(this_obj: TrampolineOnionPacket) { }
10088 /// Used only if an object of this type is returned as a trait impl by a method
10089 pub(crate) extern "C" fn TrampolineOnionPacket_free_void(this_ptr: *mut c_void) {
10090 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTrampolineOnionPacket) };
10093 impl TrampolineOnionPacket {
10094 pub(crate) fn get_native_ref(&self) -> &'static nativeTrampolineOnionPacket {
10095 unsafe { &*ObjOps::untweak_ptr(self.inner) }
10097 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTrampolineOnionPacket {
10098 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
10100 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
10101 pub(crate) fn take_inner(mut self) -> *mut nativeTrampolineOnionPacket {
10102 assert!(self.is_owned);
10103 let ret = ObjOps::untweak_ptr(self.inner);
10104 self.inner = core::ptr::null_mut();
10108 /// Bolt 04 version number
10110 pub extern "C" fn TrampolineOnionPacket_get_version(this_ptr: &TrampolineOnionPacket) -> u8 {
10111 let mut inner_val = &mut this_ptr.get_native_mut_ref().version;
10114 /// Bolt 04 version number
10116 pub extern "C" fn TrampolineOnionPacket_set_version(this_ptr: &mut TrampolineOnionPacket, mut val: u8) {
10117 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.version = val;
10119 /// A random sepc256k1 point, used to build the ECDH shared secret to decrypt hop_data
10121 pub extern "C" fn TrampolineOnionPacket_get_public_key(this_ptr: &TrampolineOnionPacket) -> crate::c_types::PublicKey {
10122 let mut inner_val = &mut this_ptr.get_native_mut_ref().public_key;
10123 crate::c_types::PublicKey::from_rust(&inner_val)
10125 /// A random sepc256k1 point, used to build the ECDH shared secret to decrypt hop_data
10127 pub extern "C" fn TrampolineOnionPacket_set_public_key(this_ptr: &mut TrampolineOnionPacket, mut val: crate::c_types::PublicKey) {
10128 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.public_key = val.into_rust();
10130 /// Encrypted payload for the next hop
10132 /// Returns a copy of the field.
10134 pub extern "C" fn TrampolineOnionPacket_get_hop_data(this_ptr: &TrampolineOnionPacket) -> crate::c_types::derived::CVec_u8Z {
10135 let mut inner_val = this_ptr.get_native_mut_ref().hop_data.clone();
10136 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
10137 local_inner_val.into()
10139 /// Encrypted payload for the next hop
10141 pub extern "C" fn TrampolineOnionPacket_set_hop_data(this_ptr: &mut TrampolineOnionPacket, mut val: crate::c_types::derived::CVec_u8Z) {
10142 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
10143 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.hop_data = local_val;
10145 /// HMAC to verify the integrity of hop_data
10147 pub extern "C" fn TrampolineOnionPacket_get_hmac(this_ptr: &TrampolineOnionPacket) -> *const [u8; 32] {
10148 let mut inner_val = &mut this_ptr.get_native_mut_ref().hmac;
10151 /// HMAC to verify the integrity of hop_data
10153 pub extern "C" fn TrampolineOnionPacket_set_hmac(this_ptr: &mut TrampolineOnionPacket, mut val: crate::c_types::ThirtyTwoBytes) {
10154 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.hmac = val.data;
10156 /// Constructs a new TrampolineOnionPacket given each field
10159 pub extern "C" fn TrampolineOnionPacket_new(mut version_arg: u8, mut public_key_arg: crate::c_types::PublicKey, mut hop_data_arg: crate::c_types::derived::CVec_u8Z, mut hmac_arg: crate::c_types::ThirtyTwoBytes) -> TrampolineOnionPacket {
10160 let mut local_hop_data_arg = Vec::new(); for mut item in hop_data_arg.into_rust().drain(..) { local_hop_data_arg.push( { item }); };
10161 TrampolineOnionPacket { inner: ObjOps::heap_alloc(nativeTrampolineOnionPacket {
10162 version: version_arg,
10163 public_key: public_key_arg.into_rust(),
10164 hop_data: local_hop_data_arg,
10165 hmac: hmac_arg.data,
10166 }), is_owned: true }
10168 impl Clone for TrampolineOnionPacket {
10169 fn clone(&self) -> Self {
10171 inner: if <*mut nativeTrampolineOnionPacket>::is_null(self.inner) { core::ptr::null_mut() } else {
10172 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
10178 /// Used only if an object of this type is returned as a trait impl by a method
10179 pub(crate) extern "C" fn TrampolineOnionPacket_clone_void(this_ptr: *const c_void) -> *mut c_void {
10180 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTrampolineOnionPacket)).clone() })) as *mut c_void
10183 /// Creates a copy of the TrampolineOnionPacket
10184 pub extern "C" fn TrampolineOnionPacket_clone(orig: &TrampolineOnionPacket) -> TrampolineOnionPacket {
10187 /// Generates a non-cryptographic 64-bit hash of the TrampolineOnionPacket.
10189 pub extern "C" fn TrampolineOnionPacket_hash(o: &TrampolineOnionPacket) -> u64 {
10190 if o.inner.is_null() { return 0; }
10191 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
10192 #[allow(deprecated)]
10193 let mut hasher = core::hash::SipHasher::new();
10194 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
10195 core::hash::Hasher::finish(&hasher)
10197 /// Checks if two TrampolineOnionPackets contain equal inner contents.
10198 /// This ignores pointers and is_owned flags and looks at the values in fields.
10199 /// Two objects with NULL inner values will be considered "equal" here.
10201 pub extern "C" fn TrampolineOnionPacket_eq(a: &TrampolineOnionPacket, b: &TrampolineOnionPacket) -> bool {
10202 if a.inner == b.inner { return true; }
10203 if a.inner.is_null() || b.inner.is_null() { return false; }
10204 if a.get_native_ref() == b.get_native_ref() { true } else { false }
10207 /// Serialize the TrampolineOnionPacket object into a byte array which can be read by TrampolineOnionPacket_read
10208 pub extern "C" fn TrampolineOnionPacket_write(obj: &crate::lightning::ln::msgs::TrampolineOnionPacket) -> crate::c_types::derived::CVec_u8Z {
10209 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10212 pub(crate) extern "C" fn TrampolineOnionPacket_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10213 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTrampolineOnionPacket) })
10215 /// Get a string which allows debug introspection of a TrampolineOnionPacket object
10216 pub extern "C" fn TrampolineOnionPacket_debug_str_void(o: *const c_void) -> Str {
10217 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TrampolineOnionPacket }).into()}
10219 /// Get the string representation of a DecodeError object
10220 pub extern "C" fn DecodeError_to_str(o: &crate::lightning::ln::msgs::DecodeError) -> Str {
10221 alloc::format!("{}", &o.to_native()).into()
10224 /// Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read
10225 pub extern "C" fn AcceptChannel_write(obj: &crate::lightning::ln::msgs::AcceptChannel) -> crate::c_types::derived::CVec_u8Z {
10226 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10229 pub(crate) extern "C" fn AcceptChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10230 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannel) })
10233 /// Read a AcceptChannel from a byte array, created by AcceptChannel_write
10234 pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelDecodeErrorZ {
10235 let res: Result<lightning::ln::msgs::AcceptChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10236 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::AcceptChannel { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10240 /// Serialize the AcceptChannelV2 object into a byte array which can be read by AcceptChannelV2_read
10241 pub extern "C" fn AcceptChannelV2_write(obj: &crate::lightning::ln::msgs::AcceptChannelV2) -> crate::c_types::derived::CVec_u8Z {
10242 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10245 pub(crate) extern "C" fn AcceptChannelV2_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10246 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannelV2) })
10249 /// Read a AcceptChannelV2 from a byte array, created by AcceptChannelV2_write
10250 pub extern "C" fn AcceptChannelV2_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelV2DecodeErrorZ {
10251 let res: Result<lightning::ln::msgs::AcceptChannelV2, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10252 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::AcceptChannelV2 { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10256 /// Serialize the Stfu object into a byte array which can be read by Stfu_read
10257 pub extern "C" fn Stfu_write(obj: &crate::lightning::ln::msgs::Stfu) -> crate::c_types::derived::CVec_u8Z {
10258 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10261 pub(crate) extern "C" fn Stfu_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10262 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeStfu) })
10265 /// Read a Stfu from a byte array, created by Stfu_write
10266 pub extern "C" fn Stfu_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_StfuDecodeErrorZ {
10267 let res: Result<lightning::ln::msgs::Stfu, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10268 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::Stfu { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10272 /// Serialize the Splice object into a byte array which can be read by Splice_read
10273 pub extern "C" fn Splice_write(obj: &crate::lightning::ln::msgs::Splice) -> crate::c_types::derived::CVec_u8Z {
10274 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10277 pub(crate) extern "C" fn Splice_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10278 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeSplice) })
10281 /// Read a Splice from a byte array, created by Splice_write
10282 pub extern "C" fn Splice_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SpliceDecodeErrorZ {
10283 let res: Result<lightning::ln::msgs::Splice, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10284 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::Splice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10288 /// Serialize the SpliceAck object into a byte array which can be read by SpliceAck_read
10289 pub extern "C" fn SpliceAck_write(obj: &crate::lightning::ln::msgs::SpliceAck) -> crate::c_types::derived::CVec_u8Z {
10290 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10293 pub(crate) extern "C" fn SpliceAck_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10294 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeSpliceAck) })
10297 /// Read a SpliceAck from a byte array, created by SpliceAck_write
10298 pub extern "C" fn SpliceAck_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SpliceAckDecodeErrorZ {
10299 let res: Result<lightning::ln::msgs::SpliceAck, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10300 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::SpliceAck { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10304 /// Serialize the SpliceLocked object into a byte array which can be read by SpliceLocked_read
10305 pub extern "C" fn SpliceLocked_write(obj: &crate::lightning::ln::msgs::SpliceLocked) -> crate::c_types::derived::CVec_u8Z {
10306 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10309 pub(crate) extern "C" fn SpliceLocked_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10310 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeSpliceLocked) })
10313 /// Read a SpliceLocked from a byte array, created by SpliceLocked_write
10314 pub extern "C" fn SpliceLocked_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SpliceLockedDecodeErrorZ {
10315 let res: Result<lightning::ln::msgs::SpliceLocked, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10316 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::SpliceLocked { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10320 /// Serialize the TxAddInput object into a byte array which can be read by TxAddInput_read
10321 pub extern "C" fn TxAddInput_write(obj: &crate::lightning::ln::msgs::TxAddInput) -> crate::c_types::derived::CVec_u8Z {
10322 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10325 pub(crate) extern "C" fn TxAddInput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10326 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAddInput) })
10329 /// Read a TxAddInput from a byte array, created by TxAddInput_write
10330 pub extern "C" fn TxAddInput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAddInputDecodeErrorZ {
10331 let res: Result<lightning::ln::msgs::TxAddInput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10332 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxAddInput { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10336 /// Serialize the TxAddOutput object into a byte array which can be read by TxAddOutput_read
10337 pub extern "C" fn TxAddOutput_write(obj: &crate::lightning::ln::msgs::TxAddOutput) -> crate::c_types::derived::CVec_u8Z {
10338 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10341 pub(crate) extern "C" fn TxAddOutput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10342 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAddOutput) })
10345 /// Read a TxAddOutput from a byte array, created by TxAddOutput_write
10346 pub extern "C" fn TxAddOutput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAddOutputDecodeErrorZ {
10347 let res: Result<lightning::ln::msgs::TxAddOutput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10348 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxAddOutput { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10352 /// Serialize the TxRemoveInput object into a byte array which can be read by TxRemoveInput_read
10353 pub extern "C" fn TxRemoveInput_write(obj: &crate::lightning::ln::msgs::TxRemoveInput) -> crate::c_types::derived::CVec_u8Z {
10354 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10357 pub(crate) extern "C" fn TxRemoveInput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10358 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxRemoveInput) })
10361 /// Read a TxRemoveInput from a byte array, created by TxRemoveInput_write
10362 pub extern "C" fn TxRemoveInput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxRemoveInputDecodeErrorZ {
10363 let res: Result<lightning::ln::msgs::TxRemoveInput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10364 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxRemoveInput { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10368 /// Serialize the TxRemoveOutput object into a byte array which can be read by TxRemoveOutput_read
10369 pub extern "C" fn TxRemoveOutput_write(obj: &crate::lightning::ln::msgs::TxRemoveOutput) -> crate::c_types::derived::CVec_u8Z {
10370 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10373 pub(crate) extern "C" fn TxRemoveOutput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10374 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxRemoveOutput) })
10377 /// Read a TxRemoveOutput from a byte array, created by TxRemoveOutput_write
10378 pub extern "C" fn TxRemoveOutput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxRemoveOutputDecodeErrorZ {
10379 let res: Result<lightning::ln::msgs::TxRemoveOutput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10380 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxRemoveOutput { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10384 /// Serialize the TxComplete object into a byte array which can be read by TxComplete_read
10385 pub extern "C" fn TxComplete_write(obj: &crate::lightning::ln::msgs::TxComplete) -> crate::c_types::derived::CVec_u8Z {
10386 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10389 pub(crate) extern "C" fn TxComplete_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10390 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxComplete) })
10393 /// Read a TxComplete from a byte array, created by TxComplete_write
10394 pub extern "C" fn TxComplete_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxCompleteDecodeErrorZ {
10395 let res: Result<lightning::ln::msgs::TxComplete, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10396 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxComplete { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10400 /// Serialize the TxSignatures object into a byte array which can be read by TxSignatures_read
10401 pub extern "C" fn TxSignatures_write(obj: &crate::lightning::ln::msgs::TxSignatures) -> crate::c_types::derived::CVec_u8Z {
10402 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10405 pub(crate) extern "C" fn TxSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10406 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxSignatures) })
10409 /// Read a TxSignatures from a byte array, created by TxSignatures_write
10410 pub extern "C" fn TxSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxSignaturesDecodeErrorZ {
10411 let res: Result<lightning::ln::msgs::TxSignatures, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10412 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxSignatures { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10416 /// Serialize the TxInitRbf object into a byte array which can be read by TxInitRbf_read
10417 pub extern "C" fn TxInitRbf_write(obj: &crate::lightning::ln::msgs::TxInitRbf) -> crate::c_types::derived::CVec_u8Z {
10418 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10421 pub(crate) extern "C" fn TxInitRbf_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10422 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxInitRbf) })
10425 /// Read a TxInitRbf from a byte array, created by TxInitRbf_write
10426 pub extern "C" fn TxInitRbf_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxInitRbfDecodeErrorZ {
10427 let res: Result<lightning::ln::msgs::TxInitRbf, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10428 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxInitRbf { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10432 /// Serialize the TxAckRbf object into a byte array which can be read by TxAckRbf_read
10433 pub extern "C" fn TxAckRbf_write(obj: &crate::lightning::ln::msgs::TxAckRbf) -> crate::c_types::derived::CVec_u8Z {
10434 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10437 pub(crate) extern "C" fn TxAckRbf_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10438 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAckRbf) })
10441 /// Read a TxAckRbf from a byte array, created by TxAckRbf_write
10442 pub extern "C" fn TxAckRbf_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAckRbfDecodeErrorZ {
10443 let res: Result<lightning::ln::msgs::TxAckRbf, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10444 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxAckRbf { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10448 /// Serialize the TxAbort object into a byte array which can be read by TxAbort_read
10449 pub extern "C" fn TxAbort_write(obj: &crate::lightning::ln::msgs::TxAbort) -> crate::c_types::derived::CVec_u8Z {
10450 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10453 pub(crate) extern "C" fn TxAbort_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10454 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAbort) })
10457 /// Read a TxAbort from a byte array, created by TxAbort_write
10458 pub extern "C" fn TxAbort_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAbortDecodeErrorZ {
10459 let res: Result<lightning::ln::msgs::TxAbort, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10460 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxAbort { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10464 /// Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read
10465 pub extern "C" fn AnnouncementSignatures_write(obj: &crate::lightning::ln::msgs::AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z {
10466 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10469 pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10470 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAnnouncementSignatures) })
10473 /// Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write
10474 pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AnnouncementSignaturesDecodeErrorZ {
10475 let res: Result<lightning::ln::msgs::AnnouncementSignatures, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10476 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::AnnouncementSignatures { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10480 /// Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read
10481 pub extern "C" fn ChannelReestablish_write(obj: &crate::lightning::ln::msgs::ChannelReestablish) -> crate::c_types::derived::CVec_u8Z {
10482 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10485 pub(crate) extern "C" fn ChannelReestablish_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10486 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReestablish) })
10489 /// Read a ChannelReestablish from a byte array, created by ChannelReestablish_write
10490 pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReestablishDecodeErrorZ {
10491 let res: Result<lightning::ln::msgs::ChannelReestablish, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10492 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ChannelReestablish { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10496 /// Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read
10497 pub extern "C" fn ClosingSigned_write(obj: &crate::lightning::ln::msgs::ClosingSigned) -> crate::c_types::derived::CVec_u8Z {
10498 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10501 pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10502 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSigned) })
10505 /// Read a ClosingSigned from a byte array, created by ClosingSigned_write
10506 pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedDecodeErrorZ {
10507 let res: Result<lightning::ln::msgs::ClosingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10508 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ClosingSigned { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10512 /// Serialize the ClosingSignedFeeRange object into a byte array which can be read by ClosingSignedFeeRange_read
10513 pub extern "C" fn ClosingSignedFeeRange_write(obj: &crate::lightning::ln::msgs::ClosingSignedFeeRange) -> crate::c_types::derived::CVec_u8Z {
10514 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10517 pub(crate) extern "C" fn ClosingSignedFeeRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10518 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSignedFeeRange) })
10521 /// Read a ClosingSignedFeeRange from a byte array, created by ClosingSignedFeeRange_write
10522 pub extern "C" fn ClosingSignedFeeRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedFeeRangeDecodeErrorZ {
10523 let res: Result<lightning::ln::msgs::ClosingSignedFeeRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10524 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ClosingSignedFeeRange { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10528 /// Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read
10529 pub extern "C" fn CommitmentSigned_write(obj: &crate::lightning::ln::msgs::CommitmentSigned) -> crate::c_types::derived::CVec_u8Z {
10530 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10533 pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10534 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentSigned) })
10537 /// Read a CommitmentSigned from a byte array, created by CommitmentSigned_write
10538 pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CommitmentSignedDecodeErrorZ {
10539 let res: Result<lightning::ln::msgs::CommitmentSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10540 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::CommitmentSigned { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10544 /// Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read
10545 pub extern "C" fn FundingCreated_write(obj: &crate::lightning::ln::msgs::FundingCreated) -> crate::c_types::derived::CVec_u8Z {
10546 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10549 pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10550 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingCreated) })
10553 /// Read a FundingCreated from a byte array, created by FundingCreated_write
10554 pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingCreatedDecodeErrorZ {
10555 let res: Result<lightning::ln::msgs::FundingCreated, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10556 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::FundingCreated { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10560 /// Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read
10561 pub extern "C" fn FundingSigned_write(obj: &crate::lightning::ln::msgs::FundingSigned) -> crate::c_types::derived::CVec_u8Z {
10562 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10565 pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10566 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingSigned) })
10569 /// Read a FundingSigned from a byte array, created by FundingSigned_write
10570 pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingSignedDecodeErrorZ {
10571 let res: Result<lightning::ln::msgs::FundingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10572 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::FundingSigned { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10576 /// Serialize the ChannelReady object into a byte array which can be read by ChannelReady_read
10577 pub extern "C" fn ChannelReady_write(obj: &crate::lightning::ln::msgs::ChannelReady) -> crate::c_types::derived::CVec_u8Z {
10578 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10581 pub(crate) extern "C" fn ChannelReady_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10582 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReady) })
10585 /// Read a ChannelReady from a byte array, created by ChannelReady_write
10586 pub extern "C" fn ChannelReady_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReadyDecodeErrorZ {
10587 let res: Result<lightning::ln::msgs::ChannelReady, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10588 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ChannelReady { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10592 /// Serialize the Init object into a byte array which can be read by Init_read
10593 pub extern "C" fn Init_write(obj: &crate::lightning::ln::msgs::Init) -> crate::c_types::derived::CVec_u8Z {
10594 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10597 pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10598 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInit) })
10601 /// Read a Init from a byte array, created by Init_write
10602 pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitDecodeErrorZ {
10603 let res: Result<lightning::ln::msgs::Init, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10604 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::Init { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10608 /// Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read
10609 pub extern "C" fn OpenChannel_write(obj: &crate::lightning::ln::msgs::OpenChannel) -> crate::c_types::derived::CVec_u8Z {
10610 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10613 pub(crate) extern "C" fn OpenChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10614 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannel) })
10617 /// Read a OpenChannel from a byte array, created by OpenChannel_write
10618 pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelDecodeErrorZ {
10619 let res: Result<lightning::ln::msgs::OpenChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10620 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::OpenChannel { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10624 /// Serialize the OpenChannelV2 object into a byte array which can be read by OpenChannelV2_read
10625 pub extern "C" fn OpenChannelV2_write(obj: &crate::lightning::ln::msgs::OpenChannelV2) -> crate::c_types::derived::CVec_u8Z {
10626 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10629 pub(crate) extern "C" fn OpenChannelV2_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10630 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannelV2) })
10633 /// Read a OpenChannelV2 from a byte array, created by OpenChannelV2_write
10634 pub extern "C" fn OpenChannelV2_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelV2DecodeErrorZ {
10635 let res: Result<lightning::ln::msgs::OpenChannelV2, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10636 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::OpenChannelV2 { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10640 /// Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read
10641 pub extern "C" fn RevokeAndACK_write(obj: &crate::lightning::ln::msgs::RevokeAndACK) -> crate::c_types::derived::CVec_u8Z {
10642 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10645 pub(crate) extern "C" fn RevokeAndACK_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10646 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevokeAndACK) })
10649 /// Read a RevokeAndACK from a byte array, created by RevokeAndACK_write
10650 pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RevokeAndACKDecodeErrorZ {
10651 let res: Result<lightning::ln::msgs::RevokeAndACK, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10652 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::RevokeAndACK { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10656 /// Serialize the Shutdown object into a byte array which can be read by Shutdown_read
10657 pub extern "C" fn Shutdown_write(obj: &crate::lightning::ln::msgs::Shutdown) -> crate::c_types::derived::CVec_u8Z {
10658 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10661 pub(crate) extern "C" fn Shutdown_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10662 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeShutdown) })
10665 /// Read a Shutdown from a byte array, created by Shutdown_write
10666 pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ShutdownDecodeErrorZ {
10667 let res: Result<lightning::ln::msgs::Shutdown, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10668 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::Shutdown { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10672 /// Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read
10673 pub extern "C" fn UpdateFailHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFailHTLC) -> crate::c_types::derived::CVec_u8Z {
10674 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10677 pub(crate) extern "C" fn UpdateFailHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10678 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailHTLC) })
10681 /// Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write
10682 pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailHTLCDecodeErrorZ {
10683 let res: Result<lightning::ln::msgs::UpdateFailHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10684 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UpdateFailHTLC { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10688 /// Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read
10689 pub extern "C" fn UpdateFailMalformedHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFailMalformedHTLC) -> crate::c_types::derived::CVec_u8Z {
10690 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10693 pub(crate) extern "C" fn UpdateFailMalformedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10694 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailMalformedHTLC) })
10697 /// Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write
10698 pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailMalformedHTLCDecodeErrorZ {
10699 let res: Result<lightning::ln::msgs::UpdateFailMalformedHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10700 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UpdateFailMalformedHTLC { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10704 /// Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read
10705 pub extern "C" fn UpdateFee_write(obj: &crate::lightning::ln::msgs::UpdateFee) -> crate::c_types::derived::CVec_u8Z {
10706 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10709 pub(crate) extern "C" fn UpdateFee_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10710 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFee) })
10713 /// Read a UpdateFee from a byte array, created by UpdateFee_write
10714 pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFeeDecodeErrorZ {
10715 let res: Result<lightning::ln::msgs::UpdateFee, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10716 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UpdateFee { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10720 /// Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read
10721 pub extern "C" fn UpdateFulfillHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFulfillHTLC) -> crate::c_types::derived::CVec_u8Z {
10722 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10725 pub(crate) extern "C" fn UpdateFulfillHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10726 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFulfillHTLC) })
10729 /// Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write
10730 pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFulfillHTLCDecodeErrorZ {
10731 let res: Result<lightning::ln::msgs::UpdateFulfillHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10732 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UpdateFulfillHTLC { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10736 /// Serialize the OnionPacket object into a byte array which can be read by OnionPacket_read
10737 pub extern "C" fn OnionPacket_write(obj: &crate::lightning::ln::msgs::OnionPacket) -> crate::c_types::derived::CVec_u8Z {
10738 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10741 pub(crate) extern "C" fn OnionPacket_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10742 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOnionPacket) })
10745 /// Read a OnionPacket from a byte array, created by OnionPacket_write
10746 pub extern "C" fn OnionPacket_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OnionPacketDecodeErrorZ {
10747 let res: Result<lightning::ln::msgs::OnionPacket, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10748 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::OnionPacket { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10752 /// Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read
10753 pub extern "C" fn UpdateAddHTLC_write(obj: &crate::lightning::ln::msgs::UpdateAddHTLC) -> crate::c_types::derived::CVec_u8Z {
10754 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10757 pub(crate) extern "C" fn UpdateAddHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10758 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateAddHTLC) })
10761 /// Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write
10762 pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateAddHTLCDecodeErrorZ {
10763 let res: Result<lightning::ln::msgs::UpdateAddHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10764 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UpdateAddHTLC { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10768 /// Read a OnionMessage from a byte array, created by OnionMessage_write
10769 pub extern "C" fn OnionMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OnionMessageDecodeErrorZ {
10770 let res: Result<lightning::ln::msgs::OnionMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10771 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::OnionMessage { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10775 /// Serialize the OnionMessage object into a byte array which can be read by OnionMessage_read
10776 pub extern "C" fn OnionMessage_write(obj: &crate::lightning::ln::msgs::OnionMessage) -> crate::c_types::derived::CVec_u8Z {
10777 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10780 pub(crate) extern "C" fn OnionMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10781 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOnionMessage) })
10784 /// Serialize the FinalOnionHopData object into a byte array which can be read by FinalOnionHopData_read
10785 pub extern "C" fn FinalOnionHopData_write(obj: &crate::lightning::ln::msgs::FinalOnionHopData) -> crate::c_types::derived::CVec_u8Z {
10786 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10789 pub(crate) extern "C" fn FinalOnionHopData_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10790 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFinalOnionHopData) })
10793 /// Read a FinalOnionHopData from a byte array, created by FinalOnionHopData_write
10794 pub extern "C" fn FinalOnionHopData_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FinalOnionHopDataDecodeErrorZ {
10795 let res: Result<lightning::ln::msgs::FinalOnionHopData, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10796 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::FinalOnionHopData { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10800 /// Serialize the Ping object into a byte array which can be read by Ping_read
10801 pub extern "C" fn Ping_write(obj: &crate::lightning::ln::msgs::Ping) -> crate::c_types::derived::CVec_u8Z {
10802 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10805 pub(crate) extern "C" fn Ping_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10806 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePing) })
10809 /// Read a Ping from a byte array, created by Ping_write
10810 pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PingDecodeErrorZ {
10811 let res: Result<lightning::ln::msgs::Ping, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10812 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::Ping { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10816 /// Serialize the Pong object into a byte array which can be read by Pong_read
10817 pub extern "C" fn Pong_write(obj: &crate::lightning::ln::msgs::Pong) -> crate::c_types::derived::CVec_u8Z {
10818 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10821 pub(crate) extern "C" fn Pong_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10822 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePong) })
10825 /// Read a Pong from a byte array, created by Pong_write
10826 pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PongDecodeErrorZ {
10827 let res: Result<lightning::ln::msgs::Pong, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10828 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::Pong { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10832 /// Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read
10833 pub extern "C" fn UnsignedChannelAnnouncement_write(obj: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
10834 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10837 pub(crate) extern "C" fn UnsignedChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10838 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelAnnouncement) })
10841 /// Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write
10842 pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelAnnouncementDecodeErrorZ {
10843 let res: Result<lightning::ln::msgs::UnsignedChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10844 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10848 /// Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read
10849 pub extern "C" fn ChannelAnnouncement_write(obj: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
10850 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10853 pub(crate) extern "C" fn ChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10854 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelAnnouncement) })
10857 /// Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write
10858 pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelAnnouncementDecodeErrorZ {
10859 let res: Result<lightning::ln::msgs::ChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10860 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10864 /// Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read
10865 pub extern "C" fn UnsignedChannelUpdate_write(obj: &crate::lightning::ln::msgs::UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
10866 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10869 pub(crate) extern "C" fn UnsignedChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10870 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelUpdate) })
10873 /// Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write
10874 pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelUpdateDecodeErrorZ {
10875 let res: Result<lightning::ln::msgs::UnsignedChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10876 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10880 /// Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read
10881 pub extern "C" fn ChannelUpdate_write(obj: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
10882 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10885 pub(crate) extern "C" fn ChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10886 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdate) })
10889 /// Read a ChannelUpdate from a byte array, created by ChannelUpdate_write
10890 pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelUpdateDecodeErrorZ {
10891 let res: Result<lightning::ln::msgs::ChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10892 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10896 /// Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read
10897 pub extern "C" fn ErrorMessage_write(obj: &crate::lightning::ln::msgs::ErrorMessage) -> crate::c_types::derived::CVec_u8Z {
10898 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10901 pub(crate) extern "C" fn ErrorMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10902 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeErrorMessage) })
10905 /// Read a ErrorMessage from a byte array, created by ErrorMessage_write
10906 pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ErrorMessageDecodeErrorZ {
10907 let res: Result<lightning::ln::msgs::ErrorMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10908 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10912 /// Serialize the WarningMessage object into a byte array which can be read by WarningMessage_read
10913 pub extern "C" fn WarningMessage_write(obj: &crate::lightning::ln::msgs::WarningMessage) -> crate::c_types::derived::CVec_u8Z {
10914 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10917 pub(crate) extern "C" fn WarningMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10918 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeWarningMessage) })
10921 /// Read a WarningMessage from a byte array, created by WarningMessage_write
10922 pub extern "C" fn WarningMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_WarningMessageDecodeErrorZ {
10923 let res: Result<lightning::ln::msgs::WarningMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10924 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10928 /// Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read
10929 pub extern "C" fn UnsignedNodeAnnouncement_write(obj: &crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
10930 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10933 pub(crate) extern "C" fn UnsignedNodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10934 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedNodeAnnouncement) })
10937 /// Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write
10938 pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedNodeAnnouncementDecodeErrorZ {
10939 let res: Result<lightning::ln::msgs::UnsignedNodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10940 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10944 /// Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read
10945 pub extern "C" fn NodeAnnouncement_write(obj: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
10946 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10949 pub(crate) extern "C" fn NodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10950 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncement) })
10953 /// Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write
10954 pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementDecodeErrorZ {
10955 let res: Result<lightning::ln::msgs::NodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10956 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::NodeAnnouncement { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10960 /// Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write
10961 pub extern "C" fn QueryShortChannelIds_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryShortChannelIdsDecodeErrorZ {
10962 let res: Result<lightning::ln::msgs::QueryShortChannelIds, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10963 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::QueryShortChannelIds { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10967 /// Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read
10968 pub extern "C" fn QueryShortChannelIds_write(obj: &crate::lightning::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CVec_u8Z {
10969 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10972 pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10973 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) })
10976 /// Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read
10977 pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z {
10978 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
10981 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
10982 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) })
10985 /// Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write
10986 pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyShortChannelIdsEndDecodeErrorZ {
10987 let res: Result<lightning::ln::msgs::ReplyShortChannelIdsEnd, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
10988 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
10991 /// Calculates the overflow safe ending block height for the query.
10993 /// Overflow returns `0xffffffff`, otherwise returns `first_blocknum + number_of_blocks`.
10996 pub extern "C" fn QueryChannelRange_end_blocknum(this_arg: &crate::lightning::ln::msgs::QueryChannelRange) -> u32 {
10997 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.end_blocknum();
11002 /// Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read
11003 pub extern "C" fn QueryChannelRange_write(obj: &crate::lightning::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CVec_u8Z {
11004 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
11007 pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
11008 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) })
11011 /// Read a QueryChannelRange from a byte array, created by QueryChannelRange_write
11012 pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ {
11013 let res: Result<lightning::ln::msgs::QueryChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
11014 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::QueryChannelRange { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
11018 /// Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write
11019 pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyChannelRangeDecodeErrorZ {
11020 let res: Result<lightning::ln::msgs::ReplyChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
11021 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ReplyChannelRange { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
11025 /// Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read
11026 pub extern "C" fn ReplyChannelRange_write(obj: &crate::lightning::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CVec_u8Z {
11027 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
11030 pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
11031 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) })
11034 /// Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read
11035 pub extern "C" fn GossipTimestampFilter_write(obj: &crate::lightning::ln::msgs::GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z {
11036 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
11039 pub(crate) extern "C" fn GossipTimestampFilter_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
11040 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeGossipTimestampFilter) })
11043 /// Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write
11044 pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_GossipTimestampFilterDecodeErrorZ {
11045 let res: Result<lightning::ln::msgs::GossipTimestampFilter, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
11046 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::GossipTimestampFilter { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };