1 // This file is Copyright its original authors, visible in version control
2 // history and in the source files from which this was generated.
4 // This file is licensed under the license available in the LICENSE or LICENSE.md
5 // file in the root of this repository or, if no such file exists, the same
6 // license as that which applies to the original source files from which this
7 // source was automatically generated.
9 //! Wire messages, traits representing wire message handlers, and a few error types live here.
11 //! For a normal node you probably don't need to use anything here, however, if you wish to split a
12 //! node into an internet-facing route/message socket handling daemon and a separate daemon (or
13 //! server entirely) which handles only channel-related messages you may wish to implement
14 //! [`ChannelMessageHandler`] yourself and use it to re-serialize messages and pass them across
17 //! Note that if you go with such an architecture (instead of passing raw socket events to a
18 //! non-internet-facing system) you trust the frontend internet-facing system to not lie about the
19 //! source `node_id` of the message, however this does allow you to significantly reduce bandwidth
20 //! between the systems as routing messages can represent a significant chunk of bandwidth usage
21 //! (especially for non-channel-publicly-announcing nodes). As an alternate design which avoids
22 //! this issue, if you have sufficient bidirectional bandwidth between your systems, you may send
23 //! raw socket events into your non-internet-facing system and then send routing events back to
24 //! track the network on the less-secure system.
26 use alloc::str::FromStr;
27 use alloc::string::String;
28 use core::ffi::c_void;
29 use core::convert::Infallible;
30 use bitcoin::hashes::Hash;
31 use crate::c_types::*;
32 #[cfg(feature="no-std")]
33 use alloc::{vec::Vec, boxed::Box};
35 /// An error in decoding a message or struct.
39 pub enum DecodeError {
40 /// A version byte specified something we don't know how to handle.
42 /// Includes unknown realm byte in an onion hop data packet.
44 /// Unknown feature mandating we fail to parse message (e.g., TLV with an even, unknown type)
45 UnknownRequiredFeature,
46 /// Value was invalid.
48 /// For example, a byte which was supposed to be a bool was something other than a 0
49 /// or 1, a public key/private key/signature was invalid, text wasn't UTF-8, TLV was
50 /// syntactically incorrect, etc.
52 /// The buffer to be read was too short.
54 /// A length descriptor in the packet didn't describe the later data correctly.
56 /// Error from [`std::io`].
58 crate::c_types::IOError),
59 /// The message included zlib-compressed values, which we don't support.
60 UnsupportedCompression,
62 use lightning::ln::msgs::DecodeError as DecodeErrorImport;
63 pub(crate) type nativeDecodeError = DecodeErrorImport;
67 pub(crate) fn to_native(&self) -> nativeDecodeError {
69 DecodeError::UnknownVersion => nativeDecodeError::UnknownVersion,
70 DecodeError::UnknownRequiredFeature => nativeDecodeError::UnknownRequiredFeature,
71 DecodeError::InvalidValue => nativeDecodeError::InvalidValue,
72 DecodeError::ShortRead => nativeDecodeError::ShortRead,
73 DecodeError::BadLengthDescriptor => nativeDecodeError::BadLengthDescriptor,
74 DecodeError::Io (ref a, ) => {
75 let mut a_nonref = Clone::clone(a);
76 nativeDecodeError::Io (
77 a_nonref.to_rust_kind(),
80 DecodeError::UnsupportedCompression => nativeDecodeError::UnsupportedCompression,
84 pub(crate) fn into_native(self) -> nativeDecodeError {
86 DecodeError::UnknownVersion => nativeDecodeError::UnknownVersion,
87 DecodeError::UnknownRequiredFeature => nativeDecodeError::UnknownRequiredFeature,
88 DecodeError::InvalidValue => nativeDecodeError::InvalidValue,
89 DecodeError::ShortRead => nativeDecodeError::ShortRead,
90 DecodeError::BadLengthDescriptor => nativeDecodeError::BadLengthDescriptor,
91 DecodeError::Io (mut a, ) => {
92 nativeDecodeError::Io (
96 DecodeError::UnsupportedCompression => nativeDecodeError::UnsupportedCompression,
100 pub(crate) fn from_native(native: &nativeDecodeError) -> Self {
102 nativeDecodeError::UnknownVersion => DecodeError::UnknownVersion,
103 nativeDecodeError::UnknownRequiredFeature => DecodeError::UnknownRequiredFeature,
104 nativeDecodeError::InvalidValue => DecodeError::InvalidValue,
105 nativeDecodeError::ShortRead => DecodeError::ShortRead,
106 nativeDecodeError::BadLengthDescriptor => DecodeError::BadLengthDescriptor,
107 nativeDecodeError::Io (ref a, ) => {
108 let mut a_nonref = Clone::clone(a);
110 crate::c_types::IOError::from_rust_kind(a_nonref),
113 nativeDecodeError::UnsupportedCompression => DecodeError::UnsupportedCompression,
117 pub(crate) fn native_into(native: nativeDecodeError) -> Self {
119 nativeDecodeError::UnknownVersion => DecodeError::UnknownVersion,
120 nativeDecodeError::UnknownRequiredFeature => DecodeError::UnknownRequiredFeature,
121 nativeDecodeError::InvalidValue => DecodeError::InvalidValue,
122 nativeDecodeError::ShortRead => DecodeError::ShortRead,
123 nativeDecodeError::BadLengthDescriptor => DecodeError::BadLengthDescriptor,
124 nativeDecodeError::Io (mut a, ) => {
126 crate::c_types::IOError::from_rust_kind(a),
129 nativeDecodeError::UnsupportedCompression => DecodeError::UnsupportedCompression,
133 /// Frees any resources used by the DecodeError
135 pub extern "C" fn DecodeError_free(this_ptr: DecodeError) { }
136 /// Creates a copy of the DecodeError
138 pub extern "C" fn DecodeError_clone(orig: &DecodeError) -> DecodeError {
142 /// Used only if an object of this type is returned as a trait impl by a method
143 pub(crate) extern "C" fn DecodeError_clone_void(this_ptr: *const c_void) -> *mut c_void {
144 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const DecodeError)).clone() })) as *mut c_void
147 /// Used only if an object of this type is returned as a trait impl by a method
148 pub(crate) extern "C" fn DecodeError_free_void(this_ptr: *mut c_void) {
149 let _ = unsafe { Box::from_raw(this_ptr as *mut DecodeError) };
152 /// Utility method to constructs a new UnknownVersion-variant DecodeError
153 pub extern "C" fn DecodeError_unknown_version() -> DecodeError {
154 DecodeError::UnknownVersion}
156 /// Utility method to constructs a new UnknownRequiredFeature-variant DecodeError
157 pub extern "C" fn DecodeError_unknown_required_feature() -> DecodeError {
158 DecodeError::UnknownRequiredFeature}
160 /// Utility method to constructs a new InvalidValue-variant DecodeError
161 pub extern "C" fn DecodeError_invalid_value() -> DecodeError {
162 DecodeError::InvalidValue}
164 /// Utility method to constructs a new ShortRead-variant DecodeError
165 pub extern "C" fn DecodeError_short_read() -> DecodeError {
166 DecodeError::ShortRead}
168 /// Utility method to constructs a new BadLengthDescriptor-variant DecodeError
169 pub extern "C" fn DecodeError_bad_length_descriptor() -> DecodeError {
170 DecodeError::BadLengthDescriptor}
172 /// Utility method to constructs a new Io-variant DecodeError
173 pub extern "C" fn DecodeError_io(a: crate::c_types::IOError) -> DecodeError {
177 /// Utility method to constructs a new UnsupportedCompression-variant DecodeError
178 pub extern "C" fn DecodeError_unsupported_compression() -> DecodeError {
179 DecodeError::UnsupportedCompression}
180 /// Checks if two DecodeErrors contain equal inner contents.
181 /// This ignores pointers and is_owned flags and looks at the values in fields.
183 pub extern "C" fn DecodeError_eq(a: &DecodeError, b: &DecodeError) -> bool {
184 if &a.to_native() == &b.to_native() { true } else { false }
187 use lightning::ln::msgs::Init as nativeInitImport;
188 pub(crate) type nativeInit = nativeInitImport;
190 /// An [`init`] message to be sent to or received from a peer.
192 /// [`init`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-init-message
196 /// A pointer to the opaque Rust object.
198 /// Nearly everywhere, inner must be non-null, however in places where
199 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
200 pub inner: *mut nativeInit,
201 /// Indicates that this is the only struct which contains the same pointer.
203 /// Rust functions which take ownership of an object provided via an argument require
204 /// this to be true and invalidate the object pointed to by inner.
210 if self.is_owned && !<*mut nativeInit>::is_null(self.inner) {
211 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
215 /// Frees any resources used by the Init, if is_owned is set and inner is non-NULL.
217 pub extern "C" fn Init_free(this_obj: Init) { }
219 /// Used only if an object of this type is returned as a trait impl by a method
220 pub(crate) extern "C" fn Init_free_void(this_ptr: *mut c_void) {
221 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInit) };
225 pub(crate) fn get_native_ref(&self) -> &'static nativeInit {
226 unsafe { &*ObjOps::untweak_ptr(self.inner) }
228 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInit {
229 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
231 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
232 pub(crate) fn take_inner(mut self) -> *mut nativeInit {
233 assert!(self.is_owned);
234 let ret = ObjOps::untweak_ptr(self.inner);
235 self.inner = core::ptr::null_mut();
239 /// The relevant features which the sender supports.
241 pub extern "C" fn Init_get_features(this_ptr: &Init) -> crate::lightning::ln::features::InitFeatures {
242 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
243 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 }
245 /// The relevant features which the sender supports.
247 pub extern "C" fn Init_set_features(this_ptr: &mut Init, mut val: crate::lightning::ln::features::InitFeatures) {
248 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
250 /// Indicates chains the sender is interested in.
252 /// If there are no common chains, the connection will be closed.
254 /// Returns a copy of the field.
256 pub extern "C" fn Init_get_networks(this_ptr: &Init) -> crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ {
257 let mut inner_val = this_ptr.get_native_mut_ref().networks.clone();
258 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ::None } else { crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ::Some( { let mut local_inner_val_0 = Vec::new(); for mut item in inner_val.unwrap().drain(..) { local_inner_val_0.push( { crate::c_types::ThirtyTwoBytes { data: item.to_bytes() } }); }; local_inner_val_0.into() }) };
261 /// Indicates chains the sender is interested in.
263 /// If there are no common chains, the connection will be closed.
265 pub extern "C" fn Init_set_networks(this_ptr: &mut Init, mut val: crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ) {
266 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 }})} };
267 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.networks = local_val;
269 /// The receipient's network address.
271 /// This adds the option to report a remote IP address back to a connecting peer using the init
272 /// message. A node can decide to use that information to discover a potential update to its
273 /// public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing
276 pub extern "C" fn Init_get_remote_network_address(this_ptr: &Init) -> crate::c_types::derived::COption_SocketAddressZ {
277 let mut inner_val = &mut this_ptr.get_native_mut_ref().remote_network_address;
278 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()) }) };
281 /// The receipient's network address.
283 /// This adds the option to report a remote IP address back to a connecting peer using the init
284 /// message. A node can decide to use that information to discover a potential update to its
285 /// public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing
288 pub extern "C" fn Init_set_remote_network_address(this_ptr: &mut Init, mut val: crate::c_types::derived::COption_SocketAddressZ) {
289 let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_native() }})} };
290 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.remote_network_address = local_val;
292 /// Constructs a new Init given each field
295 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 {
296 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 }})} };
297 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() }})} };
298 Init { inner: ObjOps::heap_alloc(nativeInit {
299 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
300 networks: local_networks_arg,
301 remote_network_address: local_remote_network_address_arg,
304 impl Clone for Init {
305 fn clone(&self) -> Self {
307 inner: if <*mut nativeInit>::is_null(self.inner) { core::ptr::null_mut() } else {
308 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
314 /// Used only if an object of this type is returned as a trait impl by a method
315 pub(crate) extern "C" fn Init_clone_void(this_ptr: *const c_void) -> *mut c_void {
316 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeInit)).clone() })) as *mut c_void
319 /// Creates a copy of the Init
320 pub extern "C" fn Init_clone(orig: &Init) -> Init {
323 /// Checks if two Inits contain equal inner contents.
324 /// This ignores pointers and is_owned flags and looks at the values in fields.
325 /// Two objects with NULL inner values will be considered "equal" here.
327 pub extern "C" fn Init_eq(a: &Init, b: &Init) -> bool {
328 if a.inner == b.inner { return true; }
329 if a.inner.is_null() || b.inner.is_null() { return false; }
330 if a.get_native_ref() == b.get_native_ref() { true } else { false }
333 use lightning::ln::msgs::ErrorMessage as nativeErrorMessageImport;
334 pub(crate) type nativeErrorMessage = nativeErrorMessageImport;
336 /// An [`error`] message to be sent to or received from a peer.
338 /// [`error`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages
341 pub struct ErrorMessage {
342 /// A pointer to the opaque Rust object.
344 /// Nearly everywhere, inner must be non-null, however in places where
345 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
346 pub inner: *mut nativeErrorMessage,
347 /// Indicates that this is the only struct which contains the same pointer.
349 /// Rust functions which take ownership of an object provided via an argument require
350 /// this to be true and invalidate the object pointed to by inner.
354 impl Drop for ErrorMessage {
356 if self.is_owned && !<*mut nativeErrorMessage>::is_null(self.inner) {
357 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
361 /// Frees any resources used by the ErrorMessage, if is_owned is set and inner is non-NULL.
363 pub extern "C" fn ErrorMessage_free(this_obj: ErrorMessage) { }
365 /// Used only if an object of this type is returned as a trait impl by a method
366 pub(crate) extern "C" fn ErrorMessage_free_void(this_ptr: *mut c_void) {
367 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeErrorMessage) };
371 pub(crate) fn get_native_ref(&self) -> &'static nativeErrorMessage {
372 unsafe { &*ObjOps::untweak_ptr(self.inner) }
374 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeErrorMessage {
375 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
377 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
378 pub(crate) fn take_inner(mut self) -> *mut nativeErrorMessage {
379 assert!(self.is_owned);
380 let ret = ObjOps::untweak_ptr(self.inner);
381 self.inner = core::ptr::null_mut();
385 /// The channel ID involved in the error.
387 /// All-0s indicates a general error unrelated to a specific channel, after which all channels
388 /// with the sending peer should be closed.
390 pub extern "C" fn ErrorMessage_get_channel_id(this_ptr: &ErrorMessage) -> *const [u8; 32] {
391 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
394 /// The channel ID involved in the error.
396 /// All-0s indicates a general error unrelated to a specific channel, after which all channels
397 /// with the sending peer should be closed.
399 pub extern "C" fn ErrorMessage_set_channel_id(this_ptr: &mut ErrorMessage, mut val: crate::c_types::ThirtyTwoBytes) {
400 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
402 /// A possibly human-readable error description.
404 /// The string should be sanitized before it is used (e.g., emitted to logs or printed to
405 /// `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in
406 /// the terminal emulator or the logging subsystem.
408 pub extern "C" fn ErrorMessage_get_data(this_ptr: &ErrorMessage) -> crate::c_types::Str {
409 let mut inner_val = &mut this_ptr.get_native_mut_ref().data;
410 inner_val.as_str().into()
412 /// A possibly human-readable error description.
414 /// The string should be sanitized before it is used (e.g., emitted to logs or printed to
415 /// `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in
416 /// the terminal emulator or the logging subsystem.
418 pub extern "C" fn ErrorMessage_set_data(this_ptr: &mut ErrorMessage, mut val: crate::c_types::Str) {
419 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string();
421 /// Constructs a new ErrorMessage given each field
424 pub extern "C" fn ErrorMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::Str) -> ErrorMessage {
425 ErrorMessage { inner: ObjOps::heap_alloc(nativeErrorMessage {
426 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
427 data: data_arg.into_string(),
430 impl Clone for ErrorMessage {
431 fn clone(&self) -> Self {
433 inner: if <*mut nativeErrorMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
434 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
440 /// Used only if an object of this type is returned as a trait impl by a method
441 pub(crate) extern "C" fn ErrorMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
442 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeErrorMessage)).clone() })) as *mut c_void
445 /// Creates a copy of the ErrorMessage
446 pub extern "C" fn ErrorMessage_clone(orig: &ErrorMessage) -> ErrorMessage {
449 /// Checks if two ErrorMessages contain equal inner contents.
450 /// This ignores pointers and is_owned flags and looks at the values in fields.
451 /// Two objects with NULL inner values will be considered "equal" here.
453 pub extern "C" fn ErrorMessage_eq(a: &ErrorMessage, b: &ErrorMessage) -> bool {
454 if a.inner == b.inner { return true; }
455 if a.inner.is_null() || b.inner.is_null() { return false; }
456 if a.get_native_ref() == b.get_native_ref() { true } else { false }
459 use lightning::ln::msgs::WarningMessage as nativeWarningMessageImport;
460 pub(crate) type nativeWarningMessage = nativeWarningMessageImport;
462 /// A [`warning`] message to be sent to or received from a peer.
464 /// [`warning`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages
467 pub struct WarningMessage {
468 /// A pointer to the opaque Rust object.
470 /// Nearly everywhere, inner must be non-null, however in places where
471 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
472 pub inner: *mut nativeWarningMessage,
473 /// Indicates that this is the only struct which contains the same pointer.
475 /// Rust functions which take ownership of an object provided via an argument require
476 /// this to be true and invalidate the object pointed to by inner.
480 impl Drop for WarningMessage {
482 if self.is_owned && !<*mut nativeWarningMessage>::is_null(self.inner) {
483 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
487 /// Frees any resources used by the WarningMessage, if is_owned is set and inner is non-NULL.
489 pub extern "C" fn WarningMessage_free(this_obj: WarningMessage) { }
491 /// Used only if an object of this type is returned as a trait impl by a method
492 pub(crate) extern "C" fn WarningMessage_free_void(this_ptr: *mut c_void) {
493 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeWarningMessage) };
496 impl WarningMessage {
497 pub(crate) fn get_native_ref(&self) -> &'static nativeWarningMessage {
498 unsafe { &*ObjOps::untweak_ptr(self.inner) }
500 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeWarningMessage {
501 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
503 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
504 pub(crate) fn take_inner(mut self) -> *mut nativeWarningMessage {
505 assert!(self.is_owned);
506 let ret = ObjOps::untweak_ptr(self.inner);
507 self.inner = core::ptr::null_mut();
511 /// The channel ID involved in the warning.
513 /// All-0s indicates a warning unrelated to a specific channel.
515 pub extern "C" fn WarningMessage_get_channel_id(this_ptr: &WarningMessage) -> *const [u8; 32] {
516 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
519 /// The channel ID involved in the warning.
521 /// All-0s indicates a warning unrelated to a specific channel.
523 pub extern "C" fn WarningMessage_set_channel_id(this_ptr: &mut WarningMessage, mut val: crate::c_types::ThirtyTwoBytes) {
524 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
526 /// A possibly human-readable warning description.
528 /// The string should be sanitized before it is used (e.g. emitted to logs or printed to
529 /// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
530 /// the terminal emulator or the logging subsystem.
532 pub extern "C" fn WarningMessage_get_data(this_ptr: &WarningMessage) -> crate::c_types::Str {
533 let mut inner_val = &mut this_ptr.get_native_mut_ref().data;
534 inner_val.as_str().into()
536 /// A possibly human-readable warning description.
538 /// The string should be sanitized before it is used (e.g. emitted to logs or printed to
539 /// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
540 /// the terminal emulator or the logging subsystem.
542 pub extern "C" fn WarningMessage_set_data(this_ptr: &mut WarningMessage, mut val: crate::c_types::Str) {
543 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string();
545 /// Constructs a new WarningMessage given each field
548 pub extern "C" fn WarningMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::Str) -> WarningMessage {
549 WarningMessage { inner: ObjOps::heap_alloc(nativeWarningMessage {
550 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
551 data: data_arg.into_string(),
554 impl Clone for WarningMessage {
555 fn clone(&self) -> Self {
557 inner: if <*mut nativeWarningMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
558 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
564 /// Used only if an object of this type is returned as a trait impl by a method
565 pub(crate) extern "C" fn WarningMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
566 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeWarningMessage)).clone() })) as *mut c_void
569 /// Creates a copy of the WarningMessage
570 pub extern "C" fn WarningMessage_clone(orig: &WarningMessage) -> WarningMessage {
573 /// Checks if two WarningMessages contain equal inner contents.
574 /// This ignores pointers and is_owned flags and looks at the values in fields.
575 /// Two objects with NULL inner values will be considered "equal" here.
577 pub extern "C" fn WarningMessage_eq(a: &WarningMessage, b: &WarningMessage) -> bool {
578 if a.inner == b.inner { return true; }
579 if a.inner.is_null() || b.inner.is_null() { return false; }
580 if a.get_native_ref() == b.get_native_ref() { true } else { false }
583 use lightning::ln::msgs::Ping as nativePingImport;
584 pub(crate) type nativePing = nativePingImport;
586 /// A [`ping`] message to be sent to or received from a peer.
588 /// [`ping`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-ping-and-pong-messages
592 /// A pointer to the opaque Rust object.
594 /// Nearly everywhere, inner must be non-null, however in places where
595 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
596 pub inner: *mut nativePing,
597 /// Indicates that this is the only struct which contains the same pointer.
599 /// Rust functions which take ownership of an object provided via an argument require
600 /// this to be true and invalidate the object pointed to by inner.
606 if self.is_owned && !<*mut nativePing>::is_null(self.inner) {
607 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
611 /// Frees any resources used by the Ping, if is_owned is set and inner is non-NULL.
613 pub extern "C" fn Ping_free(this_obj: Ping) { }
615 /// Used only if an object of this type is returned as a trait impl by a method
616 pub(crate) extern "C" fn Ping_free_void(this_ptr: *mut c_void) {
617 let _ = unsafe { Box::from_raw(this_ptr as *mut nativePing) };
621 pub(crate) fn get_native_ref(&self) -> &'static nativePing {
622 unsafe { &*ObjOps::untweak_ptr(self.inner) }
624 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePing {
625 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
627 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
628 pub(crate) fn take_inner(mut self) -> *mut nativePing {
629 assert!(self.is_owned);
630 let ret = ObjOps::untweak_ptr(self.inner);
631 self.inner = core::ptr::null_mut();
635 /// The desired response length.
637 pub extern "C" fn Ping_get_ponglen(this_ptr: &Ping) -> u16 {
638 let mut inner_val = &mut this_ptr.get_native_mut_ref().ponglen;
641 /// The desired response length.
643 pub extern "C" fn Ping_set_ponglen(this_ptr: &mut Ping, mut val: u16) {
644 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.ponglen = val;
646 /// The ping packet size.
648 /// This field is not sent on the wire. byteslen zeros are sent.
650 pub extern "C" fn Ping_get_byteslen(this_ptr: &Ping) -> u16 {
651 let mut inner_val = &mut this_ptr.get_native_mut_ref().byteslen;
654 /// The ping packet size.
656 /// This field is not sent on the wire. byteslen zeros are sent.
658 pub extern "C" fn Ping_set_byteslen(this_ptr: &mut Ping, mut val: u16) {
659 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.byteslen = val;
661 /// Constructs a new Ping given each field
664 pub extern "C" fn Ping_new(mut ponglen_arg: u16, mut byteslen_arg: u16) -> Ping {
665 Ping { inner: ObjOps::heap_alloc(nativePing {
666 ponglen: ponglen_arg,
667 byteslen: byteslen_arg,
670 impl Clone for Ping {
671 fn clone(&self) -> Self {
673 inner: if <*mut nativePing>::is_null(self.inner) { core::ptr::null_mut() } else {
674 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
680 /// Used only if an object of this type is returned as a trait impl by a method
681 pub(crate) extern "C" fn Ping_clone_void(this_ptr: *const c_void) -> *mut c_void {
682 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativePing)).clone() })) as *mut c_void
685 /// Creates a copy of the Ping
686 pub extern "C" fn Ping_clone(orig: &Ping) -> Ping {
689 /// Checks if two Pings contain equal inner contents.
690 /// This ignores pointers and is_owned flags and looks at the values in fields.
691 /// Two objects with NULL inner values will be considered "equal" here.
693 pub extern "C" fn Ping_eq(a: &Ping, b: &Ping) -> bool {
694 if a.inner == b.inner { return true; }
695 if a.inner.is_null() || b.inner.is_null() { return false; }
696 if a.get_native_ref() == b.get_native_ref() { true } else { false }
699 use lightning::ln::msgs::Pong as nativePongImport;
700 pub(crate) type nativePong = nativePongImport;
702 /// A [`pong`] message to be sent to or received from a peer.
704 /// [`pong`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-ping-and-pong-messages
708 /// A pointer to the opaque Rust object.
710 /// Nearly everywhere, inner must be non-null, however in places where
711 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
712 pub inner: *mut nativePong,
713 /// Indicates that this is the only struct which contains the same pointer.
715 /// Rust functions which take ownership of an object provided via an argument require
716 /// this to be true and invalidate the object pointed to by inner.
722 if self.is_owned && !<*mut nativePong>::is_null(self.inner) {
723 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
727 /// Frees any resources used by the Pong, if is_owned is set and inner is non-NULL.
729 pub extern "C" fn Pong_free(this_obj: Pong) { }
731 /// Used only if an object of this type is returned as a trait impl by a method
732 pub(crate) extern "C" fn Pong_free_void(this_ptr: *mut c_void) {
733 let _ = unsafe { Box::from_raw(this_ptr as *mut nativePong) };
737 pub(crate) fn get_native_ref(&self) -> &'static nativePong {
738 unsafe { &*ObjOps::untweak_ptr(self.inner) }
740 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePong {
741 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
743 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
744 pub(crate) fn take_inner(mut self) -> *mut nativePong {
745 assert!(self.is_owned);
746 let ret = ObjOps::untweak_ptr(self.inner);
747 self.inner = core::ptr::null_mut();
751 /// The pong packet size.
753 /// This field is not sent on the wire. byteslen zeros are sent.
755 pub extern "C" fn Pong_get_byteslen(this_ptr: &Pong) -> u16 {
756 let mut inner_val = &mut this_ptr.get_native_mut_ref().byteslen;
759 /// The pong packet size.
761 /// This field is not sent on the wire. byteslen zeros are sent.
763 pub extern "C" fn Pong_set_byteslen(this_ptr: &mut Pong, mut val: u16) {
764 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.byteslen = val;
766 /// Constructs a new Pong given each field
769 pub extern "C" fn Pong_new(mut byteslen_arg: u16) -> Pong {
770 Pong { inner: ObjOps::heap_alloc(nativePong {
771 byteslen: byteslen_arg,
774 impl Clone for Pong {
775 fn clone(&self) -> Self {
777 inner: if <*mut nativePong>::is_null(self.inner) { core::ptr::null_mut() } else {
778 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
784 /// Used only if an object of this type is returned as a trait impl by a method
785 pub(crate) extern "C" fn Pong_clone_void(this_ptr: *const c_void) -> *mut c_void {
786 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativePong)).clone() })) as *mut c_void
789 /// Creates a copy of the Pong
790 pub extern "C" fn Pong_clone(orig: &Pong) -> Pong {
793 /// Checks if two Pongs contain equal inner contents.
794 /// This ignores pointers and is_owned flags and looks at the values in fields.
795 /// Two objects with NULL inner values will be considered "equal" here.
797 pub extern "C" fn Pong_eq(a: &Pong, b: &Pong) -> bool {
798 if a.inner == b.inner { return true; }
799 if a.inner.is_null() || b.inner.is_null() { return false; }
800 if a.get_native_ref() == b.get_native_ref() { true } else { false }
803 use lightning::ln::msgs::OpenChannel as nativeOpenChannelImport;
804 pub(crate) type nativeOpenChannel = nativeOpenChannelImport;
806 /// An [`open_channel`] message to be sent to or received from a peer.
808 /// Used in V1 channel establishment
810 /// [`open_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message
813 pub struct OpenChannel {
814 /// A pointer to the opaque Rust object.
816 /// Nearly everywhere, inner must be non-null, however in places where
817 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
818 pub inner: *mut nativeOpenChannel,
819 /// Indicates that this is the only struct which contains the same pointer.
821 /// Rust functions which take ownership of an object provided via an argument require
822 /// this to be true and invalidate the object pointed to by inner.
826 impl Drop for OpenChannel {
828 if self.is_owned && !<*mut nativeOpenChannel>::is_null(self.inner) {
829 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
833 /// Frees any resources used by the OpenChannel, if is_owned is set and inner is non-NULL.
835 pub extern "C" fn OpenChannel_free(this_obj: OpenChannel) { }
837 /// Used only if an object of this type is returned as a trait impl by a method
838 pub(crate) extern "C" fn OpenChannel_free_void(this_ptr: *mut c_void) {
839 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOpenChannel) };
843 pub(crate) fn get_native_ref(&self) -> &'static nativeOpenChannel {
844 unsafe { &*ObjOps::untweak_ptr(self.inner) }
846 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOpenChannel {
847 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
849 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
850 pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannel {
851 assert!(self.is_owned);
852 let ret = ObjOps::untweak_ptr(self.inner);
853 self.inner = core::ptr::null_mut();
857 /// The genesis hash of the blockchain where the channel is to be opened
859 pub extern "C" fn OpenChannel_get_chain_hash(this_ptr: &OpenChannel) -> *const [u8; 32] {
860 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
863 /// The genesis hash of the blockchain where the channel is to be opened
865 pub extern "C" fn OpenChannel_set_chain_hash(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
866 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data[..]);
868 /// A temporary channel ID, until the funding outpoint is announced
870 pub extern "C" fn OpenChannel_get_temporary_channel_id(this_ptr: &OpenChannel) -> *const [u8; 32] {
871 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
874 /// A temporary channel ID, until the funding outpoint is announced
876 pub extern "C" fn OpenChannel_set_temporary_channel_id(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
877 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = ::lightning::ln::ChannelId(val.data);
879 /// The channel value
881 pub extern "C" fn OpenChannel_get_funding_satoshis(this_ptr: &OpenChannel) -> u64 {
882 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
885 /// The channel value
887 pub extern "C" fn OpenChannel_set_funding_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
888 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
890 /// The amount to push to the counterparty as part of the open, in milli-satoshi
892 pub extern "C" fn OpenChannel_get_push_msat(this_ptr: &OpenChannel) -> u64 {
893 let mut inner_val = &mut this_ptr.get_native_mut_ref().push_msat;
896 /// The amount to push to the counterparty as part of the open, in milli-satoshi
898 pub extern "C" fn OpenChannel_set_push_msat(this_ptr: &mut OpenChannel, mut val: u64) {
899 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.push_msat = val;
901 /// The threshold below which outputs on transactions broadcast by sender will be omitted
903 pub extern "C" fn OpenChannel_get_dust_limit_satoshis(this_ptr: &OpenChannel) -> u64 {
904 let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
907 /// The threshold below which outputs on transactions broadcast by sender will be omitted
909 pub extern "C" fn OpenChannel_set_dust_limit_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
910 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
912 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
914 pub extern "C" fn OpenChannel_get_max_htlc_value_in_flight_msat(this_ptr: &OpenChannel) -> u64 {
915 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
918 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
920 pub extern "C" fn OpenChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut OpenChannel, mut val: u64) {
921 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
923 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
925 pub extern "C" fn OpenChannel_get_channel_reserve_satoshis(this_ptr: &OpenChannel) -> u64 {
926 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
929 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
931 pub extern "C" fn OpenChannel_set_channel_reserve_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
932 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
934 /// The minimum HTLC size incoming to sender, in milli-satoshi
936 pub extern "C" fn OpenChannel_get_htlc_minimum_msat(this_ptr: &OpenChannel) -> u64 {
937 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
940 /// The minimum HTLC size incoming to sender, in milli-satoshi
942 pub extern "C" fn OpenChannel_set_htlc_minimum_msat(this_ptr: &mut OpenChannel, mut val: u64) {
943 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
945 /// The feerate per 1000-weight of sender generated transactions, until updated by
948 pub extern "C" fn OpenChannel_get_feerate_per_kw(this_ptr: &OpenChannel) -> u32 {
949 let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
952 /// The feerate per 1000-weight of sender generated transactions, until updated by
955 pub extern "C" fn OpenChannel_set_feerate_per_kw(this_ptr: &mut OpenChannel, mut val: u32) {
956 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
958 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if
959 /// they broadcast a commitment transaction
961 pub extern "C" fn OpenChannel_get_to_self_delay(this_ptr: &OpenChannel) -> u16 {
962 let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
965 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if
966 /// they broadcast a commitment transaction
968 pub extern "C" fn OpenChannel_set_to_self_delay(this_ptr: &mut OpenChannel, mut val: u16) {
969 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
971 /// The maximum number of inbound HTLCs towards sender
973 pub extern "C" fn OpenChannel_get_max_accepted_htlcs(this_ptr: &OpenChannel) -> u16 {
974 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
977 /// The maximum number of inbound HTLCs towards sender
979 pub extern "C" fn OpenChannel_set_max_accepted_htlcs(this_ptr: &mut OpenChannel, mut val: u16) {
980 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
982 /// The sender's key controlling the funding transaction
984 pub extern "C" fn OpenChannel_get_funding_pubkey(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
985 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
986 crate::c_types::PublicKey::from_rust(&inner_val)
988 /// The sender's key controlling the funding transaction
990 pub extern "C" fn OpenChannel_set_funding_pubkey(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
991 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
993 /// Used to derive a revocation key for transactions broadcast by counterparty
995 pub extern "C" fn OpenChannel_get_revocation_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
996 let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
997 crate::c_types::PublicKey::from_rust(&inner_val)
999 /// Used to derive a revocation key for transactions broadcast by counterparty
1001 pub extern "C" fn OpenChannel_set_revocation_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1002 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
1004 /// A payment key to sender for transactions broadcast by counterparty
1006 pub extern "C" fn OpenChannel_get_payment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
1007 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_point;
1008 crate::c_types::PublicKey::from_rust(&inner_val)
1010 /// A payment key to sender for transactions broadcast by counterparty
1012 pub extern "C" fn OpenChannel_set_payment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1013 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_point = val.into_rust();
1015 /// Used to derive a payment key to sender for transactions broadcast by sender
1017 pub extern "C" fn OpenChannel_get_delayed_payment_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
1018 let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
1019 crate::c_types::PublicKey::from_rust(&inner_val)
1021 /// Used to derive a payment key to sender for transactions broadcast by sender
1023 pub extern "C" fn OpenChannel_set_delayed_payment_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1024 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
1026 /// Used to derive an HTLC payment key to sender
1028 pub extern "C" fn OpenChannel_get_htlc_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
1029 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
1030 crate::c_types::PublicKey::from_rust(&inner_val)
1032 /// Used to derive an HTLC payment key to sender
1034 pub extern "C" fn OpenChannel_set_htlc_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1035 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
1037 /// The first to-be-broadcast-by-sender transaction's per commitment point
1039 pub extern "C" fn OpenChannel_get_first_per_commitment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
1040 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
1041 crate::c_types::PublicKey::from_rust(&inner_val)
1043 /// The first to-be-broadcast-by-sender transaction's per commitment point
1045 pub extern "C" fn OpenChannel_set_first_per_commitment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1046 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
1048 /// The channel flags to be used
1050 pub extern "C" fn OpenChannel_get_channel_flags(this_ptr: &OpenChannel) -> u8 {
1051 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_flags;
1054 /// The channel flags to be used
1056 pub extern "C" fn OpenChannel_set_channel_flags(this_ptr: &mut OpenChannel, mut val: u8) {
1057 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_flags = val;
1059 /// A request to pre-set the to-sender output's `scriptPubkey` for when we collaboratively close
1061 pub extern "C" fn OpenChannel_get_shutdown_scriptpubkey(this_ptr: &OpenChannel) -> crate::c_types::derived::COption_CVec_u8ZZ {
1062 let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey;
1063 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().into_bytes().into() }) };
1066 /// A request to pre-set the to-sender output's `scriptPubkey` for when we collaboratively close
1068 pub extern "C" fn OpenChannel_set_shutdown_scriptpubkey(this_ptr: &mut OpenChannel, mut val: crate::c_types::derived::COption_CVec_u8ZZ) {
1069 let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ val_opt.take() }.into_rust()) }})} };
1070 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val;
1072 /// The channel type that this channel will represent
1074 /// If this is `None`, we derive the channel type from the intersection of our
1075 /// feature bits with our counterparty's feature bits from the [`Init`] message.
1077 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1079 pub extern "C" fn OpenChannel_get_channel_type(this_ptr: &OpenChannel) -> crate::lightning::ln::features::ChannelTypeFeatures {
1080 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1081 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 };
1084 /// The channel type that this channel will represent
1086 /// If this is `None`, we derive the channel type from the intersection of our
1087 /// feature bits with our counterparty's feature bits from the [`Init`] message.
1089 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1091 pub extern "C" fn OpenChannel_set_channel_type(this_ptr: &mut OpenChannel, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1092 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1093 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1095 /// Constructs a new OpenChannel given each field
1097 /// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
1100 pub extern "C" fn OpenChannel_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_satoshis_arg: u64, mut push_msat_arg: u64, mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut channel_reserve_satoshis_arg: u64, mut htlc_minimum_msat_arg: u64, mut feerate_per_kw_arg: u32, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16, mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_point_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey, mut first_per_commitment_point_arg: crate::c_types::PublicKey, mut channel_flags_arg: u8, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_CVec_u8ZZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures) -> OpenChannel {
1101 let mut local_shutdown_scriptpubkey_arg = { /*shutdown_scriptpubkey_arg*/ let shutdown_scriptpubkey_arg_opt = shutdown_scriptpubkey_arg; if shutdown_scriptpubkey_arg_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} };
1102 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()) } }) };
1103 OpenChannel { inner: ObjOps::heap_alloc(nativeOpenChannel {
1104 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data[..]),
1105 temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_arg.data),
1106 funding_satoshis: funding_satoshis_arg,
1107 push_msat: push_msat_arg,
1108 dust_limit_satoshis: dust_limit_satoshis_arg,
1109 max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg,
1110 channel_reserve_satoshis: channel_reserve_satoshis_arg,
1111 htlc_minimum_msat: htlc_minimum_msat_arg,
1112 feerate_per_kw: feerate_per_kw_arg,
1113 to_self_delay: to_self_delay_arg,
1114 max_accepted_htlcs: max_accepted_htlcs_arg,
1115 funding_pubkey: funding_pubkey_arg.into_rust(),
1116 revocation_basepoint: revocation_basepoint_arg.into_rust(),
1117 payment_point: payment_point_arg.into_rust(),
1118 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
1119 htlc_basepoint: htlc_basepoint_arg.into_rust(),
1120 first_per_commitment_point: first_per_commitment_point_arg.into_rust(),
1121 channel_flags: channel_flags_arg,
1122 shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg,
1123 channel_type: local_channel_type_arg,
1124 }), is_owned: true }
1126 impl Clone for OpenChannel {
1127 fn clone(&self) -> Self {
1129 inner: if <*mut nativeOpenChannel>::is_null(self.inner) { core::ptr::null_mut() } else {
1130 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1136 /// Used only if an object of this type is returned as a trait impl by a method
1137 pub(crate) extern "C" fn OpenChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
1138 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOpenChannel)).clone() })) as *mut c_void
1141 /// Creates a copy of the OpenChannel
1142 pub extern "C" fn OpenChannel_clone(orig: &OpenChannel) -> OpenChannel {
1145 /// Checks if two OpenChannels contain equal inner contents.
1146 /// This ignores pointers and is_owned flags and looks at the values in fields.
1147 /// Two objects with NULL inner values will be considered "equal" here.
1149 pub extern "C" fn OpenChannel_eq(a: &OpenChannel, b: &OpenChannel) -> bool {
1150 if a.inner == b.inner { return true; }
1151 if a.inner.is_null() || b.inner.is_null() { return false; }
1152 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1155 use lightning::ln::msgs::OpenChannelV2 as nativeOpenChannelV2Import;
1156 pub(crate) type nativeOpenChannelV2 = nativeOpenChannelV2Import;
1158 /// An open_channel2 message to be sent by or received from the channel initiator.
1160 /// Used in V2 channel establishment
1164 pub struct OpenChannelV2 {
1165 /// A pointer to the opaque Rust object.
1167 /// Nearly everywhere, inner must be non-null, however in places where
1168 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1169 pub inner: *mut nativeOpenChannelV2,
1170 /// Indicates that this is the only struct which contains the same pointer.
1172 /// Rust functions which take ownership of an object provided via an argument require
1173 /// this to be true and invalidate the object pointed to by inner.
1177 impl Drop for OpenChannelV2 {
1178 fn drop(&mut self) {
1179 if self.is_owned && !<*mut nativeOpenChannelV2>::is_null(self.inner) {
1180 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1184 /// Frees any resources used by the OpenChannelV2, if is_owned is set and inner is non-NULL.
1186 pub extern "C" fn OpenChannelV2_free(this_obj: OpenChannelV2) { }
1188 /// Used only if an object of this type is returned as a trait impl by a method
1189 pub(crate) extern "C" fn OpenChannelV2_free_void(this_ptr: *mut c_void) {
1190 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOpenChannelV2) };
1193 impl OpenChannelV2 {
1194 pub(crate) fn get_native_ref(&self) -> &'static nativeOpenChannelV2 {
1195 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1197 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOpenChannelV2 {
1198 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1200 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1201 pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannelV2 {
1202 assert!(self.is_owned);
1203 let ret = ObjOps::untweak_ptr(self.inner);
1204 self.inner = core::ptr::null_mut();
1208 /// The genesis hash of the blockchain where the channel is to be opened
1210 pub extern "C" fn OpenChannelV2_get_chain_hash(this_ptr: &OpenChannelV2) -> *const [u8; 32] {
1211 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
1212 inner_val.as_bytes()
1214 /// The genesis hash of the blockchain where the channel is to be opened
1216 pub extern "C" fn OpenChannelV2_set_chain_hash(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::ThirtyTwoBytes) {
1217 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data[..]);
1219 /// A temporary channel ID derived using a zeroed out value for the channel acceptor's revocation basepoint
1221 pub extern "C" fn OpenChannelV2_get_temporary_channel_id(this_ptr: &OpenChannelV2) -> *const [u8; 32] {
1222 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
1225 /// A temporary channel ID derived using a zeroed out value for the channel acceptor's revocation basepoint
1227 pub extern "C" fn OpenChannelV2_set_temporary_channel_id(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::ThirtyTwoBytes) {
1228 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = ::lightning::ln::ChannelId(val.data);
1230 /// The feerate for the funding transaction set by the channel initiator
1232 pub extern "C" fn OpenChannelV2_get_funding_feerate_sat_per_1000_weight(this_ptr: &OpenChannelV2) -> u32 {
1233 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_feerate_sat_per_1000_weight;
1236 /// The feerate for the funding transaction set by the channel initiator
1238 pub extern "C" fn OpenChannelV2_set_funding_feerate_sat_per_1000_weight(this_ptr: &mut OpenChannelV2, mut val: u32) {
1239 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_feerate_sat_per_1000_weight = val;
1241 /// The feerate for the commitment transaction set by the channel initiator
1243 pub extern "C" fn OpenChannelV2_get_commitment_feerate_sat_per_1000_weight(this_ptr: &OpenChannelV2) -> u32 {
1244 let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_feerate_sat_per_1000_weight;
1247 /// The feerate for the commitment transaction set by the channel initiator
1249 pub extern "C" fn OpenChannelV2_set_commitment_feerate_sat_per_1000_weight(this_ptr: &mut OpenChannelV2, mut val: u32) {
1250 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_feerate_sat_per_1000_weight = val;
1252 /// Part of the channel value contributed by the channel initiator
1254 pub extern "C" fn OpenChannelV2_get_funding_satoshis(this_ptr: &OpenChannelV2) -> u64 {
1255 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
1258 /// Part of the channel value contributed by the channel initiator
1260 pub extern "C" fn OpenChannelV2_set_funding_satoshis(this_ptr: &mut OpenChannelV2, mut val: u64) {
1261 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
1263 /// The threshold below which outputs on transactions broadcast by the channel initiator will be
1266 pub extern "C" fn OpenChannelV2_get_dust_limit_satoshis(this_ptr: &OpenChannelV2) -> u64 {
1267 let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
1270 /// The threshold below which outputs on transactions broadcast by the channel initiator will be
1273 pub extern "C" fn OpenChannelV2_set_dust_limit_satoshis(this_ptr: &mut OpenChannelV2, mut val: u64) {
1274 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
1276 /// The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi
1278 pub extern "C" fn OpenChannelV2_get_max_htlc_value_in_flight_msat(this_ptr: &OpenChannelV2) -> u64 {
1279 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
1282 /// The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi
1284 pub extern "C" fn OpenChannelV2_set_max_htlc_value_in_flight_msat(this_ptr: &mut OpenChannelV2, mut val: u64) {
1285 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
1287 /// The minimum HTLC size incoming to channel initiator, in milli-satoshi
1289 pub extern "C" fn OpenChannelV2_get_htlc_minimum_msat(this_ptr: &OpenChannelV2) -> u64 {
1290 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
1293 /// The minimum HTLC size incoming to channel initiator, in milli-satoshi
1295 pub extern "C" fn OpenChannelV2_set_htlc_minimum_msat(this_ptr: &mut OpenChannelV2, mut val: u64) {
1296 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
1298 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1299 /// broadcast a commitment transaction
1301 pub extern "C" fn OpenChannelV2_get_to_self_delay(this_ptr: &OpenChannelV2) -> u16 {
1302 let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
1305 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1306 /// broadcast a commitment transaction
1308 pub extern "C" fn OpenChannelV2_set_to_self_delay(this_ptr: &mut OpenChannelV2, mut val: u16) {
1309 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
1311 /// The maximum number of inbound HTLCs towards channel initiator
1313 pub extern "C" fn OpenChannelV2_get_max_accepted_htlcs(this_ptr: &OpenChannelV2) -> u16 {
1314 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
1317 /// The maximum number of inbound HTLCs towards channel initiator
1319 pub extern "C" fn OpenChannelV2_set_max_accepted_htlcs(this_ptr: &mut OpenChannelV2, mut val: u16) {
1320 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
1322 /// The locktime for the funding transaction
1324 pub extern "C" fn OpenChannelV2_get_locktime(this_ptr: &OpenChannelV2) -> u32 {
1325 let mut inner_val = &mut this_ptr.get_native_mut_ref().locktime;
1328 /// The locktime for the funding transaction
1330 pub extern "C" fn OpenChannelV2_set_locktime(this_ptr: &mut OpenChannelV2, mut val: u32) {
1331 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.locktime = val;
1333 /// The channel initiator's key controlling the funding transaction
1335 pub extern "C" fn OpenChannelV2_get_funding_pubkey(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1336 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
1337 crate::c_types::PublicKey::from_rust(&inner_val)
1339 /// The channel initiator's key controlling the funding transaction
1341 pub extern "C" fn OpenChannelV2_set_funding_pubkey(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1342 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
1344 /// Used to derive a revocation key for transactions broadcast by counterparty
1346 pub extern "C" fn OpenChannelV2_get_revocation_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1347 let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
1348 crate::c_types::PublicKey::from_rust(&inner_val)
1350 /// Used to derive a revocation key for transactions broadcast by counterparty
1352 pub extern "C" fn OpenChannelV2_set_revocation_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1353 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
1355 /// A payment key to channel initiator for transactions broadcast by counterparty
1357 pub extern "C" fn OpenChannelV2_get_payment_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1358 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_basepoint;
1359 crate::c_types::PublicKey::from_rust(&inner_val)
1361 /// A payment key to channel initiator for transactions broadcast by counterparty
1363 pub extern "C" fn OpenChannelV2_set_payment_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1364 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_basepoint = val.into_rust();
1366 /// Used to derive a payment key to channel initiator for transactions broadcast by channel
1369 pub extern "C" fn OpenChannelV2_get_delayed_payment_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1370 let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
1371 crate::c_types::PublicKey::from_rust(&inner_val)
1373 /// Used to derive a payment key to channel initiator for transactions broadcast by channel
1376 pub extern "C" fn OpenChannelV2_set_delayed_payment_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1377 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
1379 /// Used to derive an HTLC payment key to channel initiator
1381 pub extern "C" fn OpenChannelV2_get_htlc_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1382 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
1383 crate::c_types::PublicKey::from_rust(&inner_val)
1385 /// Used to derive an HTLC payment key to channel initiator
1387 pub extern "C" fn OpenChannelV2_set_htlc_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1388 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
1390 /// The first to-be-broadcast-by-channel-initiator transaction's per commitment point
1392 pub extern "C" fn OpenChannelV2_get_first_per_commitment_point(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1393 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
1394 crate::c_types::PublicKey::from_rust(&inner_val)
1396 /// The first to-be-broadcast-by-channel-initiator transaction's per commitment point
1398 pub extern "C" fn OpenChannelV2_set_first_per_commitment_point(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1399 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
1401 /// The second to-be-broadcast-by-channel-initiator transaction's per commitment point
1403 pub extern "C" fn OpenChannelV2_get_second_per_commitment_point(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1404 let mut inner_val = &mut this_ptr.get_native_mut_ref().second_per_commitment_point;
1405 crate::c_types::PublicKey::from_rust(&inner_val)
1407 /// The second to-be-broadcast-by-channel-initiator transaction's per commitment point
1409 pub extern "C" fn OpenChannelV2_set_second_per_commitment_point(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1410 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.second_per_commitment_point = val.into_rust();
1414 pub extern "C" fn OpenChannelV2_get_channel_flags(this_ptr: &OpenChannelV2) -> u8 {
1415 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_flags;
1420 pub extern "C" fn OpenChannelV2_set_channel_flags(this_ptr: &mut OpenChannelV2, mut val: u8) {
1421 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_flags = val;
1423 /// Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we
1424 /// collaboratively close
1426 pub extern "C" fn OpenChannelV2_get_shutdown_scriptpubkey(this_ptr: &OpenChannelV2) -> crate::c_types::derived::COption_CVec_u8ZZ {
1427 let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey;
1428 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().into_bytes().into() }) };
1431 /// Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we
1432 /// collaboratively close
1434 pub extern "C" fn OpenChannelV2_set_shutdown_scriptpubkey(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::derived::COption_CVec_u8ZZ) {
1435 let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ val_opt.take() }.into_rust()) }})} };
1436 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val;
1438 /// The channel type that this channel will represent. If none is set, we derive the channel
1439 /// type from the intersection of our feature bits with our counterparty's feature bits from
1440 /// the Init message.
1442 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1444 pub extern "C" fn OpenChannelV2_get_channel_type(this_ptr: &OpenChannelV2) -> crate::lightning::ln::features::ChannelTypeFeatures {
1445 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1446 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 };
1449 /// The channel type that this channel will represent. If none is set, we derive the channel
1450 /// type from the intersection of our feature bits with our counterparty's feature bits from
1451 /// the Init message.
1453 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1455 pub extern "C" fn OpenChannelV2_set_channel_type(this_ptr: &mut OpenChannelV2, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1456 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1457 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1459 /// Optionally, a requirement that only confirmed inputs can be added
1461 pub extern "C" fn OpenChannelV2_get_require_confirmed_inputs(this_ptr: &OpenChannelV2) -> crate::c_types::derived::COption_NoneZ {
1462 let mut inner_val = &mut this_ptr.get_native_mut_ref().require_confirmed_inputs;
1463 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 /* { () /**/ } */ };
1466 /// Optionally, a requirement that only confirmed inputs can be added
1468 pub extern "C" fn OpenChannelV2_set_require_confirmed_inputs(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::derived::COption_NoneZ) {
1469 let mut local_val = if val.is_some() { Some( { () /*val.take()*/ }) } else { None };
1470 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.require_confirmed_inputs = local_val;
1472 /// Constructs a new OpenChannelV2 given each field
1474 /// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
1477 pub extern "C" fn OpenChannelV2_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_feerate_sat_per_1000_weight_arg: u32, mut commitment_feerate_sat_per_1000_weight_arg: u32, mut funding_satoshis_arg: u64, mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut htlc_minimum_msat_arg: u64, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16, mut locktime_arg: u32, mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_basepoint_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey, mut first_per_commitment_point_arg: crate::c_types::PublicKey, mut second_per_commitment_point_arg: crate::c_types::PublicKey, mut channel_flags_arg: u8, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_CVec_u8ZZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures, mut require_confirmed_inputs_arg: crate::c_types::derived::COption_NoneZ) -> OpenChannelV2 {
1478 let mut local_shutdown_scriptpubkey_arg = { /*shutdown_scriptpubkey_arg*/ let shutdown_scriptpubkey_arg_opt = shutdown_scriptpubkey_arg; if shutdown_scriptpubkey_arg_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} };
1479 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()) } }) };
1480 let mut local_require_confirmed_inputs_arg = if require_confirmed_inputs_arg.is_some() { Some( { () /*require_confirmed_inputs_arg.take()*/ }) } else { None };
1481 OpenChannelV2 { inner: ObjOps::heap_alloc(nativeOpenChannelV2 {
1482 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data[..]),
1483 temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_arg.data),
1484 funding_feerate_sat_per_1000_weight: funding_feerate_sat_per_1000_weight_arg,
1485 commitment_feerate_sat_per_1000_weight: commitment_feerate_sat_per_1000_weight_arg,
1486 funding_satoshis: funding_satoshis_arg,
1487 dust_limit_satoshis: dust_limit_satoshis_arg,
1488 max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg,
1489 htlc_minimum_msat: htlc_minimum_msat_arg,
1490 to_self_delay: to_self_delay_arg,
1491 max_accepted_htlcs: max_accepted_htlcs_arg,
1492 locktime: locktime_arg,
1493 funding_pubkey: funding_pubkey_arg.into_rust(),
1494 revocation_basepoint: revocation_basepoint_arg.into_rust(),
1495 payment_basepoint: payment_basepoint_arg.into_rust(),
1496 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
1497 htlc_basepoint: htlc_basepoint_arg.into_rust(),
1498 first_per_commitment_point: first_per_commitment_point_arg.into_rust(),
1499 second_per_commitment_point: second_per_commitment_point_arg.into_rust(),
1500 channel_flags: channel_flags_arg,
1501 shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg,
1502 channel_type: local_channel_type_arg,
1503 require_confirmed_inputs: local_require_confirmed_inputs_arg,
1504 }), is_owned: true }
1506 impl Clone for OpenChannelV2 {
1507 fn clone(&self) -> Self {
1509 inner: if <*mut nativeOpenChannelV2>::is_null(self.inner) { core::ptr::null_mut() } else {
1510 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1516 /// Used only if an object of this type is returned as a trait impl by a method
1517 pub(crate) extern "C" fn OpenChannelV2_clone_void(this_ptr: *const c_void) -> *mut c_void {
1518 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOpenChannelV2)).clone() })) as *mut c_void
1521 /// Creates a copy of the OpenChannelV2
1522 pub extern "C" fn OpenChannelV2_clone(orig: &OpenChannelV2) -> OpenChannelV2 {
1525 /// Checks if two OpenChannelV2s contain equal inner contents.
1526 /// This ignores pointers and is_owned flags and looks at the values in fields.
1527 /// Two objects with NULL inner values will be considered "equal" here.
1529 pub extern "C" fn OpenChannelV2_eq(a: &OpenChannelV2, b: &OpenChannelV2) -> bool {
1530 if a.inner == b.inner { return true; }
1531 if a.inner.is_null() || b.inner.is_null() { return false; }
1532 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1535 use lightning::ln::msgs::AcceptChannel as nativeAcceptChannelImport;
1536 pub(crate) type nativeAcceptChannel = nativeAcceptChannelImport;
1538 /// An [`accept_channel`] message to be sent to or received from a peer.
1540 /// Used in V1 channel establishment
1542 /// [`accept_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-accept_channel-message
1545 pub struct AcceptChannel {
1546 /// A pointer to the opaque Rust object.
1548 /// Nearly everywhere, inner must be non-null, however in places where
1549 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1550 pub inner: *mut nativeAcceptChannel,
1551 /// Indicates that this is the only struct which contains the same pointer.
1553 /// Rust functions which take ownership of an object provided via an argument require
1554 /// this to be true and invalidate the object pointed to by inner.
1558 impl Drop for AcceptChannel {
1559 fn drop(&mut self) {
1560 if self.is_owned && !<*mut nativeAcceptChannel>::is_null(self.inner) {
1561 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1565 /// Frees any resources used by the AcceptChannel, if is_owned is set and inner is non-NULL.
1567 pub extern "C" fn AcceptChannel_free(this_obj: AcceptChannel) { }
1569 /// Used only if an object of this type is returned as a trait impl by a method
1570 pub(crate) extern "C" fn AcceptChannel_free_void(this_ptr: *mut c_void) {
1571 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAcceptChannel) };
1574 impl AcceptChannel {
1575 pub(crate) fn get_native_ref(&self) -> &'static nativeAcceptChannel {
1576 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1578 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAcceptChannel {
1579 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1581 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1582 pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannel {
1583 assert!(self.is_owned);
1584 let ret = ObjOps::untweak_ptr(self.inner);
1585 self.inner = core::ptr::null_mut();
1589 /// A temporary channel ID, until the funding outpoint is announced
1591 pub extern "C" fn AcceptChannel_get_temporary_channel_id(this_ptr: &AcceptChannel) -> *const [u8; 32] {
1592 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
1595 /// A temporary channel ID, until the funding outpoint is announced
1597 pub extern "C" fn AcceptChannel_set_temporary_channel_id(this_ptr: &mut AcceptChannel, mut val: crate::c_types::ThirtyTwoBytes) {
1598 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = ::lightning::ln::ChannelId(val.data);
1600 /// The threshold below which outputs on transactions broadcast by sender will be omitted
1602 pub extern "C" fn AcceptChannel_get_dust_limit_satoshis(this_ptr: &AcceptChannel) -> u64 {
1603 let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
1606 /// The threshold below which outputs on transactions broadcast by sender will be omitted
1608 pub extern "C" fn AcceptChannel_set_dust_limit_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
1609 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
1611 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
1613 pub extern "C" fn AcceptChannel_get_max_htlc_value_in_flight_msat(this_ptr: &AcceptChannel) -> u64 {
1614 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
1617 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
1619 pub extern "C" fn AcceptChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
1620 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
1622 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1624 pub extern "C" fn AcceptChannel_get_channel_reserve_satoshis(this_ptr: &AcceptChannel) -> u64 {
1625 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
1628 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1630 pub extern "C" fn AcceptChannel_set_channel_reserve_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
1631 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
1633 /// The minimum HTLC size incoming to sender, in milli-satoshi
1635 pub extern "C" fn AcceptChannel_get_htlc_minimum_msat(this_ptr: &AcceptChannel) -> u64 {
1636 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
1639 /// The minimum HTLC size incoming to sender, in milli-satoshi
1641 pub extern "C" fn AcceptChannel_set_htlc_minimum_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
1642 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
1644 /// Minimum depth of the funding transaction before the channel is considered open
1646 pub extern "C" fn AcceptChannel_get_minimum_depth(this_ptr: &AcceptChannel) -> u32 {
1647 let mut inner_val = &mut this_ptr.get_native_mut_ref().minimum_depth;
1650 /// Minimum depth of the funding transaction before the channel is considered open
1652 pub extern "C" fn AcceptChannel_set_minimum_depth(this_ptr: &mut AcceptChannel, mut val: u32) {
1653 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.minimum_depth = val;
1655 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
1657 pub extern "C" fn AcceptChannel_get_to_self_delay(this_ptr: &AcceptChannel) -> u16 {
1658 let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
1661 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
1663 pub extern "C" fn AcceptChannel_set_to_self_delay(this_ptr: &mut AcceptChannel, mut val: u16) {
1664 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
1666 /// The maximum number of inbound HTLCs towards sender
1668 pub extern "C" fn AcceptChannel_get_max_accepted_htlcs(this_ptr: &AcceptChannel) -> u16 {
1669 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
1672 /// The maximum number of inbound HTLCs towards sender
1674 pub extern "C" fn AcceptChannel_set_max_accepted_htlcs(this_ptr: &mut AcceptChannel, mut val: u16) {
1675 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
1677 /// The sender's key controlling the funding transaction
1679 pub extern "C" fn AcceptChannel_get_funding_pubkey(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1680 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
1681 crate::c_types::PublicKey::from_rust(&inner_val)
1683 /// The sender's key controlling the funding transaction
1685 pub extern "C" fn AcceptChannel_set_funding_pubkey(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1686 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
1688 /// Used to derive a revocation key for transactions broadcast by counterparty
1690 pub extern "C" fn AcceptChannel_get_revocation_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1691 let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
1692 crate::c_types::PublicKey::from_rust(&inner_val)
1694 /// Used to derive a revocation key for transactions broadcast by counterparty
1696 pub extern "C" fn AcceptChannel_set_revocation_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1697 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
1699 /// A payment key to sender for transactions broadcast by counterparty
1701 pub extern "C" fn AcceptChannel_get_payment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1702 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_point;
1703 crate::c_types::PublicKey::from_rust(&inner_val)
1705 /// A payment key to sender for transactions broadcast by counterparty
1707 pub extern "C" fn AcceptChannel_set_payment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1708 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_point = val.into_rust();
1710 /// Used to derive a payment key to sender for transactions broadcast by sender
1712 pub extern "C" fn AcceptChannel_get_delayed_payment_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1713 let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
1714 crate::c_types::PublicKey::from_rust(&inner_val)
1716 /// Used to derive a payment key to sender for transactions broadcast by sender
1718 pub extern "C" fn AcceptChannel_set_delayed_payment_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1719 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
1721 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
1723 pub extern "C" fn AcceptChannel_get_htlc_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1724 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
1725 crate::c_types::PublicKey::from_rust(&inner_val)
1727 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
1729 pub extern "C" fn AcceptChannel_set_htlc_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1730 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
1732 /// The first to-be-broadcast-by-sender transaction's per commitment point
1734 pub extern "C" fn AcceptChannel_get_first_per_commitment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1735 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
1736 crate::c_types::PublicKey::from_rust(&inner_val)
1738 /// The first to-be-broadcast-by-sender transaction's per commitment point
1740 pub extern "C" fn AcceptChannel_set_first_per_commitment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1741 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
1743 /// A request to pre-set the to-sender output's scriptPubkey for when we collaboratively close
1745 pub extern "C" fn AcceptChannel_get_shutdown_scriptpubkey(this_ptr: &AcceptChannel) -> crate::c_types::derived::COption_CVec_u8ZZ {
1746 let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey;
1747 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().into_bytes().into() }) };
1750 /// A request to pre-set the to-sender output's scriptPubkey for when we collaboratively close
1752 pub extern "C" fn AcceptChannel_set_shutdown_scriptpubkey(this_ptr: &mut AcceptChannel, mut val: crate::c_types::derived::COption_CVec_u8ZZ) {
1753 let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ val_opt.take() }.into_rust()) }})} };
1754 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val;
1756 /// The channel type that this channel will represent.
1758 /// If this is `None`, we derive the channel type from the intersection of
1759 /// our feature bits with our counterparty's feature bits from the [`Init`] message.
1760 /// This is required to match the equivalent field in [`OpenChannel::channel_type`].
1762 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1764 pub extern "C" fn AcceptChannel_get_channel_type(this_ptr: &AcceptChannel) -> crate::lightning::ln::features::ChannelTypeFeatures {
1765 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1766 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 };
1769 /// The channel type that this channel will represent.
1771 /// If this is `None`, we derive the channel type from the intersection of
1772 /// our feature bits with our counterparty's feature bits from the [`Init`] message.
1773 /// This is required to match the equivalent field in [`OpenChannel::channel_type`].
1775 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1777 pub extern "C" fn AcceptChannel_set_channel_type(this_ptr: &mut AcceptChannel, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1778 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1779 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1781 /// Constructs a new AcceptChannel given each field
1783 /// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
1786 pub extern "C" fn AcceptChannel_new(mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut channel_reserve_satoshis_arg: u64, mut htlc_minimum_msat_arg: u64, mut minimum_depth_arg: u32, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16, mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_point_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey, mut first_per_commitment_point_arg: crate::c_types::PublicKey, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_CVec_u8ZZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures) -> AcceptChannel {
1787 let mut local_shutdown_scriptpubkey_arg = { /*shutdown_scriptpubkey_arg*/ let shutdown_scriptpubkey_arg_opt = shutdown_scriptpubkey_arg; if shutdown_scriptpubkey_arg_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} };
1788 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()) } }) };
1789 AcceptChannel { inner: ObjOps::heap_alloc(nativeAcceptChannel {
1790 temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_arg.data),
1791 dust_limit_satoshis: dust_limit_satoshis_arg,
1792 max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg,
1793 channel_reserve_satoshis: channel_reserve_satoshis_arg,
1794 htlc_minimum_msat: htlc_minimum_msat_arg,
1795 minimum_depth: minimum_depth_arg,
1796 to_self_delay: to_self_delay_arg,
1797 max_accepted_htlcs: max_accepted_htlcs_arg,
1798 funding_pubkey: funding_pubkey_arg.into_rust(),
1799 revocation_basepoint: revocation_basepoint_arg.into_rust(),
1800 payment_point: payment_point_arg.into_rust(),
1801 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
1802 htlc_basepoint: htlc_basepoint_arg.into_rust(),
1803 first_per_commitment_point: first_per_commitment_point_arg.into_rust(),
1804 shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg,
1805 channel_type: local_channel_type_arg,
1806 }), is_owned: true }
1808 impl Clone for AcceptChannel {
1809 fn clone(&self) -> Self {
1811 inner: if <*mut nativeAcceptChannel>::is_null(self.inner) { core::ptr::null_mut() } else {
1812 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1818 /// Used only if an object of this type is returned as a trait impl by a method
1819 pub(crate) extern "C" fn AcceptChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
1820 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeAcceptChannel)).clone() })) as *mut c_void
1823 /// Creates a copy of the AcceptChannel
1824 pub extern "C" fn AcceptChannel_clone(orig: &AcceptChannel) -> AcceptChannel {
1827 /// Checks if two AcceptChannels contain equal inner contents.
1828 /// This ignores pointers and is_owned flags and looks at the values in fields.
1829 /// Two objects with NULL inner values will be considered "equal" here.
1831 pub extern "C" fn AcceptChannel_eq(a: &AcceptChannel, b: &AcceptChannel) -> bool {
1832 if a.inner == b.inner { return true; }
1833 if a.inner.is_null() || b.inner.is_null() { return false; }
1834 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1837 use lightning::ln::msgs::AcceptChannelV2 as nativeAcceptChannelV2Import;
1838 pub(crate) type nativeAcceptChannelV2 = nativeAcceptChannelV2Import;
1840 /// An accept_channel2 message to be sent by or received from the channel accepter.
1842 /// Used in V2 channel establishment
1846 pub struct AcceptChannelV2 {
1847 /// A pointer to the opaque Rust object.
1849 /// Nearly everywhere, inner must be non-null, however in places where
1850 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1851 pub inner: *mut nativeAcceptChannelV2,
1852 /// Indicates that this is the only struct which contains the same pointer.
1854 /// Rust functions which take ownership of an object provided via an argument require
1855 /// this to be true and invalidate the object pointed to by inner.
1859 impl Drop for AcceptChannelV2 {
1860 fn drop(&mut self) {
1861 if self.is_owned && !<*mut nativeAcceptChannelV2>::is_null(self.inner) {
1862 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1866 /// Frees any resources used by the AcceptChannelV2, if is_owned is set and inner is non-NULL.
1868 pub extern "C" fn AcceptChannelV2_free(this_obj: AcceptChannelV2) { }
1870 /// Used only if an object of this type is returned as a trait impl by a method
1871 pub(crate) extern "C" fn AcceptChannelV2_free_void(this_ptr: *mut c_void) {
1872 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAcceptChannelV2) };
1875 impl AcceptChannelV2 {
1876 pub(crate) fn get_native_ref(&self) -> &'static nativeAcceptChannelV2 {
1877 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1879 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAcceptChannelV2 {
1880 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1882 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1883 pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannelV2 {
1884 assert!(self.is_owned);
1885 let ret = ObjOps::untweak_ptr(self.inner);
1886 self.inner = core::ptr::null_mut();
1890 /// The same `temporary_channel_id` received from the initiator's `open_channel2` message.
1892 pub extern "C" fn AcceptChannelV2_get_temporary_channel_id(this_ptr: &AcceptChannelV2) -> *const [u8; 32] {
1893 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
1896 /// The same `temporary_channel_id` received from the initiator's `open_channel2` message.
1898 pub extern "C" fn AcceptChannelV2_set_temporary_channel_id(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::ThirtyTwoBytes) {
1899 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = ::lightning::ln::ChannelId(val.data);
1901 /// Part of the channel value contributed by the channel acceptor
1903 pub extern "C" fn AcceptChannelV2_get_funding_satoshis(this_ptr: &AcceptChannelV2) -> u64 {
1904 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
1907 /// Part of the channel value contributed by the channel acceptor
1909 pub extern "C" fn AcceptChannelV2_set_funding_satoshis(this_ptr: &mut AcceptChannelV2, mut val: u64) {
1910 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
1912 /// The threshold below which outputs on transactions broadcast by the channel acceptor will be
1915 pub extern "C" fn AcceptChannelV2_get_dust_limit_satoshis(this_ptr: &AcceptChannelV2) -> u64 {
1916 let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
1919 /// The threshold below which outputs on transactions broadcast by the channel acceptor will be
1922 pub extern "C" fn AcceptChannelV2_set_dust_limit_satoshis(this_ptr: &mut AcceptChannelV2, mut val: u64) {
1923 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
1925 /// The maximum inbound HTLC value in flight towards channel acceptor, in milli-satoshi
1927 pub extern "C" fn AcceptChannelV2_get_max_htlc_value_in_flight_msat(this_ptr: &AcceptChannelV2) -> u64 {
1928 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
1931 /// The maximum inbound HTLC value in flight towards channel acceptor, in milli-satoshi
1933 pub extern "C" fn AcceptChannelV2_set_max_htlc_value_in_flight_msat(this_ptr: &mut AcceptChannelV2, mut val: u64) {
1934 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
1936 /// The minimum HTLC size incoming to channel acceptor, in milli-satoshi
1938 pub extern "C" fn AcceptChannelV2_get_htlc_minimum_msat(this_ptr: &AcceptChannelV2) -> u64 {
1939 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
1942 /// The minimum HTLC size incoming to channel acceptor, in milli-satoshi
1944 pub extern "C" fn AcceptChannelV2_set_htlc_minimum_msat(this_ptr: &mut AcceptChannelV2, mut val: u64) {
1945 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
1947 /// Minimum depth of the funding transaction before the channel is considered open
1949 pub extern "C" fn AcceptChannelV2_get_minimum_depth(this_ptr: &AcceptChannelV2) -> u32 {
1950 let mut inner_val = &mut this_ptr.get_native_mut_ref().minimum_depth;
1953 /// Minimum depth of the funding transaction before the channel is considered open
1955 pub extern "C" fn AcceptChannelV2_set_minimum_depth(this_ptr: &mut AcceptChannelV2, mut val: u32) {
1956 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.minimum_depth = val;
1958 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1959 /// broadcast a commitment transaction
1961 pub extern "C" fn AcceptChannelV2_get_to_self_delay(this_ptr: &AcceptChannelV2) -> u16 {
1962 let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
1965 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1966 /// broadcast a commitment transaction
1968 pub extern "C" fn AcceptChannelV2_set_to_self_delay(this_ptr: &mut AcceptChannelV2, mut val: u16) {
1969 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
1971 /// The maximum number of inbound HTLCs towards channel acceptor
1973 pub extern "C" fn AcceptChannelV2_get_max_accepted_htlcs(this_ptr: &AcceptChannelV2) -> u16 {
1974 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
1977 /// The maximum number of inbound HTLCs towards channel acceptor
1979 pub extern "C" fn AcceptChannelV2_set_max_accepted_htlcs(this_ptr: &mut AcceptChannelV2, mut val: u16) {
1980 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
1982 /// The channel acceptor's key controlling the funding transaction
1984 pub extern "C" fn AcceptChannelV2_get_funding_pubkey(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
1985 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
1986 crate::c_types::PublicKey::from_rust(&inner_val)
1988 /// The channel acceptor's key controlling the funding transaction
1990 pub extern "C" fn AcceptChannelV2_set_funding_pubkey(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
1991 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
1993 /// Used to derive a revocation key for transactions broadcast by counterparty
1995 pub extern "C" fn AcceptChannelV2_get_revocation_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
1996 let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
1997 crate::c_types::PublicKey::from_rust(&inner_val)
1999 /// Used to derive a revocation key for transactions broadcast by counterparty
2001 pub extern "C" fn AcceptChannelV2_set_revocation_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2002 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
2004 /// A payment key to channel acceptor for transactions broadcast by counterparty
2006 pub extern "C" fn AcceptChannelV2_get_payment_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2007 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_basepoint;
2008 crate::c_types::PublicKey::from_rust(&inner_val)
2010 /// A payment key to channel acceptor for transactions broadcast by counterparty
2012 pub extern "C" fn AcceptChannelV2_set_payment_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2013 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_basepoint = val.into_rust();
2015 /// Used to derive a payment key to channel acceptor for transactions broadcast by channel
2018 pub extern "C" fn AcceptChannelV2_get_delayed_payment_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2019 let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
2020 crate::c_types::PublicKey::from_rust(&inner_val)
2022 /// Used to derive a payment key to channel acceptor for transactions broadcast by channel
2025 pub extern "C" fn AcceptChannelV2_set_delayed_payment_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2026 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
2028 /// Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty
2030 pub extern "C" fn AcceptChannelV2_get_htlc_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2031 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
2032 crate::c_types::PublicKey::from_rust(&inner_val)
2034 /// Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty
2036 pub extern "C" fn AcceptChannelV2_set_htlc_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2037 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
2039 /// The first to-be-broadcast-by-channel-acceptor transaction's per commitment point
2041 pub extern "C" fn AcceptChannelV2_get_first_per_commitment_point(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2042 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
2043 crate::c_types::PublicKey::from_rust(&inner_val)
2045 /// The first to-be-broadcast-by-channel-acceptor transaction's per commitment point
2047 pub extern "C" fn AcceptChannelV2_set_first_per_commitment_point(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2048 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
2050 /// The second to-be-broadcast-by-channel-acceptor transaction's per commitment point
2052 pub extern "C" fn AcceptChannelV2_get_second_per_commitment_point(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2053 let mut inner_val = &mut this_ptr.get_native_mut_ref().second_per_commitment_point;
2054 crate::c_types::PublicKey::from_rust(&inner_val)
2056 /// The second to-be-broadcast-by-channel-acceptor transaction's per commitment point
2058 pub extern "C" fn AcceptChannelV2_set_second_per_commitment_point(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2059 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.second_per_commitment_point = val.into_rust();
2061 /// Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we
2062 /// collaboratively close
2064 pub extern "C" fn AcceptChannelV2_get_shutdown_scriptpubkey(this_ptr: &AcceptChannelV2) -> crate::c_types::derived::COption_CVec_u8ZZ {
2065 let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey;
2066 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().into_bytes().into() }) };
2069 /// Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we
2070 /// collaboratively close
2072 pub extern "C" fn AcceptChannelV2_set_shutdown_scriptpubkey(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::derived::COption_CVec_u8ZZ) {
2073 let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ val_opt.take() }.into_rust()) }})} };
2074 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val;
2076 /// The channel type that this channel will represent. If none is set, we derive the channel
2077 /// type from the intersection of our feature bits with our counterparty's feature bits from
2078 /// the Init message.
2080 /// This is required to match the equivalent field in [`OpenChannelV2::channel_type`].
2082 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
2084 pub extern "C" fn AcceptChannelV2_get_channel_type(this_ptr: &AcceptChannelV2) -> crate::lightning::ln::features::ChannelTypeFeatures {
2085 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
2086 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 };
2089 /// The channel type that this channel will represent. If none is set, we derive the channel
2090 /// type from the intersection of our feature bits with our counterparty's feature bits from
2091 /// the Init message.
2093 /// This is required to match the equivalent field in [`OpenChannelV2::channel_type`].
2095 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
2097 pub extern "C" fn AcceptChannelV2_set_channel_type(this_ptr: &mut AcceptChannelV2, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
2098 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
2099 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
2101 /// Optionally, a requirement that only confirmed inputs can be added
2103 pub extern "C" fn AcceptChannelV2_get_require_confirmed_inputs(this_ptr: &AcceptChannelV2) -> crate::c_types::derived::COption_NoneZ {
2104 let mut inner_val = &mut this_ptr.get_native_mut_ref().require_confirmed_inputs;
2105 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 /* { () /**/ } */ };
2108 /// Optionally, a requirement that only confirmed inputs can be added
2110 pub extern "C" fn AcceptChannelV2_set_require_confirmed_inputs(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::derived::COption_NoneZ) {
2111 let mut local_val = if val.is_some() { Some( { () /*val.take()*/ }) } else { None };
2112 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.require_confirmed_inputs = local_val;
2114 /// Constructs a new AcceptChannelV2 given each field
2116 /// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
2119 pub extern "C" fn AcceptChannelV2_new(mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_satoshis_arg: u64, mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut htlc_minimum_msat_arg: u64, mut minimum_depth_arg: u32, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16, mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_basepoint_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey, mut first_per_commitment_point_arg: crate::c_types::PublicKey, mut second_per_commitment_point_arg: crate::c_types::PublicKey, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_CVec_u8ZZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures, mut require_confirmed_inputs_arg: crate::c_types::derived::COption_NoneZ) -> AcceptChannelV2 {
2120 let mut local_shutdown_scriptpubkey_arg = { /*shutdown_scriptpubkey_arg*/ let shutdown_scriptpubkey_arg_opt = shutdown_scriptpubkey_arg; if shutdown_scriptpubkey_arg_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} };
2121 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()) } }) };
2122 let mut local_require_confirmed_inputs_arg = if require_confirmed_inputs_arg.is_some() { Some( { () /*require_confirmed_inputs_arg.take()*/ }) } else { None };
2123 AcceptChannelV2 { inner: ObjOps::heap_alloc(nativeAcceptChannelV2 {
2124 temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_arg.data),
2125 funding_satoshis: funding_satoshis_arg,
2126 dust_limit_satoshis: dust_limit_satoshis_arg,
2127 max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg,
2128 htlc_minimum_msat: htlc_minimum_msat_arg,
2129 minimum_depth: minimum_depth_arg,
2130 to_self_delay: to_self_delay_arg,
2131 max_accepted_htlcs: max_accepted_htlcs_arg,
2132 funding_pubkey: funding_pubkey_arg.into_rust(),
2133 revocation_basepoint: revocation_basepoint_arg.into_rust(),
2134 payment_basepoint: payment_basepoint_arg.into_rust(),
2135 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
2136 htlc_basepoint: htlc_basepoint_arg.into_rust(),
2137 first_per_commitment_point: first_per_commitment_point_arg.into_rust(),
2138 second_per_commitment_point: second_per_commitment_point_arg.into_rust(),
2139 shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg,
2140 channel_type: local_channel_type_arg,
2141 require_confirmed_inputs: local_require_confirmed_inputs_arg,
2142 }), is_owned: true }
2144 impl Clone for AcceptChannelV2 {
2145 fn clone(&self) -> Self {
2147 inner: if <*mut nativeAcceptChannelV2>::is_null(self.inner) { core::ptr::null_mut() } else {
2148 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2154 /// Used only if an object of this type is returned as a trait impl by a method
2155 pub(crate) extern "C" fn AcceptChannelV2_clone_void(this_ptr: *const c_void) -> *mut c_void {
2156 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeAcceptChannelV2)).clone() })) as *mut c_void
2159 /// Creates a copy of the AcceptChannelV2
2160 pub extern "C" fn AcceptChannelV2_clone(orig: &AcceptChannelV2) -> AcceptChannelV2 {
2163 /// Checks if two AcceptChannelV2s contain equal inner contents.
2164 /// This ignores pointers and is_owned flags and looks at the values in fields.
2165 /// Two objects with NULL inner values will be considered "equal" here.
2167 pub extern "C" fn AcceptChannelV2_eq(a: &AcceptChannelV2, b: &AcceptChannelV2) -> bool {
2168 if a.inner == b.inner { return true; }
2169 if a.inner.is_null() || b.inner.is_null() { return false; }
2170 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2173 use lightning::ln::msgs::FundingCreated as nativeFundingCreatedImport;
2174 pub(crate) type nativeFundingCreated = nativeFundingCreatedImport;
2176 /// A [`funding_created`] message to be sent to or received from a peer.
2178 /// Used in V1 channel establishment
2180 /// [`funding_created`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_created-message
2183 pub struct FundingCreated {
2184 /// A pointer to the opaque Rust object.
2186 /// Nearly everywhere, inner must be non-null, however in places where
2187 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2188 pub inner: *mut nativeFundingCreated,
2189 /// Indicates that this is the only struct which contains the same pointer.
2191 /// Rust functions which take ownership of an object provided via an argument require
2192 /// this to be true and invalidate the object pointed to by inner.
2196 impl Drop for FundingCreated {
2197 fn drop(&mut self) {
2198 if self.is_owned && !<*mut nativeFundingCreated>::is_null(self.inner) {
2199 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2203 /// Frees any resources used by the FundingCreated, if is_owned is set and inner is non-NULL.
2205 pub extern "C" fn FundingCreated_free(this_obj: FundingCreated) { }
2207 /// Used only if an object of this type is returned as a trait impl by a method
2208 pub(crate) extern "C" fn FundingCreated_free_void(this_ptr: *mut c_void) {
2209 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeFundingCreated) };
2212 impl FundingCreated {
2213 pub(crate) fn get_native_ref(&self) -> &'static nativeFundingCreated {
2214 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2216 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingCreated {
2217 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2219 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2220 pub(crate) fn take_inner(mut self) -> *mut nativeFundingCreated {
2221 assert!(self.is_owned);
2222 let ret = ObjOps::untweak_ptr(self.inner);
2223 self.inner = core::ptr::null_mut();
2227 /// A temporary channel ID, until the funding is established
2229 pub extern "C" fn FundingCreated_get_temporary_channel_id(this_ptr: &FundingCreated) -> *const [u8; 32] {
2230 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
2233 /// A temporary channel ID, until the funding is established
2235 pub extern "C" fn FundingCreated_set_temporary_channel_id(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
2236 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = ::lightning::ln::ChannelId(val.data);
2238 /// The funding transaction ID
2240 pub extern "C" fn FundingCreated_get_funding_txid(this_ptr: &FundingCreated) -> *const [u8; 32] {
2241 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_txid;
2242 inner_val.as_inner()
2244 /// The funding transaction ID
2246 pub extern "C" fn FundingCreated_set_funding_txid(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
2247 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_txid = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
2249 /// The specific output index funding this channel
2251 pub extern "C" fn FundingCreated_get_funding_output_index(this_ptr: &FundingCreated) -> u16 {
2252 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_index;
2255 /// The specific output index funding this channel
2257 pub extern "C" fn FundingCreated_set_funding_output_index(this_ptr: &mut FundingCreated, mut val: u16) {
2258 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_index = val;
2260 /// The signature of the channel initiator (funder) on the initial commitment transaction
2262 pub extern "C" fn FundingCreated_get_signature(this_ptr: &FundingCreated) -> crate::c_types::ECDSASignature {
2263 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
2264 crate::c_types::ECDSASignature::from_rust(&inner_val)
2266 /// The signature of the channel initiator (funder) on the initial commitment transaction
2268 pub extern "C" fn FundingCreated_set_signature(this_ptr: &mut FundingCreated, mut val: crate::c_types::ECDSASignature) {
2269 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
2271 /// Constructs a new FundingCreated given each field
2274 pub extern "C" fn FundingCreated_new(mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_txid_arg: crate::c_types::ThirtyTwoBytes, mut funding_output_index_arg: u16, mut signature_arg: crate::c_types::ECDSASignature) -> FundingCreated {
2275 FundingCreated { inner: ObjOps::heap_alloc(nativeFundingCreated {
2276 temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_arg.data),
2277 funding_txid: ::bitcoin::hash_types::Txid::from_slice(&funding_txid_arg.data[..]).unwrap(),
2278 funding_output_index: funding_output_index_arg,
2279 signature: signature_arg.into_rust(),
2280 }), is_owned: true }
2282 impl Clone for FundingCreated {
2283 fn clone(&self) -> Self {
2285 inner: if <*mut nativeFundingCreated>::is_null(self.inner) { core::ptr::null_mut() } else {
2286 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2292 /// Used only if an object of this type is returned as a trait impl by a method
2293 pub(crate) extern "C" fn FundingCreated_clone_void(this_ptr: *const c_void) -> *mut c_void {
2294 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeFundingCreated)).clone() })) as *mut c_void
2297 /// Creates a copy of the FundingCreated
2298 pub extern "C" fn FundingCreated_clone(orig: &FundingCreated) -> FundingCreated {
2301 /// Checks if two FundingCreateds contain equal inner contents.
2302 /// This ignores pointers and is_owned flags and looks at the values in fields.
2303 /// Two objects with NULL inner values will be considered "equal" here.
2305 pub extern "C" fn FundingCreated_eq(a: &FundingCreated, b: &FundingCreated) -> bool {
2306 if a.inner == b.inner { return true; }
2307 if a.inner.is_null() || b.inner.is_null() { return false; }
2308 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2311 use lightning::ln::msgs::FundingSigned as nativeFundingSignedImport;
2312 pub(crate) type nativeFundingSigned = nativeFundingSignedImport;
2314 /// A [`funding_signed`] message to be sent to or received from a peer.
2316 /// Used in V1 channel establishment
2318 /// [`funding_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_signed-message
2321 pub struct FundingSigned {
2322 /// A pointer to the opaque Rust object.
2324 /// Nearly everywhere, inner must be non-null, however in places where
2325 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2326 pub inner: *mut nativeFundingSigned,
2327 /// Indicates that this is the only struct which contains the same pointer.
2329 /// Rust functions which take ownership of an object provided via an argument require
2330 /// this to be true and invalidate the object pointed to by inner.
2334 impl Drop for FundingSigned {
2335 fn drop(&mut self) {
2336 if self.is_owned && !<*mut nativeFundingSigned>::is_null(self.inner) {
2337 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2341 /// Frees any resources used by the FundingSigned, if is_owned is set and inner is non-NULL.
2343 pub extern "C" fn FundingSigned_free(this_obj: FundingSigned) { }
2345 /// Used only if an object of this type is returned as a trait impl by a method
2346 pub(crate) extern "C" fn FundingSigned_free_void(this_ptr: *mut c_void) {
2347 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeFundingSigned) };
2350 impl FundingSigned {
2351 pub(crate) fn get_native_ref(&self) -> &'static nativeFundingSigned {
2352 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2354 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingSigned {
2355 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2357 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2358 pub(crate) fn take_inner(mut self) -> *mut nativeFundingSigned {
2359 assert!(self.is_owned);
2360 let ret = ObjOps::untweak_ptr(self.inner);
2361 self.inner = core::ptr::null_mut();
2367 pub extern "C" fn FundingSigned_get_channel_id(this_ptr: &FundingSigned) -> *const [u8; 32] {
2368 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2373 pub extern "C" fn FundingSigned_set_channel_id(this_ptr: &mut FundingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
2374 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
2376 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
2378 pub extern "C" fn FundingSigned_get_signature(this_ptr: &FundingSigned) -> crate::c_types::ECDSASignature {
2379 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
2380 crate::c_types::ECDSASignature::from_rust(&inner_val)
2382 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
2384 pub extern "C" fn FundingSigned_set_signature(this_ptr: &mut FundingSigned, mut val: crate::c_types::ECDSASignature) {
2385 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
2387 /// Constructs a new FundingSigned given each field
2390 pub extern "C" fn FundingSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut signature_arg: crate::c_types::ECDSASignature) -> FundingSigned {
2391 FundingSigned { inner: ObjOps::heap_alloc(nativeFundingSigned {
2392 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
2393 signature: signature_arg.into_rust(),
2394 }), is_owned: true }
2396 impl Clone for FundingSigned {
2397 fn clone(&self) -> Self {
2399 inner: if <*mut nativeFundingSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
2400 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2406 /// Used only if an object of this type is returned as a trait impl by a method
2407 pub(crate) extern "C" fn FundingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
2408 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeFundingSigned)).clone() })) as *mut c_void
2411 /// Creates a copy of the FundingSigned
2412 pub extern "C" fn FundingSigned_clone(orig: &FundingSigned) -> FundingSigned {
2415 /// Checks if two FundingSigneds contain equal inner contents.
2416 /// This ignores pointers and is_owned flags and looks at the values in fields.
2417 /// Two objects with NULL inner values will be considered "equal" here.
2419 pub extern "C" fn FundingSigned_eq(a: &FundingSigned, b: &FundingSigned) -> bool {
2420 if a.inner == b.inner { return true; }
2421 if a.inner.is_null() || b.inner.is_null() { return false; }
2422 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2425 use lightning::ln::msgs::ChannelReady as nativeChannelReadyImport;
2426 pub(crate) type nativeChannelReady = nativeChannelReadyImport;
2428 /// A [`channel_ready`] message to be sent to or received from a peer.
2430 /// [`channel_ready`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-channel_ready-message
2433 pub struct ChannelReady {
2434 /// A pointer to the opaque Rust object.
2436 /// Nearly everywhere, inner must be non-null, however in places where
2437 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2438 pub inner: *mut nativeChannelReady,
2439 /// Indicates that this is the only struct which contains the same pointer.
2441 /// Rust functions which take ownership of an object provided via an argument require
2442 /// this to be true and invalidate the object pointed to by inner.
2446 impl Drop for ChannelReady {
2447 fn drop(&mut self) {
2448 if self.is_owned && !<*mut nativeChannelReady>::is_null(self.inner) {
2449 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2453 /// Frees any resources used by the ChannelReady, if is_owned is set and inner is non-NULL.
2455 pub extern "C" fn ChannelReady_free(this_obj: ChannelReady) { }
2457 /// Used only if an object of this type is returned as a trait impl by a method
2458 pub(crate) extern "C" fn ChannelReady_free_void(this_ptr: *mut c_void) {
2459 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelReady) };
2463 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelReady {
2464 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2466 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelReady {
2467 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2469 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2470 pub(crate) fn take_inner(mut self) -> *mut nativeChannelReady {
2471 assert!(self.is_owned);
2472 let ret = ObjOps::untweak_ptr(self.inner);
2473 self.inner = core::ptr::null_mut();
2479 pub extern "C" fn ChannelReady_get_channel_id(this_ptr: &ChannelReady) -> *const [u8; 32] {
2480 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2485 pub extern "C" fn ChannelReady_set_channel_id(this_ptr: &mut ChannelReady, mut val: crate::c_types::ThirtyTwoBytes) {
2486 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
2488 /// The per-commitment point of the second commitment transaction
2490 pub extern "C" fn ChannelReady_get_next_per_commitment_point(this_ptr: &ChannelReady) -> crate::c_types::PublicKey {
2491 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
2492 crate::c_types::PublicKey::from_rust(&inner_val)
2494 /// The per-commitment point of the second commitment transaction
2496 pub extern "C" fn ChannelReady_set_next_per_commitment_point(this_ptr: &mut ChannelReady, mut val: crate::c_types::PublicKey) {
2497 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
2499 /// If set, provides a `short_channel_id` alias for this channel.
2501 /// The sender will accept payments to be forwarded over this SCID and forward them to this
2502 /// messages' recipient.
2504 pub extern "C" fn ChannelReady_get_short_channel_id_alias(this_ptr: &ChannelReady) -> crate::c_types::derived::COption_u64Z {
2505 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id_alias;
2506 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() }) };
2509 /// If set, provides a `short_channel_id` alias for this channel.
2511 /// The sender will accept payments to be forwarded over this SCID and forward them to this
2512 /// messages' recipient.
2514 pub extern "C" fn ChannelReady_set_short_channel_id_alias(this_ptr: &mut ChannelReady, mut val: crate::c_types::derived::COption_u64Z) {
2515 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
2516 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id_alias = local_val;
2518 /// Constructs a new ChannelReady given each field
2521 pub extern "C" fn ChannelReady_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut next_per_commitment_point_arg: crate::c_types::PublicKey, mut short_channel_id_alias_arg: crate::c_types::derived::COption_u64Z) -> ChannelReady {
2522 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 };
2523 ChannelReady { inner: ObjOps::heap_alloc(nativeChannelReady {
2524 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
2525 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
2526 short_channel_id_alias: local_short_channel_id_alias_arg,
2527 }), is_owned: true }
2529 impl Clone for ChannelReady {
2530 fn clone(&self) -> Self {
2532 inner: if <*mut nativeChannelReady>::is_null(self.inner) { core::ptr::null_mut() } else {
2533 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2539 /// Used only if an object of this type is returned as a trait impl by a method
2540 pub(crate) extern "C" fn ChannelReady_clone_void(this_ptr: *const c_void) -> *mut c_void {
2541 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelReady)).clone() })) as *mut c_void
2544 /// Creates a copy of the ChannelReady
2545 pub extern "C" fn ChannelReady_clone(orig: &ChannelReady) -> ChannelReady {
2548 /// Checks if two ChannelReadys contain equal inner contents.
2549 /// This ignores pointers and is_owned flags and looks at the values in fields.
2550 /// Two objects with NULL inner values will be considered "equal" here.
2552 pub extern "C" fn ChannelReady_eq(a: &ChannelReady, b: &ChannelReady) -> bool {
2553 if a.inner == b.inner { return true; }
2554 if a.inner.is_null() || b.inner.is_null() { return false; }
2555 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2558 use lightning::ln::msgs::TxAddInput as nativeTxAddInputImport;
2559 pub(crate) type nativeTxAddInput = nativeTxAddInputImport;
2561 /// A tx_add_input message for adding an input during interactive transaction construction
2565 pub struct TxAddInput {
2566 /// A pointer to the opaque Rust object.
2568 /// Nearly everywhere, inner must be non-null, however in places where
2569 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2570 pub inner: *mut nativeTxAddInput,
2571 /// Indicates that this is the only struct which contains the same pointer.
2573 /// Rust functions which take ownership of an object provided via an argument require
2574 /// this to be true and invalidate the object pointed to by inner.
2578 impl Drop for TxAddInput {
2579 fn drop(&mut self) {
2580 if self.is_owned && !<*mut nativeTxAddInput>::is_null(self.inner) {
2581 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2585 /// Frees any resources used by the TxAddInput, if is_owned is set and inner is non-NULL.
2587 pub extern "C" fn TxAddInput_free(this_obj: TxAddInput) { }
2589 /// Used only if an object of this type is returned as a trait impl by a method
2590 pub(crate) extern "C" fn TxAddInput_free_void(this_ptr: *mut c_void) {
2591 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAddInput) };
2595 pub(crate) fn get_native_ref(&self) -> &'static nativeTxAddInput {
2596 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2598 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAddInput {
2599 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2601 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2602 pub(crate) fn take_inner(mut self) -> *mut nativeTxAddInput {
2603 assert!(self.is_owned);
2604 let ret = ObjOps::untweak_ptr(self.inner);
2605 self.inner = core::ptr::null_mut();
2611 pub extern "C" fn TxAddInput_get_channel_id(this_ptr: &TxAddInput) -> *const [u8; 32] {
2612 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2617 pub extern "C" fn TxAddInput_set_channel_id(this_ptr: &mut TxAddInput, mut val: crate::c_types::ThirtyTwoBytes) {
2618 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
2620 /// A randomly chosen unique identifier for this input, which is even for initiators and odd for
2623 pub extern "C" fn TxAddInput_get_serial_id(this_ptr: &TxAddInput) -> u64 {
2624 let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
2627 /// A randomly chosen unique identifier for this input, which is even for initiators and odd for
2630 pub extern "C" fn TxAddInput_set_serial_id(this_ptr: &mut TxAddInput, mut val: u64) {
2631 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
2633 /// Serialized transaction that contains the output this input spends to verify that it is non
2636 pub extern "C" fn TxAddInput_get_prevtx(this_ptr: &TxAddInput) -> crate::lightning::util::ser::TransactionU16LenLimited {
2637 let mut inner_val = &mut this_ptr.get_native_mut_ref().prevtx;
2638 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 }
2640 /// Serialized transaction that contains the output this input spends to verify that it is non
2643 pub extern "C" fn TxAddInput_set_prevtx(this_ptr: &mut TxAddInput, mut val: crate::lightning::util::ser::TransactionU16LenLimited) {
2644 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.prevtx = *unsafe { Box::from_raw(val.take_inner()) };
2646 /// The index of the output being spent
2648 pub extern "C" fn TxAddInput_get_prevtx_out(this_ptr: &TxAddInput) -> u32 {
2649 let mut inner_val = &mut this_ptr.get_native_mut_ref().prevtx_out;
2652 /// The index of the output being spent
2654 pub extern "C" fn TxAddInput_set_prevtx_out(this_ptr: &mut TxAddInput, mut val: u32) {
2655 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.prevtx_out = val;
2657 /// The sequence number of this input
2659 pub extern "C" fn TxAddInput_get_sequence(this_ptr: &TxAddInput) -> u32 {
2660 let mut inner_val = &mut this_ptr.get_native_mut_ref().sequence;
2663 /// The sequence number of this input
2665 pub extern "C" fn TxAddInput_set_sequence(this_ptr: &mut TxAddInput, mut val: u32) {
2666 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sequence = val;
2668 /// Constructs a new TxAddInput given each field
2671 pub extern "C" fn TxAddInput_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut serial_id_arg: u64, mut prevtx_arg: crate::lightning::util::ser::TransactionU16LenLimited, mut prevtx_out_arg: u32, mut sequence_arg: u32) -> TxAddInput {
2672 TxAddInput { inner: ObjOps::heap_alloc(nativeTxAddInput {
2673 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
2674 serial_id: serial_id_arg,
2675 prevtx: *unsafe { Box::from_raw(prevtx_arg.take_inner()) },
2676 prevtx_out: prevtx_out_arg,
2677 sequence: sequence_arg,
2678 }), is_owned: true }
2680 impl Clone for TxAddInput {
2681 fn clone(&self) -> Self {
2683 inner: if <*mut nativeTxAddInput>::is_null(self.inner) { core::ptr::null_mut() } else {
2684 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2690 /// Used only if an object of this type is returned as a trait impl by a method
2691 pub(crate) extern "C" fn TxAddInput_clone_void(this_ptr: *const c_void) -> *mut c_void {
2692 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxAddInput)).clone() })) as *mut c_void
2695 /// Creates a copy of the TxAddInput
2696 pub extern "C" fn TxAddInput_clone(orig: &TxAddInput) -> TxAddInput {
2699 /// Checks if two TxAddInputs contain equal inner contents.
2700 /// This ignores pointers and is_owned flags and looks at the values in fields.
2701 /// Two objects with NULL inner values will be considered "equal" here.
2703 pub extern "C" fn TxAddInput_eq(a: &TxAddInput, b: &TxAddInput) -> bool {
2704 if a.inner == b.inner { return true; }
2705 if a.inner.is_null() || b.inner.is_null() { return false; }
2706 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2709 use lightning::ln::msgs::TxAddOutput as nativeTxAddOutputImport;
2710 pub(crate) type nativeTxAddOutput = nativeTxAddOutputImport;
2712 /// A tx_add_output message for adding an output during interactive transaction construction.
2716 pub struct TxAddOutput {
2717 /// A pointer to the opaque Rust object.
2719 /// Nearly everywhere, inner must be non-null, however in places where
2720 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2721 pub inner: *mut nativeTxAddOutput,
2722 /// Indicates that this is the only struct which contains the same pointer.
2724 /// Rust functions which take ownership of an object provided via an argument require
2725 /// this to be true and invalidate the object pointed to by inner.
2729 impl Drop for TxAddOutput {
2730 fn drop(&mut self) {
2731 if self.is_owned && !<*mut nativeTxAddOutput>::is_null(self.inner) {
2732 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2736 /// Frees any resources used by the TxAddOutput, if is_owned is set and inner is non-NULL.
2738 pub extern "C" fn TxAddOutput_free(this_obj: TxAddOutput) { }
2740 /// Used only if an object of this type is returned as a trait impl by a method
2741 pub(crate) extern "C" fn TxAddOutput_free_void(this_ptr: *mut c_void) {
2742 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAddOutput) };
2746 pub(crate) fn get_native_ref(&self) -> &'static nativeTxAddOutput {
2747 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2749 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAddOutput {
2750 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2752 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2753 pub(crate) fn take_inner(mut self) -> *mut nativeTxAddOutput {
2754 assert!(self.is_owned);
2755 let ret = ObjOps::untweak_ptr(self.inner);
2756 self.inner = core::ptr::null_mut();
2762 pub extern "C" fn TxAddOutput_get_channel_id(this_ptr: &TxAddOutput) -> *const [u8; 32] {
2763 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2768 pub extern "C" fn TxAddOutput_set_channel_id(this_ptr: &mut TxAddOutput, mut val: crate::c_types::ThirtyTwoBytes) {
2769 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
2771 /// A randomly chosen unique identifier for this output, which is even for initiators and odd for
2774 pub extern "C" fn TxAddOutput_get_serial_id(this_ptr: &TxAddOutput) -> u64 {
2775 let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
2778 /// A randomly chosen unique identifier for this output, which is even for initiators and odd for
2781 pub extern "C" fn TxAddOutput_set_serial_id(this_ptr: &mut TxAddOutput, mut val: u64) {
2782 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
2784 /// The satoshi value of the output
2786 pub extern "C" fn TxAddOutput_get_sats(this_ptr: &TxAddOutput) -> u64 {
2787 let mut inner_val = &mut this_ptr.get_native_mut_ref().sats;
2790 /// The satoshi value of the output
2792 pub extern "C" fn TxAddOutput_set_sats(this_ptr: &mut TxAddOutput, mut val: u64) {
2793 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sats = val;
2795 /// The scriptPubKey for the output
2797 pub extern "C" fn TxAddOutput_get_script(this_ptr: &TxAddOutput) -> crate::c_types::u8slice {
2798 let mut inner_val = &mut this_ptr.get_native_mut_ref().script;
2799 crate::c_types::u8slice::from_slice(&inner_val[..])
2801 /// The scriptPubKey for the output
2803 pub extern "C" fn TxAddOutput_set_script(this_ptr: &mut TxAddOutput, mut val: crate::c_types::derived::CVec_u8Z) {
2804 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.script = ::bitcoin::blockdata::script::Script::from(val.into_rust());
2806 /// Constructs a new TxAddOutput given each field
2809 pub extern "C" fn TxAddOutput_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut serial_id_arg: u64, mut sats_arg: u64, mut script_arg: crate::c_types::derived::CVec_u8Z) -> TxAddOutput {
2810 TxAddOutput { inner: ObjOps::heap_alloc(nativeTxAddOutput {
2811 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
2812 serial_id: serial_id_arg,
2814 script: ::bitcoin::blockdata::script::Script::from(script_arg.into_rust()),
2815 }), is_owned: true }
2817 impl Clone for TxAddOutput {
2818 fn clone(&self) -> Self {
2820 inner: if <*mut nativeTxAddOutput>::is_null(self.inner) { core::ptr::null_mut() } else {
2821 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2827 /// Used only if an object of this type is returned as a trait impl by a method
2828 pub(crate) extern "C" fn TxAddOutput_clone_void(this_ptr: *const c_void) -> *mut c_void {
2829 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxAddOutput)).clone() })) as *mut c_void
2832 /// Creates a copy of the TxAddOutput
2833 pub extern "C" fn TxAddOutput_clone(orig: &TxAddOutput) -> TxAddOutput {
2836 /// Checks if two TxAddOutputs contain equal inner contents.
2837 /// This ignores pointers and is_owned flags and looks at the values in fields.
2838 /// Two objects with NULL inner values will be considered "equal" here.
2840 pub extern "C" fn TxAddOutput_eq(a: &TxAddOutput, b: &TxAddOutput) -> bool {
2841 if a.inner == b.inner { return true; }
2842 if a.inner.is_null() || b.inner.is_null() { return false; }
2843 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2846 use lightning::ln::msgs::TxRemoveInput as nativeTxRemoveInputImport;
2847 pub(crate) type nativeTxRemoveInput = nativeTxRemoveInputImport;
2849 /// A tx_remove_input message for removing an input during interactive transaction construction.
2853 pub struct TxRemoveInput {
2854 /// A pointer to the opaque Rust object.
2856 /// Nearly everywhere, inner must be non-null, however in places where
2857 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2858 pub inner: *mut nativeTxRemoveInput,
2859 /// Indicates that this is the only struct which contains the same pointer.
2861 /// Rust functions which take ownership of an object provided via an argument require
2862 /// this to be true and invalidate the object pointed to by inner.
2866 impl Drop for TxRemoveInput {
2867 fn drop(&mut self) {
2868 if self.is_owned && !<*mut nativeTxRemoveInput>::is_null(self.inner) {
2869 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2873 /// Frees any resources used by the TxRemoveInput, if is_owned is set and inner is non-NULL.
2875 pub extern "C" fn TxRemoveInput_free(this_obj: TxRemoveInput) { }
2877 /// Used only if an object of this type is returned as a trait impl by a method
2878 pub(crate) extern "C" fn TxRemoveInput_free_void(this_ptr: *mut c_void) {
2879 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxRemoveInput) };
2882 impl TxRemoveInput {
2883 pub(crate) fn get_native_ref(&self) -> &'static nativeTxRemoveInput {
2884 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2886 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxRemoveInput {
2887 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2889 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2890 pub(crate) fn take_inner(mut self) -> *mut nativeTxRemoveInput {
2891 assert!(self.is_owned);
2892 let ret = ObjOps::untweak_ptr(self.inner);
2893 self.inner = core::ptr::null_mut();
2899 pub extern "C" fn TxRemoveInput_get_channel_id(this_ptr: &TxRemoveInput) -> *const [u8; 32] {
2900 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2905 pub extern "C" fn TxRemoveInput_set_channel_id(this_ptr: &mut TxRemoveInput, mut val: crate::c_types::ThirtyTwoBytes) {
2906 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
2908 /// The serial ID of the input to be removed
2910 pub extern "C" fn TxRemoveInput_get_serial_id(this_ptr: &TxRemoveInput) -> u64 {
2911 let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
2914 /// The serial ID of the input to be removed
2916 pub extern "C" fn TxRemoveInput_set_serial_id(this_ptr: &mut TxRemoveInput, mut val: u64) {
2917 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
2919 /// Constructs a new TxRemoveInput given each field
2922 pub extern "C" fn TxRemoveInput_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut serial_id_arg: u64) -> TxRemoveInput {
2923 TxRemoveInput { inner: ObjOps::heap_alloc(nativeTxRemoveInput {
2924 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
2925 serial_id: serial_id_arg,
2926 }), is_owned: true }
2928 impl Clone for TxRemoveInput {
2929 fn clone(&self) -> Self {
2931 inner: if <*mut nativeTxRemoveInput>::is_null(self.inner) { core::ptr::null_mut() } else {
2932 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2938 /// Used only if an object of this type is returned as a trait impl by a method
2939 pub(crate) extern "C" fn TxRemoveInput_clone_void(this_ptr: *const c_void) -> *mut c_void {
2940 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxRemoveInput)).clone() })) as *mut c_void
2943 /// Creates a copy of the TxRemoveInput
2944 pub extern "C" fn TxRemoveInput_clone(orig: &TxRemoveInput) -> TxRemoveInput {
2947 /// Checks if two TxRemoveInputs contain equal inner contents.
2948 /// This ignores pointers and is_owned flags and looks at the values in fields.
2949 /// Two objects with NULL inner values will be considered "equal" here.
2951 pub extern "C" fn TxRemoveInput_eq(a: &TxRemoveInput, b: &TxRemoveInput) -> bool {
2952 if a.inner == b.inner { return true; }
2953 if a.inner.is_null() || b.inner.is_null() { return false; }
2954 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2957 use lightning::ln::msgs::TxRemoveOutput as nativeTxRemoveOutputImport;
2958 pub(crate) type nativeTxRemoveOutput = nativeTxRemoveOutputImport;
2960 /// A tx_remove_output message for removing an output during interactive transaction construction.
2964 pub struct TxRemoveOutput {
2965 /// A pointer to the opaque Rust object.
2967 /// Nearly everywhere, inner must be non-null, however in places where
2968 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2969 pub inner: *mut nativeTxRemoveOutput,
2970 /// Indicates that this is the only struct which contains the same pointer.
2972 /// Rust functions which take ownership of an object provided via an argument require
2973 /// this to be true and invalidate the object pointed to by inner.
2977 impl Drop for TxRemoveOutput {
2978 fn drop(&mut self) {
2979 if self.is_owned && !<*mut nativeTxRemoveOutput>::is_null(self.inner) {
2980 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2984 /// Frees any resources used by the TxRemoveOutput, if is_owned is set and inner is non-NULL.
2986 pub extern "C" fn TxRemoveOutput_free(this_obj: TxRemoveOutput) { }
2988 /// Used only if an object of this type is returned as a trait impl by a method
2989 pub(crate) extern "C" fn TxRemoveOutput_free_void(this_ptr: *mut c_void) {
2990 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxRemoveOutput) };
2993 impl TxRemoveOutput {
2994 pub(crate) fn get_native_ref(&self) -> &'static nativeTxRemoveOutput {
2995 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2997 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxRemoveOutput {
2998 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3000 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3001 pub(crate) fn take_inner(mut self) -> *mut nativeTxRemoveOutput {
3002 assert!(self.is_owned);
3003 let ret = ObjOps::untweak_ptr(self.inner);
3004 self.inner = core::ptr::null_mut();
3010 pub extern "C" fn TxRemoveOutput_get_channel_id(this_ptr: &TxRemoveOutput) -> *const [u8; 32] {
3011 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3016 pub extern "C" fn TxRemoveOutput_set_channel_id(this_ptr: &mut TxRemoveOutput, mut val: crate::c_types::ThirtyTwoBytes) {
3017 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3019 /// The serial ID of the output to be removed
3021 pub extern "C" fn TxRemoveOutput_get_serial_id(this_ptr: &TxRemoveOutput) -> u64 {
3022 let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
3025 /// The serial ID of the output to be removed
3027 pub extern "C" fn TxRemoveOutput_set_serial_id(this_ptr: &mut TxRemoveOutput, mut val: u64) {
3028 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
3030 /// Constructs a new TxRemoveOutput given each field
3033 pub extern "C" fn TxRemoveOutput_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut serial_id_arg: u64) -> TxRemoveOutput {
3034 TxRemoveOutput { inner: ObjOps::heap_alloc(nativeTxRemoveOutput {
3035 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3036 serial_id: serial_id_arg,
3037 }), is_owned: true }
3039 impl Clone for TxRemoveOutput {
3040 fn clone(&self) -> Self {
3042 inner: if <*mut nativeTxRemoveOutput>::is_null(self.inner) { core::ptr::null_mut() } else {
3043 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3049 /// Used only if an object of this type is returned as a trait impl by a method
3050 pub(crate) extern "C" fn TxRemoveOutput_clone_void(this_ptr: *const c_void) -> *mut c_void {
3051 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxRemoveOutput)).clone() })) as *mut c_void
3054 /// Creates a copy of the TxRemoveOutput
3055 pub extern "C" fn TxRemoveOutput_clone(orig: &TxRemoveOutput) -> TxRemoveOutput {
3058 /// Checks if two TxRemoveOutputs contain equal inner contents.
3059 /// This ignores pointers and is_owned flags and looks at the values in fields.
3060 /// Two objects with NULL inner values will be considered "equal" here.
3062 pub extern "C" fn TxRemoveOutput_eq(a: &TxRemoveOutput, b: &TxRemoveOutput) -> bool {
3063 if a.inner == b.inner { return true; }
3064 if a.inner.is_null() || b.inner.is_null() { return false; }
3065 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3068 use lightning::ln::msgs::TxComplete as nativeTxCompleteImport;
3069 pub(crate) type nativeTxComplete = nativeTxCompleteImport;
3071 /// A tx_complete message signalling the conclusion of a peer's transaction contributions during
3072 /// interactive transaction construction.
3076 pub struct TxComplete {
3077 /// A pointer to the opaque Rust object.
3079 /// Nearly everywhere, inner must be non-null, however in places where
3080 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3081 pub inner: *mut nativeTxComplete,
3082 /// Indicates that this is the only struct which contains the same pointer.
3084 /// Rust functions which take ownership of an object provided via an argument require
3085 /// this to be true and invalidate the object pointed to by inner.
3089 impl Drop for TxComplete {
3090 fn drop(&mut self) {
3091 if self.is_owned && !<*mut nativeTxComplete>::is_null(self.inner) {
3092 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3096 /// Frees any resources used by the TxComplete, if is_owned is set and inner is non-NULL.
3098 pub extern "C" fn TxComplete_free(this_obj: TxComplete) { }
3100 /// Used only if an object of this type is returned as a trait impl by a method
3101 pub(crate) extern "C" fn TxComplete_free_void(this_ptr: *mut c_void) {
3102 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxComplete) };
3106 pub(crate) fn get_native_ref(&self) -> &'static nativeTxComplete {
3107 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3109 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxComplete {
3110 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3112 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3113 pub(crate) fn take_inner(mut self) -> *mut nativeTxComplete {
3114 assert!(self.is_owned);
3115 let ret = ObjOps::untweak_ptr(self.inner);
3116 self.inner = core::ptr::null_mut();
3122 pub extern "C" fn TxComplete_get_channel_id(this_ptr: &TxComplete) -> *const [u8; 32] {
3123 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3128 pub extern "C" fn TxComplete_set_channel_id(this_ptr: &mut TxComplete, mut val: crate::c_types::ThirtyTwoBytes) {
3129 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3131 /// Constructs a new TxComplete given each field
3134 pub extern "C" fn TxComplete_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes) -> TxComplete {
3135 TxComplete { inner: ObjOps::heap_alloc(nativeTxComplete {
3136 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3137 }), is_owned: true }
3139 impl Clone for TxComplete {
3140 fn clone(&self) -> Self {
3142 inner: if <*mut nativeTxComplete>::is_null(self.inner) { core::ptr::null_mut() } else {
3143 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3149 /// Used only if an object of this type is returned as a trait impl by a method
3150 pub(crate) extern "C" fn TxComplete_clone_void(this_ptr: *const c_void) -> *mut c_void {
3151 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxComplete)).clone() })) as *mut c_void
3154 /// Creates a copy of the TxComplete
3155 pub extern "C" fn TxComplete_clone(orig: &TxComplete) -> TxComplete {
3158 /// Checks if two TxCompletes contain equal inner contents.
3159 /// This ignores pointers and is_owned flags and looks at the values in fields.
3160 /// Two objects with NULL inner values will be considered "equal" here.
3162 pub extern "C" fn TxComplete_eq(a: &TxComplete, b: &TxComplete) -> bool {
3163 if a.inner == b.inner { return true; }
3164 if a.inner.is_null() || b.inner.is_null() { return false; }
3165 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3168 use lightning::ln::msgs::TxSignatures as nativeTxSignaturesImport;
3169 pub(crate) type nativeTxSignatures = nativeTxSignaturesImport;
3171 /// A tx_signatures message containing the sender's signatures for a transaction constructed with
3172 /// interactive transaction construction.
3176 pub struct TxSignatures {
3177 /// A pointer to the opaque Rust object.
3179 /// Nearly everywhere, inner must be non-null, however in places where
3180 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3181 pub inner: *mut nativeTxSignatures,
3182 /// Indicates that this is the only struct which contains the same pointer.
3184 /// Rust functions which take ownership of an object provided via an argument require
3185 /// this to be true and invalidate the object pointed to by inner.
3189 impl Drop for TxSignatures {
3190 fn drop(&mut self) {
3191 if self.is_owned && !<*mut nativeTxSignatures>::is_null(self.inner) {
3192 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3196 /// Frees any resources used by the TxSignatures, if is_owned is set and inner is non-NULL.
3198 pub extern "C" fn TxSignatures_free(this_obj: TxSignatures) { }
3200 /// Used only if an object of this type is returned as a trait impl by a method
3201 pub(crate) extern "C" fn TxSignatures_free_void(this_ptr: *mut c_void) {
3202 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxSignatures) };
3206 pub(crate) fn get_native_ref(&self) -> &'static nativeTxSignatures {
3207 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3209 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxSignatures {
3210 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3212 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3213 pub(crate) fn take_inner(mut self) -> *mut nativeTxSignatures {
3214 assert!(self.is_owned);
3215 let ret = ObjOps::untweak_ptr(self.inner);
3216 self.inner = core::ptr::null_mut();
3222 pub extern "C" fn TxSignatures_get_channel_id(this_ptr: &TxSignatures) -> *const [u8; 32] {
3223 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3228 pub extern "C" fn TxSignatures_set_channel_id(this_ptr: &mut TxSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
3229 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3233 pub extern "C" fn TxSignatures_get_tx_hash(this_ptr: &TxSignatures) -> *const [u8; 32] {
3234 let mut inner_val = &mut this_ptr.get_native_mut_ref().tx_hash;
3235 inner_val.as_inner()
3239 pub extern "C" fn TxSignatures_set_tx_hash(this_ptr: &mut TxSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
3240 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.tx_hash = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
3242 /// The list of witnesses
3244 /// Returns a copy of the field.
3246 pub extern "C" fn TxSignatures_get_witnesses(this_ptr: &TxSignatures) -> crate::c_types::derived::CVec_WitnessZ {
3247 let mut inner_val = this_ptr.get_native_mut_ref().witnesses.clone();
3248 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) }); };
3249 local_inner_val.into()
3251 /// The list of witnesses
3253 pub extern "C" fn TxSignatures_set_witnesses(this_ptr: &mut TxSignatures, mut val: crate::c_types::derived::CVec_WitnessZ) {
3254 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_bitcoin() }); };
3255 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.witnesses = local_val;
3257 /// Constructs a new TxSignatures given each field
3260 pub extern "C" fn TxSignatures_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut tx_hash_arg: crate::c_types::ThirtyTwoBytes, mut witnesses_arg: crate::c_types::derived::CVec_WitnessZ) -> TxSignatures {
3261 let mut local_witnesses_arg = Vec::new(); for mut item in witnesses_arg.into_rust().drain(..) { local_witnesses_arg.push( { item.into_bitcoin() }); };
3262 TxSignatures { inner: ObjOps::heap_alloc(nativeTxSignatures {
3263 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3264 tx_hash: ::bitcoin::hash_types::Txid::from_slice(&tx_hash_arg.data[..]).unwrap(),
3265 witnesses: local_witnesses_arg,
3266 }), is_owned: true }
3268 impl Clone for TxSignatures {
3269 fn clone(&self) -> Self {
3271 inner: if <*mut nativeTxSignatures>::is_null(self.inner) { core::ptr::null_mut() } else {
3272 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3278 /// Used only if an object of this type is returned as a trait impl by a method
3279 pub(crate) extern "C" fn TxSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
3280 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxSignatures)).clone() })) as *mut c_void
3283 /// Creates a copy of the TxSignatures
3284 pub extern "C" fn TxSignatures_clone(orig: &TxSignatures) -> TxSignatures {
3287 /// Checks if two TxSignaturess contain equal inner contents.
3288 /// This ignores pointers and is_owned flags and looks at the values in fields.
3289 /// Two objects with NULL inner values will be considered "equal" here.
3291 pub extern "C" fn TxSignatures_eq(a: &TxSignatures, b: &TxSignatures) -> bool {
3292 if a.inner == b.inner { return true; }
3293 if a.inner.is_null() || b.inner.is_null() { return false; }
3294 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3297 use lightning::ln::msgs::TxInitRbf as nativeTxInitRbfImport;
3298 pub(crate) type nativeTxInitRbf = nativeTxInitRbfImport;
3300 /// A tx_init_rbf message which initiates a replacement of the transaction after it's been
3305 pub struct TxInitRbf {
3306 /// A pointer to the opaque Rust object.
3308 /// Nearly everywhere, inner must be non-null, however in places where
3309 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3310 pub inner: *mut nativeTxInitRbf,
3311 /// Indicates that this is the only struct which contains the same pointer.
3313 /// Rust functions which take ownership of an object provided via an argument require
3314 /// this to be true and invalidate the object pointed to by inner.
3318 impl Drop for TxInitRbf {
3319 fn drop(&mut self) {
3320 if self.is_owned && !<*mut nativeTxInitRbf>::is_null(self.inner) {
3321 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3325 /// Frees any resources used by the TxInitRbf, if is_owned is set and inner is non-NULL.
3327 pub extern "C" fn TxInitRbf_free(this_obj: TxInitRbf) { }
3329 /// Used only if an object of this type is returned as a trait impl by a method
3330 pub(crate) extern "C" fn TxInitRbf_free_void(this_ptr: *mut c_void) {
3331 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxInitRbf) };
3335 pub(crate) fn get_native_ref(&self) -> &'static nativeTxInitRbf {
3336 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3338 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxInitRbf {
3339 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3341 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3342 pub(crate) fn take_inner(mut self) -> *mut nativeTxInitRbf {
3343 assert!(self.is_owned);
3344 let ret = ObjOps::untweak_ptr(self.inner);
3345 self.inner = core::ptr::null_mut();
3351 pub extern "C" fn TxInitRbf_get_channel_id(this_ptr: &TxInitRbf) -> *const [u8; 32] {
3352 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3357 pub extern "C" fn TxInitRbf_set_channel_id(this_ptr: &mut TxInitRbf, mut val: crate::c_types::ThirtyTwoBytes) {
3358 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3360 /// The locktime of the transaction
3362 pub extern "C" fn TxInitRbf_get_locktime(this_ptr: &TxInitRbf) -> u32 {
3363 let mut inner_val = &mut this_ptr.get_native_mut_ref().locktime;
3366 /// The locktime of the transaction
3368 pub extern "C" fn TxInitRbf_set_locktime(this_ptr: &mut TxInitRbf, mut val: u32) {
3369 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.locktime = val;
3371 /// The feerate of the transaction
3373 pub extern "C" fn TxInitRbf_get_feerate_sat_per_1000_weight(this_ptr: &TxInitRbf) -> u32 {
3374 let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_sat_per_1000_weight;
3377 /// The feerate of the transaction
3379 pub extern "C" fn TxInitRbf_set_feerate_sat_per_1000_weight(this_ptr: &mut TxInitRbf, mut val: u32) {
3380 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_sat_per_1000_weight = val;
3382 /// The number of satoshis the sender will contribute to or, if negative, remove from
3383 /// (e.g. splice-out) the funding output of the transaction
3385 pub extern "C" fn TxInitRbf_get_funding_output_contribution(this_ptr: &TxInitRbf) -> crate::c_types::derived::COption_i64Z {
3386 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_contribution;
3387 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() }) };
3390 /// The number of satoshis the sender will contribute to or, if negative, remove from
3391 /// (e.g. splice-out) the funding output of the transaction
3393 pub extern "C" fn TxInitRbf_set_funding_output_contribution(this_ptr: &mut TxInitRbf, mut val: crate::c_types::derived::COption_i64Z) {
3394 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
3395 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_contribution = local_val;
3397 /// Constructs a new TxInitRbf given each field
3400 pub extern "C" fn TxInitRbf_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut locktime_arg: u32, mut feerate_sat_per_1000_weight_arg: u32, mut funding_output_contribution_arg: crate::c_types::derived::COption_i64Z) -> TxInitRbf {
3401 let mut local_funding_output_contribution_arg = if funding_output_contribution_arg.is_some() { Some( { funding_output_contribution_arg.take() }) } else { None };
3402 TxInitRbf { inner: ObjOps::heap_alloc(nativeTxInitRbf {
3403 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3404 locktime: locktime_arg,
3405 feerate_sat_per_1000_weight: feerate_sat_per_1000_weight_arg,
3406 funding_output_contribution: local_funding_output_contribution_arg,
3407 }), is_owned: true }
3409 impl Clone for TxInitRbf {
3410 fn clone(&self) -> Self {
3412 inner: if <*mut nativeTxInitRbf>::is_null(self.inner) { core::ptr::null_mut() } else {
3413 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3419 /// Used only if an object of this type is returned as a trait impl by a method
3420 pub(crate) extern "C" fn TxInitRbf_clone_void(this_ptr: *const c_void) -> *mut c_void {
3421 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxInitRbf)).clone() })) as *mut c_void
3424 /// Creates a copy of the TxInitRbf
3425 pub extern "C" fn TxInitRbf_clone(orig: &TxInitRbf) -> TxInitRbf {
3428 /// Checks if two TxInitRbfs contain equal inner contents.
3429 /// This ignores pointers and is_owned flags and looks at the values in fields.
3430 /// Two objects with NULL inner values will be considered "equal" here.
3432 pub extern "C" fn TxInitRbf_eq(a: &TxInitRbf, b: &TxInitRbf) -> bool {
3433 if a.inner == b.inner { return true; }
3434 if a.inner.is_null() || b.inner.is_null() { return false; }
3435 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3438 use lightning::ln::msgs::TxAckRbf as nativeTxAckRbfImport;
3439 pub(crate) type nativeTxAckRbf = nativeTxAckRbfImport;
3441 /// A tx_ack_rbf message which acknowledges replacement of the transaction after it's been
3446 pub struct TxAckRbf {
3447 /// A pointer to the opaque Rust object.
3449 /// Nearly everywhere, inner must be non-null, however in places where
3450 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3451 pub inner: *mut nativeTxAckRbf,
3452 /// Indicates that this is the only struct which contains the same pointer.
3454 /// Rust functions which take ownership of an object provided via an argument require
3455 /// this to be true and invalidate the object pointed to by inner.
3459 impl Drop for TxAckRbf {
3460 fn drop(&mut self) {
3461 if self.is_owned && !<*mut nativeTxAckRbf>::is_null(self.inner) {
3462 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3466 /// Frees any resources used by the TxAckRbf, if is_owned is set and inner is non-NULL.
3468 pub extern "C" fn TxAckRbf_free(this_obj: TxAckRbf) { }
3470 /// Used only if an object of this type is returned as a trait impl by a method
3471 pub(crate) extern "C" fn TxAckRbf_free_void(this_ptr: *mut c_void) {
3472 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAckRbf) };
3476 pub(crate) fn get_native_ref(&self) -> &'static nativeTxAckRbf {
3477 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3479 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAckRbf {
3480 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3482 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3483 pub(crate) fn take_inner(mut self) -> *mut nativeTxAckRbf {
3484 assert!(self.is_owned);
3485 let ret = ObjOps::untweak_ptr(self.inner);
3486 self.inner = core::ptr::null_mut();
3492 pub extern "C" fn TxAckRbf_get_channel_id(this_ptr: &TxAckRbf) -> *const [u8; 32] {
3493 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3498 pub extern "C" fn TxAckRbf_set_channel_id(this_ptr: &mut TxAckRbf, mut val: crate::c_types::ThirtyTwoBytes) {
3499 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3501 /// The number of satoshis the sender will contribute to or, if negative, remove from
3502 /// (e.g. splice-out) the funding output of the transaction
3504 pub extern "C" fn TxAckRbf_get_funding_output_contribution(this_ptr: &TxAckRbf) -> crate::c_types::derived::COption_i64Z {
3505 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_contribution;
3506 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() }) };
3509 /// The number of satoshis the sender will contribute to or, if negative, remove from
3510 /// (e.g. splice-out) the funding output of the transaction
3512 pub extern "C" fn TxAckRbf_set_funding_output_contribution(this_ptr: &mut TxAckRbf, mut val: crate::c_types::derived::COption_i64Z) {
3513 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
3514 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_contribution = local_val;
3516 /// Constructs a new TxAckRbf given each field
3519 pub extern "C" fn TxAckRbf_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_output_contribution_arg: crate::c_types::derived::COption_i64Z) -> TxAckRbf {
3520 let mut local_funding_output_contribution_arg = if funding_output_contribution_arg.is_some() { Some( { funding_output_contribution_arg.take() }) } else { None };
3521 TxAckRbf { inner: ObjOps::heap_alloc(nativeTxAckRbf {
3522 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3523 funding_output_contribution: local_funding_output_contribution_arg,
3524 }), is_owned: true }
3526 impl Clone for TxAckRbf {
3527 fn clone(&self) -> Self {
3529 inner: if <*mut nativeTxAckRbf>::is_null(self.inner) { core::ptr::null_mut() } else {
3530 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3536 /// Used only if an object of this type is returned as a trait impl by a method
3537 pub(crate) extern "C" fn TxAckRbf_clone_void(this_ptr: *const c_void) -> *mut c_void {
3538 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxAckRbf)).clone() })) as *mut c_void
3541 /// Creates a copy of the TxAckRbf
3542 pub extern "C" fn TxAckRbf_clone(orig: &TxAckRbf) -> TxAckRbf {
3545 /// Checks if two TxAckRbfs contain equal inner contents.
3546 /// This ignores pointers and is_owned flags and looks at the values in fields.
3547 /// Two objects with NULL inner values will be considered "equal" here.
3549 pub extern "C" fn TxAckRbf_eq(a: &TxAckRbf, b: &TxAckRbf) -> bool {
3550 if a.inner == b.inner { return true; }
3551 if a.inner.is_null() || b.inner.is_null() { return false; }
3552 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3555 use lightning::ln::msgs::TxAbort as nativeTxAbortImport;
3556 pub(crate) type nativeTxAbort = nativeTxAbortImport;
3558 /// A tx_abort message which signals the cancellation of an in-progress transaction negotiation.
3562 pub struct TxAbort {
3563 /// A pointer to the opaque Rust object.
3565 /// Nearly everywhere, inner must be non-null, however in places where
3566 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3567 pub inner: *mut nativeTxAbort,
3568 /// Indicates that this is the only struct which contains the same pointer.
3570 /// Rust functions which take ownership of an object provided via an argument require
3571 /// this to be true and invalidate the object pointed to by inner.
3575 impl Drop for TxAbort {
3576 fn drop(&mut self) {
3577 if self.is_owned && !<*mut nativeTxAbort>::is_null(self.inner) {
3578 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3582 /// Frees any resources used by the TxAbort, if is_owned is set and inner is non-NULL.
3584 pub extern "C" fn TxAbort_free(this_obj: TxAbort) { }
3586 /// Used only if an object of this type is returned as a trait impl by a method
3587 pub(crate) extern "C" fn TxAbort_free_void(this_ptr: *mut c_void) {
3588 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAbort) };
3592 pub(crate) fn get_native_ref(&self) -> &'static nativeTxAbort {
3593 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3595 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAbort {
3596 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3598 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3599 pub(crate) fn take_inner(mut self) -> *mut nativeTxAbort {
3600 assert!(self.is_owned);
3601 let ret = ObjOps::untweak_ptr(self.inner);
3602 self.inner = core::ptr::null_mut();
3608 pub extern "C" fn TxAbort_get_channel_id(this_ptr: &TxAbort) -> *const [u8; 32] {
3609 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3614 pub extern "C" fn TxAbort_set_channel_id(this_ptr: &mut TxAbort, mut val: crate::c_types::ThirtyTwoBytes) {
3615 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3619 /// Returns a copy of the field.
3621 pub extern "C" fn TxAbort_get_data(this_ptr: &TxAbort) -> crate::c_types::derived::CVec_u8Z {
3622 let mut inner_val = this_ptr.get_native_mut_ref().data.clone();
3623 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
3624 local_inner_val.into()
3628 pub extern "C" fn TxAbort_set_data(this_ptr: &mut TxAbort, mut val: crate::c_types::derived::CVec_u8Z) {
3629 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
3630 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = local_val;
3632 /// Constructs a new TxAbort given each field
3635 pub extern "C" fn TxAbort_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::derived::CVec_u8Z) -> TxAbort {
3636 let mut local_data_arg = Vec::new(); for mut item in data_arg.into_rust().drain(..) { local_data_arg.push( { item }); };
3637 TxAbort { inner: ObjOps::heap_alloc(nativeTxAbort {
3638 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3639 data: local_data_arg,
3640 }), is_owned: true }
3642 impl Clone for TxAbort {
3643 fn clone(&self) -> Self {
3645 inner: if <*mut nativeTxAbort>::is_null(self.inner) { core::ptr::null_mut() } else {
3646 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3652 /// Used only if an object of this type is returned as a trait impl by a method
3653 pub(crate) extern "C" fn TxAbort_clone_void(this_ptr: *const c_void) -> *mut c_void {
3654 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTxAbort)).clone() })) as *mut c_void
3657 /// Creates a copy of the TxAbort
3658 pub extern "C" fn TxAbort_clone(orig: &TxAbort) -> TxAbort {
3661 /// Checks if two TxAborts contain equal inner contents.
3662 /// This ignores pointers and is_owned flags and looks at the values in fields.
3663 /// Two objects with NULL inner values will be considered "equal" here.
3665 pub extern "C" fn TxAbort_eq(a: &TxAbort, b: &TxAbort) -> bool {
3666 if a.inner == b.inner { return true; }
3667 if a.inner.is_null() || b.inner.is_null() { return false; }
3668 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3671 use lightning::ln::msgs::Shutdown as nativeShutdownImport;
3672 pub(crate) type nativeShutdown = nativeShutdownImport;
3674 /// A [`shutdown`] message to be sent to or received from a peer.
3676 /// [`shutdown`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-initiation-shutdown
3679 pub struct Shutdown {
3680 /// A pointer to the opaque Rust object.
3682 /// Nearly everywhere, inner must be non-null, however in places where
3683 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3684 pub inner: *mut nativeShutdown,
3685 /// Indicates that this is the only struct which contains the same pointer.
3687 /// Rust functions which take ownership of an object provided via an argument require
3688 /// this to be true and invalidate the object pointed to by inner.
3692 impl Drop for Shutdown {
3693 fn drop(&mut self) {
3694 if self.is_owned && !<*mut nativeShutdown>::is_null(self.inner) {
3695 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3699 /// Frees any resources used by the Shutdown, if is_owned is set and inner is non-NULL.
3701 pub extern "C" fn Shutdown_free(this_obj: Shutdown) { }
3703 /// Used only if an object of this type is returned as a trait impl by a method
3704 pub(crate) extern "C" fn Shutdown_free_void(this_ptr: *mut c_void) {
3705 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeShutdown) };
3709 pub(crate) fn get_native_ref(&self) -> &'static nativeShutdown {
3710 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3712 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeShutdown {
3713 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3715 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3716 pub(crate) fn take_inner(mut self) -> *mut nativeShutdown {
3717 assert!(self.is_owned);
3718 let ret = ObjOps::untweak_ptr(self.inner);
3719 self.inner = core::ptr::null_mut();
3725 pub extern "C" fn Shutdown_get_channel_id(this_ptr: &Shutdown) -> *const [u8; 32] {
3726 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3731 pub extern "C" fn Shutdown_set_channel_id(this_ptr: &mut Shutdown, mut val: crate::c_types::ThirtyTwoBytes) {
3732 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3734 /// The destination of this peer's funds on closing.
3736 /// Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.
3738 pub extern "C" fn Shutdown_get_scriptpubkey(this_ptr: &Shutdown) -> crate::c_types::u8slice {
3739 let mut inner_val = &mut this_ptr.get_native_mut_ref().scriptpubkey;
3740 crate::c_types::u8slice::from_slice(&inner_val[..])
3742 /// The destination of this peer's funds on closing.
3744 /// Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.
3746 pub extern "C" fn Shutdown_set_scriptpubkey(this_ptr: &mut Shutdown, mut val: crate::c_types::derived::CVec_u8Z) {
3747 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.scriptpubkey = ::bitcoin::blockdata::script::Script::from(val.into_rust());
3749 /// Constructs a new Shutdown given each field
3752 pub extern "C" fn Shutdown_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut scriptpubkey_arg: crate::c_types::derived::CVec_u8Z) -> Shutdown {
3753 Shutdown { inner: ObjOps::heap_alloc(nativeShutdown {
3754 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3755 scriptpubkey: ::bitcoin::blockdata::script::Script::from(scriptpubkey_arg.into_rust()),
3756 }), is_owned: true }
3758 impl Clone for Shutdown {
3759 fn clone(&self) -> Self {
3761 inner: if <*mut nativeShutdown>::is_null(self.inner) { core::ptr::null_mut() } else {
3762 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3768 /// Used only if an object of this type is returned as a trait impl by a method
3769 pub(crate) extern "C" fn Shutdown_clone_void(this_ptr: *const c_void) -> *mut c_void {
3770 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeShutdown)).clone() })) as *mut c_void
3773 /// Creates a copy of the Shutdown
3774 pub extern "C" fn Shutdown_clone(orig: &Shutdown) -> Shutdown {
3777 /// Checks if two Shutdowns contain equal inner contents.
3778 /// This ignores pointers and is_owned flags and looks at the values in fields.
3779 /// Two objects with NULL inner values will be considered "equal" here.
3781 pub extern "C" fn Shutdown_eq(a: &Shutdown, b: &Shutdown) -> bool {
3782 if a.inner == b.inner { return true; }
3783 if a.inner.is_null() || b.inner.is_null() { return false; }
3784 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3787 use lightning::ln::msgs::ClosingSignedFeeRange as nativeClosingSignedFeeRangeImport;
3788 pub(crate) type nativeClosingSignedFeeRange = nativeClosingSignedFeeRangeImport;
3790 /// The minimum and maximum fees which the sender is willing to place on the closing transaction.
3792 /// This is provided in [`ClosingSigned`] by both sides to indicate the fee range they are willing
3796 pub struct ClosingSignedFeeRange {
3797 /// A pointer to the opaque Rust object.
3799 /// Nearly everywhere, inner must be non-null, however in places where
3800 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3801 pub inner: *mut nativeClosingSignedFeeRange,
3802 /// Indicates that this is the only struct which contains the same pointer.
3804 /// Rust functions which take ownership of an object provided via an argument require
3805 /// this to be true and invalidate the object pointed to by inner.
3809 impl Drop for ClosingSignedFeeRange {
3810 fn drop(&mut self) {
3811 if self.is_owned && !<*mut nativeClosingSignedFeeRange>::is_null(self.inner) {
3812 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3816 /// Frees any resources used by the ClosingSignedFeeRange, if is_owned is set and inner is non-NULL.
3818 pub extern "C" fn ClosingSignedFeeRange_free(this_obj: ClosingSignedFeeRange) { }
3820 /// Used only if an object of this type is returned as a trait impl by a method
3821 pub(crate) extern "C" fn ClosingSignedFeeRange_free_void(this_ptr: *mut c_void) {
3822 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeClosingSignedFeeRange) };
3825 impl ClosingSignedFeeRange {
3826 pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSignedFeeRange {
3827 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3829 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSignedFeeRange {
3830 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3832 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3833 pub(crate) fn take_inner(mut self) -> *mut nativeClosingSignedFeeRange {
3834 assert!(self.is_owned);
3835 let ret = ObjOps::untweak_ptr(self.inner);
3836 self.inner = core::ptr::null_mut();
3840 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
3843 pub extern "C" fn ClosingSignedFeeRange_get_min_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
3844 let mut inner_val = &mut this_ptr.get_native_mut_ref().min_fee_satoshis;
3847 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
3850 pub extern "C" fn ClosingSignedFeeRange_set_min_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
3851 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_fee_satoshis = val;
3853 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
3856 pub extern "C" fn ClosingSignedFeeRange_get_max_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
3857 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_fee_satoshis;
3860 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
3863 pub extern "C" fn ClosingSignedFeeRange_set_max_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
3864 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_fee_satoshis = val;
3866 /// Constructs a new ClosingSignedFeeRange given each field
3869 pub extern "C" fn ClosingSignedFeeRange_new(mut min_fee_satoshis_arg: u64, mut max_fee_satoshis_arg: u64) -> ClosingSignedFeeRange {
3870 ClosingSignedFeeRange { inner: ObjOps::heap_alloc(nativeClosingSignedFeeRange {
3871 min_fee_satoshis: min_fee_satoshis_arg,
3872 max_fee_satoshis: max_fee_satoshis_arg,
3873 }), is_owned: true }
3875 impl Clone for ClosingSignedFeeRange {
3876 fn clone(&self) -> Self {
3878 inner: if <*mut nativeClosingSignedFeeRange>::is_null(self.inner) { core::ptr::null_mut() } else {
3879 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3885 /// Used only if an object of this type is returned as a trait impl by a method
3886 pub(crate) extern "C" fn ClosingSignedFeeRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
3887 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeClosingSignedFeeRange)).clone() })) as *mut c_void
3890 /// Creates a copy of the ClosingSignedFeeRange
3891 pub extern "C" fn ClosingSignedFeeRange_clone(orig: &ClosingSignedFeeRange) -> ClosingSignedFeeRange {
3894 /// Checks if two ClosingSignedFeeRanges contain equal inner contents.
3895 /// This ignores pointers and is_owned flags and looks at the values in fields.
3896 /// Two objects with NULL inner values will be considered "equal" here.
3898 pub extern "C" fn ClosingSignedFeeRange_eq(a: &ClosingSignedFeeRange, b: &ClosingSignedFeeRange) -> bool {
3899 if a.inner == b.inner { return true; }
3900 if a.inner.is_null() || b.inner.is_null() { return false; }
3901 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3904 use lightning::ln::msgs::ClosingSigned as nativeClosingSignedImport;
3905 pub(crate) type nativeClosingSigned = nativeClosingSignedImport;
3907 /// A [`closing_signed`] message to be sent to or received from a peer.
3909 /// [`closing_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-negotiation-closing_signed
3912 pub struct ClosingSigned {
3913 /// A pointer to the opaque Rust object.
3915 /// Nearly everywhere, inner must be non-null, however in places where
3916 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3917 pub inner: *mut nativeClosingSigned,
3918 /// Indicates that this is the only struct which contains the same pointer.
3920 /// Rust functions which take ownership of an object provided via an argument require
3921 /// this to be true and invalidate the object pointed to by inner.
3925 impl Drop for ClosingSigned {
3926 fn drop(&mut self) {
3927 if self.is_owned && !<*mut nativeClosingSigned>::is_null(self.inner) {
3928 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3932 /// Frees any resources used by the ClosingSigned, if is_owned is set and inner is non-NULL.
3934 pub extern "C" fn ClosingSigned_free(this_obj: ClosingSigned) { }
3936 /// Used only if an object of this type is returned as a trait impl by a method
3937 pub(crate) extern "C" fn ClosingSigned_free_void(this_ptr: *mut c_void) {
3938 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeClosingSigned) };
3941 impl ClosingSigned {
3942 pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSigned {
3943 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3945 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSigned {
3946 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3948 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3949 pub(crate) fn take_inner(mut self) -> *mut nativeClosingSigned {
3950 assert!(self.is_owned);
3951 let ret = ObjOps::untweak_ptr(self.inner);
3952 self.inner = core::ptr::null_mut();
3958 pub extern "C" fn ClosingSigned_get_channel_id(this_ptr: &ClosingSigned) -> *const [u8; 32] {
3959 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3964 pub extern "C" fn ClosingSigned_set_channel_id(this_ptr: &mut ClosingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
3965 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3967 /// The proposed total fee for the closing transaction
3969 pub extern "C" fn ClosingSigned_get_fee_satoshis(this_ptr: &ClosingSigned) -> u64 {
3970 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_satoshis;
3973 /// The proposed total fee for the closing transaction
3975 pub extern "C" fn ClosingSigned_set_fee_satoshis(this_ptr: &mut ClosingSigned, mut val: u64) {
3976 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_satoshis = val;
3978 /// A signature on the closing transaction
3980 pub extern "C" fn ClosingSigned_get_signature(this_ptr: &ClosingSigned) -> crate::c_types::ECDSASignature {
3981 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
3982 crate::c_types::ECDSASignature::from_rust(&inner_val)
3984 /// A signature on the closing transaction
3986 pub extern "C" fn ClosingSigned_set_signature(this_ptr: &mut ClosingSigned, mut val: crate::c_types::ECDSASignature) {
3987 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
3989 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
3992 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
3994 pub extern "C" fn ClosingSigned_get_fee_range(this_ptr: &ClosingSigned) -> crate::lightning::ln::msgs::ClosingSignedFeeRange {
3995 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_range;
3996 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 };
3999 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
4002 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
4004 pub extern "C" fn ClosingSigned_set_fee_range(this_ptr: &mut ClosingSigned, mut val: crate::lightning::ln::msgs::ClosingSignedFeeRange) {
4005 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
4006 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_range = local_val;
4008 /// Constructs a new ClosingSigned given each field
4010 /// Note that fee_range_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
4013 pub extern "C" fn ClosingSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut fee_satoshis_arg: u64, mut signature_arg: crate::c_types::ECDSASignature, mut fee_range_arg: crate::lightning::ln::msgs::ClosingSignedFeeRange) -> ClosingSigned {
4014 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()) } }) };
4015 ClosingSigned { inner: ObjOps::heap_alloc(nativeClosingSigned {
4016 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
4017 fee_satoshis: fee_satoshis_arg,
4018 signature: signature_arg.into_rust(),
4019 fee_range: local_fee_range_arg,
4020 }), is_owned: true }
4022 impl Clone for ClosingSigned {
4023 fn clone(&self) -> Self {
4025 inner: if <*mut nativeClosingSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
4026 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4032 /// Used only if an object of this type is returned as a trait impl by a method
4033 pub(crate) extern "C" fn ClosingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
4034 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeClosingSigned)).clone() })) as *mut c_void
4037 /// Creates a copy of the ClosingSigned
4038 pub extern "C" fn ClosingSigned_clone(orig: &ClosingSigned) -> ClosingSigned {
4041 /// Checks if two ClosingSigneds contain equal inner contents.
4042 /// This ignores pointers and is_owned flags and looks at the values in fields.
4043 /// Two objects with NULL inner values will be considered "equal" here.
4045 pub extern "C" fn ClosingSigned_eq(a: &ClosingSigned, b: &ClosingSigned) -> bool {
4046 if a.inner == b.inner { return true; }
4047 if a.inner.is_null() || b.inner.is_null() { return false; }
4048 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4051 use lightning::ln::msgs::UpdateAddHTLC as nativeUpdateAddHTLCImport;
4052 pub(crate) type nativeUpdateAddHTLC = nativeUpdateAddHTLCImport;
4054 /// An [`update_add_htlc`] message to be sent to or received from a peer.
4056 /// [`update_add_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#adding-an-htlc-update_add_htlc
4059 pub struct UpdateAddHTLC {
4060 /// A pointer to the opaque Rust object.
4062 /// Nearly everywhere, inner must be non-null, however in places where
4063 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4064 pub inner: *mut nativeUpdateAddHTLC,
4065 /// Indicates that this is the only struct which contains the same pointer.
4067 /// Rust functions which take ownership of an object provided via an argument require
4068 /// this to be true and invalidate the object pointed to by inner.
4072 impl Drop for UpdateAddHTLC {
4073 fn drop(&mut self) {
4074 if self.is_owned && !<*mut nativeUpdateAddHTLC>::is_null(self.inner) {
4075 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4079 /// Frees any resources used by the UpdateAddHTLC, if is_owned is set and inner is non-NULL.
4081 pub extern "C" fn UpdateAddHTLC_free(this_obj: UpdateAddHTLC) { }
4083 /// Used only if an object of this type is returned as a trait impl by a method
4084 pub(crate) extern "C" fn UpdateAddHTLC_free_void(this_ptr: *mut c_void) {
4085 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateAddHTLC) };
4088 impl UpdateAddHTLC {
4089 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateAddHTLC {
4090 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4092 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateAddHTLC {
4093 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4095 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4096 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateAddHTLC {
4097 assert!(self.is_owned);
4098 let ret = ObjOps::untweak_ptr(self.inner);
4099 self.inner = core::ptr::null_mut();
4105 pub extern "C" fn UpdateAddHTLC_get_channel_id(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
4106 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4111 pub extern "C" fn UpdateAddHTLC_set_channel_id(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4112 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4116 pub extern "C" fn UpdateAddHTLC_get_htlc_id(this_ptr: &UpdateAddHTLC) -> u64 {
4117 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
4122 pub extern "C" fn UpdateAddHTLC_set_htlc_id(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
4123 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
4125 /// The HTLC value in milli-satoshi
4127 pub extern "C" fn UpdateAddHTLC_get_amount_msat(this_ptr: &UpdateAddHTLC) -> u64 {
4128 let mut inner_val = &mut this_ptr.get_native_mut_ref().amount_msat;
4131 /// The HTLC value in milli-satoshi
4133 pub extern "C" fn UpdateAddHTLC_set_amount_msat(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
4134 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.amount_msat = val;
4136 /// The payment hash, the pre-image of which controls HTLC redemption
4138 pub extern "C" fn UpdateAddHTLC_get_payment_hash(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
4139 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_hash;
4142 /// The payment hash, the pre-image of which controls HTLC redemption
4144 pub extern "C" fn UpdateAddHTLC_set_payment_hash(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4145 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_hash = ::lightning::ln::PaymentHash(val.data);
4147 /// The expiry height of the HTLC
4149 pub extern "C" fn UpdateAddHTLC_get_cltv_expiry(this_ptr: &UpdateAddHTLC) -> u32 {
4150 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry;
4153 /// The expiry height of the HTLC
4155 pub extern "C" fn UpdateAddHTLC_set_cltv_expiry(this_ptr: &mut UpdateAddHTLC, mut val: u32) {
4156 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry = val;
4158 /// The extra fee skimmed by the sender of this message. See
4159 /// [`ChannelConfig::accept_underpaying_htlcs`].
4161 /// [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
4163 pub extern "C" fn UpdateAddHTLC_get_skimmed_fee_msat(this_ptr: &UpdateAddHTLC) -> crate::c_types::derived::COption_u64Z {
4164 let mut inner_val = &mut this_ptr.get_native_mut_ref().skimmed_fee_msat;
4165 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() }) };
4168 /// The extra fee skimmed by the sender of this message. See
4169 /// [`ChannelConfig::accept_underpaying_htlcs`].
4171 /// [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
4173 pub extern "C" fn UpdateAddHTLC_set_skimmed_fee_msat(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::derived::COption_u64Z) {
4174 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
4175 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.skimmed_fee_msat = local_val;
4177 impl Clone for UpdateAddHTLC {
4178 fn clone(&self) -> Self {
4180 inner: if <*mut nativeUpdateAddHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
4181 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4187 /// Used only if an object of this type is returned as a trait impl by a method
4188 pub(crate) extern "C" fn UpdateAddHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
4189 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUpdateAddHTLC)).clone() })) as *mut c_void
4192 /// Creates a copy of the UpdateAddHTLC
4193 pub extern "C" fn UpdateAddHTLC_clone(orig: &UpdateAddHTLC) -> UpdateAddHTLC {
4196 /// Checks if two UpdateAddHTLCs contain equal inner contents.
4197 /// This ignores pointers and is_owned flags and looks at the values in fields.
4198 /// Two objects with NULL inner values will be considered "equal" here.
4200 pub extern "C" fn UpdateAddHTLC_eq(a: &UpdateAddHTLC, b: &UpdateAddHTLC) -> bool {
4201 if a.inner == b.inner { return true; }
4202 if a.inner.is_null() || b.inner.is_null() { return false; }
4203 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4206 use lightning::ln::msgs::OnionMessage as nativeOnionMessageImport;
4207 pub(crate) type nativeOnionMessage = nativeOnionMessageImport;
4209 /// An onion message to be sent to or received from a peer.
4213 pub struct OnionMessage {
4214 /// A pointer to the opaque Rust object.
4216 /// Nearly everywhere, inner must be non-null, however in places where
4217 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4218 pub inner: *mut nativeOnionMessage,
4219 /// Indicates that this is the only struct which contains the same pointer.
4221 /// Rust functions which take ownership of an object provided via an argument require
4222 /// this to be true and invalidate the object pointed to by inner.
4226 impl Drop for OnionMessage {
4227 fn drop(&mut self) {
4228 if self.is_owned && !<*mut nativeOnionMessage>::is_null(self.inner) {
4229 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4233 /// Frees any resources used by the OnionMessage, if is_owned is set and inner is non-NULL.
4235 pub extern "C" fn OnionMessage_free(this_obj: OnionMessage) { }
4237 /// Used only if an object of this type is returned as a trait impl by a method
4238 pub(crate) extern "C" fn OnionMessage_free_void(this_ptr: *mut c_void) {
4239 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOnionMessage) };
4243 pub(crate) fn get_native_ref(&self) -> &'static nativeOnionMessage {
4244 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4246 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOnionMessage {
4247 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4249 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4250 pub(crate) fn take_inner(mut self) -> *mut nativeOnionMessage {
4251 assert!(self.is_owned);
4252 let ret = ObjOps::untweak_ptr(self.inner);
4253 self.inner = core::ptr::null_mut();
4257 /// Used in decrypting the onion packet's payload.
4259 pub extern "C" fn OnionMessage_get_blinding_point(this_ptr: &OnionMessage) -> crate::c_types::PublicKey {
4260 let mut inner_val = &mut this_ptr.get_native_mut_ref().blinding_point;
4261 crate::c_types::PublicKey::from_rust(&inner_val)
4263 /// Used in decrypting the onion packet's payload.
4265 pub extern "C" fn OnionMessage_set_blinding_point(this_ptr: &mut OnionMessage, mut val: crate::c_types::PublicKey) {
4266 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.blinding_point = val.into_rust();
4268 /// The full onion packet including hop data, pubkey, and hmac
4270 pub extern "C" fn OnionMessage_get_onion_routing_packet(this_ptr: &OnionMessage) -> crate::lightning::onion_message::packet::Packet {
4271 let mut inner_val = &mut this_ptr.get_native_mut_ref().onion_routing_packet;
4272 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 }
4274 /// The full onion packet including hop data, pubkey, and hmac
4276 pub extern "C" fn OnionMessage_set_onion_routing_packet(this_ptr: &mut OnionMessage, mut val: crate::lightning::onion_message::packet::Packet) {
4277 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.onion_routing_packet = *unsafe { Box::from_raw(val.take_inner()) };
4279 /// Constructs a new OnionMessage given each field
4282 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 {
4283 OnionMessage { inner: ObjOps::heap_alloc(nativeOnionMessage {
4284 blinding_point: blinding_point_arg.into_rust(),
4285 onion_routing_packet: *unsafe { Box::from_raw(onion_routing_packet_arg.take_inner()) },
4286 }), is_owned: true }
4288 impl Clone for OnionMessage {
4289 fn clone(&self) -> Self {
4291 inner: if <*mut nativeOnionMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
4292 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4298 /// Used only if an object of this type is returned as a trait impl by a method
4299 pub(crate) extern "C" fn OnionMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
4300 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOnionMessage)).clone() })) as *mut c_void
4303 /// Creates a copy of the OnionMessage
4304 pub extern "C" fn OnionMessage_clone(orig: &OnionMessage) -> OnionMessage {
4307 /// Checks if two OnionMessages contain equal inner contents.
4308 /// This ignores pointers and is_owned flags and looks at the values in fields.
4309 /// Two objects with NULL inner values will be considered "equal" here.
4311 pub extern "C" fn OnionMessage_eq(a: &OnionMessage, b: &OnionMessage) -> bool {
4312 if a.inner == b.inner { return true; }
4313 if a.inner.is_null() || b.inner.is_null() { return false; }
4314 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4317 use lightning::ln::msgs::UpdateFulfillHTLC as nativeUpdateFulfillHTLCImport;
4318 pub(crate) type nativeUpdateFulfillHTLC = nativeUpdateFulfillHTLCImport;
4320 /// An [`update_fulfill_htlc`] message to be sent to or received from a peer.
4322 /// [`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
4325 pub struct UpdateFulfillHTLC {
4326 /// A pointer to the opaque Rust object.
4328 /// Nearly everywhere, inner must be non-null, however in places where
4329 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4330 pub inner: *mut nativeUpdateFulfillHTLC,
4331 /// Indicates that this is the only struct which contains the same pointer.
4333 /// Rust functions which take ownership of an object provided via an argument require
4334 /// this to be true and invalidate the object pointed to by inner.
4338 impl Drop for UpdateFulfillHTLC {
4339 fn drop(&mut self) {
4340 if self.is_owned && !<*mut nativeUpdateFulfillHTLC>::is_null(self.inner) {
4341 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4345 /// Frees any resources used by the UpdateFulfillHTLC, if is_owned is set and inner is non-NULL.
4347 pub extern "C" fn UpdateFulfillHTLC_free(this_obj: UpdateFulfillHTLC) { }
4349 /// Used only if an object of this type is returned as a trait impl by a method
4350 pub(crate) extern "C" fn UpdateFulfillHTLC_free_void(this_ptr: *mut c_void) {
4351 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFulfillHTLC) };
4354 impl UpdateFulfillHTLC {
4355 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFulfillHTLC {
4356 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4358 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFulfillHTLC {
4359 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4361 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4362 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFulfillHTLC {
4363 assert!(self.is_owned);
4364 let ret = ObjOps::untweak_ptr(self.inner);
4365 self.inner = core::ptr::null_mut();
4371 pub extern "C" fn UpdateFulfillHTLC_get_channel_id(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
4372 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4377 pub extern "C" fn UpdateFulfillHTLC_set_channel_id(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4378 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4382 pub extern "C" fn UpdateFulfillHTLC_get_htlc_id(this_ptr: &UpdateFulfillHTLC) -> u64 {
4383 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
4388 pub extern "C" fn UpdateFulfillHTLC_set_htlc_id(this_ptr: &mut UpdateFulfillHTLC, mut val: u64) {
4389 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
4391 /// The pre-image of the payment hash, allowing HTLC redemption
4393 pub extern "C" fn UpdateFulfillHTLC_get_payment_preimage(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
4394 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_preimage;
4397 /// The pre-image of the payment hash, allowing HTLC redemption
4399 pub extern "C" fn UpdateFulfillHTLC_set_payment_preimage(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4400 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_preimage = ::lightning::ln::PaymentPreimage(val.data);
4402 /// Constructs a new UpdateFulfillHTLC given each field
4405 pub extern "C" fn UpdateFulfillHTLC_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut htlc_id_arg: u64, mut payment_preimage_arg: crate::c_types::ThirtyTwoBytes) -> UpdateFulfillHTLC {
4406 UpdateFulfillHTLC { inner: ObjOps::heap_alloc(nativeUpdateFulfillHTLC {
4407 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
4408 htlc_id: htlc_id_arg,
4409 payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_arg.data),
4410 }), is_owned: true }
4412 impl Clone for UpdateFulfillHTLC {
4413 fn clone(&self) -> Self {
4415 inner: if <*mut nativeUpdateFulfillHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
4416 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4422 /// Used only if an object of this type is returned as a trait impl by a method
4423 pub(crate) extern "C" fn UpdateFulfillHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
4424 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUpdateFulfillHTLC)).clone() })) as *mut c_void
4427 /// Creates a copy of the UpdateFulfillHTLC
4428 pub extern "C" fn UpdateFulfillHTLC_clone(orig: &UpdateFulfillHTLC) -> UpdateFulfillHTLC {
4431 /// Checks if two UpdateFulfillHTLCs contain equal inner contents.
4432 /// This ignores pointers and is_owned flags and looks at the values in fields.
4433 /// Two objects with NULL inner values will be considered "equal" here.
4435 pub extern "C" fn UpdateFulfillHTLC_eq(a: &UpdateFulfillHTLC, b: &UpdateFulfillHTLC) -> bool {
4436 if a.inner == b.inner { return true; }
4437 if a.inner.is_null() || b.inner.is_null() { return false; }
4438 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4441 use lightning::ln::msgs::UpdateFailHTLC as nativeUpdateFailHTLCImport;
4442 pub(crate) type nativeUpdateFailHTLC = nativeUpdateFailHTLCImport;
4444 /// An [`update_fail_htlc`] message to be sent to or received from a peer.
4446 /// [`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
4449 pub struct UpdateFailHTLC {
4450 /// A pointer to the opaque Rust object.
4452 /// Nearly everywhere, inner must be non-null, however in places where
4453 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4454 pub inner: *mut nativeUpdateFailHTLC,
4455 /// Indicates that this is the only struct which contains the same pointer.
4457 /// Rust functions which take ownership of an object provided via an argument require
4458 /// this to be true and invalidate the object pointed to by inner.
4462 impl Drop for UpdateFailHTLC {
4463 fn drop(&mut self) {
4464 if self.is_owned && !<*mut nativeUpdateFailHTLC>::is_null(self.inner) {
4465 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4469 /// Frees any resources used by the UpdateFailHTLC, if is_owned is set and inner is non-NULL.
4471 pub extern "C" fn UpdateFailHTLC_free(this_obj: UpdateFailHTLC) { }
4473 /// Used only if an object of this type is returned as a trait impl by a method
4474 pub(crate) extern "C" fn UpdateFailHTLC_free_void(this_ptr: *mut c_void) {
4475 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFailHTLC) };
4478 impl UpdateFailHTLC {
4479 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailHTLC {
4480 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4482 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailHTLC {
4483 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4485 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4486 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailHTLC {
4487 assert!(self.is_owned);
4488 let ret = ObjOps::untweak_ptr(self.inner);
4489 self.inner = core::ptr::null_mut();
4495 pub extern "C" fn UpdateFailHTLC_get_channel_id(this_ptr: &UpdateFailHTLC) -> *const [u8; 32] {
4496 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4501 pub extern "C" fn UpdateFailHTLC_set_channel_id(this_ptr: &mut UpdateFailHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4502 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4506 pub extern "C" fn UpdateFailHTLC_get_htlc_id(this_ptr: &UpdateFailHTLC) -> u64 {
4507 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
4512 pub extern "C" fn UpdateFailHTLC_set_htlc_id(this_ptr: &mut UpdateFailHTLC, mut val: u64) {
4513 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
4515 impl Clone for UpdateFailHTLC {
4516 fn clone(&self) -> Self {
4518 inner: if <*mut nativeUpdateFailHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
4519 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4525 /// Used only if an object of this type is returned as a trait impl by a method
4526 pub(crate) extern "C" fn UpdateFailHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
4527 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUpdateFailHTLC)).clone() })) as *mut c_void
4530 /// Creates a copy of the UpdateFailHTLC
4531 pub extern "C" fn UpdateFailHTLC_clone(orig: &UpdateFailHTLC) -> UpdateFailHTLC {
4534 /// Checks if two UpdateFailHTLCs contain equal inner contents.
4535 /// This ignores pointers and is_owned flags and looks at the values in fields.
4536 /// Two objects with NULL inner values will be considered "equal" here.
4538 pub extern "C" fn UpdateFailHTLC_eq(a: &UpdateFailHTLC, b: &UpdateFailHTLC) -> bool {
4539 if a.inner == b.inner { return true; }
4540 if a.inner.is_null() || b.inner.is_null() { return false; }
4541 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4544 use lightning::ln::msgs::UpdateFailMalformedHTLC as nativeUpdateFailMalformedHTLCImport;
4545 pub(crate) type nativeUpdateFailMalformedHTLC = nativeUpdateFailMalformedHTLCImport;
4547 /// An [`update_fail_malformed_htlc`] message to be sent to or received from a peer.
4549 /// [`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
4552 pub struct UpdateFailMalformedHTLC {
4553 /// A pointer to the opaque Rust object.
4555 /// Nearly everywhere, inner must be non-null, however in places where
4556 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4557 pub inner: *mut nativeUpdateFailMalformedHTLC,
4558 /// Indicates that this is the only struct which contains the same pointer.
4560 /// Rust functions which take ownership of an object provided via an argument require
4561 /// this to be true and invalidate the object pointed to by inner.
4565 impl Drop for UpdateFailMalformedHTLC {
4566 fn drop(&mut self) {
4567 if self.is_owned && !<*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) {
4568 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4572 /// Frees any resources used by the UpdateFailMalformedHTLC, if is_owned is set and inner is non-NULL.
4574 pub extern "C" fn UpdateFailMalformedHTLC_free(this_obj: UpdateFailMalformedHTLC) { }
4576 /// Used only if an object of this type is returned as a trait impl by a method
4577 pub(crate) extern "C" fn UpdateFailMalformedHTLC_free_void(this_ptr: *mut c_void) {
4578 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFailMalformedHTLC) };
4581 impl UpdateFailMalformedHTLC {
4582 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailMalformedHTLC {
4583 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4585 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailMalformedHTLC {
4586 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4588 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4589 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailMalformedHTLC {
4590 assert!(self.is_owned);
4591 let ret = ObjOps::untweak_ptr(self.inner);
4592 self.inner = core::ptr::null_mut();
4598 pub extern "C" fn UpdateFailMalformedHTLC_get_channel_id(this_ptr: &UpdateFailMalformedHTLC) -> *const [u8; 32] {
4599 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4604 pub extern "C" fn UpdateFailMalformedHTLC_set_channel_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4605 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4609 pub extern "C" fn UpdateFailMalformedHTLC_get_htlc_id(this_ptr: &UpdateFailMalformedHTLC) -> u64 {
4610 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
4615 pub extern "C" fn UpdateFailMalformedHTLC_set_htlc_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u64) {
4616 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
4618 /// The failure code
4620 pub extern "C" fn UpdateFailMalformedHTLC_get_failure_code(this_ptr: &UpdateFailMalformedHTLC) -> u16 {
4621 let mut inner_val = &mut this_ptr.get_native_mut_ref().failure_code;
4624 /// The failure code
4626 pub extern "C" fn UpdateFailMalformedHTLC_set_failure_code(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u16) {
4627 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.failure_code = val;
4629 impl Clone for UpdateFailMalformedHTLC {
4630 fn clone(&self) -> Self {
4632 inner: if <*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
4633 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4639 /// Used only if an object of this type is returned as a trait impl by a method
4640 pub(crate) extern "C" fn UpdateFailMalformedHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
4641 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUpdateFailMalformedHTLC)).clone() })) as *mut c_void
4644 /// Creates a copy of the UpdateFailMalformedHTLC
4645 pub extern "C" fn UpdateFailMalformedHTLC_clone(orig: &UpdateFailMalformedHTLC) -> UpdateFailMalformedHTLC {
4648 /// Checks if two UpdateFailMalformedHTLCs contain equal inner contents.
4649 /// This ignores pointers and is_owned flags and looks at the values in fields.
4650 /// Two objects with NULL inner values will be considered "equal" here.
4652 pub extern "C" fn UpdateFailMalformedHTLC_eq(a: &UpdateFailMalformedHTLC, b: &UpdateFailMalformedHTLC) -> bool {
4653 if a.inner == b.inner { return true; }
4654 if a.inner.is_null() || b.inner.is_null() { return false; }
4655 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4658 use lightning::ln::msgs::CommitmentSigned as nativeCommitmentSignedImport;
4659 pub(crate) type nativeCommitmentSigned = nativeCommitmentSignedImport;
4661 /// A [`commitment_signed`] message to be sent to or received from a peer.
4663 /// [`commitment_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#committing-updates-so-far-commitment_signed
4666 pub struct CommitmentSigned {
4667 /// A pointer to the opaque Rust object.
4669 /// Nearly everywhere, inner must be non-null, however in places where
4670 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4671 pub inner: *mut nativeCommitmentSigned,
4672 /// Indicates that this is the only struct which contains the same pointer.
4674 /// Rust functions which take ownership of an object provided via an argument require
4675 /// this to be true and invalidate the object pointed to by inner.
4679 impl Drop for CommitmentSigned {
4680 fn drop(&mut self) {
4681 if self.is_owned && !<*mut nativeCommitmentSigned>::is_null(self.inner) {
4682 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4686 /// Frees any resources used by the CommitmentSigned, if is_owned is set and inner is non-NULL.
4688 pub extern "C" fn CommitmentSigned_free(this_obj: CommitmentSigned) { }
4690 /// Used only if an object of this type is returned as a trait impl by a method
4691 pub(crate) extern "C" fn CommitmentSigned_free_void(this_ptr: *mut c_void) {
4692 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCommitmentSigned) };
4695 impl CommitmentSigned {
4696 pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentSigned {
4697 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4699 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentSigned {
4700 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4702 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4703 pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentSigned {
4704 assert!(self.is_owned);
4705 let ret = ObjOps::untweak_ptr(self.inner);
4706 self.inner = core::ptr::null_mut();
4712 pub extern "C" fn CommitmentSigned_get_channel_id(this_ptr: &CommitmentSigned) -> *const [u8; 32] {
4713 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4718 pub extern "C" fn CommitmentSigned_set_channel_id(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::ThirtyTwoBytes) {
4719 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4721 /// A signature on the commitment transaction
4723 pub extern "C" fn CommitmentSigned_get_signature(this_ptr: &CommitmentSigned) -> crate::c_types::ECDSASignature {
4724 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
4725 crate::c_types::ECDSASignature::from_rust(&inner_val)
4727 /// A signature on the commitment transaction
4729 pub extern "C" fn CommitmentSigned_set_signature(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::ECDSASignature) {
4730 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
4732 /// Signatures on the HTLC transactions
4734 /// Returns a copy of the field.
4736 pub extern "C" fn CommitmentSigned_get_htlc_signatures(this_ptr: &CommitmentSigned) -> crate::c_types::derived::CVec_ECDSASignatureZ {
4737 let mut inner_val = this_ptr.get_native_mut_ref().htlc_signatures.clone();
4738 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) }); };
4739 local_inner_val.into()
4741 /// Signatures on the HTLC transactions
4743 pub extern "C" fn CommitmentSigned_set_htlc_signatures(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::derived::CVec_ECDSASignatureZ) {
4744 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_rust() }); };
4745 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_signatures = local_val;
4747 /// Constructs a new CommitmentSigned given each field
4750 pub extern "C" fn CommitmentSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut signature_arg: crate::c_types::ECDSASignature, mut htlc_signatures_arg: crate::c_types::derived::CVec_ECDSASignatureZ) -> CommitmentSigned {
4751 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() }); };
4752 CommitmentSigned { inner: ObjOps::heap_alloc(nativeCommitmentSigned {
4753 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
4754 signature: signature_arg.into_rust(),
4755 htlc_signatures: local_htlc_signatures_arg,
4756 }), is_owned: true }
4758 impl Clone for CommitmentSigned {
4759 fn clone(&self) -> Self {
4761 inner: if <*mut nativeCommitmentSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
4762 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4768 /// Used only if an object of this type is returned as a trait impl by a method
4769 pub(crate) extern "C" fn CommitmentSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
4770 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeCommitmentSigned)).clone() })) as *mut c_void
4773 /// Creates a copy of the CommitmentSigned
4774 pub extern "C" fn CommitmentSigned_clone(orig: &CommitmentSigned) -> CommitmentSigned {
4777 /// Checks if two CommitmentSigneds contain equal inner contents.
4778 /// This ignores pointers and is_owned flags and looks at the values in fields.
4779 /// Two objects with NULL inner values will be considered "equal" here.
4781 pub extern "C" fn CommitmentSigned_eq(a: &CommitmentSigned, b: &CommitmentSigned) -> bool {
4782 if a.inner == b.inner { return true; }
4783 if a.inner.is_null() || b.inner.is_null() { return false; }
4784 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4787 use lightning::ln::msgs::RevokeAndACK as nativeRevokeAndACKImport;
4788 pub(crate) type nativeRevokeAndACK = nativeRevokeAndACKImport;
4790 /// A [`revoke_and_ack`] message to be sent to or received from a peer.
4792 /// [`revoke_and_ack`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#completing-the-transition-to-the-updated-state-revoke_and_ack
4795 pub struct RevokeAndACK {
4796 /// A pointer to the opaque Rust object.
4798 /// Nearly everywhere, inner must be non-null, however in places where
4799 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4800 pub inner: *mut nativeRevokeAndACK,
4801 /// Indicates that this is the only struct which contains the same pointer.
4803 /// Rust functions which take ownership of an object provided via an argument require
4804 /// this to be true and invalidate the object pointed to by inner.
4808 impl Drop for RevokeAndACK {
4809 fn drop(&mut self) {
4810 if self.is_owned && !<*mut nativeRevokeAndACK>::is_null(self.inner) {
4811 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4815 /// Frees any resources used by the RevokeAndACK, if is_owned is set and inner is non-NULL.
4817 pub extern "C" fn RevokeAndACK_free(this_obj: RevokeAndACK) { }
4819 /// Used only if an object of this type is returned as a trait impl by a method
4820 pub(crate) extern "C" fn RevokeAndACK_free_void(this_ptr: *mut c_void) {
4821 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRevokeAndACK) };
4825 pub(crate) fn get_native_ref(&self) -> &'static nativeRevokeAndACK {
4826 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4828 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRevokeAndACK {
4829 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4831 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4832 pub(crate) fn take_inner(mut self) -> *mut nativeRevokeAndACK {
4833 assert!(self.is_owned);
4834 let ret = ObjOps::untweak_ptr(self.inner);
4835 self.inner = core::ptr::null_mut();
4841 pub extern "C" fn RevokeAndACK_get_channel_id(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
4842 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4847 pub extern "C" fn RevokeAndACK_set_channel_id(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
4848 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4850 /// The secret corresponding to the per-commitment point
4852 pub extern "C" fn RevokeAndACK_get_per_commitment_secret(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
4853 let mut inner_val = &mut this_ptr.get_native_mut_ref().per_commitment_secret;
4856 /// The secret corresponding to the per-commitment point
4858 pub extern "C" fn RevokeAndACK_set_per_commitment_secret(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
4859 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.per_commitment_secret = val.data;
4861 /// The next sender-broadcast commitment transaction's per-commitment point
4863 pub extern "C" fn RevokeAndACK_get_next_per_commitment_point(this_ptr: &RevokeAndACK) -> crate::c_types::PublicKey {
4864 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
4865 crate::c_types::PublicKey::from_rust(&inner_val)
4867 /// The next sender-broadcast commitment transaction's per-commitment point
4869 pub extern "C" fn RevokeAndACK_set_next_per_commitment_point(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::PublicKey) {
4870 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
4872 /// Constructs a new RevokeAndACK given each field
4875 pub extern "C" fn RevokeAndACK_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut per_commitment_secret_arg: crate::c_types::ThirtyTwoBytes, mut next_per_commitment_point_arg: crate::c_types::PublicKey) -> RevokeAndACK {
4876 RevokeAndACK { inner: ObjOps::heap_alloc(nativeRevokeAndACK {
4877 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
4878 per_commitment_secret: per_commitment_secret_arg.data,
4879 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
4880 }), is_owned: true }
4882 impl Clone for RevokeAndACK {
4883 fn clone(&self) -> Self {
4885 inner: if <*mut nativeRevokeAndACK>::is_null(self.inner) { core::ptr::null_mut() } else {
4886 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4892 /// Used only if an object of this type is returned as a trait impl by a method
4893 pub(crate) extern "C" fn RevokeAndACK_clone_void(this_ptr: *const c_void) -> *mut c_void {
4894 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeRevokeAndACK)).clone() })) as *mut c_void
4897 /// Creates a copy of the RevokeAndACK
4898 pub extern "C" fn RevokeAndACK_clone(orig: &RevokeAndACK) -> RevokeAndACK {
4901 /// Checks if two RevokeAndACKs contain equal inner contents.
4902 /// This ignores pointers and is_owned flags and looks at the values in fields.
4903 /// Two objects with NULL inner values will be considered "equal" here.
4905 pub extern "C" fn RevokeAndACK_eq(a: &RevokeAndACK, b: &RevokeAndACK) -> bool {
4906 if a.inner == b.inner { return true; }
4907 if a.inner.is_null() || b.inner.is_null() { return false; }
4908 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4911 use lightning::ln::msgs::UpdateFee as nativeUpdateFeeImport;
4912 pub(crate) type nativeUpdateFee = nativeUpdateFeeImport;
4914 /// An [`update_fee`] message to be sent to or received from a peer
4916 /// [`update_fee`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#updating-fees-update_fee
4919 pub struct UpdateFee {
4920 /// A pointer to the opaque Rust object.
4922 /// Nearly everywhere, inner must be non-null, however in places where
4923 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4924 pub inner: *mut nativeUpdateFee,
4925 /// Indicates that this is the only struct which contains the same pointer.
4927 /// Rust functions which take ownership of an object provided via an argument require
4928 /// this to be true and invalidate the object pointed to by inner.
4932 impl Drop for UpdateFee {
4933 fn drop(&mut self) {
4934 if self.is_owned && !<*mut nativeUpdateFee>::is_null(self.inner) {
4935 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4939 /// Frees any resources used by the UpdateFee, if is_owned is set and inner is non-NULL.
4941 pub extern "C" fn UpdateFee_free(this_obj: UpdateFee) { }
4943 /// Used only if an object of this type is returned as a trait impl by a method
4944 pub(crate) extern "C" fn UpdateFee_free_void(this_ptr: *mut c_void) {
4945 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFee) };
4949 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFee {
4950 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4952 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFee {
4953 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4955 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4956 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFee {
4957 assert!(self.is_owned);
4958 let ret = ObjOps::untweak_ptr(self.inner);
4959 self.inner = core::ptr::null_mut();
4965 pub extern "C" fn UpdateFee_get_channel_id(this_ptr: &UpdateFee) -> *const [u8; 32] {
4966 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4971 pub extern "C" fn UpdateFee_set_channel_id(this_ptr: &mut UpdateFee, mut val: crate::c_types::ThirtyTwoBytes) {
4972 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4974 /// Fee rate per 1000-weight of the transaction
4976 pub extern "C" fn UpdateFee_get_feerate_per_kw(this_ptr: &UpdateFee) -> u32 {
4977 let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
4980 /// Fee rate per 1000-weight of the transaction
4982 pub extern "C" fn UpdateFee_set_feerate_per_kw(this_ptr: &mut UpdateFee, mut val: u32) {
4983 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
4985 /// Constructs a new UpdateFee given each field
4988 pub extern "C" fn UpdateFee_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut feerate_per_kw_arg: u32) -> UpdateFee {
4989 UpdateFee { inner: ObjOps::heap_alloc(nativeUpdateFee {
4990 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
4991 feerate_per_kw: feerate_per_kw_arg,
4992 }), is_owned: true }
4994 impl Clone for UpdateFee {
4995 fn clone(&self) -> Self {
4997 inner: if <*mut nativeUpdateFee>::is_null(self.inner) { core::ptr::null_mut() } else {
4998 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5004 /// Used only if an object of this type is returned as a trait impl by a method
5005 pub(crate) extern "C" fn UpdateFee_clone_void(this_ptr: *const c_void) -> *mut c_void {
5006 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUpdateFee)).clone() })) as *mut c_void
5009 /// Creates a copy of the UpdateFee
5010 pub extern "C" fn UpdateFee_clone(orig: &UpdateFee) -> UpdateFee {
5013 /// Checks if two UpdateFees contain equal inner contents.
5014 /// This ignores pointers and is_owned flags and looks at the values in fields.
5015 /// Two objects with NULL inner values will be considered "equal" here.
5017 pub extern "C" fn UpdateFee_eq(a: &UpdateFee, b: &UpdateFee) -> bool {
5018 if a.inner == b.inner { return true; }
5019 if a.inner.is_null() || b.inner.is_null() { return false; }
5020 if a.get_native_ref() == b.get_native_ref() { true } else { false }
5023 use lightning::ln::msgs::ChannelReestablish as nativeChannelReestablishImport;
5024 pub(crate) type nativeChannelReestablish = nativeChannelReestablishImport;
5026 /// A [`channel_reestablish`] message to be sent to or received from a peer.
5028 /// [`channel_reestablish`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#message-retransmission
5031 pub struct ChannelReestablish {
5032 /// A pointer to the opaque Rust object.
5034 /// Nearly everywhere, inner must be non-null, however in places where
5035 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5036 pub inner: *mut nativeChannelReestablish,
5037 /// Indicates that this is the only struct which contains the same pointer.
5039 /// Rust functions which take ownership of an object provided via an argument require
5040 /// this to be true and invalidate the object pointed to by inner.
5044 impl Drop for ChannelReestablish {
5045 fn drop(&mut self) {
5046 if self.is_owned && !<*mut nativeChannelReestablish>::is_null(self.inner) {
5047 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5051 /// Frees any resources used by the ChannelReestablish, if is_owned is set and inner is non-NULL.
5053 pub extern "C" fn ChannelReestablish_free(this_obj: ChannelReestablish) { }
5055 /// Used only if an object of this type is returned as a trait impl by a method
5056 pub(crate) extern "C" fn ChannelReestablish_free_void(this_ptr: *mut c_void) {
5057 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelReestablish) };
5060 impl ChannelReestablish {
5061 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelReestablish {
5062 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5064 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelReestablish {
5065 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5067 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5068 pub(crate) fn take_inner(mut self) -> *mut nativeChannelReestablish {
5069 assert!(self.is_owned);
5070 let ret = ObjOps::untweak_ptr(self.inner);
5071 self.inner = core::ptr::null_mut();
5077 pub extern "C" fn ChannelReestablish_get_channel_id(this_ptr: &ChannelReestablish) -> *const [u8; 32] {
5078 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5083 pub extern "C" fn ChannelReestablish_set_channel_id(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) {
5084 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
5086 /// The next commitment number for the sender
5088 pub extern "C" fn ChannelReestablish_get_next_local_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
5089 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_local_commitment_number;
5092 /// The next commitment number for the sender
5094 pub extern "C" fn ChannelReestablish_set_next_local_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
5095 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_local_commitment_number = val;
5097 /// The next commitment number for the recipient
5099 pub extern "C" fn ChannelReestablish_get_next_remote_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
5100 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_remote_commitment_number;
5103 /// The next commitment number for the recipient
5105 pub extern "C" fn ChannelReestablish_set_next_remote_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
5106 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_remote_commitment_number = val;
5108 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
5109 /// belonging to the recipient
5111 pub extern "C" fn ChannelReestablish_get_your_last_per_commitment_secret(this_ptr: &ChannelReestablish) -> *const [u8; 32] {
5112 let mut inner_val = &mut this_ptr.get_native_mut_ref().your_last_per_commitment_secret;
5115 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
5116 /// belonging to the recipient
5118 pub extern "C" fn ChannelReestablish_set_your_last_per_commitment_secret(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) {
5119 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.your_last_per_commitment_secret = val.data;
5121 /// The sender's per-commitment point for their current commitment transaction
5123 pub extern "C" fn ChannelReestablish_get_my_current_per_commitment_point(this_ptr: &ChannelReestablish) -> crate::c_types::PublicKey {
5124 let mut inner_val = &mut this_ptr.get_native_mut_ref().my_current_per_commitment_point;
5125 crate::c_types::PublicKey::from_rust(&inner_val)
5127 /// The sender's per-commitment point for their current commitment transaction
5129 pub extern "C" fn ChannelReestablish_set_my_current_per_commitment_point(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::PublicKey) {
5130 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.my_current_per_commitment_point = val.into_rust();
5132 /// The next funding transaction ID
5134 pub extern "C" fn ChannelReestablish_get_next_funding_txid(this_ptr: &ChannelReestablish) -> crate::c_types::derived::COption_ThirtyTwoBytesZ {
5135 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_funding_txid;
5136 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { crate::c_types::ThirtyTwoBytes { data: (*inner_val.as_ref().unwrap()).clone().into_inner() } }) };
5139 /// The next funding transaction ID
5141 pub extern "C" fn ChannelReestablish_set_next_funding_txid(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::derived::COption_ThirtyTwoBytesZ) {
5142 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() }})} };
5143 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_funding_txid = local_val;
5145 /// Constructs a new ChannelReestablish given each field
5148 pub extern "C" fn ChannelReestablish_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut next_local_commitment_number_arg: u64, mut next_remote_commitment_number_arg: u64, mut your_last_per_commitment_secret_arg: crate::c_types::ThirtyTwoBytes, mut my_current_per_commitment_point_arg: crate::c_types::PublicKey, mut next_funding_txid_arg: crate::c_types::derived::COption_ThirtyTwoBytesZ) -> ChannelReestablish {
5149 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() }})} };
5150 ChannelReestablish { inner: ObjOps::heap_alloc(nativeChannelReestablish {
5151 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
5152 next_local_commitment_number: next_local_commitment_number_arg,
5153 next_remote_commitment_number: next_remote_commitment_number_arg,
5154 your_last_per_commitment_secret: your_last_per_commitment_secret_arg.data,
5155 my_current_per_commitment_point: my_current_per_commitment_point_arg.into_rust(),
5156 next_funding_txid: local_next_funding_txid_arg,
5157 }), is_owned: true }
5159 impl Clone for ChannelReestablish {
5160 fn clone(&self) -> Self {
5162 inner: if <*mut nativeChannelReestablish>::is_null(self.inner) { core::ptr::null_mut() } else {
5163 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5169 /// Used only if an object of this type is returned as a trait impl by a method
5170 pub(crate) extern "C" fn ChannelReestablish_clone_void(this_ptr: *const c_void) -> *mut c_void {
5171 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelReestablish)).clone() })) as *mut c_void
5174 /// Creates a copy of the ChannelReestablish
5175 pub extern "C" fn ChannelReestablish_clone(orig: &ChannelReestablish) -> ChannelReestablish {
5178 /// Checks if two ChannelReestablishs contain equal inner contents.
5179 /// This ignores pointers and is_owned flags and looks at the values in fields.
5180 /// Two objects with NULL inner values will be considered "equal" here.
5182 pub extern "C" fn ChannelReestablish_eq(a: &ChannelReestablish, b: &ChannelReestablish) -> bool {
5183 if a.inner == b.inner { return true; }
5184 if a.inner.is_null() || b.inner.is_null() { return false; }
5185 if a.get_native_ref() == b.get_native_ref() { true } else { false }
5188 use lightning::ln::msgs::AnnouncementSignatures as nativeAnnouncementSignaturesImport;
5189 pub(crate) type nativeAnnouncementSignatures = nativeAnnouncementSignaturesImport;
5191 /// An [`announcement_signatures`] message to be sent to or received from a peer.
5193 /// [`announcement_signatures`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-announcement_signatures-message
5196 pub struct AnnouncementSignatures {
5197 /// A pointer to the opaque Rust object.
5199 /// Nearly everywhere, inner must be non-null, however in places where
5200 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5201 pub inner: *mut nativeAnnouncementSignatures,
5202 /// Indicates that this is the only struct which contains the same pointer.
5204 /// Rust functions which take ownership of an object provided via an argument require
5205 /// this to be true and invalidate the object pointed to by inner.
5209 impl Drop for AnnouncementSignatures {
5210 fn drop(&mut self) {
5211 if self.is_owned && !<*mut nativeAnnouncementSignatures>::is_null(self.inner) {
5212 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5216 /// Frees any resources used by the AnnouncementSignatures, if is_owned is set and inner is non-NULL.
5218 pub extern "C" fn AnnouncementSignatures_free(this_obj: AnnouncementSignatures) { }
5220 /// Used only if an object of this type is returned as a trait impl by a method
5221 pub(crate) extern "C" fn AnnouncementSignatures_free_void(this_ptr: *mut c_void) {
5222 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAnnouncementSignatures) };
5225 impl AnnouncementSignatures {
5226 pub(crate) fn get_native_ref(&self) -> &'static nativeAnnouncementSignatures {
5227 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5229 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAnnouncementSignatures {
5230 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5232 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5233 pub(crate) fn take_inner(mut self) -> *mut nativeAnnouncementSignatures {
5234 assert!(self.is_owned);
5235 let ret = ObjOps::untweak_ptr(self.inner);
5236 self.inner = core::ptr::null_mut();
5242 pub extern "C" fn AnnouncementSignatures_get_channel_id(this_ptr: &AnnouncementSignatures) -> *const [u8; 32] {
5243 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5248 pub extern "C" fn AnnouncementSignatures_set_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
5249 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
5251 /// The short channel ID
5253 pub extern "C" fn AnnouncementSignatures_get_short_channel_id(this_ptr: &AnnouncementSignatures) -> u64 {
5254 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
5257 /// The short channel ID
5259 pub extern "C" fn AnnouncementSignatures_set_short_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: u64) {
5260 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
5262 /// A signature by the node key
5264 pub extern "C" fn AnnouncementSignatures_get_node_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::ECDSASignature {
5265 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature;
5266 crate::c_types::ECDSASignature::from_rust(&inner_val)
5268 /// A signature by the node key
5270 pub extern "C" fn AnnouncementSignatures_set_node_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ECDSASignature) {
5271 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature = val.into_rust();
5273 /// A signature by the funding key
5275 pub extern "C" fn AnnouncementSignatures_get_bitcoin_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::ECDSASignature {
5276 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature;
5277 crate::c_types::ECDSASignature::from_rust(&inner_val)
5279 /// A signature by the funding key
5281 pub extern "C" fn AnnouncementSignatures_set_bitcoin_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ECDSASignature) {
5282 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature = val.into_rust();
5284 /// Constructs a new AnnouncementSignatures given each field
5287 pub extern "C" fn AnnouncementSignatures_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_id_arg: u64, mut node_signature_arg: crate::c_types::ECDSASignature, mut bitcoin_signature_arg: crate::c_types::ECDSASignature) -> AnnouncementSignatures {
5288 AnnouncementSignatures { inner: ObjOps::heap_alloc(nativeAnnouncementSignatures {
5289 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
5290 short_channel_id: short_channel_id_arg,
5291 node_signature: node_signature_arg.into_rust(),
5292 bitcoin_signature: bitcoin_signature_arg.into_rust(),
5293 }), is_owned: true }
5295 impl Clone for AnnouncementSignatures {
5296 fn clone(&self) -> Self {
5298 inner: if <*mut nativeAnnouncementSignatures>::is_null(self.inner) { core::ptr::null_mut() } else {
5299 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5305 /// Used only if an object of this type is returned as a trait impl by a method
5306 pub(crate) extern "C" fn AnnouncementSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
5307 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeAnnouncementSignatures)).clone() })) as *mut c_void
5310 /// Creates a copy of the AnnouncementSignatures
5311 pub extern "C" fn AnnouncementSignatures_clone(orig: &AnnouncementSignatures) -> AnnouncementSignatures {
5314 /// Checks if two AnnouncementSignaturess contain equal inner contents.
5315 /// This ignores pointers and is_owned flags and looks at the values in fields.
5316 /// Two objects with NULL inner values will be considered "equal" here.
5318 pub extern "C" fn AnnouncementSignatures_eq(a: &AnnouncementSignatures, b: &AnnouncementSignatures) -> bool {
5319 if a.inner == b.inner { return true; }
5320 if a.inner.is_null() || b.inner.is_null() { return false; }
5321 if a.get_native_ref() == b.get_native_ref() { true } else { false }
5323 /// An address which can be used to connect to a remote peer.
5327 pub enum SocketAddress {
5328 /// An IPv4 address and port on which the peer is listening.
5330 /// The 4-byte IPv4 address
5331 addr: crate::c_types::FourBytes,
5332 /// The port on which the node is listening
5335 /// An IPv6 address and port on which the peer is listening.
5337 /// The 16-byte IPv6 address
5338 addr: crate::c_types::SixteenBytes,
5339 /// The port on which the node is listening
5342 /// An old-style Tor onion address/port on which the peer is listening.
5344 /// This field is deprecated and the Tor network generally no longer supports V2 Onion
5345 /// addresses. Thus, the details are not parsed here.
5347 crate::c_types::TwelveBytes),
5348 /// A new-style Tor onion address/port on which the peer is listening.
5350 /// To create the human-readable \"hostname\", concatenate the ED25519 pubkey, checksum, and version,
5351 /// wrap as base32 and append \".onion\".
5353 /// The ed25519 long-term public key of the peer
5354 ed25519_pubkey: crate::c_types::ThirtyTwoBytes,
5355 /// The checksum of the pubkey and version, as included in the onion address
5357 /// The version byte, as defined by the Tor Onion v3 spec.
5359 /// The port on which the node is listening
5362 /// A hostname/port on which the peer is listening.
5364 /// The hostname on which the node is listening.
5365 hostname: crate::lightning::util::ser::Hostname,
5366 /// The port on which the node is listening.
5370 use lightning::ln::msgs::SocketAddress as SocketAddressImport;
5371 pub(crate) type nativeSocketAddress = SocketAddressImport;
5373 impl SocketAddress {
5375 pub(crate) fn to_native(&self) -> nativeSocketAddress {
5377 SocketAddress::TcpIpV4 {ref addr, ref port, } => {
5378 let mut addr_nonref = Clone::clone(addr);
5379 let mut port_nonref = Clone::clone(port);
5380 nativeSocketAddress::TcpIpV4 {
5381 addr: addr_nonref.data,
5385 SocketAddress::TcpIpV6 {ref addr, ref port, } => {
5386 let mut addr_nonref = Clone::clone(addr);
5387 let mut port_nonref = Clone::clone(port);
5388 nativeSocketAddress::TcpIpV6 {
5389 addr: addr_nonref.data,
5393 SocketAddress::OnionV2 (ref a, ) => {
5394 let mut a_nonref = Clone::clone(a);
5395 nativeSocketAddress::OnionV2 (
5399 SocketAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
5400 let mut ed25519_pubkey_nonref = Clone::clone(ed25519_pubkey);
5401 let mut checksum_nonref = Clone::clone(checksum);
5402 let mut version_nonref = Clone::clone(version);
5403 let mut port_nonref = Clone::clone(port);
5404 nativeSocketAddress::OnionV3 {
5405 ed25519_pubkey: ed25519_pubkey_nonref.data,
5406 checksum: checksum_nonref,
5407 version: version_nonref,
5411 SocketAddress::Hostname {ref hostname, ref port, } => {
5412 let mut hostname_nonref = Clone::clone(hostname);
5413 let mut port_nonref = Clone::clone(port);
5414 nativeSocketAddress::Hostname {
5415 hostname: *unsafe { Box::from_raw(hostname_nonref.take_inner()) },
5422 pub(crate) fn into_native(self) -> nativeSocketAddress {
5424 SocketAddress::TcpIpV4 {mut addr, mut port, } => {
5425 nativeSocketAddress::TcpIpV4 {
5430 SocketAddress::TcpIpV6 {mut addr, mut port, } => {
5431 nativeSocketAddress::TcpIpV6 {
5436 SocketAddress::OnionV2 (mut a, ) => {
5437 nativeSocketAddress::OnionV2 (
5441 SocketAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
5442 nativeSocketAddress::OnionV3 {
5443 ed25519_pubkey: ed25519_pubkey.data,
5449 SocketAddress::Hostname {mut hostname, mut port, } => {
5450 nativeSocketAddress::Hostname {
5451 hostname: *unsafe { Box::from_raw(hostname.take_inner()) },
5458 pub(crate) fn from_native(native: &nativeSocketAddress) -> Self {
5460 nativeSocketAddress::TcpIpV4 {ref addr, ref port, } => {
5461 let mut addr_nonref = Clone::clone(addr);
5462 let mut port_nonref = Clone::clone(port);
5463 SocketAddress::TcpIpV4 {
5464 addr: crate::c_types::FourBytes { data: addr_nonref },
5468 nativeSocketAddress::TcpIpV6 {ref addr, ref port, } => {
5469 let mut addr_nonref = Clone::clone(addr);
5470 let mut port_nonref = Clone::clone(port);
5471 SocketAddress::TcpIpV6 {
5472 addr: crate::c_types::SixteenBytes { data: addr_nonref },
5476 nativeSocketAddress::OnionV2 (ref a, ) => {
5477 let mut a_nonref = Clone::clone(a);
5478 SocketAddress::OnionV2 (
5479 crate::c_types::TwelveBytes { data: a_nonref },
5482 nativeSocketAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
5483 let mut ed25519_pubkey_nonref = Clone::clone(ed25519_pubkey);
5484 let mut checksum_nonref = Clone::clone(checksum);
5485 let mut version_nonref = Clone::clone(version);
5486 let mut port_nonref = Clone::clone(port);
5487 SocketAddress::OnionV3 {
5488 ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey_nonref },
5489 checksum: checksum_nonref,
5490 version: version_nonref,
5494 nativeSocketAddress::Hostname {ref hostname, ref port, } => {
5495 let mut hostname_nonref = Clone::clone(hostname);
5496 let mut port_nonref = Clone::clone(port);
5497 SocketAddress::Hostname {
5498 hostname: crate::lightning::util::ser::Hostname { inner: ObjOps::heap_alloc(hostname_nonref), is_owned: true },
5505 pub(crate) fn native_into(native: nativeSocketAddress) -> Self {
5507 nativeSocketAddress::TcpIpV4 {mut addr, mut port, } => {
5508 SocketAddress::TcpIpV4 {
5509 addr: crate::c_types::FourBytes { data: addr },
5513 nativeSocketAddress::TcpIpV6 {mut addr, mut port, } => {
5514 SocketAddress::TcpIpV6 {
5515 addr: crate::c_types::SixteenBytes { data: addr },
5519 nativeSocketAddress::OnionV2 (mut a, ) => {
5520 SocketAddress::OnionV2 (
5521 crate::c_types::TwelveBytes { data: a },
5524 nativeSocketAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
5525 SocketAddress::OnionV3 {
5526 ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey },
5532 nativeSocketAddress::Hostname {mut hostname, mut port, } => {
5533 SocketAddress::Hostname {
5534 hostname: crate::lightning::util::ser::Hostname { inner: ObjOps::heap_alloc(hostname), is_owned: true },
5541 /// Frees any resources used by the SocketAddress
5543 pub extern "C" fn SocketAddress_free(this_ptr: SocketAddress) { }
5544 /// Creates a copy of the SocketAddress
5546 pub extern "C" fn SocketAddress_clone(orig: &SocketAddress) -> SocketAddress {
5550 /// Used only if an object of this type is returned as a trait impl by a method
5551 pub(crate) extern "C" fn SocketAddress_clone_void(this_ptr: *const c_void) -> *mut c_void {
5552 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const SocketAddress)).clone() })) as *mut c_void
5555 /// Used only if an object of this type is returned as a trait impl by a method
5556 pub(crate) extern "C" fn SocketAddress_free_void(this_ptr: *mut c_void) {
5557 let _ = unsafe { Box::from_raw(this_ptr as *mut SocketAddress) };
5560 /// Utility method to constructs a new TcpIpV4-variant SocketAddress
5561 pub extern "C" fn SocketAddress_tcp_ip_v4(addr: crate::c_types::FourBytes, port: u16) -> SocketAddress {
5562 SocketAddress::TcpIpV4 {
5568 /// Utility method to constructs a new TcpIpV6-variant SocketAddress
5569 pub extern "C" fn SocketAddress_tcp_ip_v6(addr: crate::c_types::SixteenBytes, port: u16) -> SocketAddress {
5570 SocketAddress::TcpIpV6 {
5576 /// Utility method to constructs a new OnionV2-variant SocketAddress
5577 pub extern "C" fn SocketAddress_onion_v2(a: crate::c_types::TwelveBytes) -> SocketAddress {
5578 SocketAddress::OnionV2(a, )
5581 /// Utility method to constructs a new OnionV3-variant SocketAddress
5582 pub extern "C" fn SocketAddress_onion_v3(ed25519_pubkey: crate::c_types::ThirtyTwoBytes, checksum: u16, version: u8, port: u16) -> SocketAddress {
5583 SocketAddress::OnionV3 {
5591 /// Utility method to constructs a new Hostname-variant SocketAddress
5592 pub extern "C" fn SocketAddress_hostname(hostname: crate::lightning::util::ser::Hostname, port: u16) -> SocketAddress {
5593 SocketAddress::Hostname {
5598 /// Checks if two SocketAddresss contain equal inner contents.
5599 /// This ignores pointers and is_owned flags and looks at the values in fields.
5601 pub extern "C" fn SocketAddress_eq(a: &SocketAddress, b: &SocketAddress) -> bool {
5602 if &a.to_native() == &b.to_native() { true } else { false }
5605 /// Serialize the SocketAddress object into a byte array which can be read by SocketAddress_read
5606 pub extern "C" fn SocketAddress_write(obj: &crate::lightning::ln::msgs::SocketAddress) -> crate::c_types::derived::CVec_u8Z {
5607 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
5610 pub(crate) extern "C" fn SocketAddress_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5611 SocketAddress_write(unsafe { &*(obj as *const SocketAddress) })
5614 /// Read a SocketAddress from a byte array, created by SocketAddress_write
5615 pub extern "C" fn SocketAddress_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SocketAddressDecodeErrorZ {
5616 let res: Result<lightning::ln::msgs::SocketAddress, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5617 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() };
5620 /// [`SocketAddress`] error variants
5624 pub enum SocketAddressParseError {
5625 /// Socket address (IPv4/IPv6) parsing error
5627 /// Invalid input format
5631 /// Invalid onion v3 address
5634 use lightning::ln::msgs::SocketAddressParseError as SocketAddressParseErrorImport;
5635 pub(crate) type nativeSocketAddressParseError = SocketAddressParseErrorImport;
5637 impl SocketAddressParseError {
5639 pub(crate) fn to_native(&self) -> nativeSocketAddressParseError {
5641 SocketAddressParseError::SocketAddrParse => nativeSocketAddressParseError::SocketAddrParse,
5642 SocketAddressParseError::InvalidInput => nativeSocketAddressParseError::InvalidInput,
5643 SocketAddressParseError::InvalidPort => nativeSocketAddressParseError::InvalidPort,
5644 SocketAddressParseError::InvalidOnionV3 => nativeSocketAddressParseError::InvalidOnionV3,
5648 pub(crate) fn into_native(self) -> nativeSocketAddressParseError {
5650 SocketAddressParseError::SocketAddrParse => nativeSocketAddressParseError::SocketAddrParse,
5651 SocketAddressParseError::InvalidInput => nativeSocketAddressParseError::InvalidInput,
5652 SocketAddressParseError::InvalidPort => nativeSocketAddressParseError::InvalidPort,
5653 SocketAddressParseError::InvalidOnionV3 => nativeSocketAddressParseError::InvalidOnionV3,
5657 pub(crate) fn from_native(native: &nativeSocketAddressParseError) -> Self {
5659 nativeSocketAddressParseError::SocketAddrParse => SocketAddressParseError::SocketAddrParse,
5660 nativeSocketAddressParseError::InvalidInput => SocketAddressParseError::InvalidInput,
5661 nativeSocketAddressParseError::InvalidPort => SocketAddressParseError::InvalidPort,
5662 nativeSocketAddressParseError::InvalidOnionV3 => SocketAddressParseError::InvalidOnionV3,
5666 pub(crate) fn native_into(native: nativeSocketAddressParseError) -> Self {
5668 nativeSocketAddressParseError::SocketAddrParse => SocketAddressParseError::SocketAddrParse,
5669 nativeSocketAddressParseError::InvalidInput => SocketAddressParseError::InvalidInput,
5670 nativeSocketAddressParseError::InvalidPort => SocketAddressParseError::InvalidPort,
5671 nativeSocketAddressParseError::InvalidOnionV3 => SocketAddressParseError::InvalidOnionV3,
5675 /// Creates a copy of the SocketAddressParseError
5677 pub extern "C" fn SocketAddressParseError_clone(orig: &SocketAddressParseError) -> SocketAddressParseError {
5681 /// Used only if an object of this type is returned as a trait impl by a method
5682 pub(crate) extern "C" fn SocketAddressParseError_clone_void(this_ptr: *const c_void) -> *mut c_void {
5683 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const SocketAddressParseError)).clone() })) as *mut c_void
5686 /// Used only if an object of this type is returned as a trait impl by a method
5687 pub(crate) extern "C" fn SocketAddressParseError_free_void(this_ptr: *mut c_void) {
5688 let _ = unsafe { Box::from_raw(this_ptr as *mut SocketAddressParseError) };
5691 /// Utility method to constructs a new SocketAddrParse-variant SocketAddressParseError
5692 pub extern "C" fn SocketAddressParseError_socket_addr_parse() -> SocketAddressParseError {
5693 SocketAddressParseError::SocketAddrParse}
5695 /// Utility method to constructs a new InvalidInput-variant SocketAddressParseError
5696 pub extern "C" fn SocketAddressParseError_invalid_input() -> SocketAddressParseError {
5697 SocketAddressParseError::InvalidInput}
5699 /// Utility method to constructs a new InvalidPort-variant SocketAddressParseError
5700 pub extern "C" fn SocketAddressParseError_invalid_port() -> SocketAddressParseError {
5701 SocketAddressParseError::InvalidPort}
5703 /// Utility method to constructs a new InvalidOnionV3-variant SocketAddressParseError
5704 pub extern "C" fn SocketAddressParseError_invalid_onion_v3() -> SocketAddressParseError {
5705 SocketAddressParseError::InvalidOnionV3}
5706 /// Checks if two SocketAddressParseErrors contain equal inner contents.
5707 /// This ignores pointers and is_owned flags and looks at the values in fields.
5709 pub extern "C" fn SocketAddressParseError_eq(a: &SocketAddressParseError, b: &SocketAddressParseError) -> bool {
5710 if &a.to_native() == &b.to_native() { true } else { false }
5712 /// Parses an OnionV3 host and port into a [`SocketAddress::OnionV3`].
5714 /// The host part must end with \".onion\".
5716 pub extern "C" fn parse_onion_address(mut host: crate::c_types::Str, mut port: u16) -> crate::c_types::derived::CResult_SocketAddressSocketAddressParseErrorZ {
5717 let mut ret = lightning::ln::msgs::parse_onion_address(host.into_str(), port);
5718 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() };
5723 /// Get the string representation of a SocketAddress object
5724 pub extern "C" fn SocketAddress_to_str(o: &crate::lightning::ln::msgs::SocketAddress) -> Str {
5725 alloc::format!("{}", &o.to_native()).into()
5728 /// Read a SocketAddress object from a string
5729 pub extern "C" fn SocketAddress_from_str(s: crate::c_types::Str) -> crate::c_types::derived::CResult_SocketAddressSocketAddressParseErrorZ {
5730 match lightning::ln::msgs::SocketAddress::from_str(s.into_str()) {
5732 crate::c_types::CResultTempl::ok(
5733 crate::lightning::ln::msgs::SocketAddress::native_into(r)
5737 crate::c_types::CResultTempl::err(
5738 crate::lightning::ln::msgs::SocketAddressParseError::native_into(e)
5743 /// Represents the set of gossip messages that require a signature from a node's identity key.
5747 pub enum UnsignedGossipMessage {
5748 /// An unsigned channel announcement.
5749 ChannelAnnouncement(
5750 crate::lightning::ln::msgs::UnsignedChannelAnnouncement),
5751 /// An unsigned channel update.
5753 crate::lightning::ln::msgs::UnsignedChannelUpdate),
5754 /// An unsigned node announcement.
5756 crate::lightning::ln::msgs::UnsignedNodeAnnouncement),
5758 use lightning::ln::msgs::UnsignedGossipMessage as UnsignedGossipMessageImport;
5759 pub(crate) type nativeUnsignedGossipMessage = UnsignedGossipMessageImport;
5761 impl UnsignedGossipMessage {
5763 pub(crate) fn to_native(&self) -> nativeUnsignedGossipMessage {
5765 UnsignedGossipMessage::ChannelAnnouncement (ref a, ) => {
5766 let mut a_nonref = Clone::clone(a);
5767 nativeUnsignedGossipMessage::ChannelAnnouncement (
5768 *unsafe { Box::from_raw(a_nonref.take_inner()) },
5771 UnsignedGossipMessage::ChannelUpdate (ref a, ) => {
5772 let mut a_nonref = Clone::clone(a);
5773 nativeUnsignedGossipMessage::ChannelUpdate (
5774 *unsafe { Box::from_raw(a_nonref.take_inner()) },
5777 UnsignedGossipMessage::NodeAnnouncement (ref a, ) => {
5778 let mut a_nonref = Clone::clone(a);
5779 nativeUnsignedGossipMessage::NodeAnnouncement (
5780 *unsafe { Box::from_raw(a_nonref.take_inner()) },
5786 pub(crate) fn into_native(self) -> nativeUnsignedGossipMessage {
5788 UnsignedGossipMessage::ChannelAnnouncement (mut a, ) => {
5789 nativeUnsignedGossipMessage::ChannelAnnouncement (
5790 *unsafe { Box::from_raw(a.take_inner()) },
5793 UnsignedGossipMessage::ChannelUpdate (mut a, ) => {
5794 nativeUnsignedGossipMessage::ChannelUpdate (
5795 *unsafe { Box::from_raw(a.take_inner()) },
5798 UnsignedGossipMessage::NodeAnnouncement (mut a, ) => {
5799 nativeUnsignedGossipMessage::NodeAnnouncement (
5800 *unsafe { Box::from_raw(a.take_inner()) },
5806 pub(crate) fn from_native(native: &nativeUnsignedGossipMessage) -> Self {
5808 nativeUnsignedGossipMessage::ChannelAnnouncement (ref a, ) => {
5809 let mut a_nonref = Clone::clone(a);
5810 UnsignedGossipMessage::ChannelAnnouncement (
5811 crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
5814 nativeUnsignedGossipMessage::ChannelUpdate (ref a, ) => {
5815 let mut a_nonref = Clone::clone(a);
5816 UnsignedGossipMessage::ChannelUpdate (
5817 crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
5820 nativeUnsignedGossipMessage::NodeAnnouncement (ref a, ) => {
5821 let mut a_nonref = Clone::clone(a);
5822 UnsignedGossipMessage::NodeAnnouncement (
5823 crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
5829 pub(crate) fn native_into(native: nativeUnsignedGossipMessage) -> Self {
5831 nativeUnsignedGossipMessage::ChannelAnnouncement (mut a, ) => {
5832 UnsignedGossipMessage::ChannelAnnouncement (
5833 crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(a), is_owned: true },
5836 nativeUnsignedGossipMessage::ChannelUpdate (mut a, ) => {
5837 UnsignedGossipMessage::ChannelUpdate (
5838 crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: ObjOps::heap_alloc(a), is_owned: true },
5841 nativeUnsignedGossipMessage::NodeAnnouncement (mut a, ) => {
5842 UnsignedGossipMessage::NodeAnnouncement (
5843 crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: ObjOps::heap_alloc(a), is_owned: true },
5849 /// Frees any resources used by the UnsignedGossipMessage
5851 pub extern "C" fn UnsignedGossipMessage_free(this_ptr: UnsignedGossipMessage) { }
5852 /// Creates a copy of the UnsignedGossipMessage
5854 pub extern "C" fn UnsignedGossipMessage_clone(orig: &UnsignedGossipMessage) -> UnsignedGossipMessage {
5858 /// Used only if an object of this type is returned as a trait impl by a method
5859 pub(crate) extern "C" fn UnsignedGossipMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
5860 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const UnsignedGossipMessage)).clone() })) as *mut c_void
5863 /// Used only if an object of this type is returned as a trait impl by a method
5864 pub(crate) extern "C" fn UnsignedGossipMessage_free_void(this_ptr: *mut c_void) {
5865 let _ = unsafe { Box::from_raw(this_ptr as *mut UnsignedGossipMessage) };
5868 /// Utility method to constructs a new ChannelAnnouncement-variant UnsignedGossipMessage
5869 pub extern "C" fn UnsignedGossipMessage_channel_announcement(a: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> UnsignedGossipMessage {
5870 UnsignedGossipMessage::ChannelAnnouncement(a, )
5873 /// Utility method to constructs a new ChannelUpdate-variant UnsignedGossipMessage
5874 pub extern "C" fn UnsignedGossipMessage_channel_update(a: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> UnsignedGossipMessage {
5875 UnsignedGossipMessage::ChannelUpdate(a, )
5878 /// Utility method to constructs a new NodeAnnouncement-variant UnsignedGossipMessage
5879 pub extern "C" fn UnsignedGossipMessage_node_announcement(a: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> UnsignedGossipMessage {
5880 UnsignedGossipMessage::NodeAnnouncement(a, )
5883 /// Serialize the UnsignedGossipMessage object into a byte array which can be read by UnsignedGossipMessage_read
5884 pub extern "C" fn UnsignedGossipMessage_write(obj: &crate::lightning::ln::msgs::UnsignedGossipMessage) -> crate::c_types::derived::CVec_u8Z {
5885 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
5888 pub(crate) extern "C" fn UnsignedGossipMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5889 UnsignedGossipMessage_write(unsafe { &*(obj as *const UnsignedGossipMessage) })
5892 use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport;
5893 pub(crate) type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport;
5895 /// The unsigned part of a [`node_announcement`] message.
5897 /// [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message
5900 pub struct UnsignedNodeAnnouncement {
5901 /// A pointer to the opaque Rust object.
5903 /// Nearly everywhere, inner must be non-null, however in places where
5904 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5905 pub inner: *mut nativeUnsignedNodeAnnouncement,
5906 /// Indicates that this is the only struct which contains the same pointer.
5908 /// Rust functions which take ownership of an object provided via an argument require
5909 /// this to be true and invalidate the object pointed to by inner.
5913 impl Drop for UnsignedNodeAnnouncement {
5914 fn drop(&mut self) {
5915 if self.is_owned && !<*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) {
5916 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5920 /// Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL.
5922 pub extern "C" fn UnsignedNodeAnnouncement_free(this_obj: UnsignedNodeAnnouncement) { }
5924 /// Used only if an object of this type is returned as a trait impl by a method
5925 pub(crate) extern "C" fn UnsignedNodeAnnouncement_free_void(this_ptr: *mut c_void) {
5926 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedNodeAnnouncement) };
5929 impl UnsignedNodeAnnouncement {
5930 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedNodeAnnouncement {
5931 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5933 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedNodeAnnouncement {
5934 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5936 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5937 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedNodeAnnouncement {
5938 assert!(self.is_owned);
5939 let ret = ObjOps::untweak_ptr(self.inner);
5940 self.inner = core::ptr::null_mut();
5944 /// The advertised features
5946 pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::ln::features::NodeFeatures {
5947 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
5948 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 }
5950 /// The advertised features
5952 pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::ln::features::NodeFeatures) {
5953 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
5955 /// A strictly monotonic announcement counter, with gaps allowed
5957 pub extern "C" fn UnsignedNodeAnnouncement_get_timestamp(this_ptr: &UnsignedNodeAnnouncement) -> u32 {
5958 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
5961 /// A strictly monotonic announcement counter, with gaps allowed
5963 pub extern "C" fn UnsignedNodeAnnouncement_set_timestamp(this_ptr: &mut UnsignedNodeAnnouncement, mut val: u32) {
5964 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
5966 /// The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back
5969 pub extern "C" fn UnsignedNodeAnnouncement_get_node_id(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::routing::gossip::NodeId {
5970 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id;
5971 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 }
5973 /// The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back
5976 pub extern "C" fn UnsignedNodeAnnouncement_set_node_id(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
5977 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id = *unsafe { Box::from_raw(val.take_inner()) };
5979 /// An RGB color for UI purposes
5981 pub extern "C" fn UnsignedNodeAnnouncement_get_rgb(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 3] {
5982 let mut inner_val = &mut this_ptr.get_native_mut_ref().rgb;
5985 /// An RGB color for UI purposes
5987 pub extern "C" fn UnsignedNodeAnnouncement_set_rgb(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThreeBytes) {
5988 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.rgb = val.data;
5990 /// An alias, for UI purposes.
5992 /// This should be sanitized before use. There is no guarantee of uniqueness.
5994 pub extern "C" fn UnsignedNodeAnnouncement_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::routing::gossip::NodeAlias {
5995 let mut inner_val = &mut this_ptr.get_native_mut_ref().alias;
5996 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 }
5998 /// An alias, for UI purposes.
6000 /// This should be sanitized before use. There is no guarantee of uniqueness.
6002 pub extern "C" fn UnsignedNodeAnnouncement_set_alias(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::routing::gossip::NodeAlias) {
6003 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.alias = *unsafe { Box::from_raw(val.take_inner()) };
6005 /// List of addresses on which this node is reachable
6007 /// Returns a copy of the field.
6009 pub extern "C" fn UnsignedNodeAnnouncement_get_addresses(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_SocketAddressZ {
6010 let mut inner_val = this_ptr.get_native_mut_ref().addresses.clone();
6011 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) }); };
6012 local_inner_val.into()
6014 /// List of addresses on which this node is reachable
6016 pub extern "C" fn UnsignedNodeAnnouncement_set_addresses(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_SocketAddressZ) {
6017 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
6018 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.addresses = local_val;
6020 impl Clone for UnsignedNodeAnnouncement {
6021 fn clone(&self) -> Self {
6023 inner: if <*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
6024 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6030 /// Used only if an object of this type is returned as a trait impl by a method
6031 pub(crate) extern "C" fn UnsignedNodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
6032 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUnsignedNodeAnnouncement)).clone() })) as *mut c_void
6035 /// Creates a copy of the UnsignedNodeAnnouncement
6036 pub extern "C" fn UnsignedNodeAnnouncement_clone(orig: &UnsignedNodeAnnouncement) -> UnsignedNodeAnnouncement {
6039 /// Checks if two UnsignedNodeAnnouncements contain equal inner contents.
6040 /// This ignores pointers and is_owned flags and looks at the values in fields.
6041 /// Two objects with NULL inner values will be considered "equal" here.
6043 pub extern "C" fn UnsignedNodeAnnouncement_eq(a: &UnsignedNodeAnnouncement, b: &UnsignedNodeAnnouncement) -> bool {
6044 if a.inner == b.inner { return true; }
6045 if a.inner.is_null() || b.inner.is_null() { return false; }
6046 if a.get_native_ref() == b.get_native_ref() { true } else { false }
6049 use lightning::ln::msgs::NodeAnnouncement as nativeNodeAnnouncementImport;
6050 pub(crate) type nativeNodeAnnouncement = nativeNodeAnnouncementImport;
6052 /// A [`node_announcement`] message to be sent to or received from a peer.
6054 /// [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message
6057 pub struct NodeAnnouncement {
6058 /// A pointer to the opaque Rust object.
6060 /// Nearly everywhere, inner must be non-null, however in places where
6061 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6062 pub inner: *mut nativeNodeAnnouncement,
6063 /// Indicates that this is the only struct which contains the same pointer.
6065 /// Rust functions which take ownership of an object provided via an argument require
6066 /// this to be true and invalidate the object pointed to by inner.
6070 impl Drop for NodeAnnouncement {
6071 fn drop(&mut self) {
6072 if self.is_owned && !<*mut nativeNodeAnnouncement>::is_null(self.inner) {
6073 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6077 /// Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL.
6079 pub extern "C" fn NodeAnnouncement_free(this_obj: NodeAnnouncement) { }
6081 /// Used only if an object of this type is returned as a trait impl by a method
6082 pub(crate) extern "C" fn NodeAnnouncement_free_void(this_ptr: *mut c_void) {
6083 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeNodeAnnouncement) };
6086 impl NodeAnnouncement {
6087 pub(crate) fn get_native_ref(&self) -> &'static nativeNodeAnnouncement {
6088 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6090 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeAnnouncement {
6091 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6093 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6094 pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncement {
6095 assert!(self.is_owned);
6096 let ret = ObjOps::untweak_ptr(self.inner);
6097 self.inner = core::ptr::null_mut();
6101 /// The signature by the node key
6103 pub extern "C" fn NodeAnnouncement_get_signature(this_ptr: &NodeAnnouncement) -> crate::c_types::ECDSASignature {
6104 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
6105 crate::c_types::ECDSASignature::from_rust(&inner_val)
6107 /// The signature by the node key
6109 pub extern "C" fn NodeAnnouncement_set_signature(this_ptr: &mut NodeAnnouncement, mut val: crate::c_types::ECDSASignature) {
6110 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
6112 /// The actual content of the announcement
6114 pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> crate::lightning::ln::msgs::UnsignedNodeAnnouncement {
6115 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
6116 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 }
6118 /// The actual content of the announcement
6120 pub extern "C" fn NodeAnnouncement_set_contents(this_ptr: &mut NodeAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) {
6121 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
6123 /// Constructs a new NodeAnnouncement given each field
6126 pub extern "C" fn NodeAnnouncement_new(mut signature_arg: crate::c_types::ECDSASignature, mut contents_arg: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> NodeAnnouncement {
6127 NodeAnnouncement { inner: ObjOps::heap_alloc(nativeNodeAnnouncement {
6128 signature: signature_arg.into_rust(),
6129 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
6130 }), is_owned: true }
6132 impl Clone for NodeAnnouncement {
6133 fn clone(&self) -> Self {
6135 inner: if <*mut nativeNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
6136 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6142 /// Used only if an object of this type is returned as a trait impl by a method
6143 pub(crate) extern "C" fn NodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
6144 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeNodeAnnouncement)).clone() })) as *mut c_void
6147 /// Creates a copy of the NodeAnnouncement
6148 pub extern "C" fn NodeAnnouncement_clone(orig: &NodeAnnouncement) -> NodeAnnouncement {
6151 /// Checks if two NodeAnnouncements contain equal inner contents.
6152 /// This ignores pointers and is_owned flags and looks at the values in fields.
6153 /// Two objects with NULL inner values will be considered "equal" here.
6155 pub extern "C" fn NodeAnnouncement_eq(a: &NodeAnnouncement, b: &NodeAnnouncement) -> bool {
6156 if a.inner == b.inner { return true; }
6157 if a.inner.is_null() || b.inner.is_null() { return false; }
6158 if a.get_native_ref() == b.get_native_ref() { true } else { false }
6161 use lightning::ln::msgs::UnsignedChannelAnnouncement as nativeUnsignedChannelAnnouncementImport;
6162 pub(crate) type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport;
6164 /// The unsigned part of a [`channel_announcement`] message.
6166 /// [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message
6169 pub struct UnsignedChannelAnnouncement {
6170 /// A pointer to the opaque Rust object.
6172 /// Nearly everywhere, inner must be non-null, however in places where
6173 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6174 pub inner: *mut nativeUnsignedChannelAnnouncement,
6175 /// Indicates that this is the only struct which contains the same pointer.
6177 /// Rust functions which take ownership of an object provided via an argument require
6178 /// this to be true and invalidate the object pointed to by inner.
6182 impl Drop for UnsignedChannelAnnouncement {
6183 fn drop(&mut self) {
6184 if self.is_owned && !<*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) {
6185 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6189 /// Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL.
6191 pub extern "C" fn UnsignedChannelAnnouncement_free(this_obj: UnsignedChannelAnnouncement) { }
6193 /// Used only if an object of this type is returned as a trait impl by a method
6194 pub(crate) extern "C" fn UnsignedChannelAnnouncement_free_void(this_ptr: *mut c_void) {
6195 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedChannelAnnouncement) };
6198 impl UnsignedChannelAnnouncement {
6199 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelAnnouncement {
6200 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6202 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelAnnouncement {
6203 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6205 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6206 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelAnnouncement {
6207 assert!(self.is_owned);
6208 let ret = ObjOps::untweak_ptr(self.inner);
6209 self.inner = core::ptr::null_mut();
6213 /// The advertised channel features
6215 pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::ln::features::ChannelFeatures {
6216 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
6217 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 }
6219 /// The advertised channel features
6221 pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::ln::features::ChannelFeatures) {
6222 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
6224 /// The genesis hash of the blockchain where the channel is to be opened
6226 pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &UnsignedChannelAnnouncement) -> *const [u8; 32] {
6227 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
6228 inner_val.as_bytes()
6230 /// The genesis hash of the blockchain where the channel is to be opened
6232 pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
6233 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data[..]);
6235 /// The short channel ID
6237 pub extern "C" fn UnsignedChannelAnnouncement_get_short_channel_id(this_ptr: &UnsignedChannelAnnouncement) -> u64 {
6238 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
6241 /// The short channel ID
6243 pub extern "C" fn UnsignedChannelAnnouncement_set_short_channel_id(this_ptr: &mut UnsignedChannelAnnouncement, mut val: u64) {
6244 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
6246 /// One of the two `node_id`s which are endpoints of this channel
6248 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
6249 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_1;
6250 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 }
6252 /// One of the two `node_id`s which are endpoints of this channel
6254 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
6255 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_1 = *unsafe { Box::from_raw(val.take_inner()) };
6257 /// The other of the two `node_id`s which are endpoints of this channel
6259 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
6260 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_2;
6261 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 }
6263 /// The other of the two `node_id`s which are endpoints of this channel
6265 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
6266 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_2 = *unsafe { Box::from_raw(val.take_inner()) };
6268 /// The funding key for the first node
6270 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
6271 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_1;
6272 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 }
6274 /// The funding key for the first node
6276 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
6277 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_1 = *unsafe { Box::from_raw(val.take_inner()) };
6279 /// The funding key for the second node
6281 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
6282 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_2;
6283 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 }
6285 /// The funding key for the second node
6287 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
6288 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_2 = *unsafe { Box::from_raw(val.take_inner()) };
6290 /// Excess data which was signed as a part of the message which we do not (yet) understand how
6293 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
6295 /// Returns a copy of the field.
6297 pub extern "C" fn UnsignedChannelAnnouncement_get_excess_data(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
6298 let mut inner_val = this_ptr.get_native_mut_ref().excess_data.clone();
6299 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
6300 local_inner_val.into()
6302 /// Excess data which was signed as a part of the message which we do not (yet) understand how
6305 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
6307 pub extern "C" fn UnsignedChannelAnnouncement_set_excess_data(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::derived::CVec_u8Z) {
6308 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
6309 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_data = local_val;
6311 /// Constructs a new UnsignedChannelAnnouncement given each field
6314 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 {
6315 let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); };
6316 UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(nativeUnsignedChannelAnnouncement {
6317 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
6318 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data[..]),
6319 short_channel_id: short_channel_id_arg,
6320 node_id_1: *unsafe { Box::from_raw(node_id_1_arg.take_inner()) },
6321 node_id_2: *unsafe { Box::from_raw(node_id_2_arg.take_inner()) },
6322 bitcoin_key_1: *unsafe { Box::from_raw(bitcoin_key_1_arg.take_inner()) },
6323 bitcoin_key_2: *unsafe { Box::from_raw(bitcoin_key_2_arg.take_inner()) },
6324 excess_data: local_excess_data_arg,
6325 }), is_owned: true }
6327 impl Clone for UnsignedChannelAnnouncement {
6328 fn clone(&self) -> Self {
6330 inner: if <*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
6331 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6337 /// Used only if an object of this type is returned as a trait impl by a method
6338 pub(crate) extern "C" fn UnsignedChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
6339 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUnsignedChannelAnnouncement)).clone() })) as *mut c_void
6342 /// Creates a copy of the UnsignedChannelAnnouncement
6343 pub extern "C" fn UnsignedChannelAnnouncement_clone(orig: &UnsignedChannelAnnouncement) -> UnsignedChannelAnnouncement {
6346 /// Checks if two UnsignedChannelAnnouncements contain equal inner contents.
6347 /// This ignores pointers and is_owned flags and looks at the values in fields.
6348 /// Two objects with NULL inner values will be considered "equal" here.
6350 pub extern "C" fn UnsignedChannelAnnouncement_eq(a: &UnsignedChannelAnnouncement, b: &UnsignedChannelAnnouncement) -> bool {
6351 if a.inner == b.inner { return true; }
6352 if a.inner.is_null() || b.inner.is_null() { return false; }
6353 if a.get_native_ref() == b.get_native_ref() { true } else { false }
6356 use lightning::ln::msgs::ChannelAnnouncement as nativeChannelAnnouncementImport;
6357 pub(crate) type nativeChannelAnnouncement = nativeChannelAnnouncementImport;
6359 /// A [`channel_announcement`] message to be sent to or received from a peer.
6361 /// [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message
6364 pub struct ChannelAnnouncement {
6365 /// A pointer to the opaque Rust object.
6367 /// Nearly everywhere, inner must be non-null, however in places where
6368 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6369 pub inner: *mut nativeChannelAnnouncement,
6370 /// Indicates that this is the only struct which contains the same pointer.
6372 /// Rust functions which take ownership of an object provided via an argument require
6373 /// this to be true and invalidate the object pointed to by inner.
6377 impl Drop for ChannelAnnouncement {
6378 fn drop(&mut self) {
6379 if self.is_owned && !<*mut nativeChannelAnnouncement>::is_null(self.inner) {
6380 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6384 /// Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL.
6386 pub extern "C" fn ChannelAnnouncement_free(this_obj: ChannelAnnouncement) { }
6388 /// Used only if an object of this type is returned as a trait impl by a method
6389 pub(crate) extern "C" fn ChannelAnnouncement_free_void(this_ptr: *mut c_void) {
6390 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelAnnouncement) };
6393 impl ChannelAnnouncement {
6394 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelAnnouncement {
6395 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6397 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelAnnouncement {
6398 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6400 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6401 pub(crate) fn take_inner(mut self) -> *mut nativeChannelAnnouncement {
6402 assert!(self.is_owned);
6403 let ret = ObjOps::untweak_ptr(self.inner);
6404 self.inner = core::ptr::null_mut();
6408 /// Authentication of the announcement by the first public node
6410 pub extern "C" fn ChannelAnnouncement_get_node_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
6411 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_1;
6412 crate::c_types::ECDSASignature::from_rust(&inner_val)
6414 /// Authentication of the announcement by the first public node
6416 pub extern "C" fn ChannelAnnouncement_set_node_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
6417 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_1 = val.into_rust();
6419 /// Authentication of the announcement by the second public node
6421 pub extern "C" fn ChannelAnnouncement_get_node_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
6422 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_2;
6423 crate::c_types::ECDSASignature::from_rust(&inner_val)
6425 /// Authentication of the announcement by the second public node
6427 pub extern "C" fn ChannelAnnouncement_set_node_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
6428 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_2 = val.into_rust();
6430 /// Proof of funding UTXO ownership by the first public node
6432 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
6433 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_1;
6434 crate::c_types::ECDSASignature::from_rust(&inner_val)
6436 /// Proof of funding UTXO ownership by the first public node
6438 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
6439 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_1 = val.into_rust();
6441 /// Proof of funding UTXO ownership by the second public node
6443 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
6444 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_2;
6445 crate::c_types::ECDSASignature::from_rust(&inner_val)
6447 /// Proof of funding UTXO ownership by the second public node
6449 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
6450 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_2 = val.into_rust();
6452 /// The actual announcement
6454 pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncement) -> crate::lightning::ln::msgs::UnsignedChannelAnnouncement {
6455 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
6456 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 }
6458 /// The actual announcement
6460 pub extern "C" fn ChannelAnnouncement_set_contents(this_ptr: &mut ChannelAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) {
6461 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
6463 /// Constructs a new ChannelAnnouncement given each field
6466 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 {
6467 ChannelAnnouncement { inner: ObjOps::heap_alloc(nativeChannelAnnouncement {
6468 node_signature_1: node_signature_1_arg.into_rust(),
6469 node_signature_2: node_signature_2_arg.into_rust(),
6470 bitcoin_signature_1: bitcoin_signature_1_arg.into_rust(),
6471 bitcoin_signature_2: bitcoin_signature_2_arg.into_rust(),
6472 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
6473 }), is_owned: true }
6475 impl Clone for ChannelAnnouncement {
6476 fn clone(&self) -> Self {
6478 inner: if <*mut nativeChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
6479 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6485 /// Used only if an object of this type is returned as a trait impl by a method
6486 pub(crate) extern "C" fn ChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
6487 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelAnnouncement)).clone() })) as *mut c_void
6490 /// Creates a copy of the ChannelAnnouncement
6491 pub extern "C" fn ChannelAnnouncement_clone(orig: &ChannelAnnouncement) -> ChannelAnnouncement {
6494 /// Checks if two ChannelAnnouncements contain equal inner contents.
6495 /// This ignores pointers and is_owned flags and looks at the values in fields.
6496 /// Two objects with NULL inner values will be considered "equal" here.
6498 pub extern "C" fn ChannelAnnouncement_eq(a: &ChannelAnnouncement, b: &ChannelAnnouncement) -> bool {
6499 if a.inner == b.inner { return true; }
6500 if a.inner.is_null() || b.inner.is_null() { return false; }
6501 if a.get_native_ref() == b.get_native_ref() { true } else { false }
6504 use lightning::ln::msgs::UnsignedChannelUpdate as nativeUnsignedChannelUpdateImport;
6505 pub(crate) type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport;
6507 /// The unsigned part of a [`channel_update`] message.
6509 /// [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
6512 pub struct UnsignedChannelUpdate {
6513 /// A pointer to the opaque Rust object.
6515 /// Nearly everywhere, inner must be non-null, however in places where
6516 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6517 pub inner: *mut nativeUnsignedChannelUpdate,
6518 /// Indicates that this is the only struct which contains the same pointer.
6520 /// Rust functions which take ownership of an object provided via an argument require
6521 /// this to be true and invalidate the object pointed to by inner.
6525 impl Drop for UnsignedChannelUpdate {
6526 fn drop(&mut self) {
6527 if self.is_owned && !<*mut nativeUnsignedChannelUpdate>::is_null(self.inner) {
6528 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6532 /// Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL.
6534 pub extern "C" fn UnsignedChannelUpdate_free(this_obj: UnsignedChannelUpdate) { }
6536 /// Used only if an object of this type is returned as a trait impl by a method
6537 pub(crate) extern "C" fn UnsignedChannelUpdate_free_void(this_ptr: *mut c_void) {
6538 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedChannelUpdate) };
6541 impl UnsignedChannelUpdate {
6542 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelUpdate {
6543 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6545 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelUpdate {
6546 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6548 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6549 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelUpdate {
6550 assert!(self.is_owned);
6551 let ret = ObjOps::untweak_ptr(self.inner);
6552 self.inner = core::ptr::null_mut();
6556 /// The genesis hash of the blockchain where the channel is to be opened
6558 pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChannelUpdate) -> *const [u8; 32] {
6559 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
6560 inner_val.as_bytes()
6562 /// The genesis hash of the blockchain where the channel is to be opened
6564 pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::ThirtyTwoBytes) {
6565 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data[..]);
6567 /// The short channel ID
6569 pub extern "C" fn UnsignedChannelUpdate_get_short_channel_id(this_ptr: &UnsignedChannelUpdate) -> u64 {
6570 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
6573 /// The short channel ID
6575 pub extern "C" fn UnsignedChannelUpdate_set_short_channel_id(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
6576 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
6578 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
6580 pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannelUpdate) -> u32 {
6581 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
6584 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
6586 pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
6587 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
6591 pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 {
6592 let mut inner_val = &mut this_ptr.get_native_mut_ref().flags;
6597 pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) {
6598 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.flags = val;
6600 /// The number of blocks such that if:
6601 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
6602 /// then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines
6603 /// the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a
6604 /// `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10,
6605 /// then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before
6606 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
6607 /// constructing the route.
6609 pub extern "C" fn UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr: &UnsignedChannelUpdate) -> u16 {
6610 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
6613 /// The number of blocks such that if:
6614 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
6615 /// then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines
6616 /// the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a
6617 /// `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10,
6618 /// then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before
6619 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
6620 /// constructing the route.
6622 pub extern "C" fn UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr: &mut UnsignedChannelUpdate, mut val: u16) {
6623 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
6625 /// The minimum HTLC size incoming to sender, in milli-satoshi
6627 pub extern "C" fn UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
6628 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
6631 /// The minimum HTLC size incoming to sender, in milli-satoshi
6633 pub extern "C" fn UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
6634 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
6636 /// The maximum HTLC value incoming to sender, in milli-satoshi.
6638 /// This used to be optional.
6640 pub extern "C" fn UnsignedChannelUpdate_get_htlc_maximum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
6641 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat;
6644 /// The maximum HTLC value incoming to sender, in milli-satoshi.
6646 /// This used to be optional.
6648 pub extern "C" fn UnsignedChannelUpdate_set_htlc_maximum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
6649 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = val;
6651 /// The base HTLC fee charged by sender, in milli-satoshi
6653 pub extern "C" fn UnsignedChannelUpdate_get_fee_base_msat(this_ptr: &UnsignedChannelUpdate) -> u32 {
6654 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat;
6657 /// The base HTLC fee charged by sender, in milli-satoshi
6659 pub extern "C" fn UnsignedChannelUpdate_set_fee_base_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
6660 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val;
6662 /// The amount to fee multiplier, in micro-satoshi
6664 pub extern "C" fn UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr: &UnsignedChannelUpdate) -> u32 {
6665 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths;
6668 /// The amount to fee multiplier, in micro-satoshi
6670 pub extern "C" fn UnsignedChannelUpdate_set_fee_proportional_millionths(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
6671 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val;
6673 /// Excess data which was signed as a part of the message which we do not (yet) understand how
6676 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
6678 /// Returns a copy of the field.
6680 pub extern "C" fn UnsignedChannelUpdate_get_excess_data(this_ptr: &UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
6681 let mut inner_val = this_ptr.get_native_mut_ref().excess_data.clone();
6682 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
6683 local_inner_val.into()
6685 /// Excess data which was signed as a part of the message which we do not (yet) understand how
6688 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
6690 pub extern "C" fn UnsignedChannelUpdate_set_excess_data(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::derived::CVec_u8Z) {
6691 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
6692 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_data = local_val;
6694 /// Constructs a new UnsignedChannelUpdate given each field
6697 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 {
6698 let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); };
6699 UnsignedChannelUpdate { inner: ObjOps::heap_alloc(nativeUnsignedChannelUpdate {
6700 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data[..]),
6701 short_channel_id: short_channel_id_arg,
6702 timestamp: timestamp_arg,
6704 cltv_expiry_delta: cltv_expiry_delta_arg,
6705 htlc_minimum_msat: htlc_minimum_msat_arg,
6706 htlc_maximum_msat: htlc_maximum_msat_arg,
6707 fee_base_msat: fee_base_msat_arg,
6708 fee_proportional_millionths: fee_proportional_millionths_arg,
6709 excess_data: local_excess_data_arg,
6710 }), is_owned: true }
6712 impl Clone for UnsignedChannelUpdate {
6713 fn clone(&self) -> Self {
6715 inner: if <*mut nativeUnsignedChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
6716 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6722 /// Used only if an object of this type is returned as a trait impl by a method
6723 pub(crate) extern "C" fn UnsignedChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
6724 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUnsignedChannelUpdate)).clone() })) as *mut c_void
6727 /// Creates a copy of the UnsignedChannelUpdate
6728 pub extern "C" fn UnsignedChannelUpdate_clone(orig: &UnsignedChannelUpdate) -> UnsignedChannelUpdate {
6731 /// Checks if two UnsignedChannelUpdates contain equal inner contents.
6732 /// This ignores pointers and is_owned flags and looks at the values in fields.
6733 /// Two objects with NULL inner values will be considered "equal" here.
6735 pub extern "C" fn UnsignedChannelUpdate_eq(a: &UnsignedChannelUpdate, b: &UnsignedChannelUpdate) -> bool {
6736 if a.inner == b.inner { return true; }
6737 if a.inner.is_null() || b.inner.is_null() { return false; }
6738 if a.get_native_ref() == b.get_native_ref() { true } else { false }
6741 use lightning::ln::msgs::ChannelUpdate as nativeChannelUpdateImport;
6742 pub(crate) type nativeChannelUpdate = nativeChannelUpdateImport;
6744 /// A [`channel_update`] message to be sent to or received from a peer.
6746 /// [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
6749 pub struct ChannelUpdate {
6750 /// A pointer to the opaque Rust object.
6752 /// Nearly everywhere, inner must be non-null, however in places where
6753 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6754 pub inner: *mut nativeChannelUpdate,
6755 /// Indicates that this is the only struct which contains the same pointer.
6757 /// Rust functions which take ownership of an object provided via an argument require
6758 /// this to be true and invalidate the object pointed to by inner.
6762 impl Drop for ChannelUpdate {
6763 fn drop(&mut self) {
6764 if self.is_owned && !<*mut nativeChannelUpdate>::is_null(self.inner) {
6765 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6769 /// Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL.
6771 pub extern "C" fn ChannelUpdate_free(this_obj: ChannelUpdate) { }
6773 /// Used only if an object of this type is returned as a trait impl by a method
6774 pub(crate) extern "C" fn ChannelUpdate_free_void(this_ptr: *mut c_void) {
6775 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelUpdate) };
6778 impl ChannelUpdate {
6779 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelUpdate {
6780 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6782 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelUpdate {
6783 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6785 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6786 pub(crate) fn take_inner(mut self) -> *mut nativeChannelUpdate {
6787 assert!(self.is_owned);
6788 let ret = ObjOps::untweak_ptr(self.inner);
6789 self.inner = core::ptr::null_mut();
6793 /// A signature of the channel update
6795 pub extern "C" fn ChannelUpdate_get_signature(this_ptr: &ChannelUpdate) -> crate::c_types::ECDSASignature {
6796 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
6797 crate::c_types::ECDSASignature::from_rust(&inner_val)
6799 /// A signature of the channel update
6801 pub extern "C" fn ChannelUpdate_set_signature(this_ptr: &mut ChannelUpdate, mut val: crate::c_types::ECDSASignature) {
6802 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
6804 /// The actual channel update
6806 pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate::lightning::ln::msgs::UnsignedChannelUpdate {
6807 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
6808 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 }
6810 /// The actual channel update
6812 pub extern "C" fn ChannelUpdate_set_contents(this_ptr: &mut ChannelUpdate, mut val: crate::lightning::ln::msgs::UnsignedChannelUpdate) {
6813 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
6815 /// Constructs a new ChannelUpdate given each field
6818 pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::ECDSASignature, mut contents_arg: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> ChannelUpdate {
6819 ChannelUpdate { inner: ObjOps::heap_alloc(nativeChannelUpdate {
6820 signature: signature_arg.into_rust(),
6821 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
6822 }), is_owned: true }
6824 impl Clone for ChannelUpdate {
6825 fn clone(&self) -> Self {
6827 inner: if <*mut nativeChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
6828 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6834 /// Used only if an object of this type is returned as a trait impl by a method
6835 pub(crate) extern "C" fn ChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
6836 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelUpdate)).clone() })) as *mut c_void
6839 /// Creates a copy of the ChannelUpdate
6840 pub extern "C" fn ChannelUpdate_clone(orig: &ChannelUpdate) -> ChannelUpdate {
6843 /// Checks if two ChannelUpdates contain equal inner contents.
6844 /// This ignores pointers and is_owned flags and looks at the values in fields.
6845 /// Two objects with NULL inner values will be considered "equal" here.
6847 pub extern "C" fn ChannelUpdate_eq(a: &ChannelUpdate, b: &ChannelUpdate) -> bool {
6848 if a.inner == b.inner { return true; }
6849 if a.inner.is_null() || b.inner.is_null() { return false; }
6850 if a.get_native_ref() == b.get_native_ref() { true } else { false }
6853 use lightning::ln::msgs::QueryChannelRange as nativeQueryChannelRangeImport;
6854 pub(crate) type nativeQueryChannelRange = nativeQueryChannelRangeImport;
6856 /// A [`query_channel_range`] message is used to query a peer for channel
6857 /// UTXOs in a range of blocks. The recipient of a query makes a best
6858 /// effort to reply to the query using one or more [`ReplyChannelRange`]
6861 /// [`query_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages
6864 pub struct QueryChannelRange {
6865 /// A pointer to the opaque Rust object.
6867 /// Nearly everywhere, inner must be non-null, however in places where
6868 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6869 pub inner: *mut nativeQueryChannelRange,
6870 /// Indicates that this is the only struct which contains the same pointer.
6872 /// Rust functions which take ownership of an object provided via an argument require
6873 /// this to be true and invalidate the object pointed to by inner.
6877 impl Drop for QueryChannelRange {
6878 fn drop(&mut self) {
6879 if self.is_owned && !<*mut nativeQueryChannelRange>::is_null(self.inner) {
6880 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6884 /// Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL.
6886 pub extern "C" fn QueryChannelRange_free(this_obj: QueryChannelRange) { }
6888 /// Used only if an object of this type is returned as a trait impl by a method
6889 pub(crate) extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) {
6890 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeQueryChannelRange) };
6893 impl QueryChannelRange {
6894 pub(crate) fn get_native_ref(&self) -> &'static nativeQueryChannelRange {
6895 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6897 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryChannelRange {
6898 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6900 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6901 pub(crate) fn take_inner(mut self) -> *mut nativeQueryChannelRange {
6902 assert!(self.is_owned);
6903 let ret = ObjOps::untweak_ptr(self.inner);
6904 self.inner = core::ptr::null_mut();
6908 /// The genesis hash of the blockchain being queried
6910 pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *const [u8; 32] {
6911 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
6912 inner_val.as_bytes()
6914 /// The genesis hash of the blockchain being queried
6916 pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
6917 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data[..]);
6919 /// The height of the first block for the channel UTXOs being queried
6921 pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 {
6922 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
6925 /// The height of the first block for the channel UTXOs being queried
6927 pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChannelRange, mut val: u32) {
6928 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
6930 /// The number of blocks to include in the query results
6932 pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 {
6933 let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
6936 /// The number of blocks to include in the query results
6938 pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryChannelRange, mut val: u32) {
6939 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
6941 /// Constructs a new QueryChannelRange given each field
6944 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 {
6945 QueryChannelRange { inner: ObjOps::heap_alloc(nativeQueryChannelRange {
6946 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data[..]),
6947 first_blocknum: first_blocknum_arg,
6948 number_of_blocks: number_of_blocks_arg,
6949 }), is_owned: true }
6951 impl Clone for QueryChannelRange {
6952 fn clone(&self) -> Self {
6954 inner: if <*mut nativeQueryChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
6955 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6961 /// Used only if an object of this type is returned as a trait impl by a method
6962 pub(crate) extern "C" fn QueryChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
6963 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeQueryChannelRange)).clone() })) as *mut c_void
6966 /// Creates a copy of the QueryChannelRange
6967 pub extern "C" fn QueryChannelRange_clone(orig: &QueryChannelRange) -> QueryChannelRange {
6970 /// Checks if two QueryChannelRanges contain equal inner contents.
6971 /// This ignores pointers and is_owned flags and looks at the values in fields.
6972 /// Two objects with NULL inner values will be considered "equal" here.
6974 pub extern "C" fn QueryChannelRange_eq(a: &QueryChannelRange, b: &QueryChannelRange) -> bool {
6975 if a.inner == b.inner { return true; }
6976 if a.inner.is_null() || b.inner.is_null() { return false; }
6977 if a.get_native_ref() == b.get_native_ref() { true } else { false }
6980 use lightning::ln::msgs::ReplyChannelRange as nativeReplyChannelRangeImport;
6981 pub(crate) type nativeReplyChannelRange = nativeReplyChannelRangeImport;
6983 /// A [`reply_channel_range`] message is a reply to a [`QueryChannelRange`]
6986 /// Multiple `reply_channel_range` messages can be sent in reply
6987 /// to a single [`QueryChannelRange`] message. The query recipient makes a
6988 /// best effort to respond based on their local network view which may
6989 /// not be a perfect view of the network. The `short_channel_id`s in the
6990 /// reply are encoded. We only support `encoding_type=0` uncompressed
6991 /// serialization and do not support `encoding_type=1` zlib serialization.
6993 /// [`reply_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages
6996 pub struct ReplyChannelRange {
6997 /// A pointer to the opaque Rust object.
6999 /// Nearly everywhere, inner must be non-null, however in places where
7000 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7001 pub inner: *mut nativeReplyChannelRange,
7002 /// Indicates that this is the only struct which contains the same pointer.
7004 /// Rust functions which take ownership of an object provided via an argument require
7005 /// this to be true and invalidate the object pointed to by inner.
7009 impl Drop for ReplyChannelRange {
7010 fn drop(&mut self) {
7011 if self.is_owned && !<*mut nativeReplyChannelRange>::is_null(self.inner) {
7012 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7016 /// Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL.
7018 pub extern "C" fn ReplyChannelRange_free(this_obj: ReplyChannelRange) { }
7020 /// Used only if an object of this type is returned as a trait impl by a method
7021 pub(crate) extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) {
7022 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeReplyChannelRange) };
7025 impl ReplyChannelRange {
7026 pub(crate) fn get_native_ref(&self) -> &'static nativeReplyChannelRange {
7027 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7029 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyChannelRange {
7030 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7032 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7033 pub(crate) fn take_inner(mut self) -> *mut nativeReplyChannelRange {
7034 assert!(self.is_owned);
7035 let ret = ObjOps::untweak_ptr(self.inner);
7036 self.inner = core::ptr::null_mut();
7040 /// The genesis hash of the blockchain being queried
7042 pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *const [u8; 32] {
7043 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
7044 inner_val.as_bytes()
7046 /// The genesis hash of the blockchain being queried
7048 pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
7049 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data[..]);
7051 /// The height of the first block in the range of the reply
7053 pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 {
7054 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
7057 /// The height of the first block in the range of the reply
7059 pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChannelRange, mut val: u32) {
7060 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
7062 /// The number of blocks included in the range of the reply
7064 pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 {
7065 let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
7068 /// The number of blocks included in the range of the reply
7070 pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyChannelRange, mut val: u32) {
7071 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
7073 /// True when this is the final reply for a query
7075 pub extern "C" fn ReplyChannelRange_get_sync_complete(this_ptr: &ReplyChannelRange) -> bool {
7076 let mut inner_val = &mut this_ptr.get_native_mut_ref().sync_complete;
7079 /// True when this is the final reply for a query
7081 pub extern "C" fn ReplyChannelRange_set_sync_complete(this_ptr: &mut ReplyChannelRange, mut val: bool) {
7082 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sync_complete = val;
7084 /// The `short_channel_id`s in the channel range
7086 /// Returns a copy of the field.
7088 pub extern "C" fn ReplyChannelRange_get_short_channel_ids(this_ptr: &ReplyChannelRange) -> crate::c_types::derived::CVec_u64Z {
7089 let mut inner_val = this_ptr.get_native_mut_ref().short_channel_ids.clone();
7090 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
7091 local_inner_val.into()
7093 /// The `short_channel_id`s in the channel range
7095 pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::derived::CVec_u64Z) {
7096 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
7097 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
7099 /// Constructs a new ReplyChannelRange given each field
7102 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 {
7103 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 }); };
7104 ReplyChannelRange { inner: ObjOps::heap_alloc(nativeReplyChannelRange {
7105 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data[..]),
7106 first_blocknum: first_blocknum_arg,
7107 number_of_blocks: number_of_blocks_arg,
7108 sync_complete: sync_complete_arg,
7109 short_channel_ids: local_short_channel_ids_arg,
7110 }), is_owned: true }
7112 impl Clone for ReplyChannelRange {
7113 fn clone(&self) -> Self {
7115 inner: if <*mut nativeReplyChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
7116 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7122 /// Used only if an object of this type is returned as a trait impl by a method
7123 pub(crate) extern "C" fn ReplyChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
7124 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeReplyChannelRange)).clone() })) as *mut c_void
7127 /// Creates a copy of the ReplyChannelRange
7128 pub extern "C" fn ReplyChannelRange_clone(orig: &ReplyChannelRange) -> ReplyChannelRange {
7131 /// Checks if two ReplyChannelRanges contain equal inner contents.
7132 /// This ignores pointers and is_owned flags and looks at the values in fields.
7133 /// Two objects with NULL inner values will be considered "equal" here.
7135 pub extern "C" fn ReplyChannelRange_eq(a: &ReplyChannelRange, b: &ReplyChannelRange) -> bool {
7136 if a.inner == b.inner { return true; }
7137 if a.inner.is_null() || b.inner.is_null() { return false; }
7138 if a.get_native_ref() == b.get_native_ref() { true } else { false }
7141 use lightning::ln::msgs::QueryShortChannelIds as nativeQueryShortChannelIdsImport;
7142 pub(crate) type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport;
7144 /// A [`query_short_channel_ids`] message is used to query a peer for
7145 /// routing gossip messages related to one or more `short_channel_id`s.
7147 /// The query recipient will reply with the latest, if available,
7148 /// [`ChannelAnnouncement`], [`ChannelUpdate`] and [`NodeAnnouncement`] messages
7149 /// it maintains for the requested `short_channel_id`s followed by a
7150 /// [`ReplyShortChannelIdsEnd`] message. The `short_channel_id`s sent in
7151 /// this query are encoded. We only support `encoding_type=0` uncompressed
7152 /// serialization and do not support `encoding_type=1` zlib serialization.
7154 /// [`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
7157 pub struct QueryShortChannelIds {
7158 /// A pointer to the opaque Rust object.
7160 /// Nearly everywhere, inner must be non-null, however in places where
7161 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7162 pub inner: *mut nativeQueryShortChannelIds,
7163 /// Indicates that this is the only struct which contains the same pointer.
7165 /// Rust functions which take ownership of an object provided via an argument require
7166 /// this to be true and invalidate the object pointed to by inner.
7170 impl Drop for QueryShortChannelIds {
7171 fn drop(&mut self) {
7172 if self.is_owned && !<*mut nativeQueryShortChannelIds>::is_null(self.inner) {
7173 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7177 /// Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL.
7179 pub extern "C" fn QueryShortChannelIds_free(this_obj: QueryShortChannelIds) { }
7181 /// Used only if an object of this type is returned as a trait impl by a method
7182 pub(crate) extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) {
7183 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeQueryShortChannelIds) };
7186 impl QueryShortChannelIds {
7187 pub(crate) fn get_native_ref(&self) -> &'static nativeQueryShortChannelIds {
7188 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7190 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryShortChannelIds {
7191 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7193 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7194 pub(crate) fn take_inner(mut self) -> *mut nativeQueryShortChannelIds {
7195 assert!(self.is_owned);
7196 let ret = ObjOps::untweak_ptr(self.inner);
7197 self.inner = core::ptr::null_mut();
7201 /// The genesis hash of the blockchain being queried
7203 pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *const [u8; 32] {
7204 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
7205 inner_val.as_bytes()
7207 /// The genesis hash of the blockchain being queried
7209 pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::ThirtyTwoBytes) {
7210 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data[..]);
7212 /// The short_channel_ids that are being queried
7214 /// Returns a copy of the field.
7216 pub extern "C" fn QueryShortChannelIds_get_short_channel_ids(this_ptr: &QueryShortChannelIds) -> crate::c_types::derived::CVec_u64Z {
7217 let mut inner_val = this_ptr.get_native_mut_ref().short_channel_ids.clone();
7218 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
7219 local_inner_val.into()
7221 /// The short_channel_ids that are being queried
7223 pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::derived::CVec_u64Z) {
7224 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
7225 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
7227 /// Constructs a new QueryShortChannelIds given each field
7230 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 {
7231 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 }); };
7232 QueryShortChannelIds { inner: ObjOps::heap_alloc(nativeQueryShortChannelIds {
7233 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data[..]),
7234 short_channel_ids: local_short_channel_ids_arg,
7235 }), is_owned: true }
7237 impl Clone for QueryShortChannelIds {
7238 fn clone(&self) -> Self {
7240 inner: if <*mut nativeQueryShortChannelIds>::is_null(self.inner) { core::ptr::null_mut() } else {
7241 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7247 /// Used only if an object of this type is returned as a trait impl by a method
7248 pub(crate) extern "C" fn QueryShortChannelIds_clone_void(this_ptr: *const c_void) -> *mut c_void {
7249 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeQueryShortChannelIds)).clone() })) as *mut c_void
7252 /// Creates a copy of the QueryShortChannelIds
7253 pub extern "C" fn QueryShortChannelIds_clone(orig: &QueryShortChannelIds) -> QueryShortChannelIds {
7256 /// Checks if two QueryShortChannelIdss contain equal inner contents.
7257 /// This ignores pointers and is_owned flags and looks at the values in fields.
7258 /// Two objects with NULL inner values will be considered "equal" here.
7260 pub extern "C" fn QueryShortChannelIds_eq(a: &QueryShortChannelIds, b: &QueryShortChannelIds) -> bool {
7261 if a.inner == b.inner { return true; }
7262 if a.inner.is_null() || b.inner.is_null() { return false; }
7263 if a.get_native_ref() == b.get_native_ref() { true } else { false }
7266 use lightning::ln::msgs::ReplyShortChannelIdsEnd as nativeReplyShortChannelIdsEndImport;
7267 pub(crate) type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport;
7269 /// A [`reply_short_channel_ids_end`] message is sent as a reply to a
7270 /// message. The query recipient makes a best
7271 /// effort to respond based on their local network view which may not be
7272 /// a perfect view of the network.
7274 /// [`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
7277 pub struct ReplyShortChannelIdsEnd {
7278 /// A pointer to the opaque Rust object.
7280 /// Nearly everywhere, inner must be non-null, however in places where
7281 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7282 pub inner: *mut nativeReplyShortChannelIdsEnd,
7283 /// Indicates that this is the only struct which contains the same pointer.
7285 /// Rust functions which take ownership of an object provided via an argument require
7286 /// this to be true and invalidate the object pointed to by inner.
7290 impl Drop for ReplyShortChannelIdsEnd {
7291 fn drop(&mut self) {
7292 if self.is_owned && !<*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) {
7293 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7297 /// Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL.
7299 pub extern "C" fn ReplyShortChannelIdsEnd_free(this_obj: ReplyShortChannelIdsEnd) { }
7301 /// Used only if an object of this type is returned as a trait impl by a method
7302 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) {
7303 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeReplyShortChannelIdsEnd) };
7306 impl ReplyShortChannelIdsEnd {
7307 pub(crate) fn get_native_ref(&self) -> &'static nativeReplyShortChannelIdsEnd {
7308 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7310 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyShortChannelIdsEnd {
7311 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7313 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7314 pub(crate) fn take_inner(mut self) -> *mut nativeReplyShortChannelIdsEnd {
7315 assert!(self.is_owned);
7316 let ret = ObjOps::untweak_ptr(self.inner);
7317 self.inner = core::ptr::null_mut();
7321 /// The genesis hash of the blockchain that was queried
7323 pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *const [u8; 32] {
7324 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
7325 inner_val.as_bytes()
7327 /// The genesis hash of the blockchain that was queried
7329 pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) {
7330 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data[..]);
7332 /// Indicates if the query recipient maintains up-to-date channel
7333 /// information for the `chain_hash`
7335 pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool {
7336 let mut inner_val = &mut this_ptr.get_native_mut_ref().full_information;
7339 /// Indicates if the query recipient maintains up-to-date channel
7340 /// information for the `chain_hash`
7342 pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: bool) {
7343 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.full_information = val;
7345 /// Constructs a new ReplyShortChannelIdsEnd given each field
7348 pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd {
7349 ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(nativeReplyShortChannelIdsEnd {
7350 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data[..]),
7351 full_information: full_information_arg,
7352 }), is_owned: true }
7354 impl Clone for ReplyShortChannelIdsEnd {
7355 fn clone(&self) -> Self {
7357 inner: if <*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) { core::ptr::null_mut() } else {
7358 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7364 /// Used only if an object of this type is returned as a trait impl by a method
7365 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_void) -> *mut c_void {
7366 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeReplyShortChannelIdsEnd)).clone() })) as *mut c_void
7369 /// Creates a copy of the ReplyShortChannelIdsEnd
7370 pub extern "C" fn ReplyShortChannelIdsEnd_clone(orig: &ReplyShortChannelIdsEnd) -> ReplyShortChannelIdsEnd {
7373 /// Checks if two ReplyShortChannelIdsEnds contain equal inner contents.
7374 /// This ignores pointers and is_owned flags and looks at the values in fields.
7375 /// Two objects with NULL inner values will be considered "equal" here.
7377 pub extern "C" fn ReplyShortChannelIdsEnd_eq(a: &ReplyShortChannelIdsEnd, b: &ReplyShortChannelIdsEnd) -> bool {
7378 if a.inner == b.inner { return true; }
7379 if a.inner.is_null() || b.inner.is_null() { return false; }
7380 if a.get_native_ref() == b.get_native_ref() { true } else { false }
7383 use lightning::ln::msgs::GossipTimestampFilter as nativeGossipTimestampFilterImport;
7384 pub(crate) type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport;
7386 /// A [`gossip_timestamp_filter`] message is used by a node to request
7387 /// gossip relay for messages in the requested time range when the
7388 /// `gossip_queries` feature has been negotiated.
7390 /// [`gossip_timestamp_filter`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-gossip_timestamp_filter-message
7393 pub struct GossipTimestampFilter {
7394 /// A pointer to the opaque Rust object.
7396 /// Nearly everywhere, inner must be non-null, however in places where
7397 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7398 pub inner: *mut nativeGossipTimestampFilter,
7399 /// Indicates that this is the only struct which contains the same pointer.
7401 /// Rust functions which take ownership of an object provided via an argument require
7402 /// this to be true and invalidate the object pointed to by inner.
7406 impl Drop for GossipTimestampFilter {
7407 fn drop(&mut self) {
7408 if self.is_owned && !<*mut nativeGossipTimestampFilter>::is_null(self.inner) {
7409 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7413 /// Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL.
7415 pub extern "C" fn GossipTimestampFilter_free(this_obj: GossipTimestampFilter) { }
7417 /// Used only if an object of this type is returned as a trait impl by a method
7418 pub(crate) extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) {
7419 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeGossipTimestampFilter) };
7422 impl GossipTimestampFilter {
7423 pub(crate) fn get_native_ref(&self) -> &'static nativeGossipTimestampFilter {
7424 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7426 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeGossipTimestampFilter {
7427 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7429 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7430 pub(crate) fn take_inner(mut self) -> *mut nativeGossipTimestampFilter {
7431 assert!(self.is_owned);
7432 let ret = ObjOps::untweak_ptr(self.inner);
7433 self.inner = core::ptr::null_mut();
7437 /// The genesis hash of the blockchain for channel and node information
7439 pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *const [u8; 32] {
7440 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
7441 inner_val.as_bytes()
7443 /// The genesis hash of the blockchain for channel and node information
7445 pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) {
7446 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data[..]);
7448 /// The starting unix timestamp
7450 pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 {
7451 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_timestamp;
7454 /// The starting unix timestamp
7456 pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
7457 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_timestamp = val;
7459 /// The range of information in seconds
7461 pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 {
7462 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp_range;
7465 /// The range of information in seconds
7467 pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
7468 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp_range = val;
7470 /// Constructs a new GossipTimestampFilter given each field
7473 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 {
7474 GossipTimestampFilter { inner: ObjOps::heap_alloc(nativeGossipTimestampFilter {
7475 chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data[..]),
7476 first_timestamp: first_timestamp_arg,
7477 timestamp_range: timestamp_range_arg,
7478 }), is_owned: true }
7480 impl Clone for GossipTimestampFilter {
7481 fn clone(&self) -> Self {
7483 inner: if <*mut nativeGossipTimestampFilter>::is_null(self.inner) { core::ptr::null_mut() } else {
7484 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7490 /// Used only if an object of this type is returned as a trait impl by a method
7491 pub(crate) extern "C" fn GossipTimestampFilter_clone_void(this_ptr: *const c_void) -> *mut c_void {
7492 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeGossipTimestampFilter)).clone() })) as *mut c_void
7495 /// Creates a copy of the GossipTimestampFilter
7496 pub extern "C" fn GossipTimestampFilter_clone(orig: &GossipTimestampFilter) -> GossipTimestampFilter {
7499 /// Checks if two GossipTimestampFilters contain equal inner contents.
7500 /// This ignores pointers and is_owned flags and looks at the values in fields.
7501 /// Two objects with NULL inner values will be considered "equal" here.
7503 pub extern "C" fn GossipTimestampFilter_eq(a: &GossipTimestampFilter, b: &GossipTimestampFilter) -> bool {
7504 if a.inner == b.inner { return true; }
7505 if a.inner.is_null() || b.inner.is_null() { return false; }
7506 if a.get_native_ref() == b.get_native_ref() { true } else { false }
7508 /// Used to put an error message in a [`LightningError`].
7512 pub enum ErrorAction {
7513 /// The peer took some action which made us think they were useless. Disconnect them.
7515 /// An error message which we should make an effort to send before we disconnect.
7517 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
7518 msg: crate::lightning::ln::msgs::ErrorMessage,
7520 /// The peer did something incorrect. Tell them without closing any channels and disconnect them.
7521 DisconnectPeerWithWarning {
7522 /// A warning message which we should make an effort to send before we disconnect.
7523 msg: crate::lightning::ln::msgs::WarningMessage,
7525 /// The peer did something harmless that we weren't able to process, just log and ignore
7527 /// The peer did something harmless that we weren't able to meaningfully process.
7528 /// If the error is logged, log it at the given level.
7530 crate::lightning::util::logger::Level),
7531 /// The peer provided us with a gossip message which we'd already seen. In most cases this
7532 /// should be ignored, but it may result in the message being forwarded if it is a duplicate of
7533 /// our own channel announcements.
7534 IgnoreDuplicateGossip,
7535 /// The peer did something incorrect. Tell them.
7537 /// The message to send.
7538 msg: crate::lightning::ln::msgs::ErrorMessage,
7540 /// The peer did something incorrect. Tell them without closing any channels.
7541 SendWarningMessage {
7542 /// The message to send.
7543 msg: crate::lightning::ln::msgs::WarningMessage,
7544 /// The peer may have done something harmless that we weren't able to meaningfully process,
7545 /// though we should still tell them about it.
7546 /// If this event is logged, log it at the given level.
7547 log_level: crate::lightning::util::logger::Level,
7550 use lightning::ln::msgs::ErrorAction as ErrorActionImport;
7551 pub(crate) type nativeErrorAction = ErrorActionImport;
7555 pub(crate) fn to_native(&self) -> nativeErrorAction {
7557 ErrorAction::DisconnectPeer {ref msg, } => {
7558 let mut msg_nonref = Clone::clone(msg);
7559 let mut local_msg_nonref = if msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg_nonref.take_inner()) } }) };
7560 nativeErrorAction::DisconnectPeer {
7561 msg: local_msg_nonref,
7564 ErrorAction::DisconnectPeerWithWarning {ref msg, } => {
7565 let mut msg_nonref = Clone::clone(msg);
7566 nativeErrorAction::DisconnectPeerWithWarning {
7567 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
7570 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
7571 ErrorAction::IgnoreAndLog (ref a, ) => {
7572 let mut a_nonref = Clone::clone(a);
7573 nativeErrorAction::IgnoreAndLog (
7574 a_nonref.into_native(),
7577 ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
7578 ErrorAction::SendErrorMessage {ref msg, } => {
7579 let mut msg_nonref = Clone::clone(msg);
7580 nativeErrorAction::SendErrorMessage {
7581 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
7584 ErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
7585 let mut msg_nonref = Clone::clone(msg);
7586 let mut log_level_nonref = Clone::clone(log_level);
7587 nativeErrorAction::SendWarningMessage {
7588 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
7589 log_level: log_level_nonref.into_native(),
7595 pub(crate) fn into_native(self) -> nativeErrorAction {
7597 ErrorAction::DisconnectPeer {mut msg, } => {
7598 let mut local_msg = if msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg.take_inner()) } }) };
7599 nativeErrorAction::DisconnectPeer {
7603 ErrorAction::DisconnectPeerWithWarning {mut msg, } => {
7604 nativeErrorAction::DisconnectPeerWithWarning {
7605 msg: *unsafe { Box::from_raw(msg.take_inner()) },
7608 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
7609 ErrorAction::IgnoreAndLog (mut a, ) => {
7610 nativeErrorAction::IgnoreAndLog (
7614 ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
7615 ErrorAction::SendErrorMessage {mut msg, } => {
7616 nativeErrorAction::SendErrorMessage {
7617 msg: *unsafe { Box::from_raw(msg.take_inner()) },
7620 ErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
7621 nativeErrorAction::SendWarningMessage {
7622 msg: *unsafe { Box::from_raw(msg.take_inner()) },
7623 log_level: log_level.into_native(),
7629 pub(crate) fn from_native(native: &nativeErrorAction) -> Self {
7631 nativeErrorAction::DisconnectPeer {ref msg, } => {
7632 let mut msg_nonref = Clone::clone(msg);
7633 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 };
7634 ErrorAction::DisconnectPeer {
7635 msg: local_msg_nonref,
7638 nativeErrorAction::DisconnectPeerWithWarning {ref msg, } => {
7639 let mut msg_nonref = Clone::clone(msg);
7640 ErrorAction::DisconnectPeerWithWarning {
7641 msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
7644 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
7645 nativeErrorAction::IgnoreAndLog (ref a, ) => {
7646 let mut a_nonref = Clone::clone(a);
7647 ErrorAction::IgnoreAndLog (
7648 crate::lightning::util::logger::Level::native_into(a_nonref),
7651 nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
7652 nativeErrorAction::SendErrorMessage {ref msg, } => {
7653 let mut msg_nonref = Clone::clone(msg);
7654 ErrorAction::SendErrorMessage {
7655 msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
7658 nativeErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
7659 let mut msg_nonref = Clone::clone(msg);
7660 let mut log_level_nonref = Clone::clone(log_level);
7661 ErrorAction::SendWarningMessage {
7662 msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
7663 log_level: crate::lightning::util::logger::Level::native_into(log_level_nonref),
7669 pub(crate) fn native_into(native: nativeErrorAction) -> Self {
7671 nativeErrorAction::DisconnectPeer {mut msg, } => {
7672 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 };
7673 ErrorAction::DisconnectPeer {
7677 nativeErrorAction::DisconnectPeerWithWarning {mut msg, } => {
7678 ErrorAction::DisconnectPeerWithWarning {
7679 msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
7682 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
7683 nativeErrorAction::IgnoreAndLog (mut a, ) => {
7684 ErrorAction::IgnoreAndLog (
7685 crate::lightning::util::logger::Level::native_into(a),
7688 nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
7689 nativeErrorAction::SendErrorMessage {mut msg, } => {
7690 ErrorAction::SendErrorMessage {
7691 msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
7694 nativeErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
7695 ErrorAction::SendWarningMessage {
7696 msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
7697 log_level: crate::lightning::util::logger::Level::native_into(log_level),
7703 /// Frees any resources used by the ErrorAction
7705 pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { }
7706 /// Creates a copy of the ErrorAction
7708 pub extern "C" fn ErrorAction_clone(orig: &ErrorAction) -> ErrorAction {
7712 /// Used only if an object of this type is returned as a trait impl by a method
7713 pub(crate) extern "C" fn ErrorAction_clone_void(this_ptr: *const c_void) -> *mut c_void {
7714 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const ErrorAction)).clone() })) as *mut c_void
7717 /// Used only if an object of this type is returned as a trait impl by a method
7718 pub(crate) extern "C" fn ErrorAction_free_void(this_ptr: *mut c_void) {
7719 let _ = unsafe { Box::from_raw(this_ptr as *mut ErrorAction) };
7722 /// Utility method to constructs a new DisconnectPeer-variant ErrorAction
7723 pub extern "C" fn ErrorAction_disconnect_peer(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
7724 ErrorAction::DisconnectPeer {
7729 /// Utility method to constructs a new DisconnectPeerWithWarning-variant ErrorAction
7730 pub extern "C" fn ErrorAction_disconnect_peer_with_warning(msg: crate::lightning::ln::msgs::WarningMessage) -> ErrorAction {
7731 ErrorAction::DisconnectPeerWithWarning {
7736 /// Utility method to constructs a new IgnoreError-variant ErrorAction
7737 pub extern "C" fn ErrorAction_ignore_error() -> ErrorAction {
7738 ErrorAction::IgnoreError}
7740 /// Utility method to constructs a new IgnoreAndLog-variant ErrorAction
7741 pub extern "C" fn ErrorAction_ignore_and_log(a: crate::lightning::util::logger::Level) -> ErrorAction {
7742 ErrorAction::IgnoreAndLog(a, )
7745 /// Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction
7746 pub extern "C" fn ErrorAction_ignore_duplicate_gossip() -> ErrorAction {
7747 ErrorAction::IgnoreDuplicateGossip}
7749 /// Utility method to constructs a new SendErrorMessage-variant ErrorAction
7750 pub extern "C" fn ErrorAction_send_error_message(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
7751 ErrorAction::SendErrorMessage {
7756 /// Utility method to constructs a new SendWarningMessage-variant ErrorAction
7757 pub extern "C" fn ErrorAction_send_warning_message(msg: crate::lightning::ln::msgs::WarningMessage, log_level: crate::lightning::util::logger::Level) -> ErrorAction {
7758 ErrorAction::SendWarningMessage {
7764 use lightning::ln::msgs::LightningError as nativeLightningErrorImport;
7765 pub(crate) type nativeLightningError = nativeLightningErrorImport;
7767 /// An Err type for failure to process messages.
7770 pub struct LightningError {
7771 /// A pointer to the opaque Rust object.
7773 /// Nearly everywhere, inner must be non-null, however in places where
7774 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7775 pub inner: *mut nativeLightningError,
7776 /// Indicates that this is the only struct which contains the same pointer.
7778 /// Rust functions which take ownership of an object provided via an argument require
7779 /// this to be true and invalidate the object pointed to by inner.
7783 impl Drop for LightningError {
7784 fn drop(&mut self) {
7785 if self.is_owned && !<*mut nativeLightningError>::is_null(self.inner) {
7786 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7790 /// Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL.
7792 pub extern "C" fn LightningError_free(this_obj: LightningError) { }
7794 /// Used only if an object of this type is returned as a trait impl by a method
7795 pub(crate) extern "C" fn LightningError_free_void(this_ptr: *mut c_void) {
7796 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLightningError) };
7799 impl LightningError {
7800 pub(crate) fn get_native_ref(&self) -> &'static nativeLightningError {
7801 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7803 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLightningError {
7804 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7806 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7807 pub(crate) fn take_inner(mut self) -> *mut nativeLightningError {
7808 assert!(self.is_owned);
7809 let ret = ObjOps::untweak_ptr(self.inner);
7810 self.inner = core::ptr::null_mut();
7814 /// A human-readable message describing the error
7816 pub extern "C" fn LightningError_get_err(this_ptr: &LightningError) -> crate::c_types::Str {
7817 let mut inner_val = &mut this_ptr.get_native_mut_ref().err;
7818 inner_val.as_str().into()
7820 /// A human-readable message describing the error
7822 pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: crate::c_types::Str) {
7823 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.err = val.into_string();
7825 /// The action which should be taken against the offending peer.
7827 pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate::lightning::ln::msgs::ErrorAction {
7828 let mut inner_val = &mut this_ptr.get_native_mut_ref().action;
7829 crate::lightning::ln::msgs::ErrorAction::from_native(inner_val)
7831 /// The action which should be taken against the offending peer.
7833 pub extern "C" fn LightningError_set_action(this_ptr: &mut LightningError, mut val: crate::lightning::ln::msgs::ErrorAction) {
7834 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.action = val.into_native();
7836 /// Constructs a new LightningError given each field
7839 pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::Str, mut action_arg: crate::lightning::ln::msgs::ErrorAction) -> LightningError {
7840 LightningError { inner: ObjOps::heap_alloc(nativeLightningError {
7841 err: err_arg.into_string(),
7842 action: action_arg.into_native(),
7843 }), is_owned: true }
7845 impl Clone for LightningError {
7846 fn clone(&self) -> Self {
7848 inner: if <*mut nativeLightningError>::is_null(self.inner) { core::ptr::null_mut() } else {
7849 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7855 /// Used only if an object of this type is returned as a trait impl by a method
7856 pub(crate) extern "C" fn LightningError_clone_void(this_ptr: *const c_void) -> *mut c_void {
7857 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeLightningError)).clone() })) as *mut c_void
7860 /// Creates a copy of the LightningError
7861 pub extern "C" fn LightningError_clone(orig: &LightningError) -> LightningError {
7865 use lightning::ln::msgs::CommitmentUpdate as nativeCommitmentUpdateImport;
7866 pub(crate) type nativeCommitmentUpdate = nativeCommitmentUpdateImport;
7868 /// Struct used to return values from [`RevokeAndACK`] messages, containing a bunch of commitment
7869 /// transaction updates if they were pending.
7872 pub struct CommitmentUpdate {
7873 /// A pointer to the opaque Rust object.
7875 /// Nearly everywhere, inner must be non-null, however in places where
7876 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7877 pub inner: *mut nativeCommitmentUpdate,
7878 /// Indicates that this is the only struct which contains the same pointer.
7880 /// Rust functions which take ownership of an object provided via an argument require
7881 /// this to be true and invalidate the object pointed to by inner.
7885 impl Drop for CommitmentUpdate {
7886 fn drop(&mut self) {
7887 if self.is_owned && !<*mut nativeCommitmentUpdate>::is_null(self.inner) {
7888 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7892 /// Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL.
7894 pub extern "C" fn CommitmentUpdate_free(this_obj: CommitmentUpdate) { }
7896 /// Used only if an object of this type is returned as a trait impl by a method
7897 pub(crate) extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) {
7898 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCommitmentUpdate) };
7901 impl CommitmentUpdate {
7902 pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentUpdate {
7903 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7905 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentUpdate {
7906 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7908 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7909 pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentUpdate {
7910 assert!(self.is_owned);
7911 let ret = ObjOps::untweak_ptr(self.inner);
7912 self.inner = core::ptr::null_mut();
7916 /// `update_add_htlc` messages which should be sent
7918 pub extern "C" fn CommitmentUpdate_get_update_add_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateAddHTLCZ {
7919 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_add_htlcs;
7920 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 } }); };
7921 local_inner_val.into()
7923 /// `update_add_htlc` messages which should be sent
7925 pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) {
7926 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
7927 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_add_htlcs = local_val;
7929 /// `update_fulfill_htlc` messages which should be sent
7931 pub extern "C" fn CommitmentUpdate_get_update_fulfill_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFulfillHTLCZ {
7932 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fulfill_htlcs;
7933 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 } }); };
7934 local_inner_val.into()
7936 /// `update_fulfill_htlc` messages which should be sent
7938 pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) {
7939 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
7940 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fulfill_htlcs = local_val;
7942 /// `update_fail_htlc` messages which should be sent
7944 pub extern "C" fn CommitmentUpdate_get_update_fail_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailHTLCZ {
7945 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_htlcs;
7946 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 } }); };
7947 local_inner_val.into()
7949 /// `update_fail_htlc` messages which should be sent
7951 pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) {
7952 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
7953 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_htlcs = local_val;
7955 /// `update_fail_malformed_htlc` messages which should be sent
7957 pub extern "C" fn CommitmentUpdate_get_update_fail_malformed_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ {
7958 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_malformed_htlcs;
7959 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 } }); };
7960 local_inner_val.into()
7962 /// `update_fail_malformed_htlc` messages which should be sent
7964 pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) {
7965 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
7966 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_malformed_htlcs = local_val;
7968 /// An `update_fee` message which should be sent
7970 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
7972 pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::UpdateFee {
7973 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fee;
7974 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 };
7977 /// An `update_fee` message which should be sent
7979 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
7981 pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::UpdateFee) {
7982 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
7983 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fee = local_val;
7985 /// A `commitment_signed` message which should be sent
7987 pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::CommitmentSigned {
7988 let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_signed;
7989 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 }
7991 /// A `commitment_signed` message which should be sent
7993 pub extern "C" fn CommitmentUpdate_set_commitment_signed(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::CommitmentSigned) {
7994 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_signed = *unsafe { Box::from_raw(val.take_inner()) };
7996 /// Constructs a new CommitmentUpdate given each field
7998 /// Note that update_fee_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
8001 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 {
8002 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()) } }); };
8003 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()) } }); };
8004 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()) } }); };
8005 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()) } }); };
8006 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()) } }) };
8007 CommitmentUpdate { inner: ObjOps::heap_alloc(nativeCommitmentUpdate {
8008 update_add_htlcs: local_update_add_htlcs_arg,
8009 update_fulfill_htlcs: local_update_fulfill_htlcs_arg,
8010 update_fail_htlcs: local_update_fail_htlcs_arg,
8011 update_fail_malformed_htlcs: local_update_fail_malformed_htlcs_arg,
8012 update_fee: local_update_fee_arg,
8013 commitment_signed: *unsafe { Box::from_raw(commitment_signed_arg.take_inner()) },
8014 }), is_owned: true }
8016 impl Clone for CommitmentUpdate {
8017 fn clone(&self) -> Self {
8019 inner: if <*mut nativeCommitmentUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
8020 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
8026 /// Used only if an object of this type is returned as a trait impl by a method
8027 pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
8028 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeCommitmentUpdate)).clone() })) as *mut c_void
8031 /// Creates a copy of the CommitmentUpdate
8032 pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentUpdate {
8035 /// Checks if two CommitmentUpdates contain equal inner contents.
8036 /// This ignores pointers and is_owned flags and looks at the values in fields.
8037 /// Two objects with NULL inner values will be considered "equal" here.
8039 pub extern "C" fn CommitmentUpdate_eq(a: &CommitmentUpdate, b: &CommitmentUpdate) -> bool {
8040 if a.inner == b.inner { return true; }
8041 if a.inner.is_null() || b.inner.is_null() { return false; }
8042 if a.get_native_ref() == b.get_native_ref() { true } else { false }
8044 /// A trait to describe an object which can receive channel messages.
8046 /// Messages MAY be called in parallel when they originate from different `their_node_ids`, however
8047 /// they MUST NOT be called in parallel when the two calls have the same `their_node_id`.
8049 pub struct ChannelMessageHandler {
8050 /// An opaque pointer which is passed to your function implementations as an argument.
8051 /// This has no meaning in the LDK, and can be NULL or any other value.
8052 pub this_arg: *mut c_void,
8053 /// Handle an incoming `open_channel` message from the given peer.
8054 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),
8055 /// Handle an incoming `open_channel2` message from the given peer.
8056 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),
8057 /// Handle an incoming `accept_channel` message from the given peer.
8058 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),
8059 /// Handle an incoming `accept_channel2` message from the given peer.
8060 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),
8061 /// Handle an incoming `funding_created` message from the given peer.
8062 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),
8063 /// Handle an incoming `funding_signed` message from the given peer.
8064 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),
8065 /// Handle an incoming `channel_ready` message from the given peer.
8066 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),
8067 /// Handle an incoming `shutdown` message from the given peer.
8068 pub handle_shutdown: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Shutdown),
8069 /// Handle an incoming `closing_signed` message from the given peer.
8070 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),
8071 /// Handle an incoming `tx_add_input message` from the given peer.
8072 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),
8073 /// Handle an incoming `tx_add_output` message from the given peer.
8074 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),
8075 /// Handle an incoming `tx_remove_input` message from the given peer.
8076 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),
8077 /// Handle an incoming `tx_remove_output` message from the given peer.
8078 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),
8079 /// Handle an incoming `tx_complete message` from the given peer.
8080 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),
8081 /// Handle an incoming `tx_signatures` message from the given peer.
8082 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),
8083 /// Handle an incoming `tx_init_rbf` message from the given peer.
8084 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),
8085 /// Handle an incoming `tx_ack_rbf` message from the given peer.
8086 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),
8087 /// Handle an incoming `tx_abort message` from the given peer.
8088 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),
8089 /// Handle an incoming `update_add_htlc` message from the given peer.
8090 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),
8091 /// Handle an incoming `update_fulfill_htlc` message from the given peer.
8092 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),
8093 /// Handle an incoming `update_fail_htlc` message from the given peer.
8094 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),
8095 /// Handle an incoming `update_fail_malformed_htlc` message from the given peer.
8096 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),
8097 /// Handle an incoming `commitment_signed` message from the given peer.
8098 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),
8099 /// Handle an incoming `revoke_and_ack` message from the given peer.
8100 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),
8101 /// Handle an incoming `update_fee` message from the given peer.
8102 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),
8103 /// Handle an incoming `announcement_signatures` message from the given peer.
8104 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),
8105 /// Indicates a connection to the peer failed/an existing connection was lost.
8106 pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey),
8107 /// Handle a peer reconnecting, possibly generating `channel_reestablish` message(s).
8109 /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
8110 /// with us. Implementors should be somewhat conservative about doing so, however, as other
8111 /// message handlers may still wish to communicate with this peer.
8112 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,
8113 /// Handle an incoming `channel_reestablish` message from the given peer.
8114 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),
8115 /// Handle an incoming `channel_update` message from the given peer.
8116 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),
8117 /// Handle an incoming `error` message from the given peer.
8118 pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ErrorMessage),
8119 /// Gets the node feature flags which this handler itself supports. All available handlers are
8120 /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
8121 /// which are broadcasted in our [`NodeAnnouncement`] message.
8122 pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
8123 /// Gets the init feature flags which should be sent to the given peer. All available handlers
8124 /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
8125 /// which are sent in our [`Init`] message.
8127 /// Note that this method is called before [`Self::peer_connected`].
8128 pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
8129 /// Gets the chain hashes for this `ChannelMessageHandler` indicating which chains it supports.
8131 /// If it's `None`, then no particular network chain hash compatibility will be enforced when
8132 /// connecting to peers.
8133 pub get_chain_hashes: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ,
8134 /// Implementation of MessageSendEventsProvider for this object.
8135 pub MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider,
8136 /// Frees any resources associated with this object given its this_arg pointer.
8137 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
8138 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
8140 unsafe impl Send for ChannelMessageHandler {}
8141 unsafe impl Sync for ChannelMessageHandler {}
8143 pub(crate) fn ChannelMessageHandler_clone_fields(orig: &ChannelMessageHandler) -> ChannelMessageHandler {
8144 ChannelMessageHandler {
8145 this_arg: orig.this_arg,
8146 handle_open_channel: Clone::clone(&orig.handle_open_channel),
8147 handle_open_channel_v2: Clone::clone(&orig.handle_open_channel_v2),
8148 handle_accept_channel: Clone::clone(&orig.handle_accept_channel),
8149 handle_accept_channel_v2: Clone::clone(&orig.handle_accept_channel_v2),
8150 handle_funding_created: Clone::clone(&orig.handle_funding_created),
8151 handle_funding_signed: Clone::clone(&orig.handle_funding_signed),
8152 handle_channel_ready: Clone::clone(&orig.handle_channel_ready),
8153 handle_shutdown: Clone::clone(&orig.handle_shutdown),
8154 handle_closing_signed: Clone::clone(&orig.handle_closing_signed),
8155 handle_tx_add_input: Clone::clone(&orig.handle_tx_add_input),
8156 handle_tx_add_output: Clone::clone(&orig.handle_tx_add_output),
8157 handle_tx_remove_input: Clone::clone(&orig.handle_tx_remove_input),
8158 handle_tx_remove_output: Clone::clone(&orig.handle_tx_remove_output),
8159 handle_tx_complete: Clone::clone(&orig.handle_tx_complete),
8160 handle_tx_signatures: Clone::clone(&orig.handle_tx_signatures),
8161 handle_tx_init_rbf: Clone::clone(&orig.handle_tx_init_rbf),
8162 handle_tx_ack_rbf: Clone::clone(&orig.handle_tx_ack_rbf),
8163 handle_tx_abort: Clone::clone(&orig.handle_tx_abort),
8164 handle_update_add_htlc: Clone::clone(&orig.handle_update_add_htlc),
8165 handle_update_fulfill_htlc: Clone::clone(&orig.handle_update_fulfill_htlc),
8166 handle_update_fail_htlc: Clone::clone(&orig.handle_update_fail_htlc),
8167 handle_update_fail_malformed_htlc: Clone::clone(&orig.handle_update_fail_malformed_htlc),
8168 handle_commitment_signed: Clone::clone(&orig.handle_commitment_signed),
8169 handle_revoke_and_ack: Clone::clone(&orig.handle_revoke_and_ack),
8170 handle_update_fee: Clone::clone(&orig.handle_update_fee),
8171 handle_announcement_signatures: Clone::clone(&orig.handle_announcement_signatures),
8172 peer_disconnected: Clone::clone(&orig.peer_disconnected),
8173 peer_connected: Clone::clone(&orig.peer_connected),
8174 handle_channel_reestablish: Clone::clone(&orig.handle_channel_reestablish),
8175 handle_channel_update: Clone::clone(&orig.handle_channel_update),
8176 handle_error: Clone::clone(&orig.handle_error),
8177 provided_node_features: Clone::clone(&orig.provided_node_features),
8178 provided_init_features: Clone::clone(&orig.provided_init_features),
8179 get_chain_hashes: Clone::clone(&orig.get_chain_hashes),
8180 MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
8181 free: Clone::clone(&orig.free),
8184 impl lightning::events::MessageSendEventsProvider for ChannelMessageHandler {
8185 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::events::MessageSendEvent> {
8186 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
8187 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
8192 use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler;
8193 impl rustChannelMessageHandler for ChannelMessageHandler {
8194 fn handle_open_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OpenChannel) {
8195 (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 })
8197 fn handle_open_channel_v2(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OpenChannelV2) {
8198 (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 })
8200 fn handle_accept_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AcceptChannel) {
8201 (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 })
8203 fn handle_accept_channel_v2(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AcceptChannelV2) {
8204 (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 })
8206 fn handle_funding_created(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingCreated) {
8207 (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 })
8209 fn handle_funding_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingSigned) {
8210 (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 })
8212 fn handle_channel_ready(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReady) {
8213 (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 })
8215 fn handle_shutdown(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Shutdown) {
8216 (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 })
8218 fn handle_closing_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ClosingSigned) {
8219 (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 })
8221 fn handle_tx_add_input(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAddInput) {
8222 (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 })
8224 fn handle_tx_add_output(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAddOutput) {
8225 (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 })
8227 fn handle_tx_remove_input(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxRemoveInput) {
8228 (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 })
8230 fn handle_tx_remove_output(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxRemoveOutput) {
8231 (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 })
8233 fn handle_tx_complete(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxComplete) {
8234 (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 })
8236 fn handle_tx_signatures(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxSignatures) {
8237 (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 })
8239 fn handle_tx_init_rbf(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxInitRbf) {
8240 (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 })
8242 fn handle_tx_ack_rbf(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAckRbf) {
8243 (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 })
8245 fn handle_tx_abort(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAbort) {
8246 (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 })
8248 fn handle_update_add_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateAddHTLC) {
8249 (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 })
8251 fn handle_update_fulfill_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFulfillHTLC) {
8252 (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 })
8254 fn handle_update_fail_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailHTLC) {
8255 (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 })
8257 fn handle_update_fail_malformed_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) {
8258 (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 })
8260 fn handle_commitment_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::CommitmentSigned) {
8261 (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 })
8263 fn handle_revoke_and_ack(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::RevokeAndACK) {
8264 (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 })
8266 fn handle_update_fee(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFee) {
8267 (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 })
8269 fn handle_announcement_signatures(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AnnouncementSignatures) {
8270 (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 })
8272 fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) {
8273 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id))
8275 fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
8276 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);
8277 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)) })*/ })};
8280 fn handle_channel_reestablish(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReestablish) {
8281 (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 })
8283 fn handle_channel_update(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelUpdate) {
8284 (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 })
8286 fn handle_error(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ErrorMessage) {
8287 (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 })
8289 fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
8290 let mut ret = (self.provided_node_features)(self.this_arg);
8291 *unsafe { Box::from_raw(ret.take_inner()) }
8293 fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
8294 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
8295 *unsafe { Box::from_raw(ret.take_inner()) }
8297 fn get_chain_hashes(&self) -> Option<Vec<bitcoin::blockdata::constants::ChainHash>> {
8298 let mut ret = (self.get_chain_hashes)(self.this_arg);
8299 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 }})} };
8304 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
8305 // directly as a Deref trait in higher-level structs:
8306 impl core::ops::Deref for ChannelMessageHandler {
8308 fn deref(&self) -> &Self {
8312 impl core::ops::DerefMut for ChannelMessageHandler {
8313 fn deref_mut(&mut self) -> &mut Self {
8317 /// Calls the free function if one is set
8319 pub extern "C" fn ChannelMessageHandler_free(this_ptr: ChannelMessageHandler) { }
8320 impl Drop for ChannelMessageHandler {
8321 fn drop(&mut self) {
8322 if let Some(f) = self.free {
8327 /// A trait to describe an object which can receive routing messages.
8329 /// # Implementor DoS Warnings
8331 /// For messages enabled with the `gossip_queries` feature there are potential DoS vectors when
8332 /// handling inbound queries. Implementors using an on-disk network graph should be aware of
8333 /// repeated disk I/O for queries accessing different parts of the network graph.
8335 pub struct RoutingMessageHandler {
8336 /// An opaque pointer which is passed to your function implementations as an argument.
8337 /// This has no meaning in the LDK, and can be NULL or any other value.
8338 pub this_arg: *mut c_void,
8339 /// Handle an incoming `node_announcement` message, returning `true` if it should be forwarded on,
8340 /// `false` or returning an `Err` otherwise.
8341 pub handle_node_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
8342 /// Handle a `channel_announcement` message, returning `true` if it should be forwarded on, `false`
8343 /// or returning an `Err` otherwise.
8344 pub handle_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
8345 /// Handle an incoming `channel_update` message, returning true if it should be forwarded on,
8346 /// `false` or returning an `Err` otherwise.
8347 pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ,
8348 /// Gets channel announcements and updates required to dump our routing table to a remote node,
8349 /// starting at the `short_channel_id` indicated by `starting_point` and including announcements
8350 /// for a single channel.
8351 pub get_next_channel_announcement: extern "C" fn (this_arg: *const c_void, starting_point: u64) -> crate::c_types::derived::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ,
8352 /// Gets a node announcement required to dump our routing table to a remote node, starting at
8353 /// the node *after* the provided pubkey and including up to one announcement immediately
8354 /// higher (as defined by `<PublicKey as Ord>::cmp`) than `starting_point`.
8355 /// If `None` is provided for `starting_point`, we start at the first node.
8357 /// Note that starting_point (or a relevant inner pointer) may be NULL or all-0s to represent None
8358 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
8359 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,
8360 /// Called when a connection is established with a peer. This can be used to
8361 /// perform routing table synchronization using a strategy defined by the
8364 /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
8365 /// with us. Implementors should be somewhat conservative about doing so, however, as other
8366 /// message handlers may still wish to communicate with this peer.
8367 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,
8368 /// Handles the reply of a query we initiated to learn about channels
8369 /// for a given range of blocks. We can expect to receive one or more
8370 /// replies to a single query.
8371 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,
8372 /// Handles the reply of a query we initiated asking for routing gossip
8373 /// messages for a list of channels. We should receive this message when
8374 /// a node has completed its best effort to send us the pertaining routing
8375 /// gossip messages.
8376 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,
8377 /// Handles when a peer asks us to send a list of `short_channel_id`s
8378 /// for the requested range of blocks.
8379 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,
8380 /// Handles when a peer asks us to send routing gossip messages for a
8381 /// list of `short_channel_id`s.
8382 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,
8383 /// Indicates that there are a large number of [`ChannelAnnouncement`] (or other) messages
8384 /// pending some async action. While there is no guarantee of the rate of future messages, the
8385 /// caller should seek to reduce the rate of new gossip messages handled, especially
8386 /// [`ChannelAnnouncement`]s.
8387 pub processing_queue_high: extern "C" fn (this_arg: *const c_void) -> bool,
8388 /// Gets the node feature flags which this handler itself supports. All available handlers are
8389 /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
8390 /// which are broadcasted in our [`NodeAnnouncement`] message.
8391 pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
8392 /// Gets the init feature flags which should be sent to the given peer. All available handlers
8393 /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
8394 /// which are sent in our [`Init`] message.
8396 /// Note that this method is called before [`Self::peer_connected`].
8397 pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
8398 /// Implementation of MessageSendEventsProvider for this object.
8399 pub MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider,
8400 /// Frees any resources associated with this object given its this_arg pointer.
8401 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
8402 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
8404 unsafe impl Send for RoutingMessageHandler {}
8405 unsafe impl Sync for RoutingMessageHandler {}
8407 pub(crate) fn RoutingMessageHandler_clone_fields(orig: &RoutingMessageHandler) -> RoutingMessageHandler {
8408 RoutingMessageHandler {
8409 this_arg: orig.this_arg,
8410 handle_node_announcement: Clone::clone(&orig.handle_node_announcement),
8411 handle_channel_announcement: Clone::clone(&orig.handle_channel_announcement),
8412 handle_channel_update: Clone::clone(&orig.handle_channel_update),
8413 get_next_channel_announcement: Clone::clone(&orig.get_next_channel_announcement),
8414 get_next_node_announcement: Clone::clone(&orig.get_next_node_announcement),
8415 peer_connected: Clone::clone(&orig.peer_connected),
8416 handle_reply_channel_range: Clone::clone(&orig.handle_reply_channel_range),
8417 handle_reply_short_channel_ids_end: Clone::clone(&orig.handle_reply_short_channel_ids_end),
8418 handle_query_channel_range: Clone::clone(&orig.handle_query_channel_range),
8419 handle_query_short_channel_ids: Clone::clone(&orig.handle_query_short_channel_ids),
8420 processing_queue_high: Clone::clone(&orig.processing_queue_high),
8421 provided_node_features: Clone::clone(&orig.provided_node_features),
8422 provided_init_features: Clone::clone(&orig.provided_init_features),
8423 MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
8424 free: Clone::clone(&orig.free),
8427 impl lightning::events::MessageSendEventsProvider for RoutingMessageHandler {
8428 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::events::MessageSendEvent> {
8429 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
8430 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
8435 use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler;
8436 impl rustRoutingMessageHandler for RoutingMessageHandler {
8437 fn handle_node_announcement(&self, mut msg: &lightning::ln::msgs::NodeAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
8438 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 });
8439 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()) } })};
8442 fn handle_channel_announcement(&self, mut msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
8443 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 });
8444 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()) } })};
8447 fn handle_channel_update(&self, mut msg: &lightning::ln::msgs::ChannelUpdate) -> Result<bool, lightning::ln::msgs::LightningError> {
8448 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 });
8449 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()) } })};
8452 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>)> {
8453 let mut ret = (self.get_next_channel_announcement)(self.this_arg, starting_point);
8454 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 };
8457 fn get_next_node_announcement(&self, mut starting_point: Option<&lightning::routing::gossip::NodeId>) -> Option<lightning::ln::msgs::NodeAnnouncement> {
8458 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 };
8459 let mut ret = (self.get_next_node_announcement)(self.this_arg, local_starting_point);
8460 let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) };
8463 fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
8464 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);
8465 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)) })*/ })};
8468 fn handle_reply_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::ReplyChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
8469 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 });
8470 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()) } })};
8473 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> {
8474 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 });
8475 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()) } })};
8478 fn handle_query_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::QueryChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
8479 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 });
8480 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()) } })};
8483 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> {
8484 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 });
8485 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()) } })};
8488 fn processing_queue_high(&self) -> bool {
8489 let mut ret = (self.processing_queue_high)(self.this_arg);
8492 fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
8493 let mut ret = (self.provided_node_features)(self.this_arg);
8494 *unsafe { Box::from_raw(ret.take_inner()) }
8496 fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
8497 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
8498 *unsafe { Box::from_raw(ret.take_inner()) }
8502 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
8503 // directly as a Deref trait in higher-level structs:
8504 impl core::ops::Deref for RoutingMessageHandler {
8506 fn deref(&self) -> &Self {
8510 impl core::ops::DerefMut for RoutingMessageHandler {
8511 fn deref_mut(&mut self) -> &mut Self {
8515 /// Calls the free function if one is set
8517 pub extern "C" fn RoutingMessageHandler_free(this_ptr: RoutingMessageHandler) { }
8518 impl Drop for RoutingMessageHandler {
8519 fn drop(&mut self) {
8520 if let Some(f) = self.free {
8525 /// A handler for received [`OnionMessage`]s and for providing generated ones to send.
8527 pub struct OnionMessageHandler {
8528 /// An opaque pointer which is passed to your function implementations as an argument.
8529 /// This has no meaning in the LDK, and can be NULL or any other value.
8530 pub this_arg: *mut c_void,
8531 /// Handle an incoming `onion_message` message from the given peer.
8532 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),
8533 /// Returns the next pending onion message for the peer with the given node id.
8535 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
8536 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,
8537 /// Called when a connection is established with a peer. Can be used to track which peers
8538 /// advertise onion message support and are online.
8540 /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
8541 /// with us. Implementors should be somewhat conservative about doing so, however, as other
8542 /// message handlers may still wish to communicate with this peer.
8543 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,
8544 /// Indicates a connection to the peer failed/an existing connection was lost. Allows handlers to
8545 /// drop and refuse to forward onion messages to this peer.
8546 pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey),
8547 /// Gets the node feature flags which this handler itself supports. All available handlers are
8548 /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
8549 /// which are broadcasted in our [`NodeAnnouncement`] message.
8550 pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
8551 /// Gets the init feature flags which should be sent to the given peer. All available handlers
8552 /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
8553 /// which are sent in our [`Init`] message.
8555 /// Note that this method is called before [`Self::peer_connected`].
8556 pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
8557 /// Frees any resources associated with this object given its this_arg pointer.
8558 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
8559 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
8561 unsafe impl Send for OnionMessageHandler {}
8562 unsafe impl Sync for OnionMessageHandler {}
8564 pub(crate) fn OnionMessageHandler_clone_fields(orig: &OnionMessageHandler) -> OnionMessageHandler {
8565 OnionMessageHandler {
8566 this_arg: orig.this_arg,
8567 handle_onion_message: Clone::clone(&orig.handle_onion_message),
8568 next_onion_message_for_peer: Clone::clone(&orig.next_onion_message_for_peer),
8569 peer_connected: Clone::clone(&orig.peer_connected),
8570 peer_disconnected: Clone::clone(&orig.peer_disconnected),
8571 provided_node_features: Clone::clone(&orig.provided_node_features),
8572 provided_init_features: Clone::clone(&orig.provided_init_features),
8573 free: Clone::clone(&orig.free),
8577 use lightning::ln::msgs::OnionMessageHandler as rustOnionMessageHandler;
8578 impl rustOnionMessageHandler for OnionMessageHandler {
8579 fn handle_onion_message(&self, mut peer_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OnionMessage) {
8580 (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 })
8582 fn next_onion_message_for_peer(&self, mut peer_node_id: bitcoin::secp256k1::PublicKey) -> Option<lightning::ln::msgs::OnionMessage> {
8583 let mut ret = (self.next_onion_message_for_peer)(self.this_arg, crate::c_types::PublicKey::from_rust(&peer_node_id));
8584 let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) };
8587 fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
8588 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);
8589 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)) })*/ })};
8592 fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) {
8593 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id))
8595 fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
8596 let mut ret = (self.provided_node_features)(self.this_arg);
8597 *unsafe { Box::from_raw(ret.take_inner()) }
8599 fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
8600 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
8601 *unsafe { Box::from_raw(ret.take_inner()) }
8605 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
8606 // directly as a Deref trait in higher-level structs:
8607 impl core::ops::Deref for OnionMessageHandler {
8609 fn deref(&self) -> &Self {
8613 impl core::ops::DerefMut for OnionMessageHandler {
8614 fn deref_mut(&mut self) -> &mut Self {
8618 /// Calls the free function if one is set
8620 pub extern "C" fn OnionMessageHandler_free(this_ptr: OnionMessageHandler) { }
8621 impl Drop for OnionMessageHandler {
8622 fn drop(&mut self) {
8623 if let Some(f) = self.free {
8628 mod fuzzy_internal_msgs {
8630 use alloc::str::FromStr;
8631 use alloc::string::String;
8632 use core::ffi::c_void;
8633 use core::convert::Infallible;
8634 use bitcoin::hashes::Hash;
8635 use crate::c_types::*;
8636 #[cfg(feature="no-std")]
8637 use alloc::{vec::Vec, boxed::Box};
8641 /// Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read
8642 pub extern "C" fn AcceptChannel_write(obj: &crate::lightning::ln::msgs::AcceptChannel) -> crate::c_types::derived::CVec_u8Z {
8643 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8646 pub(crate) extern "C" fn AcceptChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8647 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannel) })
8650 /// Read a AcceptChannel from a byte array, created by AcceptChannel_write
8651 pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelDecodeErrorZ {
8652 let res: Result<lightning::ln::msgs::AcceptChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8653 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() };
8657 /// Serialize the AcceptChannelV2 object into a byte array which can be read by AcceptChannelV2_read
8658 pub extern "C" fn AcceptChannelV2_write(obj: &crate::lightning::ln::msgs::AcceptChannelV2) -> crate::c_types::derived::CVec_u8Z {
8659 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8662 pub(crate) extern "C" fn AcceptChannelV2_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8663 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannelV2) })
8666 /// Read a AcceptChannelV2 from a byte array, created by AcceptChannelV2_write
8667 pub extern "C" fn AcceptChannelV2_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelV2DecodeErrorZ {
8668 let res: Result<lightning::ln::msgs::AcceptChannelV2, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8669 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() };
8673 /// Serialize the TxAddInput object into a byte array which can be read by TxAddInput_read
8674 pub extern "C" fn TxAddInput_write(obj: &crate::lightning::ln::msgs::TxAddInput) -> crate::c_types::derived::CVec_u8Z {
8675 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8678 pub(crate) extern "C" fn TxAddInput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8679 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAddInput) })
8682 /// Read a TxAddInput from a byte array, created by TxAddInput_write
8683 pub extern "C" fn TxAddInput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAddInputDecodeErrorZ {
8684 let res: Result<lightning::ln::msgs::TxAddInput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8685 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() };
8689 /// Serialize the TxAddOutput object into a byte array which can be read by TxAddOutput_read
8690 pub extern "C" fn TxAddOutput_write(obj: &crate::lightning::ln::msgs::TxAddOutput) -> crate::c_types::derived::CVec_u8Z {
8691 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8694 pub(crate) extern "C" fn TxAddOutput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8695 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAddOutput) })
8698 /// Read a TxAddOutput from a byte array, created by TxAddOutput_write
8699 pub extern "C" fn TxAddOutput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAddOutputDecodeErrorZ {
8700 let res: Result<lightning::ln::msgs::TxAddOutput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8701 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() };
8705 /// Serialize the TxRemoveInput object into a byte array which can be read by TxRemoveInput_read
8706 pub extern "C" fn TxRemoveInput_write(obj: &crate::lightning::ln::msgs::TxRemoveInput) -> crate::c_types::derived::CVec_u8Z {
8707 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8710 pub(crate) extern "C" fn TxRemoveInput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8711 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxRemoveInput) })
8714 /// Read a TxRemoveInput from a byte array, created by TxRemoveInput_write
8715 pub extern "C" fn TxRemoveInput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxRemoveInputDecodeErrorZ {
8716 let res: Result<lightning::ln::msgs::TxRemoveInput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8717 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() };
8721 /// Serialize the TxRemoveOutput object into a byte array which can be read by TxRemoveOutput_read
8722 pub extern "C" fn TxRemoveOutput_write(obj: &crate::lightning::ln::msgs::TxRemoveOutput) -> crate::c_types::derived::CVec_u8Z {
8723 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8726 pub(crate) extern "C" fn TxRemoveOutput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8727 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxRemoveOutput) })
8730 /// Read a TxRemoveOutput from a byte array, created by TxRemoveOutput_write
8731 pub extern "C" fn TxRemoveOutput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxRemoveOutputDecodeErrorZ {
8732 let res: Result<lightning::ln::msgs::TxRemoveOutput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8733 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() };
8737 /// Serialize the TxComplete object into a byte array which can be read by TxComplete_read
8738 pub extern "C" fn TxComplete_write(obj: &crate::lightning::ln::msgs::TxComplete) -> crate::c_types::derived::CVec_u8Z {
8739 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8742 pub(crate) extern "C" fn TxComplete_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8743 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxComplete) })
8746 /// Read a TxComplete from a byte array, created by TxComplete_write
8747 pub extern "C" fn TxComplete_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxCompleteDecodeErrorZ {
8748 let res: Result<lightning::ln::msgs::TxComplete, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8749 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() };
8753 /// Serialize the TxSignatures object into a byte array which can be read by TxSignatures_read
8754 pub extern "C" fn TxSignatures_write(obj: &crate::lightning::ln::msgs::TxSignatures) -> crate::c_types::derived::CVec_u8Z {
8755 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8758 pub(crate) extern "C" fn TxSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8759 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxSignatures) })
8762 /// Read a TxSignatures from a byte array, created by TxSignatures_write
8763 pub extern "C" fn TxSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxSignaturesDecodeErrorZ {
8764 let res: Result<lightning::ln::msgs::TxSignatures, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8765 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() };
8769 /// Serialize the TxInitRbf object into a byte array which can be read by TxInitRbf_read
8770 pub extern "C" fn TxInitRbf_write(obj: &crate::lightning::ln::msgs::TxInitRbf) -> crate::c_types::derived::CVec_u8Z {
8771 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8774 pub(crate) extern "C" fn TxInitRbf_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8775 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxInitRbf) })
8778 /// Read a TxInitRbf from a byte array, created by TxInitRbf_write
8779 pub extern "C" fn TxInitRbf_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxInitRbfDecodeErrorZ {
8780 let res: Result<lightning::ln::msgs::TxInitRbf, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8781 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() };
8785 /// Serialize the TxAckRbf object into a byte array which can be read by TxAckRbf_read
8786 pub extern "C" fn TxAckRbf_write(obj: &crate::lightning::ln::msgs::TxAckRbf) -> crate::c_types::derived::CVec_u8Z {
8787 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8790 pub(crate) extern "C" fn TxAckRbf_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8791 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAckRbf) })
8794 /// Read a TxAckRbf from a byte array, created by TxAckRbf_write
8795 pub extern "C" fn TxAckRbf_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAckRbfDecodeErrorZ {
8796 let res: Result<lightning::ln::msgs::TxAckRbf, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8797 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() };
8801 /// Serialize the TxAbort object into a byte array which can be read by TxAbort_read
8802 pub extern "C" fn TxAbort_write(obj: &crate::lightning::ln::msgs::TxAbort) -> crate::c_types::derived::CVec_u8Z {
8803 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8806 pub(crate) extern "C" fn TxAbort_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8807 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAbort) })
8810 /// Read a TxAbort from a byte array, created by TxAbort_write
8811 pub extern "C" fn TxAbort_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAbortDecodeErrorZ {
8812 let res: Result<lightning::ln::msgs::TxAbort, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8813 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() };
8817 /// Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read
8818 pub extern "C" fn AnnouncementSignatures_write(obj: &crate::lightning::ln::msgs::AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z {
8819 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8822 pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8823 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAnnouncementSignatures) })
8826 /// Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write
8827 pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AnnouncementSignaturesDecodeErrorZ {
8828 let res: Result<lightning::ln::msgs::AnnouncementSignatures, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8829 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() };
8833 /// Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read
8834 pub extern "C" fn ChannelReestablish_write(obj: &crate::lightning::ln::msgs::ChannelReestablish) -> crate::c_types::derived::CVec_u8Z {
8835 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8838 pub(crate) extern "C" fn ChannelReestablish_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8839 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReestablish) })
8842 /// Read a ChannelReestablish from a byte array, created by ChannelReestablish_write
8843 pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReestablishDecodeErrorZ {
8844 let res: Result<lightning::ln::msgs::ChannelReestablish, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8845 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() };
8849 /// Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read
8850 pub extern "C" fn ClosingSigned_write(obj: &crate::lightning::ln::msgs::ClosingSigned) -> crate::c_types::derived::CVec_u8Z {
8851 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8854 pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8855 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSigned) })
8858 /// Read a ClosingSigned from a byte array, created by ClosingSigned_write
8859 pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedDecodeErrorZ {
8860 let res: Result<lightning::ln::msgs::ClosingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8861 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() };
8865 /// Serialize the ClosingSignedFeeRange object into a byte array which can be read by ClosingSignedFeeRange_read
8866 pub extern "C" fn ClosingSignedFeeRange_write(obj: &crate::lightning::ln::msgs::ClosingSignedFeeRange) -> crate::c_types::derived::CVec_u8Z {
8867 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8870 pub(crate) extern "C" fn ClosingSignedFeeRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8871 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSignedFeeRange) })
8874 /// Read a ClosingSignedFeeRange from a byte array, created by ClosingSignedFeeRange_write
8875 pub extern "C" fn ClosingSignedFeeRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedFeeRangeDecodeErrorZ {
8876 let res: Result<lightning::ln::msgs::ClosingSignedFeeRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8877 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() };
8881 /// Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read
8882 pub extern "C" fn CommitmentSigned_write(obj: &crate::lightning::ln::msgs::CommitmentSigned) -> crate::c_types::derived::CVec_u8Z {
8883 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8886 pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8887 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentSigned) })
8890 /// Read a CommitmentSigned from a byte array, created by CommitmentSigned_write
8891 pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CommitmentSignedDecodeErrorZ {
8892 let res: Result<lightning::ln::msgs::CommitmentSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8893 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() };
8897 /// Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read
8898 pub extern "C" fn FundingCreated_write(obj: &crate::lightning::ln::msgs::FundingCreated) -> crate::c_types::derived::CVec_u8Z {
8899 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8902 pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8903 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingCreated) })
8906 /// Read a FundingCreated from a byte array, created by FundingCreated_write
8907 pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingCreatedDecodeErrorZ {
8908 let res: Result<lightning::ln::msgs::FundingCreated, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8909 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() };
8913 /// Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read
8914 pub extern "C" fn FundingSigned_write(obj: &crate::lightning::ln::msgs::FundingSigned) -> crate::c_types::derived::CVec_u8Z {
8915 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8918 pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8919 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingSigned) })
8922 /// Read a FundingSigned from a byte array, created by FundingSigned_write
8923 pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingSignedDecodeErrorZ {
8924 let res: Result<lightning::ln::msgs::FundingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8925 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() };
8929 /// Serialize the ChannelReady object into a byte array which can be read by ChannelReady_read
8930 pub extern "C" fn ChannelReady_write(obj: &crate::lightning::ln::msgs::ChannelReady) -> crate::c_types::derived::CVec_u8Z {
8931 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8934 pub(crate) extern "C" fn ChannelReady_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8935 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReady) })
8938 /// Read a ChannelReady from a byte array, created by ChannelReady_write
8939 pub extern "C" fn ChannelReady_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReadyDecodeErrorZ {
8940 let res: Result<lightning::ln::msgs::ChannelReady, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8941 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() };
8945 /// Serialize the Init object into a byte array which can be read by Init_read
8946 pub extern "C" fn Init_write(obj: &crate::lightning::ln::msgs::Init) -> crate::c_types::derived::CVec_u8Z {
8947 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8950 pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8951 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInit) })
8954 /// Read a Init from a byte array, created by Init_write
8955 pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitDecodeErrorZ {
8956 let res: Result<lightning::ln::msgs::Init, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8957 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() };
8961 /// Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read
8962 pub extern "C" fn OpenChannel_write(obj: &crate::lightning::ln::msgs::OpenChannel) -> crate::c_types::derived::CVec_u8Z {
8963 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8966 pub(crate) extern "C" fn OpenChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8967 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannel) })
8970 /// Read a OpenChannel from a byte array, created by OpenChannel_write
8971 pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelDecodeErrorZ {
8972 let res: Result<lightning::ln::msgs::OpenChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8973 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() };
8977 /// Serialize the OpenChannelV2 object into a byte array which can be read by OpenChannelV2_read
8978 pub extern "C" fn OpenChannelV2_write(obj: &crate::lightning::ln::msgs::OpenChannelV2) -> crate::c_types::derived::CVec_u8Z {
8979 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8982 pub(crate) extern "C" fn OpenChannelV2_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8983 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannelV2) })
8986 /// Read a OpenChannelV2 from a byte array, created by OpenChannelV2_write
8987 pub extern "C" fn OpenChannelV2_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelV2DecodeErrorZ {
8988 let res: Result<lightning::ln::msgs::OpenChannelV2, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8989 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() };
8993 /// Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read
8994 pub extern "C" fn RevokeAndACK_write(obj: &crate::lightning::ln::msgs::RevokeAndACK) -> crate::c_types::derived::CVec_u8Z {
8995 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8998 pub(crate) extern "C" fn RevokeAndACK_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8999 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevokeAndACK) })
9002 /// Read a RevokeAndACK from a byte array, created by RevokeAndACK_write
9003 pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RevokeAndACKDecodeErrorZ {
9004 let res: Result<lightning::ln::msgs::RevokeAndACK, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9005 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() };
9009 /// Serialize the Shutdown object into a byte array which can be read by Shutdown_read
9010 pub extern "C" fn Shutdown_write(obj: &crate::lightning::ln::msgs::Shutdown) -> crate::c_types::derived::CVec_u8Z {
9011 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9014 pub(crate) extern "C" fn Shutdown_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9015 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeShutdown) })
9018 /// Read a Shutdown from a byte array, created by Shutdown_write
9019 pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ShutdownDecodeErrorZ {
9020 let res: Result<lightning::ln::msgs::Shutdown, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9021 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() };
9025 /// Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read
9026 pub extern "C" fn UpdateFailHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFailHTLC) -> crate::c_types::derived::CVec_u8Z {
9027 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9030 pub(crate) extern "C" fn UpdateFailHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9031 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailHTLC) })
9034 /// Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write
9035 pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailHTLCDecodeErrorZ {
9036 let res: Result<lightning::ln::msgs::UpdateFailHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9037 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() };
9041 /// Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read
9042 pub extern "C" fn UpdateFailMalformedHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFailMalformedHTLC) -> crate::c_types::derived::CVec_u8Z {
9043 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9046 pub(crate) extern "C" fn UpdateFailMalformedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9047 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailMalformedHTLC) })
9050 /// Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write
9051 pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailMalformedHTLCDecodeErrorZ {
9052 let res: Result<lightning::ln::msgs::UpdateFailMalformedHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9053 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() };
9057 /// Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read
9058 pub extern "C" fn UpdateFee_write(obj: &crate::lightning::ln::msgs::UpdateFee) -> crate::c_types::derived::CVec_u8Z {
9059 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9062 pub(crate) extern "C" fn UpdateFee_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9063 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFee) })
9066 /// Read a UpdateFee from a byte array, created by UpdateFee_write
9067 pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFeeDecodeErrorZ {
9068 let res: Result<lightning::ln::msgs::UpdateFee, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9069 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() };
9073 /// Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read
9074 pub extern "C" fn UpdateFulfillHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFulfillHTLC) -> crate::c_types::derived::CVec_u8Z {
9075 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9078 pub(crate) extern "C" fn UpdateFulfillHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9079 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFulfillHTLC) })
9082 /// Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write
9083 pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFulfillHTLCDecodeErrorZ {
9084 let res: Result<lightning::ln::msgs::UpdateFulfillHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9085 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() };
9089 /// Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read
9090 pub extern "C" fn UpdateAddHTLC_write(obj: &crate::lightning::ln::msgs::UpdateAddHTLC) -> crate::c_types::derived::CVec_u8Z {
9091 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9094 pub(crate) extern "C" fn UpdateAddHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9095 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateAddHTLC) })
9098 /// Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write
9099 pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateAddHTLCDecodeErrorZ {
9100 let res: Result<lightning::ln::msgs::UpdateAddHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9101 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() };
9105 /// Read a OnionMessage from a byte array, created by OnionMessage_write
9106 pub extern "C" fn OnionMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OnionMessageDecodeErrorZ {
9107 let res: Result<lightning::ln::msgs::OnionMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9108 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() };
9112 /// Serialize the OnionMessage object into a byte array which can be read by OnionMessage_read
9113 pub extern "C" fn OnionMessage_write(obj: &crate::lightning::ln::msgs::OnionMessage) -> crate::c_types::derived::CVec_u8Z {
9114 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9117 pub(crate) extern "C" fn OnionMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9118 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOnionMessage) })
9121 /// Serialize the Ping object into a byte array which can be read by Ping_read
9122 pub extern "C" fn Ping_write(obj: &crate::lightning::ln::msgs::Ping) -> crate::c_types::derived::CVec_u8Z {
9123 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9126 pub(crate) extern "C" fn Ping_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9127 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePing) })
9130 /// Read a Ping from a byte array, created by Ping_write
9131 pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PingDecodeErrorZ {
9132 let res: Result<lightning::ln::msgs::Ping, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9133 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() };
9137 /// Serialize the Pong object into a byte array which can be read by Pong_read
9138 pub extern "C" fn Pong_write(obj: &crate::lightning::ln::msgs::Pong) -> crate::c_types::derived::CVec_u8Z {
9139 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9142 pub(crate) extern "C" fn Pong_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9143 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePong) })
9146 /// Read a Pong from a byte array, created by Pong_write
9147 pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PongDecodeErrorZ {
9148 let res: Result<lightning::ln::msgs::Pong, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9149 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() };
9153 /// Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read
9154 pub extern "C" fn UnsignedChannelAnnouncement_write(obj: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
9155 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9158 pub(crate) extern "C" fn UnsignedChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9159 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelAnnouncement) })
9162 /// Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write
9163 pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelAnnouncementDecodeErrorZ {
9164 let res: Result<lightning::ln::msgs::UnsignedChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9165 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() };
9169 /// Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read
9170 pub extern "C" fn ChannelAnnouncement_write(obj: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
9171 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9174 pub(crate) extern "C" fn ChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9175 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelAnnouncement) })
9178 /// Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write
9179 pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelAnnouncementDecodeErrorZ {
9180 let res: Result<lightning::ln::msgs::ChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9181 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() };
9185 /// Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read
9186 pub extern "C" fn UnsignedChannelUpdate_write(obj: &crate::lightning::ln::msgs::UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
9187 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9190 pub(crate) extern "C" fn UnsignedChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9191 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelUpdate) })
9194 /// Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write
9195 pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelUpdateDecodeErrorZ {
9196 let res: Result<lightning::ln::msgs::UnsignedChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9197 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() };
9201 /// Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read
9202 pub extern "C" fn ChannelUpdate_write(obj: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
9203 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9206 pub(crate) extern "C" fn ChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9207 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdate) })
9210 /// Read a ChannelUpdate from a byte array, created by ChannelUpdate_write
9211 pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelUpdateDecodeErrorZ {
9212 let res: Result<lightning::ln::msgs::ChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9213 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() };
9217 /// Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read
9218 pub extern "C" fn ErrorMessage_write(obj: &crate::lightning::ln::msgs::ErrorMessage) -> crate::c_types::derived::CVec_u8Z {
9219 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9222 pub(crate) extern "C" fn ErrorMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9223 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeErrorMessage) })
9226 /// Read a ErrorMessage from a byte array, created by ErrorMessage_write
9227 pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ErrorMessageDecodeErrorZ {
9228 let res: Result<lightning::ln::msgs::ErrorMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9229 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() };
9233 /// Serialize the WarningMessage object into a byte array which can be read by WarningMessage_read
9234 pub extern "C" fn WarningMessage_write(obj: &crate::lightning::ln::msgs::WarningMessage) -> crate::c_types::derived::CVec_u8Z {
9235 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9238 pub(crate) extern "C" fn WarningMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9239 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeWarningMessage) })
9242 /// Read a WarningMessage from a byte array, created by WarningMessage_write
9243 pub extern "C" fn WarningMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_WarningMessageDecodeErrorZ {
9244 let res: Result<lightning::ln::msgs::WarningMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9245 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() };
9249 /// Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read
9250 pub extern "C" fn UnsignedNodeAnnouncement_write(obj: &crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
9251 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9254 pub(crate) extern "C" fn UnsignedNodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9255 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedNodeAnnouncement) })
9258 /// Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write
9259 pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedNodeAnnouncementDecodeErrorZ {
9260 let res: Result<lightning::ln::msgs::UnsignedNodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9261 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() };
9265 /// Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read
9266 pub extern "C" fn NodeAnnouncement_write(obj: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
9267 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9270 pub(crate) extern "C" fn NodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9271 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncement) })
9274 /// Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write
9275 pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementDecodeErrorZ {
9276 let res: Result<lightning::ln::msgs::NodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9277 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() };
9281 /// Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write
9282 pub extern "C" fn QueryShortChannelIds_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryShortChannelIdsDecodeErrorZ {
9283 let res: Result<lightning::ln::msgs::QueryShortChannelIds, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9284 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() };
9288 /// Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read
9289 pub extern "C" fn QueryShortChannelIds_write(obj: &crate::lightning::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CVec_u8Z {
9290 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9293 pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9294 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) })
9297 /// Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read
9298 pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z {
9299 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9302 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9303 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) })
9306 /// Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write
9307 pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyShortChannelIdsEndDecodeErrorZ {
9308 let res: Result<lightning::ln::msgs::ReplyShortChannelIdsEnd, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9309 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() };
9312 /// Calculates the overflow safe ending block height for the query.
9314 /// Overflow returns `0xffffffff`, otherwise returns `first_blocknum + number_of_blocks`.
9317 pub extern "C" fn QueryChannelRange_end_blocknum(this_arg: &crate::lightning::ln::msgs::QueryChannelRange) -> u32 {
9318 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.end_blocknum();
9323 /// Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read
9324 pub extern "C" fn QueryChannelRange_write(obj: &crate::lightning::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CVec_u8Z {
9325 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9328 pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9329 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) })
9332 /// Read a QueryChannelRange from a byte array, created by QueryChannelRange_write
9333 pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ {
9334 let res: Result<lightning::ln::msgs::QueryChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9335 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() };
9339 /// Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write
9340 pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyChannelRangeDecodeErrorZ {
9341 let res: Result<lightning::ln::msgs::ReplyChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9342 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() };
9346 /// Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read
9347 pub extern "C" fn ReplyChannelRange_write(obj: &crate::lightning::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CVec_u8Z {
9348 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9351 pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9352 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) })
9355 /// Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read
9356 pub extern "C" fn GossipTimestampFilter_write(obj: &crate::lightning::ln::msgs::GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z {
9357 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9360 pub(crate) extern "C" fn GossipTimestampFilter_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9361 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeGossipTimestampFilter) })
9364 /// Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write
9365 pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_GossipTimestampFilterDecodeErrorZ {
9366 let res: Result<lightning::ln::msgs::GossipTimestampFilter, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9367 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() };