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 core::ffi::c_void;
28 use core::convert::Infallible;
29 use bitcoin::hashes::Hash;
30 use crate::c_types::*;
31 #[cfg(feature="no-std")]
32 use alloc::{vec::Vec, boxed::Box};
34 /// An error in decoding a message or struct.
38 pub enum DecodeError {
39 /// A version byte specified something we don't know how to handle.
41 /// Includes unknown realm byte in an onion hop data packet.
43 /// Unknown feature mandating we fail to parse message (e.g., TLV with an even, unknown type)
44 UnknownRequiredFeature,
45 /// Value was invalid.
47 /// For example, a byte which was supposed to be a bool was something other than a 0
48 /// or 1, a public key/private key/signature was invalid, text wasn't UTF-8, TLV was
49 /// syntactically incorrect, etc.
51 /// The buffer to be read was too short.
53 /// A length descriptor in the packet didn't describe the later data correctly.
55 /// Error from [`std::io`].
57 crate::c_types::IOError),
58 /// The message included zlib-compressed values, which we don't support.
59 UnsupportedCompression,
61 use lightning::ln::msgs::DecodeError as DecodeErrorImport;
62 pub(crate) type nativeDecodeError = DecodeErrorImport;
66 pub(crate) fn to_native(&self) -> nativeDecodeError {
68 DecodeError::UnknownVersion => nativeDecodeError::UnknownVersion,
69 DecodeError::UnknownRequiredFeature => nativeDecodeError::UnknownRequiredFeature,
70 DecodeError::InvalidValue => nativeDecodeError::InvalidValue,
71 DecodeError::ShortRead => nativeDecodeError::ShortRead,
72 DecodeError::BadLengthDescriptor => nativeDecodeError::BadLengthDescriptor,
73 DecodeError::Io (ref a, ) => {
74 let mut a_nonref = Clone::clone(a);
75 nativeDecodeError::Io (
76 a_nonref.to_rust_kind(),
79 DecodeError::UnsupportedCompression => nativeDecodeError::UnsupportedCompression,
83 pub(crate) fn into_native(self) -> nativeDecodeError {
85 DecodeError::UnknownVersion => nativeDecodeError::UnknownVersion,
86 DecodeError::UnknownRequiredFeature => nativeDecodeError::UnknownRequiredFeature,
87 DecodeError::InvalidValue => nativeDecodeError::InvalidValue,
88 DecodeError::ShortRead => nativeDecodeError::ShortRead,
89 DecodeError::BadLengthDescriptor => nativeDecodeError::BadLengthDescriptor,
90 DecodeError::Io (mut a, ) => {
91 nativeDecodeError::Io (
95 DecodeError::UnsupportedCompression => nativeDecodeError::UnsupportedCompression,
99 pub(crate) fn from_native(native: &nativeDecodeError) -> Self {
101 nativeDecodeError::UnknownVersion => DecodeError::UnknownVersion,
102 nativeDecodeError::UnknownRequiredFeature => DecodeError::UnknownRequiredFeature,
103 nativeDecodeError::InvalidValue => DecodeError::InvalidValue,
104 nativeDecodeError::ShortRead => DecodeError::ShortRead,
105 nativeDecodeError::BadLengthDescriptor => DecodeError::BadLengthDescriptor,
106 nativeDecodeError::Io (ref a, ) => {
107 let mut a_nonref = Clone::clone(a);
109 crate::c_types::IOError::from_rust_kind(a_nonref),
112 nativeDecodeError::UnsupportedCompression => DecodeError::UnsupportedCompression,
116 pub(crate) fn native_into(native: nativeDecodeError) -> Self {
118 nativeDecodeError::UnknownVersion => DecodeError::UnknownVersion,
119 nativeDecodeError::UnknownRequiredFeature => DecodeError::UnknownRequiredFeature,
120 nativeDecodeError::InvalidValue => DecodeError::InvalidValue,
121 nativeDecodeError::ShortRead => DecodeError::ShortRead,
122 nativeDecodeError::BadLengthDescriptor => DecodeError::BadLengthDescriptor,
123 nativeDecodeError::Io (mut a, ) => {
125 crate::c_types::IOError::from_rust_kind(a),
128 nativeDecodeError::UnsupportedCompression => DecodeError::UnsupportedCompression,
132 /// Frees any resources used by the DecodeError
134 pub extern "C" fn DecodeError_free(this_ptr: DecodeError) { }
135 /// Creates a copy of the DecodeError
137 pub extern "C" fn DecodeError_clone(orig: &DecodeError) -> DecodeError {
141 /// Utility method to constructs a new UnknownVersion-variant DecodeError
142 pub extern "C" fn DecodeError_unknown_version() -> DecodeError {
143 DecodeError::UnknownVersion}
145 /// Utility method to constructs a new UnknownRequiredFeature-variant DecodeError
146 pub extern "C" fn DecodeError_unknown_required_feature() -> DecodeError {
147 DecodeError::UnknownRequiredFeature}
149 /// Utility method to constructs a new InvalidValue-variant DecodeError
150 pub extern "C" fn DecodeError_invalid_value() -> DecodeError {
151 DecodeError::InvalidValue}
153 /// Utility method to constructs a new ShortRead-variant DecodeError
154 pub extern "C" fn DecodeError_short_read() -> DecodeError {
155 DecodeError::ShortRead}
157 /// Utility method to constructs a new BadLengthDescriptor-variant DecodeError
158 pub extern "C" fn DecodeError_bad_length_descriptor() -> DecodeError {
159 DecodeError::BadLengthDescriptor}
161 /// Utility method to constructs a new Io-variant DecodeError
162 pub extern "C" fn DecodeError_io(a: crate::c_types::IOError) -> DecodeError {
166 /// Utility method to constructs a new UnsupportedCompression-variant DecodeError
167 pub extern "C" fn DecodeError_unsupported_compression() -> DecodeError {
168 DecodeError::UnsupportedCompression}
169 /// Checks if two DecodeErrors contain equal inner contents.
170 /// This ignores pointers and is_owned flags and looks at the values in fields.
172 pub extern "C" fn DecodeError_eq(a: &DecodeError, b: &DecodeError) -> bool {
173 if &a.to_native() == &b.to_native() { true } else { false }
176 use lightning::ln::msgs::Init as nativeInitImport;
177 pub(crate) type nativeInit = nativeInitImport;
179 /// An [`init`] message to be sent to or received from a peer.
181 /// [`init`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-init-message
185 /// A pointer to the opaque Rust object.
187 /// Nearly everywhere, inner must be non-null, however in places where
188 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
189 pub inner: *mut nativeInit,
190 /// Indicates that this is the only struct which contains the same pointer.
192 /// Rust functions which take ownership of an object provided via an argument require
193 /// this to be true and invalidate the object pointed to by inner.
199 if self.is_owned && !<*mut nativeInit>::is_null(self.inner) {
200 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
204 /// Frees any resources used by the Init, if is_owned is set and inner is non-NULL.
206 pub extern "C" fn Init_free(this_obj: Init) { }
208 /// Used only if an object of this type is returned as a trait impl by a method
209 pub(crate) extern "C" fn Init_free_void(this_ptr: *mut c_void) {
210 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInit) };
214 pub(crate) fn get_native_ref(&self) -> &'static nativeInit {
215 unsafe { &*ObjOps::untweak_ptr(self.inner) }
217 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInit {
218 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
220 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
221 pub(crate) fn take_inner(mut self) -> *mut nativeInit {
222 assert!(self.is_owned);
223 let ret = ObjOps::untweak_ptr(self.inner);
224 self.inner = core::ptr::null_mut();
228 /// The relevant features which the sender supports.
230 pub extern "C" fn Init_get_features(this_ptr: &Init) -> crate::lightning::ln::features::InitFeatures {
231 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
232 crate::lightning::ln::features::InitFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::InitFeatures<>) as *mut _) }, is_owned: false }
234 /// The relevant features which the sender supports.
236 pub extern "C" fn Init_set_features(this_ptr: &mut Init, mut val: crate::lightning::ln::features::InitFeatures) {
237 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
239 /// Indicates chains the sender is interested in.
241 /// If there are no common chains, the connection will be closed.
243 /// Returns a copy of the field.
245 pub extern "C" fn Init_get_networks(this_ptr: &Init) -> crate::c_types::derived::COption_CVec_ChainHashZZ {
246 let mut inner_val = this_ptr.get_native_mut_ref().networks.clone();
247 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_ChainHashZZ::None } else { crate::c_types::derived::COption_CVec_ChainHashZZ::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() }) };
250 /// Indicates chains the sender is interested in.
252 /// If there are no common chains, the connection will be closed.
254 pub extern "C" fn Init_set_networks(this_ptr: &mut Init, mut val: crate::c_types::derived::COption_CVec_ChainHashZZ) {
255 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 }})} };
256 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.networks = local_val;
258 /// The receipient's network address.
260 /// This adds the option to report a remote IP address back to a connecting peer using the init
261 /// message. A node can decide to use that information to discover a potential update to its
262 /// public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing
265 pub extern "C" fn Init_get_remote_network_address(this_ptr: &Init) -> crate::c_types::derived::COption_NetAddressZ {
266 let mut inner_val = &mut this_ptr.get_native_mut_ref().remote_network_address;
267 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_NetAddressZ::None } else { crate::c_types::derived::COption_NetAddressZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { crate::lightning::ln::msgs::NetAddress::native_into((*inner_val.as_ref().unwrap()).clone()) }) };
270 /// The receipient's network address.
272 /// This adds the option to report a remote IP address back to a connecting peer using the init
273 /// message. A node can decide to use that information to discover a potential update to its
274 /// public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing
277 pub extern "C" fn Init_set_remote_network_address(this_ptr: &mut Init, mut val: crate::c_types::derived::COption_NetAddressZ) {
278 let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_native() }})} };
279 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.remote_network_address = local_val;
281 /// Constructs a new Init given each field
284 pub extern "C" fn Init_new(mut features_arg: crate::lightning::ln::features::InitFeatures, mut networks_arg: crate::c_types::derived::COption_CVec_ChainHashZZ, mut remote_network_address_arg: crate::c_types::derived::COption_NetAddressZ) -> Init {
285 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 }})} };
286 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() }})} };
287 Init { inner: ObjOps::heap_alloc(nativeInit {
288 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
289 networks: local_networks_arg,
290 remote_network_address: local_remote_network_address_arg,
293 impl Clone for Init {
294 fn clone(&self) -> Self {
296 inner: if <*mut nativeInit>::is_null(self.inner) { core::ptr::null_mut() } else {
297 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
303 /// Used only if an object of this type is returned as a trait impl by a method
304 pub(crate) extern "C" fn Init_clone_void(this_ptr: *const c_void) -> *mut c_void {
305 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInit)).clone() })) as *mut c_void
308 /// Creates a copy of the Init
309 pub extern "C" fn Init_clone(orig: &Init) -> Init {
312 /// Checks if two Inits contain equal inner contents.
313 /// This ignores pointers and is_owned flags and looks at the values in fields.
314 /// Two objects with NULL inner values will be considered "equal" here.
316 pub extern "C" fn Init_eq(a: &Init, b: &Init) -> bool {
317 if a.inner == b.inner { return true; }
318 if a.inner.is_null() || b.inner.is_null() { return false; }
319 if a.get_native_ref() == b.get_native_ref() { true } else { false }
322 use lightning::ln::msgs::ErrorMessage as nativeErrorMessageImport;
323 pub(crate) type nativeErrorMessage = nativeErrorMessageImport;
325 /// An [`error`] message to be sent to or received from a peer.
327 /// [`error`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages
330 pub struct ErrorMessage {
331 /// A pointer to the opaque Rust object.
333 /// Nearly everywhere, inner must be non-null, however in places where
334 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
335 pub inner: *mut nativeErrorMessage,
336 /// Indicates that this is the only struct which contains the same pointer.
338 /// Rust functions which take ownership of an object provided via an argument require
339 /// this to be true and invalidate the object pointed to by inner.
343 impl Drop for ErrorMessage {
345 if self.is_owned && !<*mut nativeErrorMessage>::is_null(self.inner) {
346 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
350 /// Frees any resources used by the ErrorMessage, if is_owned is set and inner is non-NULL.
352 pub extern "C" fn ErrorMessage_free(this_obj: ErrorMessage) { }
354 /// Used only if an object of this type is returned as a trait impl by a method
355 pub(crate) extern "C" fn ErrorMessage_free_void(this_ptr: *mut c_void) {
356 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeErrorMessage) };
360 pub(crate) fn get_native_ref(&self) -> &'static nativeErrorMessage {
361 unsafe { &*ObjOps::untweak_ptr(self.inner) }
363 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeErrorMessage {
364 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
366 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
367 pub(crate) fn take_inner(mut self) -> *mut nativeErrorMessage {
368 assert!(self.is_owned);
369 let ret = ObjOps::untweak_ptr(self.inner);
370 self.inner = core::ptr::null_mut();
374 /// The channel ID involved in the error.
376 /// All-0s indicates a general error unrelated to a specific channel, after which all channels
377 /// with the sending peer should be closed.
379 pub extern "C" fn ErrorMessage_get_channel_id(this_ptr: &ErrorMessage) -> *const [u8; 32] {
380 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
383 /// The channel ID involved in the error.
385 /// All-0s indicates a general error unrelated to a specific channel, after which all channels
386 /// with the sending peer should be closed.
388 pub extern "C" fn ErrorMessage_set_channel_id(this_ptr: &mut ErrorMessage, mut val: crate::c_types::ThirtyTwoBytes) {
389 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
391 /// A possibly human-readable error description.
393 /// The string should be sanitized before it is used (e.g., emitted to logs or printed to
394 /// `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in
395 /// the terminal emulator or the logging subsystem.
397 pub extern "C" fn ErrorMessage_get_data(this_ptr: &ErrorMessage) -> crate::c_types::Str {
398 let mut inner_val = &mut this_ptr.get_native_mut_ref().data;
399 inner_val.as_str().into()
401 /// A possibly human-readable error description.
403 /// The string should be sanitized before it is used (e.g., emitted to logs or printed to
404 /// `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in
405 /// the terminal emulator or the logging subsystem.
407 pub extern "C" fn ErrorMessage_set_data(this_ptr: &mut ErrorMessage, mut val: crate::c_types::Str) {
408 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string();
410 /// Constructs a new ErrorMessage given each field
413 pub extern "C" fn ErrorMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::Str) -> ErrorMessage {
414 ErrorMessage { inner: ObjOps::heap_alloc(nativeErrorMessage {
415 channel_id: channel_id_arg.data,
416 data: data_arg.into_string(),
419 impl Clone for ErrorMessage {
420 fn clone(&self) -> Self {
422 inner: if <*mut nativeErrorMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
423 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
429 /// Used only if an object of this type is returned as a trait impl by a method
430 pub(crate) extern "C" fn ErrorMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
431 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeErrorMessage)).clone() })) as *mut c_void
434 /// Creates a copy of the ErrorMessage
435 pub extern "C" fn ErrorMessage_clone(orig: &ErrorMessage) -> ErrorMessage {
438 /// Checks if two ErrorMessages contain equal inner contents.
439 /// This ignores pointers and is_owned flags and looks at the values in fields.
440 /// Two objects with NULL inner values will be considered "equal" here.
442 pub extern "C" fn ErrorMessage_eq(a: &ErrorMessage, b: &ErrorMessage) -> bool {
443 if a.inner == b.inner { return true; }
444 if a.inner.is_null() || b.inner.is_null() { return false; }
445 if a.get_native_ref() == b.get_native_ref() { true } else { false }
448 use lightning::ln::msgs::WarningMessage as nativeWarningMessageImport;
449 pub(crate) type nativeWarningMessage = nativeWarningMessageImport;
451 /// A [`warning`] message to be sent to or received from a peer.
453 /// [`warning`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages
456 pub struct WarningMessage {
457 /// A pointer to the opaque Rust object.
459 /// Nearly everywhere, inner must be non-null, however in places where
460 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
461 pub inner: *mut nativeWarningMessage,
462 /// Indicates that this is the only struct which contains the same pointer.
464 /// Rust functions which take ownership of an object provided via an argument require
465 /// this to be true and invalidate the object pointed to by inner.
469 impl Drop for WarningMessage {
471 if self.is_owned && !<*mut nativeWarningMessage>::is_null(self.inner) {
472 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
476 /// Frees any resources used by the WarningMessage, if is_owned is set and inner is non-NULL.
478 pub extern "C" fn WarningMessage_free(this_obj: WarningMessage) { }
480 /// Used only if an object of this type is returned as a trait impl by a method
481 pub(crate) extern "C" fn WarningMessage_free_void(this_ptr: *mut c_void) {
482 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeWarningMessage) };
485 impl WarningMessage {
486 pub(crate) fn get_native_ref(&self) -> &'static nativeWarningMessage {
487 unsafe { &*ObjOps::untweak_ptr(self.inner) }
489 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeWarningMessage {
490 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
492 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
493 pub(crate) fn take_inner(mut self) -> *mut nativeWarningMessage {
494 assert!(self.is_owned);
495 let ret = ObjOps::untweak_ptr(self.inner);
496 self.inner = core::ptr::null_mut();
500 /// The channel ID involved in the warning.
502 /// All-0s indicates a warning unrelated to a specific channel.
504 pub extern "C" fn WarningMessage_get_channel_id(this_ptr: &WarningMessage) -> *const [u8; 32] {
505 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
508 /// The channel ID involved in the warning.
510 /// All-0s indicates a warning unrelated to a specific channel.
512 pub extern "C" fn WarningMessage_set_channel_id(this_ptr: &mut WarningMessage, mut val: crate::c_types::ThirtyTwoBytes) {
513 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
515 /// A possibly human-readable warning description.
517 /// The string should be sanitized before it is used (e.g. emitted to logs or printed to
518 /// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
519 /// the terminal emulator or the logging subsystem.
521 pub extern "C" fn WarningMessage_get_data(this_ptr: &WarningMessage) -> crate::c_types::Str {
522 let mut inner_val = &mut this_ptr.get_native_mut_ref().data;
523 inner_val.as_str().into()
525 /// A possibly human-readable warning description.
527 /// The string should be sanitized before it is used (e.g. emitted to logs or printed to
528 /// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
529 /// the terminal emulator or the logging subsystem.
531 pub extern "C" fn WarningMessage_set_data(this_ptr: &mut WarningMessage, mut val: crate::c_types::Str) {
532 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string();
534 /// Constructs a new WarningMessage given each field
537 pub extern "C" fn WarningMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::Str) -> WarningMessage {
538 WarningMessage { inner: ObjOps::heap_alloc(nativeWarningMessage {
539 channel_id: channel_id_arg.data,
540 data: data_arg.into_string(),
543 impl Clone for WarningMessage {
544 fn clone(&self) -> Self {
546 inner: if <*mut nativeWarningMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
547 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
553 /// Used only if an object of this type is returned as a trait impl by a method
554 pub(crate) extern "C" fn WarningMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
555 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeWarningMessage)).clone() })) as *mut c_void
558 /// Creates a copy of the WarningMessage
559 pub extern "C" fn WarningMessage_clone(orig: &WarningMessage) -> WarningMessage {
562 /// Checks if two WarningMessages contain equal inner contents.
563 /// This ignores pointers and is_owned flags and looks at the values in fields.
564 /// Two objects with NULL inner values will be considered "equal" here.
566 pub extern "C" fn WarningMessage_eq(a: &WarningMessage, b: &WarningMessage) -> bool {
567 if a.inner == b.inner { return true; }
568 if a.inner.is_null() || b.inner.is_null() { return false; }
569 if a.get_native_ref() == b.get_native_ref() { true } else { false }
572 use lightning::ln::msgs::Ping as nativePingImport;
573 pub(crate) type nativePing = nativePingImport;
575 /// A [`ping`] message to be sent to or received from a peer.
577 /// [`ping`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-ping-and-pong-messages
581 /// A pointer to the opaque Rust object.
583 /// Nearly everywhere, inner must be non-null, however in places where
584 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
585 pub inner: *mut nativePing,
586 /// Indicates that this is the only struct which contains the same pointer.
588 /// Rust functions which take ownership of an object provided via an argument require
589 /// this to be true and invalidate the object pointed to by inner.
595 if self.is_owned && !<*mut nativePing>::is_null(self.inner) {
596 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
600 /// Frees any resources used by the Ping, if is_owned is set and inner is non-NULL.
602 pub extern "C" fn Ping_free(this_obj: Ping) { }
604 /// Used only if an object of this type is returned as a trait impl by a method
605 pub(crate) extern "C" fn Ping_free_void(this_ptr: *mut c_void) {
606 let _ = unsafe { Box::from_raw(this_ptr as *mut nativePing) };
610 pub(crate) fn get_native_ref(&self) -> &'static nativePing {
611 unsafe { &*ObjOps::untweak_ptr(self.inner) }
613 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePing {
614 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
616 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
617 pub(crate) fn take_inner(mut self) -> *mut nativePing {
618 assert!(self.is_owned);
619 let ret = ObjOps::untweak_ptr(self.inner);
620 self.inner = core::ptr::null_mut();
624 /// The desired response length.
626 pub extern "C" fn Ping_get_ponglen(this_ptr: &Ping) -> u16 {
627 let mut inner_val = &mut this_ptr.get_native_mut_ref().ponglen;
630 /// The desired response length.
632 pub extern "C" fn Ping_set_ponglen(this_ptr: &mut Ping, mut val: u16) {
633 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.ponglen = val;
635 /// The ping packet size.
637 /// This field is not sent on the wire. byteslen zeros are sent.
639 pub extern "C" fn Ping_get_byteslen(this_ptr: &Ping) -> u16 {
640 let mut inner_val = &mut this_ptr.get_native_mut_ref().byteslen;
643 /// The ping packet size.
645 /// This field is not sent on the wire. byteslen zeros are sent.
647 pub extern "C" fn Ping_set_byteslen(this_ptr: &mut Ping, mut val: u16) {
648 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.byteslen = val;
650 /// Constructs a new Ping given each field
653 pub extern "C" fn Ping_new(mut ponglen_arg: u16, mut byteslen_arg: u16) -> Ping {
654 Ping { inner: ObjOps::heap_alloc(nativePing {
655 ponglen: ponglen_arg,
656 byteslen: byteslen_arg,
659 impl Clone for Ping {
660 fn clone(&self) -> Self {
662 inner: if <*mut nativePing>::is_null(self.inner) { core::ptr::null_mut() } else {
663 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
669 /// Used only if an object of this type is returned as a trait impl by a method
670 pub(crate) extern "C" fn Ping_clone_void(this_ptr: *const c_void) -> *mut c_void {
671 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePing)).clone() })) as *mut c_void
674 /// Creates a copy of the Ping
675 pub extern "C" fn Ping_clone(orig: &Ping) -> Ping {
678 /// Checks if two Pings contain equal inner contents.
679 /// This ignores pointers and is_owned flags and looks at the values in fields.
680 /// Two objects with NULL inner values will be considered "equal" here.
682 pub extern "C" fn Ping_eq(a: &Ping, b: &Ping) -> bool {
683 if a.inner == b.inner { return true; }
684 if a.inner.is_null() || b.inner.is_null() { return false; }
685 if a.get_native_ref() == b.get_native_ref() { true } else { false }
688 use lightning::ln::msgs::Pong as nativePongImport;
689 pub(crate) type nativePong = nativePongImport;
691 /// A [`pong`] message to be sent to or received from a peer.
693 /// [`pong`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-ping-and-pong-messages
697 /// A pointer to the opaque Rust object.
699 /// Nearly everywhere, inner must be non-null, however in places where
700 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
701 pub inner: *mut nativePong,
702 /// Indicates that this is the only struct which contains the same pointer.
704 /// Rust functions which take ownership of an object provided via an argument require
705 /// this to be true and invalidate the object pointed to by inner.
711 if self.is_owned && !<*mut nativePong>::is_null(self.inner) {
712 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
716 /// Frees any resources used by the Pong, if is_owned is set and inner is non-NULL.
718 pub extern "C" fn Pong_free(this_obj: Pong) { }
720 /// Used only if an object of this type is returned as a trait impl by a method
721 pub(crate) extern "C" fn Pong_free_void(this_ptr: *mut c_void) {
722 let _ = unsafe { Box::from_raw(this_ptr as *mut nativePong) };
726 pub(crate) fn get_native_ref(&self) -> &'static nativePong {
727 unsafe { &*ObjOps::untweak_ptr(self.inner) }
729 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePong {
730 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
732 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
733 pub(crate) fn take_inner(mut self) -> *mut nativePong {
734 assert!(self.is_owned);
735 let ret = ObjOps::untweak_ptr(self.inner);
736 self.inner = core::ptr::null_mut();
740 /// The pong packet size.
742 /// This field is not sent on the wire. byteslen zeros are sent.
744 pub extern "C" fn Pong_get_byteslen(this_ptr: &Pong) -> u16 {
745 let mut inner_val = &mut this_ptr.get_native_mut_ref().byteslen;
748 /// The pong packet size.
750 /// This field is not sent on the wire. byteslen zeros are sent.
752 pub extern "C" fn Pong_set_byteslen(this_ptr: &mut Pong, mut val: u16) {
753 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.byteslen = val;
755 /// Constructs a new Pong given each field
758 pub extern "C" fn Pong_new(mut byteslen_arg: u16) -> Pong {
759 Pong { inner: ObjOps::heap_alloc(nativePong {
760 byteslen: byteslen_arg,
763 impl Clone for Pong {
764 fn clone(&self) -> Self {
766 inner: if <*mut nativePong>::is_null(self.inner) { core::ptr::null_mut() } else {
767 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
773 /// Used only if an object of this type is returned as a trait impl by a method
774 pub(crate) extern "C" fn Pong_clone_void(this_ptr: *const c_void) -> *mut c_void {
775 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePong)).clone() })) as *mut c_void
778 /// Creates a copy of the Pong
779 pub extern "C" fn Pong_clone(orig: &Pong) -> Pong {
782 /// Checks if two Pongs contain equal inner contents.
783 /// This ignores pointers and is_owned flags and looks at the values in fields.
784 /// Two objects with NULL inner values will be considered "equal" here.
786 pub extern "C" fn Pong_eq(a: &Pong, b: &Pong) -> bool {
787 if a.inner == b.inner { return true; }
788 if a.inner.is_null() || b.inner.is_null() { return false; }
789 if a.get_native_ref() == b.get_native_ref() { true } else { false }
792 use lightning::ln::msgs::OpenChannel as nativeOpenChannelImport;
793 pub(crate) type nativeOpenChannel = nativeOpenChannelImport;
795 /// An [`open_channel`] message to be sent to or received from a peer.
797 /// Used in V1 channel establishment
799 /// [`open_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message
802 pub struct OpenChannel {
803 /// A pointer to the opaque Rust object.
805 /// Nearly everywhere, inner must be non-null, however in places where
806 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
807 pub inner: *mut nativeOpenChannel,
808 /// Indicates that this is the only struct which contains the same pointer.
810 /// Rust functions which take ownership of an object provided via an argument require
811 /// this to be true and invalidate the object pointed to by inner.
815 impl Drop for OpenChannel {
817 if self.is_owned && !<*mut nativeOpenChannel>::is_null(self.inner) {
818 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
822 /// Frees any resources used by the OpenChannel, if is_owned is set and inner is non-NULL.
824 pub extern "C" fn OpenChannel_free(this_obj: OpenChannel) { }
826 /// Used only if an object of this type is returned as a trait impl by a method
827 pub(crate) extern "C" fn OpenChannel_free_void(this_ptr: *mut c_void) {
828 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOpenChannel) };
832 pub(crate) fn get_native_ref(&self) -> &'static nativeOpenChannel {
833 unsafe { &*ObjOps::untweak_ptr(self.inner) }
835 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOpenChannel {
836 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
838 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
839 pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannel {
840 assert!(self.is_owned);
841 let ret = ObjOps::untweak_ptr(self.inner);
842 self.inner = core::ptr::null_mut();
846 /// The genesis hash of the blockchain where the channel is to be opened
848 pub extern "C" fn OpenChannel_get_chain_hash(this_ptr: &OpenChannel) -> *const [u8; 32] {
849 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
852 /// The genesis hash of the blockchain where the channel is to be opened
854 pub extern "C" fn OpenChannel_set_chain_hash(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
855 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
857 /// A temporary channel ID, until the funding outpoint is announced
859 pub extern "C" fn OpenChannel_get_temporary_channel_id(this_ptr: &OpenChannel) -> *const [u8; 32] {
860 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
863 /// A temporary channel ID, until the funding outpoint is announced
865 pub extern "C" fn OpenChannel_set_temporary_channel_id(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
866 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
868 /// The channel value
870 pub extern "C" fn OpenChannel_get_funding_satoshis(this_ptr: &OpenChannel) -> u64 {
871 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
874 /// The channel value
876 pub extern "C" fn OpenChannel_set_funding_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
877 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
879 /// The amount to push to the counterparty as part of the open, in milli-satoshi
881 pub extern "C" fn OpenChannel_get_push_msat(this_ptr: &OpenChannel) -> u64 {
882 let mut inner_val = &mut this_ptr.get_native_mut_ref().push_msat;
885 /// The amount to push to the counterparty as part of the open, in milli-satoshi
887 pub extern "C" fn OpenChannel_set_push_msat(this_ptr: &mut OpenChannel, mut val: u64) {
888 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.push_msat = val;
890 /// The threshold below which outputs on transactions broadcast by sender will be omitted
892 pub extern "C" fn OpenChannel_get_dust_limit_satoshis(this_ptr: &OpenChannel) -> u64 {
893 let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
896 /// The threshold below which outputs on transactions broadcast by sender will be omitted
898 pub extern "C" fn OpenChannel_set_dust_limit_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
899 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
901 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
903 pub extern "C" fn OpenChannel_get_max_htlc_value_in_flight_msat(this_ptr: &OpenChannel) -> u64 {
904 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
907 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
909 pub extern "C" fn OpenChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut OpenChannel, mut val: u64) {
910 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
912 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
914 pub extern "C" fn OpenChannel_get_channel_reserve_satoshis(this_ptr: &OpenChannel) -> u64 {
915 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
918 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
920 pub extern "C" fn OpenChannel_set_channel_reserve_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
921 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
923 /// The minimum HTLC size incoming to sender, in milli-satoshi
925 pub extern "C" fn OpenChannel_get_htlc_minimum_msat(this_ptr: &OpenChannel) -> u64 {
926 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
929 /// The minimum HTLC size incoming to sender, in milli-satoshi
931 pub extern "C" fn OpenChannel_set_htlc_minimum_msat(this_ptr: &mut OpenChannel, mut val: u64) {
932 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
934 /// The feerate per 1000-weight of sender generated transactions, until updated by
937 pub extern "C" fn OpenChannel_get_feerate_per_kw(this_ptr: &OpenChannel) -> u32 {
938 let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
941 /// The feerate per 1000-weight of sender generated transactions, until updated by
944 pub extern "C" fn OpenChannel_set_feerate_per_kw(this_ptr: &mut OpenChannel, mut val: u32) {
945 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
947 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if
948 /// they broadcast a commitment transaction
950 pub extern "C" fn OpenChannel_get_to_self_delay(this_ptr: &OpenChannel) -> u16 {
951 let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
954 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if
955 /// they broadcast a commitment transaction
957 pub extern "C" fn OpenChannel_set_to_self_delay(this_ptr: &mut OpenChannel, mut val: u16) {
958 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
960 /// The maximum number of inbound HTLCs towards sender
962 pub extern "C" fn OpenChannel_get_max_accepted_htlcs(this_ptr: &OpenChannel) -> u16 {
963 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
966 /// The maximum number of inbound HTLCs towards sender
968 pub extern "C" fn OpenChannel_set_max_accepted_htlcs(this_ptr: &mut OpenChannel, mut val: u16) {
969 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
971 /// The sender's key controlling the funding transaction
973 pub extern "C" fn OpenChannel_get_funding_pubkey(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
974 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
975 crate::c_types::PublicKey::from_rust(&inner_val)
977 /// The sender's key controlling the funding transaction
979 pub extern "C" fn OpenChannel_set_funding_pubkey(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
980 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
982 /// Used to derive a revocation key for transactions broadcast by counterparty
984 pub extern "C" fn OpenChannel_get_revocation_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
985 let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
986 crate::c_types::PublicKey::from_rust(&inner_val)
988 /// Used to derive a revocation key for transactions broadcast by counterparty
990 pub extern "C" fn OpenChannel_set_revocation_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
991 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
993 /// A payment key to sender for transactions broadcast by counterparty
995 pub extern "C" fn OpenChannel_get_payment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
996 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_point;
997 crate::c_types::PublicKey::from_rust(&inner_val)
999 /// A payment key to sender for transactions broadcast by counterparty
1001 pub extern "C" fn OpenChannel_set_payment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1002 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_point = val.into_rust();
1004 /// Used to derive a payment key to sender for transactions broadcast by sender
1006 pub extern "C" fn OpenChannel_get_delayed_payment_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
1007 let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
1008 crate::c_types::PublicKey::from_rust(&inner_val)
1010 /// Used to derive a payment key to sender for transactions broadcast by sender
1012 pub extern "C" fn OpenChannel_set_delayed_payment_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1013 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
1015 /// Used to derive an HTLC payment key to sender
1017 pub extern "C" fn OpenChannel_get_htlc_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
1018 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
1019 crate::c_types::PublicKey::from_rust(&inner_val)
1021 /// Used to derive an HTLC payment key to sender
1023 pub extern "C" fn OpenChannel_set_htlc_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1024 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
1026 /// The first to-be-broadcast-by-sender transaction's per commitment point
1028 pub extern "C" fn OpenChannel_get_first_per_commitment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
1029 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
1030 crate::c_types::PublicKey::from_rust(&inner_val)
1032 /// The first to-be-broadcast-by-sender transaction's per commitment point
1034 pub extern "C" fn OpenChannel_set_first_per_commitment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1035 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
1037 /// The channel flags to be used
1039 pub extern "C" fn OpenChannel_get_channel_flags(this_ptr: &OpenChannel) -> u8 {
1040 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_flags;
1043 /// The channel flags to be used
1045 pub extern "C" fn OpenChannel_set_channel_flags(this_ptr: &mut OpenChannel, mut val: u8) {
1046 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_flags = val;
1048 /// A request to pre-set the to-sender output's `scriptPubkey` for when we collaboratively close
1050 pub extern "C" fn OpenChannel_get_shutdown_scriptpubkey(this_ptr: &OpenChannel) -> crate::c_types::derived::COption_ScriptZ {
1051 let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey;
1052 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ScriptZ::None } else { crate::c_types::derived::COption_ScriptZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().into_bytes().into() }) };
1055 /// A request to pre-set the to-sender output's `scriptPubkey` for when we collaboratively close
1057 pub extern "C" fn OpenChannel_set_shutdown_scriptpubkey(this_ptr: &mut OpenChannel, mut val: crate::c_types::derived::COption_ScriptZ) {
1058 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()) }})} };
1059 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val;
1061 /// The channel type that this channel will represent
1063 /// If this is `None`, we derive the channel type from the intersection of our
1064 /// feature bits with our counterparty's feature bits from the [`Init`] message.
1066 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1068 pub extern "C" fn OpenChannel_get_channel_type(this_ptr: &OpenChannel) -> crate::lightning::ln::features::ChannelTypeFeatures {
1069 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1070 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 };
1073 /// The channel type that this channel will represent
1075 /// If this is `None`, we derive the channel type from the intersection of our
1076 /// feature bits with our counterparty's feature bits from the [`Init`] message.
1078 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1080 pub extern "C" fn OpenChannel_set_channel_type(this_ptr: &mut OpenChannel, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1081 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1082 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1084 /// Constructs a new OpenChannel given each field
1087 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_ScriptZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures) -> OpenChannel {
1088 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()) }})} };
1089 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()) } }) };
1090 OpenChannel { inner: ObjOps::heap_alloc(nativeOpenChannel {
1091 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
1092 temporary_channel_id: temporary_channel_id_arg.data,
1093 funding_satoshis: funding_satoshis_arg,
1094 push_msat: push_msat_arg,
1095 dust_limit_satoshis: dust_limit_satoshis_arg,
1096 max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg,
1097 channel_reserve_satoshis: channel_reserve_satoshis_arg,
1098 htlc_minimum_msat: htlc_minimum_msat_arg,
1099 feerate_per_kw: feerate_per_kw_arg,
1100 to_self_delay: to_self_delay_arg,
1101 max_accepted_htlcs: max_accepted_htlcs_arg,
1102 funding_pubkey: funding_pubkey_arg.into_rust(),
1103 revocation_basepoint: revocation_basepoint_arg.into_rust(),
1104 payment_point: payment_point_arg.into_rust(),
1105 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
1106 htlc_basepoint: htlc_basepoint_arg.into_rust(),
1107 first_per_commitment_point: first_per_commitment_point_arg.into_rust(),
1108 channel_flags: channel_flags_arg,
1109 shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg,
1110 channel_type: local_channel_type_arg,
1111 }), is_owned: true }
1113 impl Clone for OpenChannel {
1114 fn clone(&self) -> Self {
1116 inner: if <*mut nativeOpenChannel>::is_null(self.inner) { core::ptr::null_mut() } else {
1117 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1123 /// Used only if an object of this type is returned as a trait impl by a method
1124 pub(crate) extern "C" fn OpenChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
1125 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOpenChannel)).clone() })) as *mut c_void
1128 /// Creates a copy of the OpenChannel
1129 pub extern "C" fn OpenChannel_clone(orig: &OpenChannel) -> OpenChannel {
1132 /// Checks if two OpenChannels contain equal inner contents.
1133 /// This ignores pointers and is_owned flags and looks at the values in fields.
1134 /// Two objects with NULL inner values will be considered "equal" here.
1136 pub extern "C" fn OpenChannel_eq(a: &OpenChannel, b: &OpenChannel) -> bool {
1137 if a.inner == b.inner { return true; }
1138 if a.inner.is_null() || b.inner.is_null() { return false; }
1139 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1142 use lightning::ln::msgs::OpenChannelV2 as nativeOpenChannelV2Import;
1143 pub(crate) type nativeOpenChannelV2 = nativeOpenChannelV2Import;
1145 /// An open_channel2 message to be sent by or received from the channel initiator.
1147 /// Used in V2 channel establishment
1151 pub struct OpenChannelV2 {
1152 /// A pointer to the opaque Rust object.
1154 /// Nearly everywhere, inner must be non-null, however in places where
1155 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1156 pub inner: *mut nativeOpenChannelV2,
1157 /// Indicates that this is the only struct which contains the same pointer.
1159 /// Rust functions which take ownership of an object provided via an argument require
1160 /// this to be true and invalidate the object pointed to by inner.
1164 impl Drop for OpenChannelV2 {
1165 fn drop(&mut self) {
1166 if self.is_owned && !<*mut nativeOpenChannelV2>::is_null(self.inner) {
1167 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1171 /// Frees any resources used by the OpenChannelV2, if is_owned is set and inner is non-NULL.
1173 pub extern "C" fn OpenChannelV2_free(this_obj: OpenChannelV2) { }
1175 /// Used only if an object of this type is returned as a trait impl by a method
1176 pub(crate) extern "C" fn OpenChannelV2_free_void(this_ptr: *mut c_void) {
1177 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOpenChannelV2) };
1180 impl OpenChannelV2 {
1181 pub(crate) fn get_native_ref(&self) -> &'static nativeOpenChannelV2 {
1182 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1184 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOpenChannelV2 {
1185 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1187 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1188 pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannelV2 {
1189 assert!(self.is_owned);
1190 let ret = ObjOps::untweak_ptr(self.inner);
1191 self.inner = core::ptr::null_mut();
1195 /// The genesis hash of the blockchain where the channel is to be opened
1197 pub extern "C" fn OpenChannelV2_get_chain_hash(this_ptr: &OpenChannelV2) -> *const [u8; 32] {
1198 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
1199 inner_val.as_inner()
1201 /// The genesis hash of the blockchain where the channel is to be opened
1203 pub extern "C" fn OpenChannelV2_set_chain_hash(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::ThirtyTwoBytes) {
1204 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
1206 /// A temporary channel ID derived using a zeroed out value for the channel acceptor's revocation basepoint
1208 pub extern "C" fn OpenChannelV2_get_temporary_channel_id(this_ptr: &OpenChannelV2) -> *const [u8; 32] {
1209 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
1212 /// A temporary channel ID derived using a zeroed out value for the channel acceptor's revocation basepoint
1214 pub extern "C" fn OpenChannelV2_set_temporary_channel_id(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::ThirtyTwoBytes) {
1215 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
1217 /// The feerate for the funding transaction set by the channel initiator
1219 pub extern "C" fn OpenChannelV2_get_funding_feerate_sat_per_1000_weight(this_ptr: &OpenChannelV2) -> u32 {
1220 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_feerate_sat_per_1000_weight;
1223 /// The feerate for the funding transaction set by the channel initiator
1225 pub extern "C" fn OpenChannelV2_set_funding_feerate_sat_per_1000_weight(this_ptr: &mut OpenChannelV2, mut val: u32) {
1226 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_feerate_sat_per_1000_weight = val;
1228 /// The feerate for the commitment transaction set by the channel initiator
1230 pub extern "C" fn OpenChannelV2_get_commitment_feerate_sat_per_1000_weight(this_ptr: &OpenChannelV2) -> u32 {
1231 let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_feerate_sat_per_1000_weight;
1234 /// The feerate for the commitment transaction set by the channel initiator
1236 pub extern "C" fn OpenChannelV2_set_commitment_feerate_sat_per_1000_weight(this_ptr: &mut OpenChannelV2, mut val: u32) {
1237 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_feerate_sat_per_1000_weight = val;
1239 /// Part of the channel value contributed by the channel initiator
1241 pub extern "C" fn OpenChannelV2_get_funding_satoshis(this_ptr: &OpenChannelV2) -> u64 {
1242 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
1245 /// Part of the channel value contributed by the channel initiator
1247 pub extern "C" fn OpenChannelV2_set_funding_satoshis(this_ptr: &mut OpenChannelV2, mut val: u64) {
1248 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
1250 /// The threshold below which outputs on transactions broadcast by the channel initiator will be
1253 pub extern "C" fn OpenChannelV2_get_dust_limit_satoshis(this_ptr: &OpenChannelV2) -> u64 {
1254 let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
1257 /// The threshold below which outputs on transactions broadcast by the channel initiator will be
1260 pub extern "C" fn OpenChannelV2_set_dust_limit_satoshis(this_ptr: &mut OpenChannelV2, mut val: u64) {
1261 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
1263 /// The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi
1265 pub extern "C" fn OpenChannelV2_get_max_htlc_value_in_flight_msat(this_ptr: &OpenChannelV2) -> u64 {
1266 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
1269 /// The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi
1271 pub extern "C" fn OpenChannelV2_set_max_htlc_value_in_flight_msat(this_ptr: &mut OpenChannelV2, mut val: u64) {
1272 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
1274 /// The minimum HTLC size incoming to channel initiator, in milli-satoshi
1276 pub extern "C" fn OpenChannelV2_get_htlc_minimum_msat(this_ptr: &OpenChannelV2) -> u64 {
1277 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
1280 /// The minimum HTLC size incoming to channel initiator, in milli-satoshi
1282 pub extern "C" fn OpenChannelV2_set_htlc_minimum_msat(this_ptr: &mut OpenChannelV2, mut val: u64) {
1283 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
1285 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1286 /// broadcast a commitment transaction
1288 pub extern "C" fn OpenChannelV2_get_to_self_delay(this_ptr: &OpenChannelV2) -> u16 {
1289 let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
1292 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1293 /// broadcast a commitment transaction
1295 pub extern "C" fn OpenChannelV2_set_to_self_delay(this_ptr: &mut OpenChannelV2, mut val: u16) {
1296 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
1298 /// The maximum number of inbound HTLCs towards channel initiator
1300 pub extern "C" fn OpenChannelV2_get_max_accepted_htlcs(this_ptr: &OpenChannelV2) -> u16 {
1301 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
1304 /// The maximum number of inbound HTLCs towards channel initiator
1306 pub extern "C" fn OpenChannelV2_set_max_accepted_htlcs(this_ptr: &mut OpenChannelV2, mut val: u16) {
1307 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
1309 /// The locktime for the funding transaction
1311 pub extern "C" fn OpenChannelV2_get_locktime(this_ptr: &OpenChannelV2) -> u32 {
1312 let mut inner_val = &mut this_ptr.get_native_mut_ref().locktime;
1315 /// The locktime for the funding transaction
1317 pub extern "C" fn OpenChannelV2_set_locktime(this_ptr: &mut OpenChannelV2, mut val: u32) {
1318 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.locktime = val;
1320 /// The channel initiator's key controlling the funding transaction
1322 pub extern "C" fn OpenChannelV2_get_funding_pubkey(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1323 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
1324 crate::c_types::PublicKey::from_rust(&inner_val)
1326 /// The channel initiator's key controlling the funding transaction
1328 pub extern "C" fn OpenChannelV2_set_funding_pubkey(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1329 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
1331 /// Used to derive a revocation key for transactions broadcast by counterparty
1333 pub extern "C" fn OpenChannelV2_get_revocation_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1334 let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
1335 crate::c_types::PublicKey::from_rust(&inner_val)
1337 /// Used to derive a revocation key for transactions broadcast by counterparty
1339 pub extern "C" fn OpenChannelV2_set_revocation_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1340 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
1342 /// A payment key to channel initiator for transactions broadcast by counterparty
1344 pub extern "C" fn OpenChannelV2_get_payment_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1345 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_basepoint;
1346 crate::c_types::PublicKey::from_rust(&inner_val)
1348 /// A payment key to channel initiator for transactions broadcast by counterparty
1350 pub extern "C" fn OpenChannelV2_set_payment_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1351 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_basepoint = val.into_rust();
1353 /// Used to derive a payment key to channel initiator for transactions broadcast by channel
1356 pub extern "C" fn OpenChannelV2_get_delayed_payment_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1357 let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
1358 crate::c_types::PublicKey::from_rust(&inner_val)
1360 /// Used to derive a payment key to channel initiator for transactions broadcast by channel
1363 pub extern "C" fn OpenChannelV2_set_delayed_payment_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1364 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
1366 /// Used to derive an HTLC payment key to channel initiator
1368 pub extern "C" fn OpenChannelV2_get_htlc_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1369 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
1370 crate::c_types::PublicKey::from_rust(&inner_val)
1372 /// Used to derive an HTLC payment key to channel initiator
1374 pub extern "C" fn OpenChannelV2_set_htlc_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1375 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
1377 /// The first to-be-broadcast-by-channel-initiator transaction's per commitment point
1379 pub extern "C" fn OpenChannelV2_get_first_per_commitment_point(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1380 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
1381 crate::c_types::PublicKey::from_rust(&inner_val)
1383 /// The first to-be-broadcast-by-channel-initiator transaction's per commitment point
1385 pub extern "C" fn OpenChannelV2_set_first_per_commitment_point(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1386 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
1388 /// The second to-be-broadcast-by-channel-initiator transaction's per commitment point
1390 pub extern "C" fn OpenChannelV2_get_second_per_commitment_point(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1391 let mut inner_val = &mut this_ptr.get_native_mut_ref().second_per_commitment_point;
1392 crate::c_types::PublicKey::from_rust(&inner_val)
1394 /// The second to-be-broadcast-by-channel-initiator transaction's per commitment point
1396 pub extern "C" fn OpenChannelV2_set_second_per_commitment_point(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1397 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.second_per_commitment_point = val.into_rust();
1401 pub extern "C" fn OpenChannelV2_get_channel_flags(this_ptr: &OpenChannelV2) -> u8 {
1402 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_flags;
1407 pub extern "C" fn OpenChannelV2_set_channel_flags(this_ptr: &mut OpenChannelV2, mut val: u8) {
1408 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_flags = val;
1410 /// Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we
1411 /// collaboratively close
1413 pub extern "C" fn OpenChannelV2_get_shutdown_scriptpubkey(this_ptr: &OpenChannelV2) -> crate::c_types::derived::COption_ScriptZ {
1414 let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey;
1415 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ScriptZ::None } else { crate::c_types::derived::COption_ScriptZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().into_bytes().into() }) };
1418 /// Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we
1419 /// collaboratively close
1421 pub extern "C" fn OpenChannelV2_set_shutdown_scriptpubkey(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::derived::COption_ScriptZ) {
1422 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()) }})} };
1423 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val;
1425 /// The channel type that this channel will represent. If none is set, we derive the channel
1426 /// type from the intersection of our feature bits with our counterparty's feature bits from
1427 /// the Init message.
1429 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1431 pub extern "C" fn OpenChannelV2_get_channel_type(this_ptr: &OpenChannelV2) -> crate::lightning::ln::features::ChannelTypeFeatures {
1432 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1433 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 };
1436 /// The channel type that this channel will represent. If none is set, we derive the channel
1437 /// type from the intersection of our feature bits with our counterparty's feature bits from
1438 /// the Init message.
1440 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1442 pub extern "C" fn OpenChannelV2_set_channel_type(this_ptr: &mut OpenChannelV2, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1443 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1444 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1446 /// Optionally, a requirement that only confirmed inputs can be added
1448 pub extern "C" fn OpenChannelV2_get_require_confirmed_inputs(this_ptr: &OpenChannelV2) -> crate::c_types::derived::COption_NoneZ {
1449 let mut inner_val = &mut this_ptr.get_native_mut_ref().require_confirmed_inputs;
1450 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 /* { () /**/ } */ };
1453 /// Optionally, a requirement that only confirmed inputs can be added
1455 pub extern "C" fn OpenChannelV2_set_require_confirmed_inputs(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::derived::COption_NoneZ) {
1456 let mut local_val = if val.is_some() { Some( { () /*val.take()*/ }) } else { None };
1457 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.require_confirmed_inputs = local_val;
1459 /// Constructs a new OpenChannelV2 given each field
1462 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_ScriptZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures, mut require_confirmed_inputs_arg: crate::c_types::derived::COption_NoneZ) -> OpenChannelV2 {
1463 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()) }})} };
1464 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()) } }) };
1465 let mut local_require_confirmed_inputs_arg = if require_confirmed_inputs_arg.is_some() { Some( { () /*require_confirmed_inputs_arg.take()*/ }) } else { None };
1466 OpenChannelV2 { inner: ObjOps::heap_alloc(nativeOpenChannelV2 {
1467 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
1468 temporary_channel_id: temporary_channel_id_arg.data,
1469 funding_feerate_sat_per_1000_weight: funding_feerate_sat_per_1000_weight_arg,
1470 commitment_feerate_sat_per_1000_weight: commitment_feerate_sat_per_1000_weight_arg,
1471 funding_satoshis: funding_satoshis_arg,
1472 dust_limit_satoshis: dust_limit_satoshis_arg,
1473 max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg,
1474 htlc_minimum_msat: htlc_minimum_msat_arg,
1475 to_self_delay: to_self_delay_arg,
1476 max_accepted_htlcs: max_accepted_htlcs_arg,
1477 locktime: locktime_arg,
1478 funding_pubkey: funding_pubkey_arg.into_rust(),
1479 revocation_basepoint: revocation_basepoint_arg.into_rust(),
1480 payment_basepoint: payment_basepoint_arg.into_rust(),
1481 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
1482 htlc_basepoint: htlc_basepoint_arg.into_rust(),
1483 first_per_commitment_point: first_per_commitment_point_arg.into_rust(),
1484 second_per_commitment_point: second_per_commitment_point_arg.into_rust(),
1485 channel_flags: channel_flags_arg,
1486 shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg,
1487 channel_type: local_channel_type_arg,
1488 require_confirmed_inputs: local_require_confirmed_inputs_arg,
1489 }), is_owned: true }
1491 impl Clone for OpenChannelV2 {
1492 fn clone(&self) -> Self {
1494 inner: if <*mut nativeOpenChannelV2>::is_null(self.inner) { core::ptr::null_mut() } else {
1495 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1501 /// Used only if an object of this type is returned as a trait impl by a method
1502 pub(crate) extern "C" fn OpenChannelV2_clone_void(this_ptr: *const c_void) -> *mut c_void {
1503 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOpenChannelV2)).clone() })) as *mut c_void
1506 /// Creates a copy of the OpenChannelV2
1507 pub extern "C" fn OpenChannelV2_clone(orig: &OpenChannelV2) -> OpenChannelV2 {
1510 /// Checks if two OpenChannelV2s contain equal inner contents.
1511 /// This ignores pointers and is_owned flags and looks at the values in fields.
1512 /// Two objects with NULL inner values will be considered "equal" here.
1514 pub extern "C" fn OpenChannelV2_eq(a: &OpenChannelV2, b: &OpenChannelV2) -> bool {
1515 if a.inner == b.inner { return true; }
1516 if a.inner.is_null() || b.inner.is_null() { return false; }
1517 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1520 use lightning::ln::msgs::AcceptChannel as nativeAcceptChannelImport;
1521 pub(crate) type nativeAcceptChannel = nativeAcceptChannelImport;
1523 /// An [`accept_channel`] message to be sent to or received from a peer.
1525 /// Used in V1 channel establishment
1527 /// [`accept_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-accept_channel-message
1530 pub struct AcceptChannel {
1531 /// A pointer to the opaque Rust object.
1533 /// Nearly everywhere, inner must be non-null, however in places where
1534 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1535 pub inner: *mut nativeAcceptChannel,
1536 /// Indicates that this is the only struct which contains the same pointer.
1538 /// Rust functions which take ownership of an object provided via an argument require
1539 /// this to be true and invalidate the object pointed to by inner.
1543 impl Drop for AcceptChannel {
1544 fn drop(&mut self) {
1545 if self.is_owned && !<*mut nativeAcceptChannel>::is_null(self.inner) {
1546 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1550 /// Frees any resources used by the AcceptChannel, if is_owned is set and inner is non-NULL.
1552 pub extern "C" fn AcceptChannel_free(this_obj: AcceptChannel) { }
1554 /// Used only if an object of this type is returned as a trait impl by a method
1555 pub(crate) extern "C" fn AcceptChannel_free_void(this_ptr: *mut c_void) {
1556 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAcceptChannel) };
1559 impl AcceptChannel {
1560 pub(crate) fn get_native_ref(&self) -> &'static nativeAcceptChannel {
1561 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1563 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAcceptChannel {
1564 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1566 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1567 pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannel {
1568 assert!(self.is_owned);
1569 let ret = ObjOps::untweak_ptr(self.inner);
1570 self.inner = core::ptr::null_mut();
1574 /// A temporary channel ID, until the funding outpoint is announced
1576 pub extern "C" fn AcceptChannel_get_temporary_channel_id(this_ptr: &AcceptChannel) -> *const [u8; 32] {
1577 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
1580 /// A temporary channel ID, until the funding outpoint is announced
1582 pub extern "C" fn AcceptChannel_set_temporary_channel_id(this_ptr: &mut AcceptChannel, mut val: crate::c_types::ThirtyTwoBytes) {
1583 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
1585 /// The threshold below which outputs on transactions broadcast by sender will be omitted
1587 pub extern "C" fn AcceptChannel_get_dust_limit_satoshis(this_ptr: &AcceptChannel) -> u64 {
1588 let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
1591 /// The threshold below which outputs on transactions broadcast by sender will be omitted
1593 pub extern "C" fn AcceptChannel_set_dust_limit_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
1594 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
1596 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
1598 pub extern "C" fn AcceptChannel_get_max_htlc_value_in_flight_msat(this_ptr: &AcceptChannel) -> u64 {
1599 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
1602 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
1604 pub extern "C" fn AcceptChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
1605 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
1607 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1609 pub extern "C" fn AcceptChannel_get_channel_reserve_satoshis(this_ptr: &AcceptChannel) -> u64 {
1610 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
1613 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1615 pub extern "C" fn AcceptChannel_set_channel_reserve_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
1616 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
1618 /// The minimum HTLC size incoming to sender, in milli-satoshi
1620 pub extern "C" fn AcceptChannel_get_htlc_minimum_msat(this_ptr: &AcceptChannel) -> u64 {
1621 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
1624 /// The minimum HTLC size incoming to sender, in milli-satoshi
1626 pub extern "C" fn AcceptChannel_set_htlc_minimum_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
1627 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
1629 /// Minimum depth of the funding transaction before the channel is considered open
1631 pub extern "C" fn AcceptChannel_get_minimum_depth(this_ptr: &AcceptChannel) -> u32 {
1632 let mut inner_val = &mut this_ptr.get_native_mut_ref().minimum_depth;
1635 /// Minimum depth of the funding transaction before the channel is considered open
1637 pub extern "C" fn AcceptChannel_set_minimum_depth(this_ptr: &mut AcceptChannel, mut val: u32) {
1638 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.minimum_depth = val;
1640 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
1642 pub extern "C" fn AcceptChannel_get_to_self_delay(this_ptr: &AcceptChannel) -> u16 {
1643 let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
1646 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
1648 pub extern "C" fn AcceptChannel_set_to_self_delay(this_ptr: &mut AcceptChannel, mut val: u16) {
1649 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
1651 /// The maximum number of inbound HTLCs towards sender
1653 pub extern "C" fn AcceptChannel_get_max_accepted_htlcs(this_ptr: &AcceptChannel) -> u16 {
1654 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
1657 /// The maximum number of inbound HTLCs towards sender
1659 pub extern "C" fn AcceptChannel_set_max_accepted_htlcs(this_ptr: &mut AcceptChannel, mut val: u16) {
1660 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
1662 /// The sender's key controlling the funding transaction
1664 pub extern "C" fn AcceptChannel_get_funding_pubkey(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1665 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
1666 crate::c_types::PublicKey::from_rust(&inner_val)
1668 /// The sender's key controlling the funding transaction
1670 pub extern "C" fn AcceptChannel_set_funding_pubkey(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1671 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
1673 /// Used to derive a revocation key for transactions broadcast by counterparty
1675 pub extern "C" fn AcceptChannel_get_revocation_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1676 let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
1677 crate::c_types::PublicKey::from_rust(&inner_val)
1679 /// Used to derive a revocation key for transactions broadcast by counterparty
1681 pub extern "C" fn AcceptChannel_set_revocation_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1682 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
1684 /// A payment key to sender for transactions broadcast by counterparty
1686 pub extern "C" fn AcceptChannel_get_payment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1687 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_point;
1688 crate::c_types::PublicKey::from_rust(&inner_val)
1690 /// A payment key to sender for transactions broadcast by counterparty
1692 pub extern "C" fn AcceptChannel_set_payment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1693 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_point = val.into_rust();
1695 /// Used to derive a payment key to sender for transactions broadcast by sender
1697 pub extern "C" fn AcceptChannel_get_delayed_payment_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1698 let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
1699 crate::c_types::PublicKey::from_rust(&inner_val)
1701 /// Used to derive a payment key to sender for transactions broadcast by sender
1703 pub extern "C" fn AcceptChannel_set_delayed_payment_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1704 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
1706 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
1708 pub extern "C" fn AcceptChannel_get_htlc_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1709 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
1710 crate::c_types::PublicKey::from_rust(&inner_val)
1712 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
1714 pub extern "C" fn AcceptChannel_set_htlc_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1715 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
1717 /// The first to-be-broadcast-by-sender transaction's per commitment point
1719 pub extern "C" fn AcceptChannel_get_first_per_commitment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1720 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
1721 crate::c_types::PublicKey::from_rust(&inner_val)
1723 /// The first to-be-broadcast-by-sender transaction's per commitment point
1725 pub extern "C" fn AcceptChannel_set_first_per_commitment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1726 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
1728 /// A request to pre-set the to-sender output's scriptPubkey for when we collaboratively close
1730 pub extern "C" fn AcceptChannel_get_shutdown_scriptpubkey(this_ptr: &AcceptChannel) -> crate::c_types::derived::COption_ScriptZ {
1731 let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey;
1732 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ScriptZ::None } else { crate::c_types::derived::COption_ScriptZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().into_bytes().into() }) };
1735 /// A request to pre-set the to-sender output's scriptPubkey for when we collaboratively close
1737 pub extern "C" fn AcceptChannel_set_shutdown_scriptpubkey(this_ptr: &mut AcceptChannel, mut val: crate::c_types::derived::COption_ScriptZ) {
1738 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()) }})} };
1739 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val;
1741 /// The channel type that this channel will represent.
1743 /// If this is `None`, we derive the channel type from the intersection of
1744 /// our feature bits with our counterparty's feature bits from the [`Init`] message.
1745 /// This is required to match the equivalent field in [`OpenChannel::channel_type`].
1747 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1749 pub extern "C" fn AcceptChannel_get_channel_type(this_ptr: &AcceptChannel) -> crate::lightning::ln::features::ChannelTypeFeatures {
1750 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1751 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 };
1754 /// The channel type that this channel will represent.
1756 /// If this is `None`, we derive the channel type from the intersection of
1757 /// our feature bits with our counterparty's feature bits from the [`Init`] message.
1758 /// This is required to match the equivalent field in [`OpenChannel::channel_type`].
1760 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1762 pub extern "C" fn AcceptChannel_set_channel_type(this_ptr: &mut AcceptChannel, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1763 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1764 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1766 /// Constructs a new AcceptChannel given each field
1769 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_ScriptZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures) -> AcceptChannel {
1770 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()) }})} };
1771 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()) } }) };
1772 AcceptChannel { inner: ObjOps::heap_alloc(nativeAcceptChannel {
1773 temporary_channel_id: temporary_channel_id_arg.data,
1774 dust_limit_satoshis: dust_limit_satoshis_arg,
1775 max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg,
1776 channel_reserve_satoshis: channel_reserve_satoshis_arg,
1777 htlc_minimum_msat: htlc_minimum_msat_arg,
1778 minimum_depth: minimum_depth_arg,
1779 to_self_delay: to_self_delay_arg,
1780 max_accepted_htlcs: max_accepted_htlcs_arg,
1781 funding_pubkey: funding_pubkey_arg.into_rust(),
1782 revocation_basepoint: revocation_basepoint_arg.into_rust(),
1783 payment_point: payment_point_arg.into_rust(),
1784 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
1785 htlc_basepoint: htlc_basepoint_arg.into_rust(),
1786 first_per_commitment_point: first_per_commitment_point_arg.into_rust(),
1787 shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg,
1788 channel_type: local_channel_type_arg,
1789 }), is_owned: true }
1791 impl Clone for AcceptChannel {
1792 fn clone(&self) -> Self {
1794 inner: if <*mut nativeAcceptChannel>::is_null(self.inner) { core::ptr::null_mut() } else {
1795 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1801 /// Used only if an object of this type is returned as a trait impl by a method
1802 pub(crate) extern "C" fn AcceptChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
1803 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAcceptChannel)).clone() })) as *mut c_void
1806 /// Creates a copy of the AcceptChannel
1807 pub extern "C" fn AcceptChannel_clone(orig: &AcceptChannel) -> AcceptChannel {
1810 /// Checks if two AcceptChannels contain equal inner contents.
1811 /// This ignores pointers and is_owned flags and looks at the values in fields.
1812 /// Two objects with NULL inner values will be considered "equal" here.
1814 pub extern "C" fn AcceptChannel_eq(a: &AcceptChannel, b: &AcceptChannel) -> bool {
1815 if a.inner == b.inner { return true; }
1816 if a.inner.is_null() || b.inner.is_null() { return false; }
1817 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1820 use lightning::ln::msgs::AcceptChannelV2 as nativeAcceptChannelV2Import;
1821 pub(crate) type nativeAcceptChannelV2 = nativeAcceptChannelV2Import;
1823 /// An accept_channel2 message to be sent by or received from the channel accepter.
1825 /// Used in V2 channel establishment
1829 pub struct AcceptChannelV2 {
1830 /// A pointer to the opaque Rust object.
1832 /// Nearly everywhere, inner must be non-null, however in places where
1833 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1834 pub inner: *mut nativeAcceptChannelV2,
1835 /// Indicates that this is the only struct which contains the same pointer.
1837 /// Rust functions which take ownership of an object provided via an argument require
1838 /// this to be true and invalidate the object pointed to by inner.
1842 impl Drop for AcceptChannelV2 {
1843 fn drop(&mut self) {
1844 if self.is_owned && !<*mut nativeAcceptChannelV2>::is_null(self.inner) {
1845 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1849 /// Frees any resources used by the AcceptChannelV2, if is_owned is set and inner is non-NULL.
1851 pub extern "C" fn AcceptChannelV2_free(this_obj: AcceptChannelV2) { }
1853 /// Used only if an object of this type is returned as a trait impl by a method
1854 pub(crate) extern "C" fn AcceptChannelV2_free_void(this_ptr: *mut c_void) {
1855 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAcceptChannelV2) };
1858 impl AcceptChannelV2 {
1859 pub(crate) fn get_native_ref(&self) -> &'static nativeAcceptChannelV2 {
1860 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1862 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAcceptChannelV2 {
1863 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1865 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1866 pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannelV2 {
1867 assert!(self.is_owned);
1868 let ret = ObjOps::untweak_ptr(self.inner);
1869 self.inner = core::ptr::null_mut();
1873 /// The same `temporary_channel_id` received from the initiator's `open_channel2` message.
1875 pub extern "C" fn AcceptChannelV2_get_temporary_channel_id(this_ptr: &AcceptChannelV2) -> *const [u8; 32] {
1876 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
1879 /// The same `temporary_channel_id` received from the initiator's `open_channel2` message.
1881 pub extern "C" fn AcceptChannelV2_set_temporary_channel_id(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::ThirtyTwoBytes) {
1882 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
1884 /// Part of the channel value contributed by the channel acceptor
1886 pub extern "C" fn AcceptChannelV2_get_funding_satoshis(this_ptr: &AcceptChannelV2) -> u64 {
1887 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
1890 /// Part of the channel value contributed by the channel acceptor
1892 pub extern "C" fn AcceptChannelV2_set_funding_satoshis(this_ptr: &mut AcceptChannelV2, mut val: u64) {
1893 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
1895 /// The threshold below which outputs on transactions broadcast by the channel acceptor will be
1898 pub extern "C" fn AcceptChannelV2_get_dust_limit_satoshis(this_ptr: &AcceptChannelV2) -> u64 {
1899 let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
1902 /// The threshold below which outputs on transactions broadcast by the channel acceptor will be
1905 pub extern "C" fn AcceptChannelV2_set_dust_limit_satoshis(this_ptr: &mut AcceptChannelV2, mut val: u64) {
1906 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
1908 /// The maximum inbound HTLC value in flight towards channel acceptor, in milli-satoshi
1910 pub extern "C" fn AcceptChannelV2_get_max_htlc_value_in_flight_msat(this_ptr: &AcceptChannelV2) -> u64 {
1911 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
1914 /// The maximum inbound HTLC value in flight towards channel acceptor, in milli-satoshi
1916 pub extern "C" fn AcceptChannelV2_set_max_htlc_value_in_flight_msat(this_ptr: &mut AcceptChannelV2, mut val: u64) {
1917 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
1919 /// The minimum HTLC size incoming to channel acceptor, in milli-satoshi
1921 pub extern "C" fn AcceptChannelV2_get_htlc_minimum_msat(this_ptr: &AcceptChannelV2) -> u64 {
1922 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
1925 /// The minimum HTLC size incoming to channel acceptor, in milli-satoshi
1927 pub extern "C" fn AcceptChannelV2_set_htlc_minimum_msat(this_ptr: &mut AcceptChannelV2, mut val: u64) {
1928 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
1930 /// Minimum depth of the funding transaction before the channel is considered open
1932 pub extern "C" fn AcceptChannelV2_get_minimum_depth(this_ptr: &AcceptChannelV2) -> u32 {
1933 let mut inner_val = &mut this_ptr.get_native_mut_ref().minimum_depth;
1936 /// Minimum depth of the funding transaction before the channel is considered open
1938 pub extern "C" fn AcceptChannelV2_set_minimum_depth(this_ptr: &mut AcceptChannelV2, mut val: u32) {
1939 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.minimum_depth = val;
1941 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1942 /// broadcast a commitment transaction
1944 pub extern "C" fn AcceptChannelV2_get_to_self_delay(this_ptr: &AcceptChannelV2) -> u16 {
1945 let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
1948 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1949 /// broadcast a commitment transaction
1951 pub extern "C" fn AcceptChannelV2_set_to_self_delay(this_ptr: &mut AcceptChannelV2, mut val: u16) {
1952 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
1954 /// The maximum number of inbound HTLCs towards channel acceptor
1956 pub extern "C" fn AcceptChannelV2_get_max_accepted_htlcs(this_ptr: &AcceptChannelV2) -> u16 {
1957 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
1960 /// The maximum number of inbound HTLCs towards channel acceptor
1962 pub extern "C" fn AcceptChannelV2_set_max_accepted_htlcs(this_ptr: &mut AcceptChannelV2, mut val: u16) {
1963 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
1965 /// The channel acceptor's key controlling the funding transaction
1967 pub extern "C" fn AcceptChannelV2_get_funding_pubkey(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
1968 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
1969 crate::c_types::PublicKey::from_rust(&inner_val)
1971 /// The channel acceptor's key controlling the funding transaction
1973 pub extern "C" fn AcceptChannelV2_set_funding_pubkey(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
1974 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
1976 /// Used to derive a revocation key for transactions broadcast by counterparty
1978 pub extern "C" fn AcceptChannelV2_get_revocation_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
1979 let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
1980 crate::c_types::PublicKey::from_rust(&inner_val)
1982 /// Used to derive a revocation key for transactions broadcast by counterparty
1984 pub extern "C" fn AcceptChannelV2_set_revocation_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
1985 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
1987 /// A payment key to channel acceptor for transactions broadcast by counterparty
1989 pub extern "C" fn AcceptChannelV2_get_payment_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
1990 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_basepoint;
1991 crate::c_types::PublicKey::from_rust(&inner_val)
1993 /// A payment key to channel acceptor for transactions broadcast by counterparty
1995 pub extern "C" fn AcceptChannelV2_set_payment_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
1996 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_basepoint = val.into_rust();
1998 /// Used to derive a payment key to channel acceptor for transactions broadcast by channel
2001 pub extern "C" fn AcceptChannelV2_get_delayed_payment_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2002 let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
2003 crate::c_types::PublicKey::from_rust(&inner_val)
2005 /// Used to derive a payment key to channel acceptor for transactions broadcast by channel
2008 pub extern "C" fn AcceptChannelV2_set_delayed_payment_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2009 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
2011 /// Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty
2013 pub extern "C" fn AcceptChannelV2_get_htlc_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2014 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
2015 crate::c_types::PublicKey::from_rust(&inner_val)
2017 /// Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty
2019 pub extern "C" fn AcceptChannelV2_set_htlc_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2020 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
2022 /// The first to-be-broadcast-by-channel-acceptor transaction's per commitment point
2024 pub extern "C" fn AcceptChannelV2_get_first_per_commitment_point(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2025 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
2026 crate::c_types::PublicKey::from_rust(&inner_val)
2028 /// The first to-be-broadcast-by-channel-acceptor transaction's per commitment point
2030 pub extern "C" fn AcceptChannelV2_set_first_per_commitment_point(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2031 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
2033 /// The second to-be-broadcast-by-channel-acceptor transaction's per commitment point
2035 pub extern "C" fn AcceptChannelV2_get_second_per_commitment_point(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2036 let mut inner_val = &mut this_ptr.get_native_mut_ref().second_per_commitment_point;
2037 crate::c_types::PublicKey::from_rust(&inner_val)
2039 /// The second to-be-broadcast-by-channel-acceptor transaction's per commitment point
2041 pub extern "C" fn AcceptChannelV2_set_second_per_commitment_point(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2042 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.second_per_commitment_point = val.into_rust();
2044 /// Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we
2045 /// collaboratively close
2047 pub extern "C" fn AcceptChannelV2_get_shutdown_scriptpubkey(this_ptr: &AcceptChannelV2) -> crate::c_types::derived::COption_ScriptZ {
2048 let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey;
2049 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ScriptZ::None } else { crate::c_types::derived::COption_ScriptZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().into_bytes().into() }) };
2052 /// Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we
2053 /// collaboratively close
2055 pub extern "C" fn AcceptChannelV2_set_shutdown_scriptpubkey(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::derived::COption_ScriptZ) {
2056 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()) }})} };
2057 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val;
2059 /// The channel type that this channel will represent. If none is set, we derive the channel
2060 /// type from the intersection of our feature bits with our counterparty's feature bits from
2061 /// the Init message.
2063 /// This is required to match the equivalent field in [`OpenChannelV2::channel_type`].
2065 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
2067 pub extern "C" fn AcceptChannelV2_get_channel_type(this_ptr: &AcceptChannelV2) -> crate::lightning::ln::features::ChannelTypeFeatures {
2068 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
2069 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 };
2072 /// The channel type that this channel will represent. If none is set, we derive the channel
2073 /// type from the intersection of our feature bits with our counterparty's feature bits from
2074 /// the Init message.
2076 /// This is required to match the equivalent field in [`OpenChannelV2::channel_type`].
2078 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
2080 pub extern "C" fn AcceptChannelV2_set_channel_type(this_ptr: &mut AcceptChannelV2, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
2081 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
2082 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
2084 /// Optionally, a requirement that only confirmed inputs can be added
2086 pub extern "C" fn AcceptChannelV2_get_require_confirmed_inputs(this_ptr: &AcceptChannelV2) -> crate::c_types::derived::COption_NoneZ {
2087 let mut inner_val = &mut this_ptr.get_native_mut_ref().require_confirmed_inputs;
2088 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 /* { () /**/ } */ };
2091 /// Optionally, a requirement that only confirmed inputs can be added
2093 pub extern "C" fn AcceptChannelV2_set_require_confirmed_inputs(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::derived::COption_NoneZ) {
2094 let mut local_val = if val.is_some() { Some( { () /*val.take()*/ }) } else { None };
2095 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.require_confirmed_inputs = local_val;
2097 /// Constructs a new AcceptChannelV2 given each field
2100 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_ScriptZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures, mut require_confirmed_inputs_arg: crate::c_types::derived::COption_NoneZ) -> AcceptChannelV2 {
2101 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()) }})} };
2102 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()) } }) };
2103 let mut local_require_confirmed_inputs_arg = if require_confirmed_inputs_arg.is_some() { Some( { () /*require_confirmed_inputs_arg.take()*/ }) } else { None };
2104 AcceptChannelV2 { inner: ObjOps::heap_alloc(nativeAcceptChannelV2 {
2105 temporary_channel_id: temporary_channel_id_arg.data,
2106 funding_satoshis: funding_satoshis_arg,
2107 dust_limit_satoshis: dust_limit_satoshis_arg,
2108 max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg,
2109 htlc_minimum_msat: htlc_minimum_msat_arg,
2110 minimum_depth: minimum_depth_arg,
2111 to_self_delay: to_self_delay_arg,
2112 max_accepted_htlcs: max_accepted_htlcs_arg,
2113 funding_pubkey: funding_pubkey_arg.into_rust(),
2114 revocation_basepoint: revocation_basepoint_arg.into_rust(),
2115 payment_basepoint: payment_basepoint_arg.into_rust(),
2116 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
2117 htlc_basepoint: htlc_basepoint_arg.into_rust(),
2118 first_per_commitment_point: first_per_commitment_point_arg.into_rust(),
2119 second_per_commitment_point: second_per_commitment_point_arg.into_rust(),
2120 shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg,
2121 channel_type: local_channel_type_arg,
2122 require_confirmed_inputs: local_require_confirmed_inputs_arg,
2123 }), is_owned: true }
2125 impl Clone for AcceptChannelV2 {
2126 fn clone(&self) -> Self {
2128 inner: if <*mut nativeAcceptChannelV2>::is_null(self.inner) { core::ptr::null_mut() } else {
2129 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2135 /// Used only if an object of this type is returned as a trait impl by a method
2136 pub(crate) extern "C" fn AcceptChannelV2_clone_void(this_ptr: *const c_void) -> *mut c_void {
2137 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAcceptChannelV2)).clone() })) as *mut c_void
2140 /// Creates a copy of the AcceptChannelV2
2141 pub extern "C" fn AcceptChannelV2_clone(orig: &AcceptChannelV2) -> AcceptChannelV2 {
2144 /// Checks if two AcceptChannelV2s contain equal inner contents.
2145 /// This ignores pointers and is_owned flags and looks at the values in fields.
2146 /// Two objects with NULL inner values will be considered "equal" here.
2148 pub extern "C" fn AcceptChannelV2_eq(a: &AcceptChannelV2, b: &AcceptChannelV2) -> bool {
2149 if a.inner == b.inner { return true; }
2150 if a.inner.is_null() || b.inner.is_null() { return false; }
2151 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2154 use lightning::ln::msgs::FundingCreated as nativeFundingCreatedImport;
2155 pub(crate) type nativeFundingCreated = nativeFundingCreatedImport;
2157 /// A [`funding_created`] message to be sent to or received from a peer.
2159 /// Used in V1 channel establishment
2161 /// [`funding_created`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_created-message
2164 pub struct FundingCreated {
2165 /// A pointer to the opaque Rust object.
2167 /// Nearly everywhere, inner must be non-null, however in places where
2168 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2169 pub inner: *mut nativeFundingCreated,
2170 /// Indicates that this is the only struct which contains the same pointer.
2172 /// Rust functions which take ownership of an object provided via an argument require
2173 /// this to be true and invalidate the object pointed to by inner.
2177 impl Drop for FundingCreated {
2178 fn drop(&mut self) {
2179 if self.is_owned && !<*mut nativeFundingCreated>::is_null(self.inner) {
2180 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2184 /// Frees any resources used by the FundingCreated, if is_owned is set and inner is non-NULL.
2186 pub extern "C" fn FundingCreated_free(this_obj: FundingCreated) { }
2188 /// Used only if an object of this type is returned as a trait impl by a method
2189 pub(crate) extern "C" fn FundingCreated_free_void(this_ptr: *mut c_void) {
2190 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeFundingCreated) };
2193 impl FundingCreated {
2194 pub(crate) fn get_native_ref(&self) -> &'static nativeFundingCreated {
2195 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2197 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingCreated {
2198 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2200 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2201 pub(crate) fn take_inner(mut self) -> *mut nativeFundingCreated {
2202 assert!(self.is_owned);
2203 let ret = ObjOps::untweak_ptr(self.inner);
2204 self.inner = core::ptr::null_mut();
2208 /// A temporary channel ID, until the funding is established
2210 pub extern "C" fn FundingCreated_get_temporary_channel_id(this_ptr: &FundingCreated) -> *const [u8; 32] {
2211 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
2214 /// A temporary channel ID, until the funding is established
2216 pub extern "C" fn FundingCreated_set_temporary_channel_id(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
2217 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
2219 /// The funding transaction ID
2221 pub extern "C" fn FundingCreated_get_funding_txid(this_ptr: &FundingCreated) -> *const [u8; 32] {
2222 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_txid;
2223 inner_val.as_inner()
2225 /// The funding transaction ID
2227 pub extern "C" fn FundingCreated_set_funding_txid(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
2228 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_txid = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
2230 /// The specific output index funding this channel
2232 pub extern "C" fn FundingCreated_get_funding_output_index(this_ptr: &FundingCreated) -> u16 {
2233 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_index;
2236 /// The specific output index funding this channel
2238 pub extern "C" fn FundingCreated_set_funding_output_index(this_ptr: &mut FundingCreated, mut val: u16) {
2239 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_index = val;
2241 /// The signature of the channel initiator (funder) on the initial commitment transaction
2243 pub extern "C" fn FundingCreated_get_signature(this_ptr: &FundingCreated) -> crate::c_types::Signature {
2244 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
2245 crate::c_types::Signature::from_rust(&inner_val)
2247 /// The signature of the channel initiator (funder) on the initial commitment transaction
2249 pub extern "C" fn FundingCreated_set_signature(this_ptr: &mut FundingCreated, mut val: crate::c_types::Signature) {
2250 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
2252 /// Constructs a new FundingCreated given each field
2255 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::Signature) -> FundingCreated {
2256 FundingCreated { inner: ObjOps::heap_alloc(nativeFundingCreated {
2257 temporary_channel_id: temporary_channel_id_arg.data,
2258 funding_txid: ::bitcoin::hash_types::Txid::from_slice(&funding_txid_arg.data[..]).unwrap(),
2259 funding_output_index: funding_output_index_arg,
2260 signature: signature_arg.into_rust(),
2261 }), is_owned: true }
2263 impl Clone for FundingCreated {
2264 fn clone(&self) -> Self {
2266 inner: if <*mut nativeFundingCreated>::is_null(self.inner) { core::ptr::null_mut() } else {
2267 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2273 /// Used only if an object of this type is returned as a trait impl by a method
2274 pub(crate) extern "C" fn FundingCreated_clone_void(this_ptr: *const c_void) -> *mut c_void {
2275 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingCreated)).clone() })) as *mut c_void
2278 /// Creates a copy of the FundingCreated
2279 pub extern "C" fn FundingCreated_clone(orig: &FundingCreated) -> FundingCreated {
2282 /// Checks if two FundingCreateds contain equal inner contents.
2283 /// This ignores pointers and is_owned flags and looks at the values in fields.
2284 /// Two objects with NULL inner values will be considered "equal" here.
2286 pub extern "C" fn FundingCreated_eq(a: &FundingCreated, b: &FundingCreated) -> bool {
2287 if a.inner == b.inner { return true; }
2288 if a.inner.is_null() || b.inner.is_null() { return false; }
2289 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2292 use lightning::ln::msgs::FundingSigned as nativeFundingSignedImport;
2293 pub(crate) type nativeFundingSigned = nativeFundingSignedImport;
2295 /// A [`funding_signed`] message to be sent to or received from a peer.
2297 /// Used in V1 channel establishment
2299 /// [`funding_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_signed-message
2302 pub struct FundingSigned {
2303 /// A pointer to the opaque Rust object.
2305 /// Nearly everywhere, inner must be non-null, however in places where
2306 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2307 pub inner: *mut nativeFundingSigned,
2308 /// Indicates that this is the only struct which contains the same pointer.
2310 /// Rust functions which take ownership of an object provided via an argument require
2311 /// this to be true and invalidate the object pointed to by inner.
2315 impl Drop for FundingSigned {
2316 fn drop(&mut self) {
2317 if self.is_owned && !<*mut nativeFundingSigned>::is_null(self.inner) {
2318 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2322 /// Frees any resources used by the FundingSigned, if is_owned is set and inner is non-NULL.
2324 pub extern "C" fn FundingSigned_free(this_obj: FundingSigned) { }
2326 /// Used only if an object of this type is returned as a trait impl by a method
2327 pub(crate) extern "C" fn FundingSigned_free_void(this_ptr: *mut c_void) {
2328 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeFundingSigned) };
2331 impl FundingSigned {
2332 pub(crate) fn get_native_ref(&self) -> &'static nativeFundingSigned {
2333 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2335 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingSigned {
2336 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2338 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2339 pub(crate) fn take_inner(mut self) -> *mut nativeFundingSigned {
2340 assert!(self.is_owned);
2341 let ret = ObjOps::untweak_ptr(self.inner);
2342 self.inner = core::ptr::null_mut();
2348 pub extern "C" fn FundingSigned_get_channel_id(this_ptr: &FundingSigned) -> *const [u8; 32] {
2349 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2354 pub extern "C" fn FundingSigned_set_channel_id(this_ptr: &mut FundingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
2355 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2357 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
2359 pub extern "C" fn FundingSigned_get_signature(this_ptr: &FundingSigned) -> crate::c_types::Signature {
2360 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
2361 crate::c_types::Signature::from_rust(&inner_val)
2363 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
2365 pub extern "C" fn FundingSigned_set_signature(this_ptr: &mut FundingSigned, mut val: crate::c_types::Signature) {
2366 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
2368 /// Constructs a new FundingSigned given each field
2371 pub extern "C" fn FundingSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut signature_arg: crate::c_types::Signature) -> FundingSigned {
2372 FundingSigned { inner: ObjOps::heap_alloc(nativeFundingSigned {
2373 channel_id: channel_id_arg.data,
2374 signature: signature_arg.into_rust(),
2375 }), is_owned: true }
2377 impl Clone for FundingSigned {
2378 fn clone(&self) -> Self {
2380 inner: if <*mut nativeFundingSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
2381 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2387 /// Used only if an object of this type is returned as a trait impl by a method
2388 pub(crate) extern "C" fn FundingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
2389 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingSigned)).clone() })) as *mut c_void
2392 /// Creates a copy of the FundingSigned
2393 pub extern "C" fn FundingSigned_clone(orig: &FundingSigned) -> FundingSigned {
2396 /// Checks if two FundingSigneds contain equal inner contents.
2397 /// This ignores pointers and is_owned flags and looks at the values in fields.
2398 /// Two objects with NULL inner values will be considered "equal" here.
2400 pub extern "C" fn FundingSigned_eq(a: &FundingSigned, b: &FundingSigned) -> bool {
2401 if a.inner == b.inner { return true; }
2402 if a.inner.is_null() || b.inner.is_null() { return false; }
2403 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2406 use lightning::ln::msgs::ChannelReady as nativeChannelReadyImport;
2407 pub(crate) type nativeChannelReady = nativeChannelReadyImport;
2409 /// A [`channel_ready`] message to be sent to or received from a peer.
2411 /// [`channel_ready`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-channel_ready-message
2414 pub struct ChannelReady {
2415 /// A pointer to the opaque Rust object.
2417 /// Nearly everywhere, inner must be non-null, however in places where
2418 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2419 pub inner: *mut nativeChannelReady,
2420 /// Indicates that this is the only struct which contains the same pointer.
2422 /// Rust functions which take ownership of an object provided via an argument require
2423 /// this to be true and invalidate the object pointed to by inner.
2427 impl Drop for ChannelReady {
2428 fn drop(&mut self) {
2429 if self.is_owned && !<*mut nativeChannelReady>::is_null(self.inner) {
2430 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2434 /// Frees any resources used by the ChannelReady, if is_owned is set and inner is non-NULL.
2436 pub extern "C" fn ChannelReady_free(this_obj: ChannelReady) { }
2438 /// Used only if an object of this type is returned as a trait impl by a method
2439 pub(crate) extern "C" fn ChannelReady_free_void(this_ptr: *mut c_void) {
2440 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelReady) };
2444 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelReady {
2445 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2447 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelReady {
2448 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2450 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2451 pub(crate) fn take_inner(mut self) -> *mut nativeChannelReady {
2452 assert!(self.is_owned);
2453 let ret = ObjOps::untweak_ptr(self.inner);
2454 self.inner = core::ptr::null_mut();
2460 pub extern "C" fn ChannelReady_get_channel_id(this_ptr: &ChannelReady) -> *const [u8; 32] {
2461 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2466 pub extern "C" fn ChannelReady_set_channel_id(this_ptr: &mut ChannelReady, mut val: crate::c_types::ThirtyTwoBytes) {
2467 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2469 /// The per-commitment point of the second commitment transaction
2471 pub extern "C" fn ChannelReady_get_next_per_commitment_point(this_ptr: &ChannelReady) -> crate::c_types::PublicKey {
2472 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
2473 crate::c_types::PublicKey::from_rust(&inner_val)
2475 /// The per-commitment point of the second commitment transaction
2477 pub extern "C" fn ChannelReady_set_next_per_commitment_point(this_ptr: &mut ChannelReady, mut val: crate::c_types::PublicKey) {
2478 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
2480 /// If set, provides a `short_channel_id` alias for this channel.
2482 /// The sender will accept payments to be forwarded over this SCID and forward them to this
2483 /// messages' recipient.
2485 pub extern "C" fn ChannelReady_get_short_channel_id_alias(this_ptr: &ChannelReady) -> crate::c_types::derived::COption_u64Z {
2486 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id_alias;
2487 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() }) };
2490 /// If set, provides a `short_channel_id` alias for this channel.
2492 /// The sender will accept payments to be forwarded over this SCID and forward them to this
2493 /// messages' recipient.
2495 pub extern "C" fn ChannelReady_set_short_channel_id_alias(this_ptr: &mut ChannelReady, mut val: crate::c_types::derived::COption_u64Z) {
2496 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
2497 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id_alias = local_val;
2499 /// Constructs a new ChannelReady given each field
2502 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 {
2503 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 };
2504 ChannelReady { inner: ObjOps::heap_alloc(nativeChannelReady {
2505 channel_id: channel_id_arg.data,
2506 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
2507 short_channel_id_alias: local_short_channel_id_alias_arg,
2508 }), is_owned: true }
2510 impl Clone for ChannelReady {
2511 fn clone(&self) -> Self {
2513 inner: if <*mut nativeChannelReady>::is_null(self.inner) { core::ptr::null_mut() } else {
2514 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2520 /// Used only if an object of this type is returned as a trait impl by a method
2521 pub(crate) extern "C" fn ChannelReady_clone_void(this_ptr: *const c_void) -> *mut c_void {
2522 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelReady)).clone() })) as *mut c_void
2525 /// Creates a copy of the ChannelReady
2526 pub extern "C" fn ChannelReady_clone(orig: &ChannelReady) -> ChannelReady {
2529 /// Checks if two ChannelReadys contain equal inner contents.
2530 /// This ignores pointers and is_owned flags and looks at the values in fields.
2531 /// Two objects with NULL inner values will be considered "equal" here.
2533 pub extern "C" fn ChannelReady_eq(a: &ChannelReady, b: &ChannelReady) -> bool {
2534 if a.inner == b.inner { return true; }
2535 if a.inner.is_null() || b.inner.is_null() { return false; }
2536 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2539 use lightning::ln::msgs::TxAddInput as nativeTxAddInputImport;
2540 pub(crate) type nativeTxAddInput = nativeTxAddInputImport;
2542 /// A tx_add_input message for adding an input during interactive transaction construction
2546 pub struct TxAddInput {
2547 /// A pointer to the opaque Rust object.
2549 /// Nearly everywhere, inner must be non-null, however in places where
2550 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2551 pub inner: *mut nativeTxAddInput,
2552 /// Indicates that this is the only struct which contains the same pointer.
2554 /// Rust functions which take ownership of an object provided via an argument require
2555 /// this to be true and invalidate the object pointed to by inner.
2559 impl Drop for TxAddInput {
2560 fn drop(&mut self) {
2561 if self.is_owned && !<*mut nativeTxAddInput>::is_null(self.inner) {
2562 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2566 /// Frees any resources used by the TxAddInput, if is_owned is set and inner is non-NULL.
2568 pub extern "C" fn TxAddInput_free(this_obj: TxAddInput) { }
2570 /// Used only if an object of this type is returned as a trait impl by a method
2571 pub(crate) extern "C" fn TxAddInput_free_void(this_ptr: *mut c_void) {
2572 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAddInput) };
2576 pub(crate) fn get_native_ref(&self) -> &'static nativeTxAddInput {
2577 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2579 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAddInput {
2580 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2582 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2583 pub(crate) fn take_inner(mut self) -> *mut nativeTxAddInput {
2584 assert!(self.is_owned);
2585 let ret = ObjOps::untweak_ptr(self.inner);
2586 self.inner = core::ptr::null_mut();
2592 pub extern "C" fn TxAddInput_get_channel_id(this_ptr: &TxAddInput) -> *const [u8; 32] {
2593 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2598 pub extern "C" fn TxAddInput_set_channel_id(this_ptr: &mut TxAddInput, mut val: crate::c_types::ThirtyTwoBytes) {
2599 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2601 /// A randomly chosen unique identifier for this input, which is even for initiators and odd for
2604 pub extern "C" fn TxAddInput_get_serial_id(this_ptr: &TxAddInput) -> u64 {
2605 let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
2608 /// A randomly chosen unique identifier for this input, which is even for initiators and odd for
2611 pub extern "C" fn TxAddInput_set_serial_id(this_ptr: &mut TxAddInput, mut val: u64) {
2612 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
2614 /// Serialized transaction that contains the output this input spends to verify that it is non
2617 pub extern "C" fn TxAddInput_get_prevtx(this_ptr: &TxAddInput) -> crate::lightning::util::ser::TransactionU16LenLimited {
2618 let mut inner_val = &mut this_ptr.get_native_mut_ref().prevtx;
2619 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 }
2621 /// Serialized transaction that contains the output this input spends to verify that it is non
2624 pub extern "C" fn TxAddInput_set_prevtx(this_ptr: &mut TxAddInput, mut val: crate::lightning::util::ser::TransactionU16LenLimited) {
2625 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.prevtx = *unsafe { Box::from_raw(val.take_inner()) };
2627 /// The index of the output being spent
2629 pub extern "C" fn TxAddInput_get_prevtx_out(this_ptr: &TxAddInput) -> u32 {
2630 let mut inner_val = &mut this_ptr.get_native_mut_ref().prevtx_out;
2633 /// The index of the output being spent
2635 pub extern "C" fn TxAddInput_set_prevtx_out(this_ptr: &mut TxAddInput, mut val: u32) {
2636 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.prevtx_out = val;
2638 /// The sequence number of this input
2640 pub extern "C" fn TxAddInput_get_sequence(this_ptr: &TxAddInput) -> u32 {
2641 let mut inner_val = &mut this_ptr.get_native_mut_ref().sequence;
2644 /// The sequence number of this input
2646 pub extern "C" fn TxAddInput_set_sequence(this_ptr: &mut TxAddInput, mut val: u32) {
2647 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sequence = val;
2649 /// Constructs a new TxAddInput given each field
2652 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 {
2653 TxAddInput { inner: ObjOps::heap_alloc(nativeTxAddInput {
2654 channel_id: channel_id_arg.data,
2655 serial_id: serial_id_arg,
2656 prevtx: *unsafe { Box::from_raw(prevtx_arg.take_inner()) },
2657 prevtx_out: prevtx_out_arg,
2658 sequence: sequence_arg,
2659 }), is_owned: true }
2661 impl Clone for TxAddInput {
2662 fn clone(&self) -> Self {
2664 inner: if <*mut nativeTxAddInput>::is_null(self.inner) { core::ptr::null_mut() } else {
2665 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2671 /// Used only if an object of this type is returned as a trait impl by a method
2672 pub(crate) extern "C" fn TxAddInput_clone_void(this_ptr: *const c_void) -> *mut c_void {
2673 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxAddInput)).clone() })) as *mut c_void
2676 /// Creates a copy of the TxAddInput
2677 pub extern "C" fn TxAddInput_clone(orig: &TxAddInput) -> TxAddInput {
2680 /// Checks if two TxAddInputs contain equal inner contents.
2681 /// This ignores pointers and is_owned flags and looks at the values in fields.
2682 /// Two objects with NULL inner values will be considered "equal" here.
2684 pub extern "C" fn TxAddInput_eq(a: &TxAddInput, b: &TxAddInput) -> bool {
2685 if a.inner == b.inner { return true; }
2686 if a.inner.is_null() || b.inner.is_null() { return false; }
2687 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2690 use lightning::ln::msgs::TxAddOutput as nativeTxAddOutputImport;
2691 pub(crate) type nativeTxAddOutput = nativeTxAddOutputImport;
2693 /// A tx_add_output message for adding an output during interactive transaction construction.
2697 pub struct TxAddOutput {
2698 /// A pointer to the opaque Rust object.
2700 /// Nearly everywhere, inner must be non-null, however in places where
2701 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2702 pub inner: *mut nativeTxAddOutput,
2703 /// Indicates that this is the only struct which contains the same pointer.
2705 /// Rust functions which take ownership of an object provided via an argument require
2706 /// this to be true and invalidate the object pointed to by inner.
2710 impl Drop for TxAddOutput {
2711 fn drop(&mut self) {
2712 if self.is_owned && !<*mut nativeTxAddOutput>::is_null(self.inner) {
2713 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2717 /// Frees any resources used by the TxAddOutput, if is_owned is set and inner is non-NULL.
2719 pub extern "C" fn TxAddOutput_free(this_obj: TxAddOutput) { }
2721 /// Used only if an object of this type is returned as a trait impl by a method
2722 pub(crate) extern "C" fn TxAddOutput_free_void(this_ptr: *mut c_void) {
2723 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAddOutput) };
2727 pub(crate) fn get_native_ref(&self) -> &'static nativeTxAddOutput {
2728 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2730 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAddOutput {
2731 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2733 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2734 pub(crate) fn take_inner(mut self) -> *mut nativeTxAddOutput {
2735 assert!(self.is_owned);
2736 let ret = ObjOps::untweak_ptr(self.inner);
2737 self.inner = core::ptr::null_mut();
2743 pub extern "C" fn TxAddOutput_get_channel_id(this_ptr: &TxAddOutput) -> *const [u8; 32] {
2744 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2749 pub extern "C" fn TxAddOutput_set_channel_id(this_ptr: &mut TxAddOutput, mut val: crate::c_types::ThirtyTwoBytes) {
2750 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2752 /// A randomly chosen unique identifier for this output, which is even for initiators and odd for
2755 pub extern "C" fn TxAddOutput_get_serial_id(this_ptr: &TxAddOutput) -> u64 {
2756 let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
2759 /// A randomly chosen unique identifier for this output, which is even for initiators and odd for
2762 pub extern "C" fn TxAddOutput_set_serial_id(this_ptr: &mut TxAddOutput, mut val: u64) {
2763 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
2765 /// The satoshi value of the output
2767 pub extern "C" fn TxAddOutput_get_sats(this_ptr: &TxAddOutput) -> u64 {
2768 let mut inner_val = &mut this_ptr.get_native_mut_ref().sats;
2771 /// The satoshi value of the output
2773 pub extern "C" fn TxAddOutput_set_sats(this_ptr: &mut TxAddOutput, mut val: u64) {
2774 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sats = val;
2776 /// The scriptPubKey for the output
2778 pub extern "C" fn TxAddOutput_get_script(this_ptr: &TxAddOutput) -> crate::c_types::u8slice {
2779 let mut inner_val = &mut this_ptr.get_native_mut_ref().script;
2780 crate::c_types::u8slice::from_slice(&inner_val[..])
2782 /// The scriptPubKey for the output
2784 pub extern "C" fn TxAddOutput_set_script(this_ptr: &mut TxAddOutput, mut val: crate::c_types::derived::CVec_u8Z) {
2785 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.script = ::bitcoin::blockdata::script::Script::from(val.into_rust());
2787 /// Constructs a new TxAddOutput given each field
2790 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 {
2791 TxAddOutput { inner: ObjOps::heap_alloc(nativeTxAddOutput {
2792 channel_id: channel_id_arg.data,
2793 serial_id: serial_id_arg,
2795 script: ::bitcoin::blockdata::script::Script::from(script_arg.into_rust()),
2796 }), is_owned: true }
2798 impl Clone for TxAddOutput {
2799 fn clone(&self) -> Self {
2801 inner: if <*mut nativeTxAddOutput>::is_null(self.inner) { core::ptr::null_mut() } else {
2802 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2808 /// Used only if an object of this type is returned as a trait impl by a method
2809 pub(crate) extern "C" fn TxAddOutput_clone_void(this_ptr: *const c_void) -> *mut c_void {
2810 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxAddOutput)).clone() })) as *mut c_void
2813 /// Creates a copy of the TxAddOutput
2814 pub extern "C" fn TxAddOutput_clone(orig: &TxAddOutput) -> TxAddOutput {
2817 /// Checks if two TxAddOutputs contain equal inner contents.
2818 /// This ignores pointers and is_owned flags and looks at the values in fields.
2819 /// Two objects with NULL inner values will be considered "equal" here.
2821 pub extern "C" fn TxAddOutput_eq(a: &TxAddOutput, b: &TxAddOutput) -> bool {
2822 if a.inner == b.inner { return true; }
2823 if a.inner.is_null() || b.inner.is_null() { return false; }
2824 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2827 use lightning::ln::msgs::TxRemoveInput as nativeTxRemoveInputImport;
2828 pub(crate) type nativeTxRemoveInput = nativeTxRemoveInputImport;
2830 /// A tx_remove_input message for removing an input during interactive transaction construction.
2834 pub struct TxRemoveInput {
2835 /// A pointer to the opaque Rust object.
2837 /// Nearly everywhere, inner must be non-null, however in places where
2838 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2839 pub inner: *mut nativeTxRemoveInput,
2840 /// Indicates that this is the only struct which contains the same pointer.
2842 /// Rust functions which take ownership of an object provided via an argument require
2843 /// this to be true and invalidate the object pointed to by inner.
2847 impl Drop for TxRemoveInput {
2848 fn drop(&mut self) {
2849 if self.is_owned && !<*mut nativeTxRemoveInput>::is_null(self.inner) {
2850 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2854 /// Frees any resources used by the TxRemoveInput, if is_owned is set and inner is non-NULL.
2856 pub extern "C" fn TxRemoveInput_free(this_obj: TxRemoveInput) { }
2858 /// Used only if an object of this type is returned as a trait impl by a method
2859 pub(crate) extern "C" fn TxRemoveInput_free_void(this_ptr: *mut c_void) {
2860 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxRemoveInput) };
2863 impl TxRemoveInput {
2864 pub(crate) fn get_native_ref(&self) -> &'static nativeTxRemoveInput {
2865 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2867 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxRemoveInput {
2868 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2870 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2871 pub(crate) fn take_inner(mut self) -> *mut nativeTxRemoveInput {
2872 assert!(self.is_owned);
2873 let ret = ObjOps::untweak_ptr(self.inner);
2874 self.inner = core::ptr::null_mut();
2880 pub extern "C" fn TxRemoveInput_get_channel_id(this_ptr: &TxRemoveInput) -> *const [u8; 32] {
2881 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2886 pub extern "C" fn TxRemoveInput_set_channel_id(this_ptr: &mut TxRemoveInput, mut val: crate::c_types::ThirtyTwoBytes) {
2887 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2889 /// The serial ID of the input to be removed
2891 pub extern "C" fn TxRemoveInput_get_serial_id(this_ptr: &TxRemoveInput) -> u64 {
2892 let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
2895 /// The serial ID of the input to be removed
2897 pub extern "C" fn TxRemoveInput_set_serial_id(this_ptr: &mut TxRemoveInput, mut val: u64) {
2898 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
2900 /// Constructs a new TxRemoveInput given each field
2903 pub extern "C" fn TxRemoveInput_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut serial_id_arg: u64) -> TxRemoveInput {
2904 TxRemoveInput { inner: ObjOps::heap_alloc(nativeTxRemoveInput {
2905 channel_id: channel_id_arg.data,
2906 serial_id: serial_id_arg,
2907 }), is_owned: true }
2909 impl Clone for TxRemoveInput {
2910 fn clone(&self) -> Self {
2912 inner: if <*mut nativeTxRemoveInput>::is_null(self.inner) { core::ptr::null_mut() } else {
2913 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2919 /// Used only if an object of this type is returned as a trait impl by a method
2920 pub(crate) extern "C" fn TxRemoveInput_clone_void(this_ptr: *const c_void) -> *mut c_void {
2921 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxRemoveInput)).clone() })) as *mut c_void
2924 /// Creates a copy of the TxRemoveInput
2925 pub extern "C" fn TxRemoveInput_clone(orig: &TxRemoveInput) -> TxRemoveInput {
2928 /// Checks if two TxRemoveInputs contain equal inner contents.
2929 /// This ignores pointers and is_owned flags and looks at the values in fields.
2930 /// Two objects with NULL inner values will be considered "equal" here.
2932 pub extern "C" fn TxRemoveInput_eq(a: &TxRemoveInput, b: &TxRemoveInput) -> bool {
2933 if a.inner == b.inner { return true; }
2934 if a.inner.is_null() || b.inner.is_null() { return false; }
2935 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2938 use lightning::ln::msgs::TxRemoveOutput as nativeTxRemoveOutputImport;
2939 pub(crate) type nativeTxRemoveOutput = nativeTxRemoveOutputImport;
2941 /// A tx_remove_output message for removing an output during interactive transaction construction.
2945 pub struct TxRemoveOutput {
2946 /// A pointer to the opaque Rust object.
2948 /// Nearly everywhere, inner must be non-null, however in places where
2949 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2950 pub inner: *mut nativeTxRemoveOutput,
2951 /// Indicates that this is the only struct which contains the same pointer.
2953 /// Rust functions which take ownership of an object provided via an argument require
2954 /// this to be true and invalidate the object pointed to by inner.
2958 impl Drop for TxRemoveOutput {
2959 fn drop(&mut self) {
2960 if self.is_owned && !<*mut nativeTxRemoveOutput>::is_null(self.inner) {
2961 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2965 /// Frees any resources used by the TxRemoveOutput, if is_owned is set and inner is non-NULL.
2967 pub extern "C" fn TxRemoveOutput_free(this_obj: TxRemoveOutput) { }
2969 /// Used only if an object of this type is returned as a trait impl by a method
2970 pub(crate) extern "C" fn TxRemoveOutput_free_void(this_ptr: *mut c_void) {
2971 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxRemoveOutput) };
2974 impl TxRemoveOutput {
2975 pub(crate) fn get_native_ref(&self) -> &'static nativeTxRemoveOutput {
2976 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2978 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxRemoveOutput {
2979 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2981 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2982 pub(crate) fn take_inner(mut self) -> *mut nativeTxRemoveOutput {
2983 assert!(self.is_owned);
2984 let ret = ObjOps::untweak_ptr(self.inner);
2985 self.inner = core::ptr::null_mut();
2991 pub extern "C" fn TxRemoveOutput_get_channel_id(this_ptr: &TxRemoveOutput) -> *const [u8; 32] {
2992 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2997 pub extern "C" fn TxRemoveOutput_set_channel_id(this_ptr: &mut TxRemoveOutput, mut val: crate::c_types::ThirtyTwoBytes) {
2998 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
3000 /// The serial ID of the output to be removed
3002 pub extern "C" fn TxRemoveOutput_get_serial_id(this_ptr: &TxRemoveOutput) -> u64 {
3003 let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
3006 /// The serial ID of the output to be removed
3008 pub extern "C" fn TxRemoveOutput_set_serial_id(this_ptr: &mut TxRemoveOutput, mut val: u64) {
3009 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
3011 /// Constructs a new TxRemoveOutput given each field
3014 pub extern "C" fn TxRemoveOutput_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut serial_id_arg: u64) -> TxRemoveOutput {
3015 TxRemoveOutput { inner: ObjOps::heap_alloc(nativeTxRemoveOutput {
3016 channel_id: channel_id_arg.data,
3017 serial_id: serial_id_arg,
3018 }), is_owned: true }
3020 impl Clone for TxRemoveOutput {
3021 fn clone(&self) -> Self {
3023 inner: if <*mut nativeTxRemoveOutput>::is_null(self.inner) { core::ptr::null_mut() } else {
3024 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3030 /// Used only if an object of this type is returned as a trait impl by a method
3031 pub(crate) extern "C" fn TxRemoveOutput_clone_void(this_ptr: *const c_void) -> *mut c_void {
3032 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxRemoveOutput)).clone() })) as *mut c_void
3035 /// Creates a copy of the TxRemoveOutput
3036 pub extern "C" fn TxRemoveOutput_clone(orig: &TxRemoveOutput) -> TxRemoveOutput {
3039 /// Checks if two TxRemoveOutputs contain equal inner contents.
3040 /// This ignores pointers and is_owned flags and looks at the values in fields.
3041 /// Two objects with NULL inner values will be considered "equal" here.
3043 pub extern "C" fn TxRemoveOutput_eq(a: &TxRemoveOutput, b: &TxRemoveOutput) -> bool {
3044 if a.inner == b.inner { return true; }
3045 if a.inner.is_null() || b.inner.is_null() { return false; }
3046 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3049 use lightning::ln::msgs::TxComplete as nativeTxCompleteImport;
3050 pub(crate) type nativeTxComplete = nativeTxCompleteImport;
3052 /// A tx_complete message signalling the conclusion of a peer's transaction contributions during
3053 /// interactive transaction construction.
3057 pub struct TxComplete {
3058 /// A pointer to the opaque Rust object.
3060 /// Nearly everywhere, inner must be non-null, however in places where
3061 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3062 pub inner: *mut nativeTxComplete,
3063 /// Indicates that this is the only struct which contains the same pointer.
3065 /// Rust functions which take ownership of an object provided via an argument require
3066 /// this to be true and invalidate the object pointed to by inner.
3070 impl Drop for TxComplete {
3071 fn drop(&mut self) {
3072 if self.is_owned && !<*mut nativeTxComplete>::is_null(self.inner) {
3073 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3077 /// Frees any resources used by the TxComplete, if is_owned is set and inner is non-NULL.
3079 pub extern "C" fn TxComplete_free(this_obj: TxComplete) { }
3081 /// Used only if an object of this type is returned as a trait impl by a method
3082 pub(crate) extern "C" fn TxComplete_free_void(this_ptr: *mut c_void) {
3083 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxComplete) };
3087 pub(crate) fn get_native_ref(&self) -> &'static nativeTxComplete {
3088 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3090 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxComplete {
3091 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3093 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3094 pub(crate) fn take_inner(mut self) -> *mut nativeTxComplete {
3095 assert!(self.is_owned);
3096 let ret = ObjOps::untweak_ptr(self.inner);
3097 self.inner = core::ptr::null_mut();
3103 pub extern "C" fn TxComplete_get_channel_id(this_ptr: &TxComplete) -> *const [u8; 32] {
3104 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3109 pub extern "C" fn TxComplete_set_channel_id(this_ptr: &mut TxComplete, mut val: crate::c_types::ThirtyTwoBytes) {
3110 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
3112 /// Constructs a new TxComplete given each field
3115 pub extern "C" fn TxComplete_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes) -> TxComplete {
3116 TxComplete { inner: ObjOps::heap_alloc(nativeTxComplete {
3117 channel_id: channel_id_arg.data,
3118 }), is_owned: true }
3120 impl Clone for TxComplete {
3121 fn clone(&self) -> Self {
3123 inner: if <*mut nativeTxComplete>::is_null(self.inner) { core::ptr::null_mut() } else {
3124 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3130 /// Used only if an object of this type is returned as a trait impl by a method
3131 pub(crate) extern "C" fn TxComplete_clone_void(this_ptr: *const c_void) -> *mut c_void {
3132 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxComplete)).clone() })) as *mut c_void
3135 /// Creates a copy of the TxComplete
3136 pub extern "C" fn TxComplete_clone(orig: &TxComplete) -> TxComplete {
3139 /// Checks if two TxCompletes contain equal inner contents.
3140 /// This ignores pointers and is_owned flags and looks at the values in fields.
3141 /// Two objects with NULL inner values will be considered "equal" here.
3143 pub extern "C" fn TxComplete_eq(a: &TxComplete, b: &TxComplete) -> bool {
3144 if a.inner == b.inner { return true; }
3145 if a.inner.is_null() || b.inner.is_null() { return false; }
3146 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3149 use lightning::ln::msgs::TxSignatures as nativeTxSignaturesImport;
3150 pub(crate) type nativeTxSignatures = nativeTxSignaturesImport;
3152 /// A tx_signatures message containing the sender's signatures for a transaction constructed with
3153 /// interactive transaction construction.
3157 pub struct TxSignatures {
3158 /// A pointer to the opaque Rust object.
3160 /// Nearly everywhere, inner must be non-null, however in places where
3161 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3162 pub inner: *mut nativeTxSignatures,
3163 /// Indicates that this is the only struct which contains the same pointer.
3165 /// Rust functions which take ownership of an object provided via an argument require
3166 /// this to be true and invalidate the object pointed to by inner.
3170 impl Drop for TxSignatures {
3171 fn drop(&mut self) {
3172 if self.is_owned && !<*mut nativeTxSignatures>::is_null(self.inner) {
3173 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3177 /// Frees any resources used by the TxSignatures, if is_owned is set and inner is non-NULL.
3179 pub extern "C" fn TxSignatures_free(this_obj: TxSignatures) { }
3181 /// Used only if an object of this type is returned as a trait impl by a method
3182 pub(crate) extern "C" fn TxSignatures_free_void(this_ptr: *mut c_void) {
3183 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxSignatures) };
3187 pub(crate) fn get_native_ref(&self) -> &'static nativeTxSignatures {
3188 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3190 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxSignatures {
3191 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3193 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3194 pub(crate) fn take_inner(mut self) -> *mut nativeTxSignatures {
3195 assert!(self.is_owned);
3196 let ret = ObjOps::untweak_ptr(self.inner);
3197 self.inner = core::ptr::null_mut();
3203 pub extern "C" fn TxSignatures_get_channel_id(this_ptr: &TxSignatures) -> *const [u8; 32] {
3204 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3209 pub extern "C" fn TxSignatures_set_channel_id(this_ptr: &mut TxSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
3210 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
3214 pub extern "C" fn TxSignatures_get_tx_hash(this_ptr: &TxSignatures) -> *const [u8; 32] {
3215 let mut inner_val = &mut this_ptr.get_native_mut_ref().tx_hash;
3216 inner_val.as_inner()
3220 pub extern "C" fn TxSignatures_set_tx_hash(this_ptr: &mut TxSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
3221 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.tx_hash = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
3223 /// The list of witnesses
3225 /// Returns a copy of the field.
3227 pub extern "C" fn TxSignatures_get_witnesses(this_ptr: &TxSignatures) -> crate::c_types::derived::CVec_WitnessZ {
3228 let mut inner_val = this_ptr.get_native_mut_ref().witnesses.clone();
3229 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) }); };
3230 local_inner_val.into()
3232 /// The list of witnesses
3234 pub extern "C" fn TxSignatures_set_witnesses(this_ptr: &mut TxSignatures, mut val: crate::c_types::derived::CVec_WitnessZ) {
3235 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_bitcoin() }); };
3236 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.witnesses = local_val;
3238 /// Constructs a new TxSignatures given each field
3241 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 {
3242 let mut local_witnesses_arg = Vec::new(); for mut item in witnesses_arg.into_rust().drain(..) { local_witnesses_arg.push( { item.into_bitcoin() }); };
3243 TxSignatures { inner: ObjOps::heap_alloc(nativeTxSignatures {
3244 channel_id: channel_id_arg.data,
3245 tx_hash: ::bitcoin::hash_types::Txid::from_slice(&tx_hash_arg.data[..]).unwrap(),
3246 witnesses: local_witnesses_arg,
3247 }), is_owned: true }
3249 impl Clone for TxSignatures {
3250 fn clone(&self) -> Self {
3252 inner: if <*mut nativeTxSignatures>::is_null(self.inner) { core::ptr::null_mut() } else {
3253 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3259 /// Used only if an object of this type is returned as a trait impl by a method
3260 pub(crate) extern "C" fn TxSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
3261 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxSignatures)).clone() })) as *mut c_void
3264 /// Creates a copy of the TxSignatures
3265 pub extern "C" fn TxSignatures_clone(orig: &TxSignatures) -> TxSignatures {
3268 /// Checks if two TxSignaturess contain equal inner contents.
3269 /// This ignores pointers and is_owned flags and looks at the values in fields.
3270 /// Two objects with NULL inner values will be considered "equal" here.
3272 pub extern "C" fn TxSignatures_eq(a: &TxSignatures, b: &TxSignatures) -> bool {
3273 if a.inner == b.inner { return true; }
3274 if a.inner.is_null() || b.inner.is_null() { return false; }
3275 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3278 use lightning::ln::msgs::TxInitRbf as nativeTxInitRbfImport;
3279 pub(crate) type nativeTxInitRbf = nativeTxInitRbfImport;
3281 /// A tx_init_rbf message which initiates a replacement of the transaction after it's been
3286 pub struct TxInitRbf {
3287 /// A pointer to the opaque Rust object.
3289 /// Nearly everywhere, inner must be non-null, however in places where
3290 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3291 pub inner: *mut nativeTxInitRbf,
3292 /// Indicates that this is the only struct which contains the same pointer.
3294 /// Rust functions which take ownership of an object provided via an argument require
3295 /// this to be true and invalidate the object pointed to by inner.
3299 impl Drop for TxInitRbf {
3300 fn drop(&mut self) {
3301 if self.is_owned && !<*mut nativeTxInitRbf>::is_null(self.inner) {
3302 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3306 /// Frees any resources used by the TxInitRbf, if is_owned is set and inner is non-NULL.
3308 pub extern "C" fn TxInitRbf_free(this_obj: TxInitRbf) { }
3310 /// Used only if an object of this type is returned as a trait impl by a method
3311 pub(crate) extern "C" fn TxInitRbf_free_void(this_ptr: *mut c_void) {
3312 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxInitRbf) };
3316 pub(crate) fn get_native_ref(&self) -> &'static nativeTxInitRbf {
3317 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3319 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxInitRbf {
3320 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3322 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3323 pub(crate) fn take_inner(mut self) -> *mut nativeTxInitRbf {
3324 assert!(self.is_owned);
3325 let ret = ObjOps::untweak_ptr(self.inner);
3326 self.inner = core::ptr::null_mut();
3332 pub extern "C" fn TxInitRbf_get_channel_id(this_ptr: &TxInitRbf) -> *const [u8; 32] {
3333 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3338 pub extern "C" fn TxInitRbf_set_channel_id(this_ptr: &mut TxInitRbf, mut val: crate::c_types::ThirtyTwoBytes) {
3339 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
3341 /// The locktime of the transaction
3343 pub extern "C" fn TxInitRbf_get_locktime(this_ptr: &TxInitRbf) -> u32 {
3344 let mut inner_val = &mut this_ptr.get_native_mut_ref().locktime;
3347 /// The locktime of the transaction
3349 pub extern "C" fn TxInitRbf_set_locktime(this_ptr: &mut TxInitRbf, mut val: u32) {
3350 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.locktime = val;
3352 /// The feerate of the transaction
3354 pub extern "C" fn TxInitRbf_get_feerate_sat_per_1000_weight(this_ptr: &TxInitRbf) -> u32 {
3355 let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_sat_per_1000_weight;
3358 /// The feerate of the transaction
3360 pub extern "C" fn TxInitRbf_set_feerate_sat_per_1000_weight(this_ptr: &mut TxInitRbf, mut val: u32) {
3361 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_sat_per_1000_weight = val;
3363 /// The number of satoshis the sender will contribute to or, if negative, remove from
3364 /// (e.g. splice-out) the funding output of the transaction
3366 pub extern "C" fn TxInitRbf_get_funding_output_contribution(this_ptr: &TxInitRbf) -> crate::c_types::derived::COption_i64Z {
3367 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_contribution;
3368 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() }) };
3371 /// The number of satoshis the sender will contribute to or, if negative, remove from
3372 /// (e.g. splice-out) the funding output of the transaction
3374 pub extern "C" fn TxInitRbf_set_funding_output_contribution(this_ptr: &mut TxInitRbf, mut val: crate::c_types::derived::COption_i64Z) {
3375 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
3376 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_contribution = local_val;
3378 /// Constructs a new TxInitRbf given each field
3381 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 {
3382 let mut local_funding_output_contribution_arg = if funding_output_contribution_arg.is_some() { Some( { funding_output_contribution_arg.take() }) } else { None };
3383 TxInitRbf { inner: ObjOps::heap_alloc(nativeTxInitRbf {
3384 channel_id: channel_id_arg.data,
3385 locktime: locktime_arg,
3386 feerate_sat_per_1000_weight: feerate_sat_per_1000_weight_arg,
3387 funding_output_contribution: local_funding_output_contribution_arg,
3388 }), is_owned: true }
3390 impl Clone for TxInitRbf {
3391 fn clone(&self) -> Self {
3393 inner: if <*mut nativeTxInitRbf>::is_null(self.inner) { core::ptr::null_mut() } else {
3394 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3400 /// Used only if an object of this type is returned as a trait impl by a method
3401 pub(crate) extern "C" fn TxInitRbf_clone_void(this_ptr: *const c_void) -> *mut c_void {
3402 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxInitRbf)).clone() })) as *mut c_void
3405 /// Creates a copy of the TxInitRbf
3406 pub extern "C" fn TxInitRbf_clone(orig: &TxInitRbf) -> TxInitRbf {
3409 /// Checks if two TxInitRbfs contain equal inner contents.
3410 /// This ignores pointers and is_owned flags and looks at the values in fields.
3411 /// Two objects with NULL inner values will be considered "equal" here.
3413 pub extern "C" fn TxInitRbf_eq(a: &TxInitRbf, b: &TxInitRbf) -> bool {
3414 if a.inner == b.inner { return true; }
3415 if a.inner.is_null() || b.inner.is_null() { return false; }
3416 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3419 use lightning::ln::msgs::TxAckRbf as nativeTxAckRbfImport;
3420 pub(crate) type nativeTxAckRbf = nativeTxAckRbfImport;
3422 /// A tx_ack_rbf message which acknowledges replacement of the transaction after it's been
3427 pub struct TxAckRbf {
3428 /// A pointer to the opaque Rust object.
3430 /// Nearly everywhere, inner must be non-null, however in places where
3431 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3432 pub inner: *mut nativeTxAckRbf,
3433 /// Indicates that this is the only struct which contains the same pointer.
3435 /// Rust functions which take ownership of an object provided via an argument require
3436 /// this to be true and invalidate the object pointed to by inner.
3440 impl Drop for TxAckRbf {
3441 fn drop(&mut self) {
3442 if self.is_owned && !<*mut nativeTxAckRbf>::is_null(self.inner) {
3443 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3447 /// Frees any resources used by the TxAckRbf, if is_owned is set and inner is non-NULL.
3449 pub extern "C" fn TxAckRbf_free(this_obj: TxAckRbf) { }
3451 /// Used only if an object of this type is returned as a trait impl by a method
3452 pub(crate) extern "C" fn TxAckRbf_free_void(this_ptr: *mut c_void) {
3453 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAckRbf) };
3457 pub(crate) fn get_native_ref(&self) -> &'static nativeTxAckRbf {
3458 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3460 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAckRbf {
3461 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3463 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3464 pub(crate) fn take_inner(mut self) -> *mut nativeTxAckRbf {
3465 assert!(self.is_owned);
3466 let ret = ObjOps::untweak_ptr(self.inner);
3467 self.inner = core::ptr::null_mut();
3473 pub extern "C" fn TxAckRbf_get_channel_id(this_ptr: &TxAckRbf) -> *const [u8; 32] {
3474 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3479 pub extern "C" fn TxAckRbf_set_channel_id(this_ptr: &mut TxAckRbf, mut val: crate::c_types::ThirtyTwoBytes) {
3480 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
3482 /// The number of satoshis the sender will contribute to or, if negative, remove from
3483 /// (e.g. splice-out) the funding output of the transaction
3485 pub extern "C" fn TxAckRbf_get_funding_output_contribution(this_ptr: &TxAckRbf) -> crate::c_types::derived::COption_i64Z {
3486 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_contribution;
3487 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() }) };
3490 /// The number of satoshis the sender will contribute to or, if negative, remove from
3491 /// (e.g. splice-out) the funding output of the transaction
3493 pub extern "C" fn TxAckRbf_set_funding_output_contribution(this_ptr: &mut TxAckRbf, mut val: crate::c_types::derived::COption_i64Z) {
3494 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
3495 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_contribution = local_val;
3497 /// Constructs a new TxAckRbf given each field
3500 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 {
3501 let mut local_funding_output_contribution_arg = if funding_output_contribution_arg.is_some() { Some( { funding_output_contribution_arg.take() }) } else { None };
3502 TxAckRbf { inner: ObjOps::heap_alloc(nativeTxAckRbf {
3503 channel_id: channel_id_arg.data,
3504 funding_output_contribution: local_funding_output_contribution_arg,
3505 }), is_owned: true }
3507 impl Clone for TxAckRbf {
3508 fn clone(&self) -> Self {
3510 inner: if <*mut nativeTxAckRbf>::is_null(self.inner) { core::ptr::null_mut() } else {
3511 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3517 /// Used only if an object of this type is returned as a trait impl by a method
3518 pub(crate) extern "C" fn TxAckRbf_clone_void(this_ptr: *const c_void) -> *mut c_void {
3519 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxAckRbf)).clone() })) as *mut c_void
3522 /// Creates a copy of the TxAckRbf
3523 pub extern "C" fn TxAckRbf_clone(orig: &TxAckRbf) -> TxAckRbf {
3526 /// Checks if two TxAckRbfs contain equal inner contents.
3527 /// This ignores pointers and is_owned flags and looks at the values in fields.
3528 /// Two objects with NULL inner values will be considered "equal" here.
3530 pub extern "C" fn TxAckRbf_eq(a: &TxAckRbf, b: &TxAckRbf) -> bool {
3531 if a.inner == b.inner { return true; }
3532 if a.inner.is_null() || b.inner.is_null() { return false; }
3533 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3536 use lightning::ln::msgs::TxAbort as nativeTxAbortImport;
3537 pub(crate) type nativeTxAbort = nativeTxAbortImport;
3539 /// A tx_abort message which signals the cancellation of an in-progress transaction negotiation.
3543 pub struct TxAbort {
3544 /// A pointer to the opaque Rust object.
3546 /// Nearly everywhere, inner must be non-null, however in places where
3547 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3548 pub inner: *mut nativeTxAbort,
3549 /// Indicates that this is the only struct which contains the same pointer.
3551 /// Rust functions which take ownership of an object provided via an argument require
3552 /// this to be true and invalidate the object pointed to by inner.
3556 impl Drop for TxAbort {
3557 fn drop(&mut self) {
3558 if self.is_owned && !<*mut nativeTxAbort>::is_null(self.inner) {
3559 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3563 /// Frees any resources used by the TxAbort, if is_owned is set and inner is non-NULL.
3565 pub extern "C" fn TxAbort_free(this_obj: TxAbort) { }
3567 /// Used only if an object of this type is returned as a trait impl by a method
3568 pub(crate) extern "C" fn TxAbort_free_void(this_ptr: *mut c_void) {
3569 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAbort) };
3573 pub(crate) fn get_native_ref(&self) -> &'static nativeTxAbort {
3574 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3576 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAbort {
3577 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3579 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3580 pub(crate) fn take_inner(mut self) -> *mut nativeTxAbort {
3581 assert!(self.is_owned);
3582 let ret = ObjOps::untweak_ptr(self.inner);
3583 self.inner = core::ptr::null_mut();
3589 pub extern "C" fn TxAbort_get_channel_id(this_ptr: &TxAbort) -> *const [u8; 32] {
3590 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3595 pub extern "C" fn TxAbort_set_channel_id(this_ptr: &mut TxAbort, mut val: crate::c_types::ThirtyTwoBytes) {
3596 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
3600 /// Returns a copy of the field.
3602 pub extern "C" fn TxAbort_get_data(this_ptr: &TxAbort) -> crate::c_types::derived::CVec_u8Z {
3603 let mut inner_val = this_ptr.get_native_mut_ref().data.clone();
3604 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
3605 local_inner_val.into()
3609 pub extern "C" fn TxAbort_set_data(this_ptr: &mut TxAbort, mut val: crate::c_types::derived::CVec_u8Z) {
3610 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
3611 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = local_val;
3613 /// Constructs a new TxAbort given each field
3616 pub extern "C" fn TxAbort_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::derived::CVec_u8Z) -> TxAbort {
3617 let mut local_data_arg = Vec::new(); for mut item in data_arg.into_rust().drain(..) { local_data_arg.push( { item }); };
3618 TxAbort { inner: ObjOps::heap_alloc(nativeTxAbort {
3619 channel_id: channel_id_arg.data,
3620 data: local_data_arg,
3621 }), is_owned: true }
3623 impl Clone for TxAbort {
3624 fn clone(&self) -> Self {
3626 inner: if <*mut nativeTxAbort>::is_null(self.inner) { core::ptr::null_mut() } else {
3627 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3633 /// Used only if an object of this type is returned as a trait impl by a method
3634 pub(crate) extern "C" fn TxAbort_clone_void(this_ptr: *const c_void) -> *mut c_void {
3635 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxAbort)).clone() })) as *mut c_void
3638 /// Creates a copy of the TxAbort
3639 pub extern "C" fn TxAbort_clone(orig: &TxAbort) -> TxAbort {
3642 /// Checks if two TxAborts contain equal inner contents.
3643 /// This ignores pointers and is_owned flags and looks at the values in fields.
3644 /// Two objects with NULL inner values will be considered "equal" here.
3646 pub extern "C" fn TxAbort_eq(a: &TxAbort, b: &TxAbort) -> bool {
3647 if a.inner == b.inner { return true; }
3648 if a.inner.is_null() || b.inner.is_null() { return false; }
3649 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3652 use lightning::ln::msgs::Shutdown as nativeShutdownImport;
3653 pub(crate) type nativeShutdown = nativeShutdownImport;
3655 /// A [`shutdown`] message to be sent to or received from a peer.
3657 /// [`shutdown`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-initiation-shutdown
3660 pub struct Shutdown {
3661 /// A pointer to the opaque Rust object.
3663 /// Nearly everywhere, inner must be non-null, however in places where
3664 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3665 pub inner: *mut nativeShutdown,
3666 /// Indicates that this is the only struct which contains the same pointer.
3668 /// Rust functions which take ownership of an object provided via an argument require
3669 /// this to be true and invalidate the object pointed to by inner.
3673 impl Drop for Shutdown {
3674 fn drop(&mut self) {
3675 if self.is_owned && !<*mut nativeShutdown>::is_null(self.inner) {
3676 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3680 /// Frees any resources used by the Shutdown, if is_owned is set and inner is non-NULL.
3682 pub extern "C" fn Shutdown_free(this_obj: Shutdown) { }
3684 /// Used only if an object of this type is returned as a trait impl by a method
3685 pub(crate) extern "C" fn Shutdown_free_void(this_ptr: *mut c_void) {
3686 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeShutdown) };
3690 pub(crate) fn get_native_ref(&self) -> &'static nativeShutdown {
3691 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3693 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeShutdown {
3694 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3696 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3697 pub(crate) fn take_inner(mut self) -> *mut nativeShutdown {
3698 assert!(self.is_owned);
3699 let ret = ObjOps::untweak_ptr(self.inner);
3700 self.inner = core::ptr::null_mut();
3706 pub extern "C" fn Shutdown_get_channel_id(this_ptr: &Shutdown) -> *const [u8; 32] {
3707 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3712 pub extern "C" fn Shutdown_set_channel_id(this_ptr: &mut Shutdown, mut val: crate::c_types::ThirtyTwoBytes) {
3713 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
3715 /// The destination of this peer's funds on closing.
3717 /// Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.
3719 pub extern "C" fn Shutdown_get_scriptpubkey(this_ptr: &Shutdown) -> crate::c_types::u8slice {
3720 let mut inner_val = &mut this_ptr.get_native_mut_ref().scriptpubkey;
3721 crate::c_types::u8slice::from_slice(&inner_val[..])
3723 /// The destination of this peer's funds on closing.
3725 /// Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.
3727 pub extern "C" fn Shutdown_set_scriptpubkey(this_ptr: &mut Shutdown, mut val: crate::c_types::derived::CVec_u8Z) {
3728 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.scriptpubkey = ::bitcoin::blockdata::script::Script::from(val.into_rust());
3730 /// Constructs a new Shutdown given each field
3733 pub extern "C" fn Shutdown_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut scriptpubkey_arg: crate::c_types::derived::CVec_u8Z) -> Shutdown {
3734 Shutdown { inner: ObjOps::heap_alloc(nativeShutdown {
3735 channel_id: channel_id_arg.data,
3736 scriptpubkey: ::bitcoin::blockdata::script::Script::from(scriptpubkey_arg.into_rust()),
3737 }), is_owned: true }
3739 impl Clone for Shutdown {
3740 fn clone(&self) -> Self {
3742 inner: if <*mut nativeShutdown>::is_null(self.inner) { core::ptr::null_mut() } else {
3743 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3749 /// Used only if an object of this type is returned as a trait impl by a method
3750 pub(crate) extern "C" fn Shutdown_clone_void(this_ptr: *const c_void) -> *mut c_void {
3751 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeShutdown)).clone() })) as *mut c_void
3754 /// Creates a copy of the Shutdown
3755 pub extern "C" fn Shutdown_clone(orig: &Shutdown) -> Shutdown {
3758 /// Checks if two Shutdowns contain equal inner contents.
3759 /// This ignores pointers and is_owned flags and looks at the values in fields.
3760 /// Two objects with NULL inner values will be considered "equal" here.
3762 pub extern "C" fn Shutdown_eq(a: &Shutdown, b: &Shutdown) -> bool {
3763 if a.inner == b.inner { return true; }
3764 if a.inner.is_null() || b.inner.is_null() { return false; }
3765 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3768 use lightning::ln::msgs::ClosingSignedFeeRange as nativeClosingSignedFeeRangeImport;
3769 pub(crate) type nativeClosingSignedFeeRange = nativeClosingSignedFeeRangeImport;
3771 /// The minimum and maximum fees which the sender is willing to place on the closing transaction.
3773 /// This is provided in [`ClosingSigned`] by both sides to indicate the fee range they are willing
3777 pub struct ClosingSignedFeeRange {
3778 /// A pointer to the opaque Rust object.
3780 /// Nearly everywhere, inner must be non-null, however in places where
3781 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3782 pub inner: *mut nativeClosingSignedFeeRange,
3783 /// Indicates that this is the only struct which contains the same pointer.
3785 /// Rust functions which take ownership of an object provided via an argument require
3786 /// this to be true and invalidate the object pointed to by inner.
3790 impl Drop for ClosingSignedFeeRange {
3791 fn drop(&mut self) {
3792 if self.is_owned && !<*mut nativeClosingSignedFeeRange>::is_null(self.inner) {
3793 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3797 /// Frees any resources used by the ClosingSignedFeeRange, if is_owned is set and inner is non-NULL.
3799 pub extern "C" fn ClosingSignedFeeRange_free(this_obj: ClosingSignedFeeRange) { }
3801 /// Used only if an object of this type is returned as a trait impl by a method
3802 pub(crate) extern "C" fn ClosingSignedFeeRange_free_void(this_ptr: *mut c_void) {
3803 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeClosingSignedFeeRange) };
3806 impl ClosingSignedFeeRange {
3807 pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSignedFeeRange {
3808 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3810 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSignedFeeRange {
3811 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3813 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3814 pub(crate) fn take_inner(mut self) -> *mut nativeClosingSignedFeeRange {
3815 assert!(self.is_owned);
3816 let ret = ObjOps::untweak_ptr(self.inner);
3817 self.inner = core::ptr::null_mut();
3821 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
3824 pub extern "C" fn ClosingSignedFeeRange_get_min_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
3825 let mut inner_val = &mut this_ptr.get_native_mut_ref().min_fee_satoshis;
3828 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
3831 pub extern "C" fn ClosingSignedFeeRange_set_min_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
3832 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_fee_satoshis = val;
3834 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
3837 pub extern "C" fn ClosingSignedFeeRange_get_max_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
3838 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_fee_satoshis;
3841 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
3844 pub extern "C" fn ClosingSignedFeeRange_set_max_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
3845 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_fee_satoshis = val;
3847 /// Constructs a new ClosingSignedFeeRange given each field
3850 pub extern "C" fn ClosingSignedFeeRange_new(mut min_fee_satoshis_arg: u64, mut max_fee_satoshis_arg: u64) -> ClosingSignedFeeRange {
3851 ClosingSignedFeeRange { inner: ObjOps::heap_alloc(nativeClosingSignedFeeRange {
3852 min_fee_satoshis: min_fee_satoshis_arg,
3853 max_fee_satoshis: max_fee_satoshis_arg,
3854 }), is_owned: true }
3856 impl Clone for ClosingSignedFeeRange {
3857 fn clone(&self) -> Self {
3859 inner: if <*mut nativeClosingSignedFeeRange>::is_null(self.inner) { core::ptr::null_mut() } else {
3860 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3866 /// Used only if an object of this type is returned as a trait impl by a method
3867 pub(crate) extern "C" fn ClosingSignedFeeRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
3868 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClosingSignedFeeRange)).clone() })) as *mut c_void
3871 /// Creates a copy of the ClosingSignedFeeRange
3872 pub extern "C" fn ClosingSignedFeeRange_clone(orig: &ClosingSignedFeeRange) -> ClosingSignedFeeRange {
3875 /// Checks if two ClosingSignedFeeRanges contain equal inner contents.
3876 /// This ignores pointers and is_owned flags and looks at the values in fields.
3877 /// Two objects with NULL inner values will be considered "equal" here.
3879 pub extern "C" fn ClosingSignedFeeRange_eq(a: &ClosingSignedFeeRange, b: &ClosingSignedFeeRange) -> bool {
3880 if a.inner == b.inner { return true; }
3881 if a.inner.is_null() || b.inner.is_null() { return false; }
3882 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3885 use lightning::ln::msgs::ClosingSigned as nativeClosingSignedImport;
3886 pub(crate) type nativeClosingSigned = nativeClosingSignedImport;
3888 /// A [`closing_signed`] message to be sent to or received from a peer.
3890 /// [`closing_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-negotiation-closing_signed
3893 pub struct ClosingSigned {
3894 /// A pointer to the opaque Rust object.
3896 /// Nearly everywhere, inner must be non-null, however in places where
3897 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3898 pub inner: *mut nativeClosingSigned,
3899 /// Indicates that this is the only struct which contains the same pointer.
3901 /// Rust functions which take ownership of an object provided via an argument require
3902 /// this to be true and invalidate the object pointed to by inner.
3906 impl Drop for ClosingSigned {
3907 fn drop(&mut self) {
3908 if self.is_owned && !<*mut nativeClosingSigned>::is_null(self.inner) {
3909 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3913 /// Frees any resources used by the ClosingSigned, if is_owned is set and inner is non-NULL.
3915 pub extern "C" fn ClosingSigned_free(this_obj: ClosingSigned) { }
3917 /// Used only if an object of this type is returned as a trait impl by a method
3918 pub(crate) extern "C" fn ClosingSigned_free_void(this_ptr: *mut c_void) {
3919 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeClosingSigned) };
3922 impl ClosingSigned {
3923 pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSigned {
3924 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3926 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSigned {
3927 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3929 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3930 pub(crate) fn take_inner(mut self) -> *mut nativeClosingSigned {
3931 assert!(self.is_owned);
3932 let ret = ObjOps::untweak_ptr(self.inner);
3933 self.inner = core::ptr::null_mut();
3939 pub extern "C" fn ClosingSigned_get_channel_id(this_ptr: &ClosingSigned) -> *const [u8; 32] {
3940 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3945 pub extern "C" fn ClosingSigned_set_channel_id(this_ptr: &mut ClosingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
3946 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
3948 /// The proposed total fee for the closing transaction
3950 pub extern "C" fn ClosingSigned_get_fee_satoshis(this_ptr: &ClosingSigned) -> u64 {
3951 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_satoshis;
3954 /// The proposed total fee for the closing transaction
3956 pub extern "C" fn ClosingSigned_set_fee_satoshis(this_ptr: &mut ClosingSigned, mut val: u64) {
3957 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_satoshis = val;
3959 /// A signature on the closing transaction
3961 pub extern "C" fn ClosingSigned_get_signature(this_ptr: &ClosingSigned) -> crate::c_types::Signature {
3962 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
3963 crate::c_types::Signature::from_rust(&inner_val)
3965 /// A signature on the closing transaction
3967 pub extern "C" fn ClosingSigned_set_signature(this_ptr: &mut ClosingSigned, mut val: crate::c_types::Signature) {
3968 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
3970 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
3973 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
3975 pub extern "C" fn ClosingSigned_get_fee_range(this_ptr: &ClosingSigned) -> crate::lightning::ln::msgs::ClosingSignedFeeRange {
3976 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_range;
3977 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 };
3980 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
3983 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
3985 pub extern "C" fn ClosingSigned_set_fee_range(this_ptr: &mut ClosingSigned, mut val: crate::lightning::ln::msgs::ClosingSignedFeeRange) {
3986 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
3987 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_range = local_val;
3989 /// Constructs a new ClosingSigned given each field
3992 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::Signature, mut fee_range_arg: crate::lightning::ln::msgs::ClosingSignedFeeRange) -> ClosingSigned {
3993 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()) } }) };
3994 ClosingSigned { inner: ObjOps::heap_alloc(nativeClosingSigned {
3995 channel_id: channel_id_arg.data,
3996 fee_satoshis: fee_satoshis_arg,
3997 signature: signature_arg.into_rust(),
3998 fee_range: local_fee_range_arg,
3999 }), is_owned: true }
4001 impl Clone for ClosingSigned {
4002 fn clone(&self) -> Self {
4004 inner: if <*mut nativeClosingSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
4005 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4011 /// Used only if an object of this type is returned as a trait impl by a method
4012 pub(crate) extern "C" fn ClosingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
4013 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClosingSigned)).clone() })) as *mut c_void
4016 /// Creates a copy of the ClosingSigned
4017 pub extern "C" fn ClosingSigned_clone(orig: &ClosingSigned) -> ClosingSigned {
4020 /// Checks if two ClosingSigneds contain equal inner contents.
4021 /// This ignores pointers and is_owned flags and looks at the values in fields.
4022 /// Two objects with NULL inner values will be considered "equal" here.
4024 pub extern "C" fn ClosingSigned_eq(a: &ClosingSigned, b: &ClosingSigned) -> bool {
4025 if a.inner == b.inner { return true; }
4026 if a.inner.is_null() || b.inner.is_null() { return false; }
4027 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4030 use lightning::ln::msgs::UpdateAddHTLC as nativeUpdateAddHTLCImport;
4031 pub(crate) type nativeUpdateAddHTLC = nativeUpdateAddHTLCImport;
4033 /// An [`update_add_htlc`] message to be sent to or received from a peer.
4035 /// [`update_add_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#adding-an-htlc-update_add_htlc
4038 pub struct UpdateAddHTLC {
4039 /// A pointer to the opaque Rust object.
4041 /// Nearly everywhere, inner must be non-null, however in places where
4042 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4043 pub inner: *mut nativeUpdateAddHTLC,
4044 /// Indicates that this is the only struct which contains the same pointer.
4046 /// Rust functions which take ownership of an object provided via an argument require
4047 /// this to be true and invalidate the object pointed to by inner.
4051 impl Drop for UpdateAddHTLC {
4052 fn drop(&mut self) {
4053 if self.is_owned && !<*mut nativeUpdateAddHTLC>::is_null(self.inner) {
4054 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4058 /// Frees any resources used by the UpdateAddHTLC, if is_owned is set and inner is non-NULL.
4060 pub extern "C" fn UpdateAddHTLC_free(this_obj: UpdateAddHTLC) { }
4062 /// Used only if an object of this type is returned as a trait impl by a method
4063 pub(crate) extern "C" fn UpdateAddHTLC_free_void(this_ptr: *mut c_void) {
4064 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateAddHTLC) };
4067 impl UpdateAddHTLC {
4068 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateAddHTLC {
4069 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4071 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateAddHTLC {
4072 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4074 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4075 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateAddHTLC {
4076 assert!(self.is_owned);
4077 let ret = ObjOps::untweak_ptr(self.inner);
4078 self.inner = core::ptr::null_mut();
4084 pub extern "C" fn UpdateAddHTLC_get_channel_id(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
4085 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4090 pub extern "C" fn UpdateAddHTLC_set_channel_id(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4091 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
4095 pub extern "C" fn UpdateAddHTLC_get_htlc_id(this_ptr: &UpdateAddHTLC) -> u64 {
4096 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
4101 pub extern "C" fn UpdateAddHTLC_set_htlc_id(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
4102 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
4104 /// The HTLC value in milli-satoshi
4106 pub extern "C" fn UpdateAddHTLC_get_amount_msat(this_ptr: &UpdateAddHTLC) -> u64 {
4107 let mut inner_val = &mut this_ptr.get_native_mut_ref().amount_msat;
4110 /// The HTLC value in milli-satoshi
4112 pub extern "C" fn UpdateAddHTLC_set_amount_msat(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
4113 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.amount_msat = val;
4115 /// The payment hash, the pre-image of which controls HTLC redemption
4117 pub extern "C" fn UpdateAddHTLC_get_payment_hash(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
4118 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_hash;
4121 /// The payment hash, the pre-image of which controls HTLC redemption
4123 pub extern "C" fn UpdateAddHTLC_set_payment_hash(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4124 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_hash = ::lightning::ln::PaymentHash(val.data);
4126 /// The expiry height of the HTLC
4128 pub extern "C" fn UpdateAddHTLC_get_cltv_expiry(this_ptr: &UpdateAddHTLC) -> u32 {
4129 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry;
4132 /// The expiry height of the HTLC
4134 pub extern "C" fn UpdateAddHTLC_set_cltv_expiry(this_ptr: &mut UpdateAddHTLC, mut val: u32) {
4135 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry = val;
4137 /// The extra fee skimmed by the sender of this message. See
4138 /// [`ChannelConfig::accept_underpaying_htlcs`].
4140 /// [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
4142 pub extern "C" fn UpdateAddHTLC_get_skimmed_fee_msat(this_ptr: &UpdateAddHTLC) -> crate::c_types::derived::COption_u64Z {
4143 let mut inner_val = &mut this_ptr.get_native_mut_ref().skimmed_fee_msat;
4144 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() }) };
4147 /// The extra fee skimmed by the sender of this message. See
4148 /// [`ChannelConfig::accept_underpaying_htlcs`].
4150 /// [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
4152 pub extern "C" fn UpdateAddHTLC_set_skimmed_fee_msat(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::derived::COption_u64Z) {
4153 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
4154 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.skimmed_fee_msat = local_val;
4156 impl Clone for UpdateAddHTLC {
4157 fn clone(&self) -> Self {
4159 inner: if <*mut nativeUpdateAddHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
4160 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4166 /// Used only if an object of this type is returned as a trait impl by a method
4167 pub(crate) extern "C" fn UpdateAddHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
4168 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateAddHTLC)).clone() })) as *mut c_void
4171 /// Creates a copy of the UpdateAddHTLC
4172 pub extern "C" fn UpdateAddHTLC_clone(orig: &UpdateAddHTLC) -> UpdateAddHTLC {
4175 /// Checks if two UpdateAddHTLCs contain equal inner contents.
4176 /// This ignores pointers and is_owned flags and looks at the values in fields.
4177 /// Two objects with NULL inner values will be considered "equal" here.
4179 pub extern "C" fn UpdateAddHTLC_eq(a: &UpdateAddHTLC, b: &UpdateAddHTLC) -> bool {
4180 if a.inner == b.inner { return true; }
4181 if a.inner.is_null() || b.inner.is_null() { return false; }
4182 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4185 use lightning::ln::msgs::OnionMessage as nativeOnionMessageImport;
4186 pub(crate) type nativeOnionMessage = nativeOnionMessageImport;
4188 /// An onion message to be sent to or received from a peer.
4192 pub struct OnionMessage {
4193 /// A pointer to the opaque Rust object.
4195 /// Nearly everywhere, inner must be non-null, however in places where
4196 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4197 pub inner: *mut nativeOnionMessage,
4198 /// Indicates that this is the only struct which contains the same pointer.
4200 /// Rust functions which take ownership of an object provided via an argument require
4201 /// this to be true and invalidate the object pointed to by inner.
4205 impl Drop for OnionMessage {
4206 fn drop(&mut self) {
4207 if self.is_owned && !<*mut nativeOnionMessage>::is_null(self.inner) {
4208 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4212 /// Frees any resources used by the OnionMessage, if is_owned is set and inner is non-NULL.
4214 pub extern "C" fn OnionMessage_free(this_obj: OnionMessage) { }
4216 /// Used only if an object of this type is returned as a trait impl by a method
4217 pub(crate) extern "C" fn OnionMessage_free_void(this_ptr: *mut c_void) {
4218 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOnionMessage) };
4222 pub(crate) fn get_native_ref(&self) -> &'static nativeOnionMessage {
4223 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4225 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOnionMessage {
4226 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4228 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4229 pub(crate) fn take_inner(mut self) -> *mut nativeOnionMessage {
4230 assert!(self.is_owned);
4231 let ret = ObjOps::untweak_ptr(self.inner);
4232 self.inner = core::ptr::null_mut();
4236 /// Used in decrypting the onion packet's payload.
4238 pub extern "C" fn OnionMessage_get_blinding_point(this_ptr: &OnionMessage) -> crate::c_types::PublicKey {
4239 let mut inner_val = &mut this_ptr.get_native_mut_ref().blinding_point;
4240 crate::c_types::PublicKey::from_rust(&inner_val)
4242 /// Used in decrypting the onion packet's payload.
4244 pub extern "C" fn OnionMessage_set_blinding_point(this_ptr: &mut OnionMessage, mut val: crate::c_types::PublicKey) {
4245 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.blinding_point = val.into_rust();
4247 impl Clone for OnionMessage {
4248 fn clone(&self) -> Self {
4250 inner: if <*mut nativeOnionMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
4251 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4257 /// Used only if an object of this type is returned as a trait impl by a method
4258 pub(crate) extern "C" fn OnionMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
4259 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOnionMessage)).clone() })) as *mut c_void
4262 /// Creates a copy of the OnionMessage
4263 pub extern "C" fn OnionMessage_clone(orig: &OnionMessage) -> OnionMessage {
4266 /// Checks if two OnionMessages contain equal inner contents.
4267 /// This ignores pointers and is_owned flags and looks at the values in fields.
4268 /// Two objects with NULL inner values will be considered "equal" here.
4270 pub extern "C" fn OnionMessage_eq(a: &OnionMessage, b: &OnionMessage) -> bool {
4271 if a.inner == b.inner { return true; }
4272 if a.inner.is_null() || b.inner.is_null() { return false; }
4273 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4276 use lightning::ln::msgs::UpdateFulfillHTLC as nativeUpdateFulfillHTLCImport;
4277 pub(crate) type nativeUpdateFulfillHTLC = nativeUpdateFulfillHTLCImport;
4279 /// An [`update_fulfill_htlc`] message to be sent to or received from a peer.
4281 /// [`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
4284 pub struct UpdateFulfillHTLC {
4285 /// A pointer to the opaque Rust object.
4287 /// Nearly everywhere, inner must be non-null, however in places where
4288 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4289 pub inner: *mut nativeUpdateFulfillHTLC,
4290 /// Indicates that this is the only struct which contains the same pointer.
4292 /// Rust functions which take ownership of an object provided via an argument require
4293 /// this to be true and invalidate the object pointed to by inner.
4297 impl Drop for UpdateFulfillHTLC {
4298 fn drop(&mut self) {
4299 if self.is_owned && !<*mut nativeUpdateFulfillHTLC>::is_null(self.inner) {
4300 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4304 /// Frees any resources used by the UpdateFulfillHTLC, if is_owned is set and inner is non-NULL.
4306 pub extern "C" fn UpdateFulfillHTLC_free(this_obj: UpdateFulfillHTLC) { }
4308 /// Used only if an object of this type is returned as a trait impl by a method
4309 pub(crate) extern "C" fn UpdateFulfillHTLC_free_void(this_ptr: *mut c_void) {
4310 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFulfillHTLC) };
4313 impl UpdateFulfillHTLC {
4314 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFulfillHTLC {
4315 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4317 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFulfillHTLC {
4318 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4320 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4321 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFulfillHTLC {
4322 assert!(self.is_owned);
4323 let ret = ObjOps::untweak_ptr(self.inner);
4324 self.inner = core::ptr::null_mut();
4330 pub extern "C" fn UpdateFulfillHTLC_get_channel_id(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
4331 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4336 pub extern "C" fn UpdateFulfillHTLC_set_channel_id(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4337 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
4341 pub extern "C" fn UpdateFulfillHTLC_get_htlc_id(this_ptr: &UpdateFulfillHTLC) -> u64 {
4342 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
4347 pub extern "C" fn UpdateFulfillHTLC_set_htlc_id(this_ptr: &mut UpdateFulfillHTLC, mut val: u64) {
4348 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
4350 /// The pre-image of the payment hash, allowing HTLC redemption
4352 pub extern "C" fn UpdateFulfillHTLC_get_payment_preimage(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
4353 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_preimage;
4356 /// The pre-image of the payment hash, allowing HTLC redemption
4358 pub extern "C" fn UpdateFulfillHTLC_set_payment_preimage(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4359 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_preimage = ::lightning::ln::PaymentPreimage(val.data);
4361 /// Constructs a new UpdateFulfillHTLC given each field
4364 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 {
4365 UpdateFulfillHTLC { inner: ObjOps::heap_alloc(nativeUpdateFulfillHTLC {
4366 channel_id: channel_id_arg.data,
4367 htlc_id: htlc_id_arg,
4368 payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_arg.data),
4369 }), is_owned: true }
4371 impl Clone for UpdateFulfillHTLC {
4372 fn clone(&self) -> Self {
4374 inner: if <*mut nativeUpdateFulfillHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
4375 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4381 /// Used only if an object of this type is returned as a trait impl by a method
4382 pub(crate) extern "C" fn UpdateFulfillHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
4383 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFulfillHTLC)).clone() })) as *mut c_void
4386 /// Creates a copy of the UpdateFulfillHTLC
4387 pub extern "C" fn UpdateFulfillHTLC_clone(orig: &UpdateFulfillHTLC) -> UpdateFulfillHTLC {
4390 /// Checks if two UpdateFulfillHTLCs contain equal inner contents.
4391 /// This ignores pointers and is_owned flags and looks at the values in fields.
4392 /// Two objects with NULL inner values will be considered "equal" here.
4394 pub extern "C" fn UpdateFulfillHTLC_eq(a: &UpdateFulfillHTLC, b: &UpdateFulfillHTLC) -> bool {
4395 if a.inner == b.inner { return true; }
4396 if a.inner.is_null() || b.inner.is_null() { return false; }
4397 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4400 use lightning::ln::msgs::UpdateFailHTLC as nativeUpdateFailHTLCImport;
4401 pub(crate) type nativeUpdateFailHTLC = nativeUpdateFailHTLCImport;
4403 /// An [`update_fail_htlc`] message to be sent to or received from a peer.
4405 /// [`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
4408 pub struct UpdateFailHTLC {
4409 /// A pointer to the opaque Rust object.
4411 /// Nearly everywhere, inner must be non-null, however in places where
4412 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4413 pub inner: *mut nativeUpdateFailHTLC,
4414 /// Indicates that this is the only struct which contains the same pointer.
4416 /// Rust functions which take ownership of an object provided via an argument require
4417 /// this to be true and invalidate the object pointed to by inner.
4421 impl Drop for UpdateFailHTLC {
4422 fn drop(&mut self) {
4423 if self.is_owned && !<*mut nativeUpdateFailHTLC>::is_null(self.inner) {
4424 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4428 /// Frees any resources used by the UpdateFailHTLC, if is_owned is set and inner is non-NULL.
4430 pub extern "C" fn UpdateFailHTLC_free(this_obj: UpdateFailHTLC) { }
4432 /// Used only if an object of this type is returned as a trait impl by a method
4433 pub(crate) extern "C" fn UpdateFailHTLC_free_void(this_ptr: *mut c_void) {
4434 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFailHTLC) };
4437 impl UpdateFailHTLC {
4438 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailHTLC {
4439 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4441 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailHTLC {
4442 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4444 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4445 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailHTLC {
4446 assert!(self.is_owned);
4447 let ret = ObjOps::untweak_ptr(self.inner);
4448 self.inner = core::ptr::null_mut();
4454 pub extern "C" fn UpdateFailHTLC_get_channel_id(this_ptr: &UpdateFailHTLC) -> *const [u8; 32] {
4455 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4460 pub extern "C" fn UpdateFailHTLC_set_channel_id(this_ptr: &mut UpdateFailHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4461 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
4465 pub extern "C" fn UpdateFailHTLC_get_htlc_id(this_ptr: &UpdateFailHTLC) -> u64 {
4466 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
4471 pub extern "C" fn UpdateFailHTLC_set_htlc_id(this_ptr: &mut UpdateFailHTLC, mut val: u64) {
4472 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
4474 impl Clone for UpdateFailHTLC {
4475 fn clone(&self) -> Self {
4477 inner: if <*mut nativeUpdateFailHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
4478 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4484 /// Used only if an object of this type is returned as a trait impl by a method
4485 pub(crate) extern "C" fn UpdateFailHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
4486 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailHTLC)).clone() })) as *mut c_void
4489 /// Creates a copy of the UpdateFailHTLC
4490 pub extern "C" fn UpdateFailHTLC_clone(orig: &UpdateFailHTLC) -> UpdateFailHTLC {
4493 /// Checks if two UpdateFailHTLCs contain equal inner contents.
4494 /// This ignores pointers and is_owned flags and looks at the values in fields.
4495 /// Two objects with NULL inner values will be considered "equal" here.
4497 pub extern "C" fn UpdateFailHTLC_eq(a: &UpdateFailHTLC, b: &UpdateFailHTLC) -> bool {
4498 if a.inner == b.inner { return true; }
4499 if a.inner.is_null() || b.inner.is_null() { return false; }
4500 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4503 use lightning::ln::msgs::UpdateFailMalformedHTLC as nativeUpdateFailMalformedHTLCImport;
4504 pub(crate) type nativeUpdateFailMalformedHTLC = nativeUpdateFailMalformedHTLCImport;
4506 /// An [`update_fail_malformed_htlc`] message to be sent to or received from a peer.
4508 /// [`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
4511 pub struct UpdateFailMalformedHTLC {
4512 /// A pointer to the opaque Rust object.
4514 /// Nearly everywhere, inner must be non-null, however in places where
4515 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4516 pub inner: *mut nativeUpdateFailMalformedHTLC,
4517 /// Indicates that this is the only struct which contains the same pointer.
4519 /// Rust functions which take ownership of an object provided via an argument require
4520 /// this to be true and invalidate the object pointed to by inner.
4524 impl Drop for UpdateFailMalformedHTLC {
4525 fn drop(&mut self) {
4526 if self.is_owned && !<*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) {
4527 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4531 /// Frees any resources used by the UpdateFailMalformedHTLC, if is_owned is set and inner is non-NULL.
4533 pub extern "C" fn UpdateFailMalformedHTLC_free(this_obj: UpdateFailMalformedHTLC) { }
4535 /// Used only if an object of this type is returned as a trait impl by a method
4536 pub(crate) extern "C" fn UpdateFailMalformedHTLC_free_void(this_ptr: *mut c_void) {
4537 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFailMalformedHTLC) };
4540 impl UpdateFailMalformedHTLC {
4541 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailMalformedHTLC {
4542 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4544 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailMalformedHTLC {
4545 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4547 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4548 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailMalformedHTLC {
4549 assert!(self.is_owned);
4550 let ret = ObjOps::untweak_ptr(self.inner);
4551 self.inner = core::ptr::null_mut();
4557 pub extern "C" fn UpdateFailMalformedHTLC_get_channel_id(this_ptr: &UpdateFailMalformedHTLC) -> *const [u8; 32] {
4558 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4563 pub extern "C" fn UpdateFailMalformedHTLC_set_channel_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4564 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
4568 pub extern "C" fn UpdateFailMalformedHTLC_get_htlc_id(this_ptr: &UpdateFailMalformedHTLC) -> u64 {
4569 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
4574 pub extern "C" fn UpdateFailMalformedHTLC_set_htlc_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u64) {
4575 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
4577 /// The failure code
4579 pub extern "C" fn UpdateFailMalformedHTLC_get_failure_code(this_ptr: &UpdateFailMalformedHTLC) -> u16 {
4580 let mut inner_val = &mut this_ptr.get_native_mut_ref().failure_code;
4583 /// The failure code
4585 pub extern "C" fn UpdateFailMalformedHTLC_set_failure_code(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u16) {
4586 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.failure_code = val;
4588 impl Clone for UpdateFailMalformedHTLC {
4589 fn clone(&self) -> Self {
4591 inner: if <*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
4592 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4598 /// Used only if an object of this type is returned as a trait impl by a method
4599 pub(crate) extern "C" fn UpdateFailMalformedHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
4600 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailMalformedHTLC)).clone() })) as *mut c_void
4603 /// Creates a copy of the UpdateFailMalformedHTLC
4604 pub extern "C" fn UpdateFailMalformedHTLC_clone(orig: &UpdateFailMalformedHTLC) -> UpdateFailMalformedHTLC {
4607 /// Checks if two UpdateFailMalformedHTLCs contain equal inner contents.
4608 /// This ignores pointers and is_owned flags and looks at the values in fields.
4609 /// Two objects with NULL inner values will be considered "equal" here.
4611 pub extern "C" fn UpdateFailMalformedHTLC_eq(a: &UpdateFailMalformedHTLC, b: &UpdateFailMalformedHTLC) -> bool {
4612 if a.inner == b.inner { return true; }
4613 if a.inner.is_null() || b.inner.is_null() { return false; }
4614 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4617 use lightning::ln::msgs::CommitmentSigned as nativeCommitmentSignedImport;
4618 pub(crate) type nativeCommitmentSigned = nativeCommitmentSignedImport;
4620 /// A [`commitment_signed`] message to be sent to or received from a peer.
4622 /// [`commitment_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#committing-updates-so-far-commitment_signed
4625 pub struct CommitmentSigned {
4626 /// A pointer to the opaque Rust object.
4628 /// Nearly everywhere, inner must be non-null, however in places where
4629 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4630 pub inner: *mut nativeCommitmentSigned,
4631 /// Indicates that this is the only struct which contains the same pointer.
4633 /// Rust functions which take ownership of an object provided via an argument require
4634 /// this to be true and invalidate the object pointed to by inner.
4638 impl Drop for CommitmentSigned {
4639 fn drop(&mut self) {
4640 if self.is_owned && !<*mut nativeCommitmentSigned>::is_null(self.inner) {
4641 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4645 /// Frees any resources used by the CommitmentSigned, if is_owned is set and inner is non-NULL.
4647 pub extern "C" fn CommitmentSigned_free(this_obj: CommitmentSigned) { }
4649 /// Used only if an object of this type is returned as a trait impl by a method
4650 pub(crate) extern "C" fn CommitmentSigned_free_void(this_ptr: *mut c_void) {
4651 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCommitmentSigned) };
4654 impl CommitmentSigned {
4655 pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentSigned {
4656 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4658 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentSigned {
4659 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4661 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4662 pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentSigned {
4663 assert!(self.is_owned);
4664 let ret = ObjOps::untweak_ptr(self.inner);
4665 self.inner = core::ptr::null_mut();
4671 pub extern "C" fn CommitmentSigned_get_channel_id(this_ptr: &CommitmentSigned) -> *const [u8; 32] {
4672 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4677 pub extern "C" fn CommitmentSigned_set_channel_id(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::ThirtyTwoBytes) {
4678 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
4680 /// A signature on the commitment transaction
4682 pub extern "C" fn CommitmentSigned_get_signature(this_ptr: &CommitmentSigned) -> crate::c_types::Signature {
4683 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
4684 crate::c_types::Signature::from_rust(&inner_val)
4686 /// A signature on the commitment transaction
4688 pub extern "C" fn CommitmentSigned_set_signature(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::Signature) {
4689 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
4691 /// Signatures on the HTLC transactions
4693 /// Returns a copy of the field.
4695 pub extern "C" fn CommitmentSigned_get_htlc_signatures(this_ptr: &CommitmentSigned) -> crate::c_types::derived::CVec_SignatureZ {
4696 let mut inner_val = this_ptr.get_native_mut_ref().htlc_signatures.clone();
4697 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { crate::c_types::Signature::from_rust(&item) }); };
4698 local_inner_val.into()
4700 /// Signatures on the HTLC transactions
4702 pub extern "C" fn CommitmentSigned_set_htlc_signatures(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::derived::CVec_SignatureZ) {
4703 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_rust() }); };
4704 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_signatures = local_val;
4706 /// Constructs a new CommitmentSigned given each field
4709 pub extern "C" fn CommitmentSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut signature_arg: crate::c_types::Signature, mut htlc_signatures_arg: crate::c_types::derived::CVec_SignatureZ) -> CommitmentSigned {
4710 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() }); };
4711 CommitmentSigned { inner: ObjOps::heap_alloc(nativeCommitmentSigned {
4712 channel_id: channel_id_arg.data,
4713 signature: signature_arg.into_rust(),
4714 htlc_signatures: local_htlc_signatures_arg,
4715 }), is_owned: true }
4717 impl Clone for CommitmentSigned {
4718 fn clone(&self) -> Self {
4720 inner: if <*mut nativeCommitmentSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
4721 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4727 /// Used only if an object of this type is returned as a trait impl by a method
4728 pub(crate) extern "C" fn CommitmentSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
4729 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentSigned)).clone() })) as *mut c_void
4732 /// Creates a copy of the CommitmentSigned
4733 pub extern "C" fn CommitmentSigned_clone(orig: &CommitmentSigned) -> CommitmentSigned {
4736 /// Checks if two CommitmentSigneds contain equal inner contents.
4737 /// This ignores pointers and is_owned flags and looks at the values in fields.
4738 /// Two objects with NULL inner values will be considered "equal" here.
4740 pub extern "C" fn CommitmentSigned_eq(a: &CommitmentSigned, b: &CommitmentSigned) -> bool {
4741 if a.inner == b.inner { return true; }
4742 if a.inner.is_null() || b.inner.is_null() { return false; }
4743 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4746 use lightning::ln::msgs::RevokeAndACK as nativeRevokeAndACKImport;
4747 pub(crate) type nativeRevokeAndACK = nativeRevokeAndACKImport;
4749 /// A [`revoke_and_ack`] message to be sent to or received from a peer.
4751 /// [`revoke_and_ack`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#completing-the-transition-to-the-updated-state-revoke_and_ack
4754 pub struct RevokeAndACK {
4755 /// A pointer to the opaque Rust object.
4757 /// Nearly everywhere, inner must be non-null, however in places where
4758 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4759 pub inner: *mut nativeRevokeAndACK,
4760 /// Indicates that this is the only struct which contains the same pointer.
4762 /// Rust functions which take ownership of an object provided via an argument require
4763 /// this to be true and invalidate the object pointed to by inner.
4767 impl Drop for RevokeAndACK {
4768 fn drop(&mut self) {
4769 if self.is_owned && !<*mut nativeRevokeAndACK>::is_null(self.inner) {
4770 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4774 /// Frees any resources used by the RevokeAndACK, if is_owned is set and inner is non-NULL.
4776 pub extern "C" fn RevokeAndACK_free(this_obj: RevokeAndACK) { }
4778 /// Used only if an object of this type is returned as a trait impl by a method
4779 pub(crate) extern "C" fn RevokeAndACK_free_void(this_ptr: *mut c_void) {
4780 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRevokeAndACK) };
4784 pub(crate) fn get_native_ref(&self) -> &'static nativeRevokeAndACK {
4785 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4787 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRevokeAndACK {
4788 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4790 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4791 pub(crate) fn take_inner(mut self) -> *mut nativeRevokeAndACK {
4792 assert!(self.is_owned);
4793 let ret = ObjOps::untweak_ptr(self.inner);
4794 self.inner = core::ptr::null_mut();
4800 pub extern "C" fn RevokeAndACK_get_channel_id(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
4801 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4806 pub extern "C" fn RevokeAndACK_set_channel_id(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
4807 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
4809 /// The secret corresponding to the per-commitment point
4811 pub extern "C" fn RevokeAndACK_get_per_commitment_secret(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
4812 let mut inner_val = &mut this_ptr.get_native_mut_ref().per_commitment_secret;
4815 /// The secret corresponding to the per-commitment point
4817 pub extern "C" fn RevokeAndACK_set_per_commitment_secret(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
4818 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.per_commitment_secret = val.data;
4820 /// The next sender-broadcast commitment transaction's per-commitment point
4822 pub extern "C" fn RevokeAndACK_get_next_per_commitment_point(this_ptr: &RevokeAndACK) -> crate::c_types::PublicKey {
4823 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
4824 crate::c_types::PublicKey::from_rust(&inner_val)
4826 /// The next sender-broadcast commitment transaction's per-commitment point
4828 pub extern "C" fn RevokeAndACK_set_next_per_commitment_point(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::PublicKey) {
4829 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
4831 /// Constructs a new RevokeAndACK given each field
4834 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 {
4835 RevokeAndACK { inner: ObjOps::heap_alloc(nativeRevokeAndACK {
4836 channel_id: channel_id_arg.data,
4837 per_commitment_secret: per_commitment_secret_arg.data,
4838 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
4839 }), is_owned: true }
4841 impl Clone for RevokeAndACK {
4842 fn clone(&self) -> Self {
4844 inner: if <*mut nativeRevokeAndACK>::is_null(self.inner) { core::ptr::null_mut() } else {
4845 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4851 /// Used only if an object of this type is returned as a trait impl by a method
4852 pub(crate) extern "C" fn RevokeAndACK_clone_void(this_ptr: *const c_void) -> *mut c_void {
4853 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRevokeAndACK)).clone() })) as *mut c_void
4856 /// Creates a copy of the RevokeAndACK
4857 pub extern "C" fn RevokeAndACK_clone(orig: &RevokeAndACK) -> RevokeAndACK {
4860 /// Checks if two RevokeAndACKs contain equal inner contents.
4861 /// This ignores pointers and is_owned flags and looks at the values in fields.
4862 /// Two objects with NULL inner values will be considered "equal" here.
4864 pub extern "C" fn RevokeAndACK_eq(a: &RevokeAndACK, b: &RevokeAndACK) -> bool {
4865 if a.inner == b.inner { return true; }
4866 if a.inner.is_null() || b.inner.is_null() { return false; }
4867 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4870 use lightning::ln::msgs::UpdateFee as nativeUpdateFeeImport;
4871 pub(crate) type nativeUpdateFee = nativeUpdateFeeImport;
4873 /// An [`update_fee`] message to be sent to or received from a peer
4875 /// [`update_fee`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#updating-fees-update_fee
4878 pub struct UpdateFee {
4879 /// A pointer to the opaque Rust object.
4881 /// Nearly everywhere, inner must be non-null, however in places where
4882 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4883 pub inner: *mut nativeUpdateFee,
4884 /// Indicates that this is the only struct which contains the same pointer.
4886 /// Rust functions which take ownership of an object provided via an argument require
4887 /// this to be true and invalidate the object pointed to by inner.
4891 impl Drop for UpdateFee {
4892 fn drop(&mut self) {
4893 if self.is_owned && !<*mut nativeUpdateFee>::is_null(self.inner) {
4894 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4898 /// Frees any resources used by the UpdateFee, if is_owned is set and inner is non-NULL.
4900 pub extern "C" fn UpdateFee_free(this_obj: UpdateFee) { }
4902 /// Used only if an object of this type is returned as a trait impl by a method
4903 pub(crate) extern "C" fn UpdateFee_free_void(this_ptr: *mut c_void) {
4904 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFee) };
4908 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFee {
4909 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4911 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFee {
4912 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4914 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4915 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFee {
4916 assert!(self.is_owned);
4917 let ret = ObjOps::untweak_ptr(self.inner);
4918 self.inner = core::ptr::null_mut();
4924 pub extern "C" fn UpdateFee_get_channel_id(this_ptr: &UpdateFee) -> *const [u8; 32] {
4925 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4930 pub extern "C" fn UpdateFee_set_channel_id(this_ptr: &mut UpdateFee, mut val: crate::c_types::ThirtyTwoBytes) {
4931 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
4933 /// Fee rate per 1000-weight of the transaction
4935 pub extern "C" fn UpdateFee_get_feerate_per_kw(this_ptr: &UpdateFee) -> u32 {
4936 let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
4939 /// Fee rate per 1000-weight of the transaction
4941 pub extern "C" fn UpdateFee_set_feerate_per_kw(this_ptr: &mut UpdateFee, mut val: u32) {
4942 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
4944 /// Constructs a new UpdateFee given each field
4947 pub extern "C" fn UpdateFee_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut feerate_per_kw_arg: u32) -> UpdateFee {
4948 UpdateFee { inner: ObjOps::heap_alloc(nativeUpdateFee {
4949 channel_id: channel_id_arg.data,
4950 feerate_per_kw: feerate_per_kw_arg,
4951 }), is_owned: true }
4953 impl Clone for UpdateFee {
4954 fn clone(&self) -> Self {
4956 inner: if <*mut nativeUpdateFee>::is_null(self.inner) { core::ptr::null_mut() } else {
4957 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4963 /// Used only if an object of this type is returned as a trait impl by a method
4964 pub(crate) extern "C" fn UpdateFee_clone_void(this_ptr: *const c_void) -> *mut c_void {
4965 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFee)).clone() })) as *mut c_void
4968 /// Creates a copy of the UpdateFee
4969 pub extern "C" fn UpdateFee_clone(orig: &UpdateFee) -> UpdateFee {
4972 /// Checks if two UpdateFees contain equal inner contents.
4973 /// This ignores pointers and is_owned flags and looks at the values in fields.
4974 /// Two objects with NULL inner values will be considered "equal" here.
4976 pub extern "C" fn UpdateFee_eq(a: &UpdateFee, b: &UpdateFee) -> bool {
4977 if a.inner == b.inner { return true; }
4978 if a.inner.is_null() || b.inner.is_null() { return false; }
4979 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4982 use lightning::ln::msgs::ChannelReestablish as nativeChannelReestablishImport;
4983 pub(crate) type nativeChannelReestablish = nativeChannelReestablishImport;
4985 /// A [`channel_reestablish`] message to be sent to or received from a peer.
4987 /// [`channel_reestablish`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#message-retransmission
4990 pub struct ChannelReestablish {
4991 /// A pointer to the opaque Rust object.
4993 /// Nearly everywhere, inner must be non-null, however in places where
4994 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4995 pub inner: *mut nativeChannelReestablish,
4996 /// Indicates that this is the only struct which contains the same pointer.
4998 /// Rust functions which take ownership of an object provided via an argument require
4999 /// this to be true and invalidate the object pointed to by inner.
5003 impl Drop for ChannelReestablish {
5004 fn drop(&mut self) {
5005 if self.is_owned && !<*mut nativeChannelReestablish>::is_null(self.inner) {
5006 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5010 /// Frees any resources used by the ChannelReestablish, if is_owned is set and inner is non-NULL.
5012 pub extern "C" fn ChannelReestablish_free(this_obj: ChannelReestablish) { }
5014 /// Used only if an object of this type is returned as a trait impl by a method
5015 pub(crate) extern "C" fn ChannelReestablish_free_void(this_ptr: *mut c_void) {
5016 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelReestablish) };
5019 impl ChannelReestablish {
5020 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelReestablish {
5021 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5023 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelReestablish {
5024 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5026 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5027 pub(crate) fn take_inner(mut self) -> *mut nativeChannelReestablish {
5028 assert!(self.is_owned);
5029 let ret = ObjOps::untweak_ptr(self.inner);
5030 self.inner = core::ptr::null_mut();
5036 pub extern "C" fn ChannelReestablish_get_channel_id(this_ptr: &ChannelReestablish) -> *const [u8; 32] {
5037 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5042 pub extern "C" fn ChannelReestablish_set_channel_id(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) {
5043 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
5045 /// The next commitment number for the sender
5047 pub extern "C" fn ChannelReestablish_get_next_local_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
5048 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_local_commitment_number;
5051 /// The next commitment number for the sender
5053 pub extern "C" fn ChannelReestablish_set_next_local_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
5054 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_local_commitment_number = val;
5056 /// The next commitment number for the recipient
5058 pub extern "C" fn ChannelReestablish_get_next_remote_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
5059 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_remote_commitment_number;
5062 /// The next commitment number for the recipient
5064 pub extern "C" fn ChannelReestablish_set_next_remote_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
5065 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_remote_commitment_number = val;
5067 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
5068 /// belonging to the recipient
5070 pub extern "C" fn ChannelReestablish_get_your_last_per_commitment_secret(this_ptr: &ChannelReestablish) -> *const [u8; 32] {
5071 let mut inner_val = &mut this_ptr.get_native_mut_ref().your_last_per_commitment_secret;
5074 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
5075 /// belonging to the recipient
5077 pub extern "C" fn ChannelReestablish_set_your_last_per_commitment_secret(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) {
5078 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.your_last_per_commitment_secret = val.data;
5080 /// The sender's per-commitment point for their current commitment transaction
5082 pub extern "C" fn ChannelReestablish_get_my_current_per_commitment_point(this_ptr: &ChannelReestablish) -> crate::c_types::PublicKey {
5083 let mut inner_val = &mut this_ptr.get_native_mut_ref().my_current_per_commitment_point;
5084 crate::c_types::PublicKey::from_rust(&inner_val)
5086 /// The sender's per-commitment point for their current commitment transaction
5088 pub extern "C" fn ChannelReestablish_set_my_current_per_commitment_point(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::PublicKey) {
5089 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.my_current_per_commitment_point = val.into_rust();
5091 /// The next funding transaction ID
5093 pub extern "C" fn ChannelReestablish_get_next_funding_txid(this_ptr: &ChannelReestablish) -> crate::c_types::derived::COption_TxidZ {
5094 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_funding_txid;
5095 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_TxidZ::None } else { crate::c_types::derived::COption_TxidZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { crate::c_types::ThirtyTwoBytes { data: (*inner_val.as_ref().unwrap()).clone().into_inner() } }) };
5098 /// The next funding transaction ID
5100 pub extern "C" fn ChannelReestablish_set_next_funding_txid(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::derived::COption_TxidZ) {
5101 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() }})} };
5102 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_funding_txid = local_val;
5104 /// Constructs a new ChannelReestablish given each field
5107 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_TxidZ) -> ChannelReestablish {
5108 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() }})} };
5109 ChannelReestablish { inner: ObjOps::heap_alloc(nativeChannelReestablish {
5110 channel_id: channel_id_arg.data,
5111 next_local_commitment_number: next_local_commitment_number_arg,
5112 next_remote_commitment_number: next_remote_commitment_number_arg,
5113 your_last_per_commitment_secret: your_last_per_commitment_secret_arg.data,
5114 my_current_per_commitment_point: my_current_per_commitment_point_arg.into_rust(),
5115 next_funding_txid: local_next_funding_txid_arg,
5116 }), is_owned: true }
5118 impl Clone for ChannelReestablish {
5119 fn clone(&self) -> Self {
5121 inner: if <*mut nativeChannelReestablish>::is_null(self.inner) { core::ptr::null_mut() } else {
5122 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5128 /// Used only if an object of this type is returned as a trait impl by a method
5129 pub(crate) extern "C" fn ChannelReestablish_clone_void(this_ptr: *const c_void) -> *mut c_void {
5130 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelReestablish)).clone() })) as *mut c_void
5133 /// Creates a copy of the ChannelReestablish
5134 pub extern "C" fn ChannelReestablish_clone(orig: &ChannelReestablish) -> ChannelReestablish {
5137 /// Checks if two ChannelReestablishs contain equal inner contents.
5138 /// This ignores pointers and is_owned flags and looks at the values in fields.
5139 /// Two objects with NULL inner values will be considered "equal" here.
5141 pub extern "C" fn ChannelReestablish_eq(a: &ChannelReestablish, b: &ChannelReestablish) -> bool {
5142 if a.inner == b.inner { return true; }
5143 if a.inner.is_null() || b.inner.is_null() { return false; }
5144 if a.get_native_ref() == b.get_native_ref() { true } else { false }
5147 use lightning::ln::msgs::AnnouncementSignatures as nativeAnnouncementSignaturesImport;
5148 pub(crate) type nativeAnnouncementSignatures = nativeAnnouncementSignaturesImport;
5150 /// An [`announcement_signatures`] message to be sent to or received from a peer.
5152 /// [`announcement_signatures`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-announcement_signatures-message
5155 pub struct AnnouncementSignatures {
5156 /// A pointer to the opaque Rust object.
5158 /// Nearly everywhere, inner must be non-null, however in places where
5159 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5160 pub inner: *mut nativeAnnouncementSignatures,
5161 /// Indicates that this is the only struct which contains the same pointer.
5163 /// Rust functions which take ownership of an object provided via an argument require
5164 /// this to be true and invalidate the object pointed to by inner.
5168 impl Drop for AnnouncementSignatures {
5169 fn drop(&mut self) {
5170 if self.is_owned && !<*mut nativeAnnouncementSignatures>::is_null(self.inner) {
5171 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5175 /// Frees any resources used by the AnnouncementSignatures, if is_owned is set and inner is non-NULL.
5177 pub extern "C" fn AnnouncementSignatures_free(this_obj: AnnouncementSignatures) { }
5179 /// Used only if an object of this type is returned as a trait impl by a method
5180 pub(crate) extern "C" fn AnnouncementSignatures_free_void(this_ptr: *mut c_void) {
5181 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAnnouncementSignatures) };
5184 impl AnnouncementSignatures {
5185 pub(crate) fn get_native_ref(&self) -> &'static nativeAnnouncementSignatures {
5186 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5188 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAnnouncementSignatures {
5189 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5191 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5192 pub(crate) fn take_inner(mut self) -> *mut nativeAnnouncementSignatures {
5193 assert!(self.is_owned);
5194 let ret = ObjOps::untweak_ptr(self.inner);
5195 self.inner = core::ptr::null_mut();
5201 pub extern "C" fn AnnouncementSignatures_get_channel_id(this_ptr: &AnnouncementSignatures) -> *const [u8; 32] {
5202 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5207 pub extern "C" fn AnnouncementSignatures_set_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
5208 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
5210 /// The short channel ID
5212 pub extern "C" fn AnnouncementSignatures_get_short_channel_id(this_ptr: &AnnouncementSignatures) -> u64 {
5213 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
5216 /// The short channel ID
5218 pub extern "C" fn AnnouncementSignatures_set_short_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: u64) {
5219 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
5221 /// A signature by the node key
5223 pub extern "C" fn AnnouncementSignatures_get_node_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
5224 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature;
5225 crate::c_types::Signature::from_rust(&inner_val)
5227 /// A signature by the node key
5229 pub extern "C" fn AnnouncementSignatures_set_node_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
5230 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature = val.into_rust();
5232 /// A signature by the funding key
5234 pub extern "C" fn AnnouncementSignatures_get_bitcoin_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
5235 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature;
5236 crate::c_types::Signature::from_rust(&inner_val)
5238 /// A signature by the funding key
5240 pub extern "C" fn AnnouncementSignatures_set_bitcoin_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
5241 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature = val.into_rust();
5243 /// Constructs a new AnnouncementSignatures given each field
5246 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::Signature, mut bitcoin_signature_arg: crate::c_types::Signature) -> AnnouncementSignatures {
5247 AnnouncementSignatures { inner: ObjOps::heap_alloc(nativeAnnouncementSignatures {
5248 channel_id: channel_id_arg.data,
5249 short_channel_id: short_channel_id_arg,
5250 node_signature: node_signature_arg.into_rust(),
5251 bitcoin_signature: bitcoin_signature_arg.into_rust(),
5252 }), is_owned: true }
5254 impl Clone for AnnouncementSignatures {
5255 fn clone(&self) -> Self {
5257 inner: if <*mut nativeAnnouncementSignatures>::is_null(self.inner) { core::ptr::null_mut() } else {
5258 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5264 /// Used only if an object of this type is returned as a trait impl by a method
5265 pub(crate) extern "C" fn AnnouncementSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
5266 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAnnouncementSignatures)).clone() })) as *mut c_void
5269 /// Creates a copy of the AnnouncementSignatures
5270 pub extern "C" fn AnnouncementSignatures_clone(orig: &AnnouncementSignatures) -> AnnouncementSignatures {
5273 /// Checks if two AnnouncementSignaturess contain equal inner contents.
5274 /// This ignores pointers and is_owned flags and looks at the values in fields.
5275 /// Two objects with NULL inner values will be considered "equal" here.
5277 pub extern "C" fn AnnouncementSignatures_eq(a: &AnnouncementSignatures, b: &AnnouncementSignatures) -> bool {
5278 if a.inner == b.inner { return true; }
5279 if a.inner.is_null() || b.inner.is_null() { return false; }
5280 if a.get_native_ref() == b.get_native_ref() { true } else { false }
5282 /// An address which can be used to connect to a remote peer.
5286 pub enum NetAddress {
5287 /// An IPv4 address/port on which the peer is listening.
5289 /// The 4-byte IPv4 address
5290 addr: crate::c_types::FourBytes,
5291 /// The port on which the node is listening
5294 /// An IPv6 address/port on which the peer is listening.
5296 /// The 16-byte IPv6 address
5297 addr: crate::c_types::SixteenBytes,
5298 /// The port on which the node is listening
5301 /// An old-style Tor onion address/port on which the peer is listening.
5303 /// This field is deprecated and the Tor network generally no longer supports V2 Onion
5304 /// addresses. Thus, the details are not parsed here.
5306 crate::c_types::TwelveBytes),
5307 /// A new-style Tor onion address/port on which the peer is listening.
5309 /// To create the human-readable \"hostname\", concatenate the ED25519 pubkey, checksum, and version,
5310 /// wrap as base32 and append \".onion\".
5312 /// The ed25519 long-term public key of the peer
5313 ed25519_pubkey: crate::c_types::ThirtyTwoBytes,
5314 /// The checksum of the pubkey and version, as included in the onion address
5316 /// The version byte, as defined by the Tor Onion v3 spec.
5318 /// The port on which the node is listening
5321 /// A hostname/port on which the peer is listening.
5323 /// The hostname on which the node is listening.
5324 hostname: crate::lightning::util::ser::Hostname,
5325 /// The port on which the node is listening.
5329 use lightning::ln::msgs::NetAddress as NetAddressImport;
5330 pub(crate) type nativeNetAddress = NetAddressImport;
5334 pub(crate) fn to_native(&self) -> nativeNetAddress {
5336 NetAddress::IPv4 {ref addr, ref port, } => {
5337 let mut addr_nonref = Clone::clone(addr);
5338 let mut port_nonref = Clone::clone(port);
5339 nativeNetAddress::IPv4 {
5340 addr: addr_nonref.data,
5344 NetAddress::IPv6 {ref addr, ref port, } => {
5345 let mut addr_nonref = Clone::clone(addr);
5346 let mut port_nonref = Clone::clone(port);
5347 nativeNetAddress::IPv6 {
5348 addr: addr_nonref.data,
5352 NetAddress::OnionV2 (ref a, ) => {
5353 let mut a_nonref = Clone::clone(a);
5354 nativeNetAddress::OnionV2 (
5358 NetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
5359 let mut ed25519_pubkey_nonref = Clone::clone(ed25519_pubkey);
5360 let mut checksum_nonref = Clone::clone(checksum);
5361 let mut version_nonref = Clone::clone(version);
5362 let mut port_nonref = Clone::clone(port);
5363 nativeNetAddress::OnionV3 {
5364 ed25519_pubkey: ed25519_pubkey_nonref.data,
5365 checksum: checksum_nonref,
5366 version: version_nonref,
5370 NetAddress::Hostname {ref hostname, ref port, } => {
5371 let mut hostname_nonref = Clone::clone(hostname);
5372 let mut port_nonref = Clone::clone(port);
5373 nativeNetAddress::Hostname {
5374 hostname: *unsafe { Box::from_raw(hostname_nonref.take_inner()) },
5381 pub(crate) fn into_native(self) -> nativeNetAddress {
5383 NetAddress::IPv4 {mut addr, mut port, } => {
5384 nativeNetAddress::IPv4 {
5389 NetAddress::IPv6 {mut addr, mut port, } => {
5390 nativeNetAddress::IPv6 {
5395 NetAddress::OnionV2 (mut a, ) => {
5396 nativeNetAddress::OnionV2 (
5400 NetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
5401 nativeNetAddress::OnionV3 {
5402 ed25519_pubkey: ed25519_pubkey.data,
5408 NetAddress::Hostname {mut hostname, mut port, } => {
5409 nativeNetAddress::Hostname {
5410 hostname: *unsafe { Box::from_raw(hostname.take_inner()) },
5417 pub(crate) fn from_native(native: &nativeNetAddress) -> Self {
5419 nativeNetAddress::IPv4 {ref addr, ref port, } => {
5420 let mut addr_nonref = Clone::clone(addr);
5421 let mut port_nonref = Clone::clone(port);
5423 addr: crate::c_types::FourBytes { data: addr_nonref },
5427 nativeNetAddress::IPv6 {ref addr, ref port, } => {
5428 let mut addr_nonref = Clone::clone(addr);
5429 let mut port_nonref = Clone::clone(port);
5431 addr: crate::c_types::SixteenBytes { data: addr_nonref },
5435 nativeNetAddress::OnionV2 (ref a, ) => {
5436 let mut a_nonref = Clone::clone(a);
5437 NetAddress::OnionV2 (
5438 crate::c_types::TwelveBytes { data: a_nonref },
5441 nativeNetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
5442 let mut ed25519_pubkey_nonref = Clone::clone(ed25519_pubkey);
5443 let mut checksum_nonref = Clone::clone(checksum);
5444 let mut version_nonref = Clone::clone(version);
5445 let mut port_nonref = Clone::clone(port);
5446 NetAddress::OnionV3 {
5447 ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey_nonref },
5448 checksum: checksum_nonref,
5449 version: version_nonref,
5453 nativeNetAddress::Hostname {ref hostname, ref port, } => {
5454 let mut hostname_nonref = Clone::clone(hostname);
5455 let mut port_nonref = Clone::clone(port);
5456 NetAddress::Hostname {
5457 hostname: crate::lightning::util::ser::Hostname { inner: ObjOps::heap_alloc(hostname_nonref), is_owned: true },
5464 pub(crate) fn native_into(native: nativeNetAddress) -> Self {
5466 nativeNetAddress::IPv4 {mut addr, mut port, } => {
5468 addr: crate::c_types::FourBytes { data: addr },
5472 nativeNetAddress::IPv6 {mut addr, mut port, } => {
5474 addr: crate::c_types::SixteenBytes { data: addr },
5478 nativeNetAddress::OnionV2 (mut a, ) => {
5479 NetAddress::OnionV2 (
5480 crate::c_types::TwelveBytes { data: a },
5483 nativeNetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
5484 NetAddress::OnionV3 {
5485 ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey },
5491 nativeNetAddress::Hostname {mut hostname, mut port, } => {
5492 NetAddress::Hostname {
5493 hostname: crate::lightning::util::ser::Hostname { inner: ObjOps::heap_alloc(hostname), is_owned: true },
5500 /// Frees any resources used by the NetAddress
5502 pub extern "C" fn NetAddress_free(this_ptr: NetAddress) { }
5503 /// Creates a copy of the NetAddress
5505 pub extern "C" fn NetAddress_clone(orig: &NetAddress) -> NetAddress {
5509 /// Utility method to constructs a new IPv4-variant NetAddress
5510 pub extern "C" fn NetAddress_ipv4(addr: crate::c_types::FourBytes, port: u16) -> NetAddress {
5517 /// Utility method to constructs a new IPv6-variant NetAddress
5518 pub extern "C" fn NetAddress_ipv6(addr: crate::c_types::SixteenBytes, port: u16) -> NetAddress {
5525 /// Utility method to constructs a new OnionV2-variant NetAddress
5526 pub extern "C" fn NetAddress_onion_v2(a: crate::c_types::TwelveBytes) -> NetAddress {
5527 NetAddress::OnionV2(a, )
5530 /// Utility method to constructs a new OnionV3-variant NetAddress
5531 pub extern "C" fn NetAddress_onion_v3(ed25519_pubkey: crate::c_types::ThirtyTwoBytes, checksum: u16, version: u8, port: u16) -> NetAddress {
5532 NetAddress::OnionV3 {
5540 /// Utility method to constructs a new Hostname-variant NetAddress
5541 pub extern "C" fn NetAddress_hostname(hostname: crate::lightning::util::ser::Hostname, port: u16) -> NetAddress {
5542 NetAddress::Hostname {
5547 /// Checks if two NetAddresss contain equal inner contents.
5548 /// This ignores pointers and is_owned flags and looks at the values in fields.
5550 pub extern "C" fn NetAddress_eq(a: &NetAddress, b: &NetAddress) -> bool {
5551 if &a.to_native() == &b.to_native() { true } else { false }
5554 /// Serialize the NetAddress object into a byte array which can be read by NetAddress_read
5555 pub extern "C" fn NetAddress_write(obj: &crate::lightning::ln::msgs::NetAddress) -> crate::c_types::derived::CVec_u8Z {
5556 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
5559 /// Read a NetAddress from a byte array, created by NetAddress_write
5560 pub extern "C" fn NetAddress_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NetAddressDecodeErrorZ {
5561 let res: Result<lightning::ln::msgs::NetAddress, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5562 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::NetAddress::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
5565 /// Represents the set of gossip messages that require a signature from a node's identity key.
5569 pub enum UnsignedGossipMessage {
5570 /// An unsigned channel announcement.
5571 ChannelAnnouncement(
5572 crate::lightning::ln::msgs::UnsignedChannelAnnouncement),
5573 /// An unsigned channel update.
5575 crate::lightning::ln::msgs::UnsignedChannelUpdate),
5576 /// An unsigned node announcement.
5578 crate::lightning::ln::msgs::UnsignedNodeAnnouncement),
5580 use lightning::ln::msgs::UnsignedGossipMessage as UnsignedGossipMessageImport;
5581 pub(crate) type nativeUnsignedGossipMessage = UnsignedGossipMessageImport;
5583 impl UnsignedGossipMessage {
5585 pub(crate) fn to_native(&self) -> nativeUnsignedGossipMessage {
5587 UnsignedGossipMessage::ChannelAnnouncement (ref a, ) => {
5588 let mut a_nonref = Clone::clone(a);
5589 nativeUnsignedGossipMessage::ChannelAnnouncement (
5590 *unsafe { Box::from_raw(a_nonref.take_inner()) },
5593 UnsignedGossipMessage::ChannelUpdate (ref a, ) => {
5594 let mut a_nonref = Clone::clone(a);
5595 nativeUnsignedGossipMessage::ChannelUpdate (
5596 *unsafe { Box::from_raw(a_nonref.take_inner()) },
5599 UnsignedGossipMessage::NodeAnnouncement (ref a, ) => {
5600 let mut a_nonref = Clone::clone(a);
5601 nativeUnsignedGossipMessage::NodeAnnouncement (
5602 *unsafe { Box::from_raw(a_nonref.take_inner()) },
5608 pub(crate) fn into_native(self) -> nativeUnsignedGossipMessage {
5610 UnsignedGossipMessage::ChannelAnnouncement (mut a, ) => {
5611 nativeUnsignedGossipMessage::ChannelAnnouncement (
5612 *unsafe { Box::from_raw(a.take_inner()) },
5615 UnsignedGossipMessage::ChannelUpdate (mut a, ) => {
5616 nativeUnsignedGossipMessage::ChannelUpdate (
5617 *unsafe { Box::from_raw(a.take_inner()) },
5620 UnsignedGossipMessage::NodeAnnouncement (mut a, ) => {
5621 nativeUnsignedGossipMessage::NodeAnnouncement (
5622 *unsafe { Box::from_raw(a.take_inner()) },
5628 pub(crate) fn from_native(native: &nativeUnsignedGossipMessage) -> Self {
5630 nativeUnsignedGossipMessage::ChannelAnnouncement (ref a, ) => {
5631 let mut a_nonref = Clone::clone(a);
5632 UnsignedGossipMessage::ChannelAnnouncement (
5633 crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
5636 nativeUnsignedGossipMessage::ChannelUpdate (ref a, ) => {
5637 let mut a_nonref = Clone::clone(a);
5638 UnsignedGossipMessage::ChannelUpdate (
5639 crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
5642 nativeUnsignedGossipMessage::NodeAnnouncement (ref a, ) => {
5643 let mut a_nonref = Clone::clone(a);
5644 UnsignedGossipMessage::NodeAnnouncement (
5645 crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
5651 pub(crate) fn native_into(native: nativeUnsignedGossipMessage) -> Self {
5653 nativeUnsignedGossipMessage::ChannelAnnouncement (mut a, ) => {
5654 UnsignedGossipMessage::ChannelAnnouncement (
5655 crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(a), is_owned: true },
5658 nativeUnsignedGossipMessage::ChannelUpdate (mut a, ) => {
5659 UnsignedGossipMessage::ChannelUpdate (
5660 crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: ObjOps::heap_alloc(a), is_owned: true },
5663 nativeUnsignedGossipMessage::NodeAnnouncement (mut a, ) => {
5664 UnsignedGossipMessage::NodeAnnouncement (
5665 crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: ObjOps::heap_alloc(a), is_owned: true },
5671 /// Frees any resources used by the UnsignedGossipMessage
5673 pub extern "C" fn UnsignedGossipMessage_free(this_ptr: UnsignedGossipMessage) { }
5674 /// Creates a copy of the UnsignedGossipMessage
5676 pub extern "C" fn UnsignedGossipMessage_clone(orig: &UnsignedGossipMessage) -> UnsignedGossipMessage {
5680 /// Utility method to constructs a new ChannelAnnouncement-variant UnsignedGossipMessage
5681 pub extern "C" fn UnsignedGossipMessage_channel_announcement(a: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> UnsignedGossipMessage {
5682 UnsignedGossipMessage::ChannelAnnouncement(a, )
5685 /// Utility method to constructs a new ChannelUpdate-variant UnsignedGossipMessage
5686 pub extern "C" fn UnsignedGossipMessage_channel_update(a: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> UnsignedGossipMessage {
5687 UnsignedGossipMessage::ChannelUpdate(a, )
5690 /// Utility method to constructs a new NodeAnnouncement-variant UnsignedGossipMessage
5691 pub extern "C" fn UnsignedGossipMessage_node_announcement(a: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> UnsignedGossipMessage {
5692 UnsignedGossipMessage::NodeAnnouncement(a, )
5695 /// Serialize the UnsignedGossipMessage object into a byte array which can be read by UnsignedGossipMessage_read
5696 pub extern "C" fn UnsignedGossipMessage_write(obj: &crate::lightning::ln::msgs::UnsignedGossipMessage) -> crate::c_types::derived::CVec_u8Z {
5697 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
5700 use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport;
5701 pub(crate) type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport;
5703 /// The unsigned part of a [`node_announcement`] message.
5705 /// [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message
5708 pub struct UnsignedNodeAnnouncement {
5709 /// A pointer to the opaque Rust object.
5711 /// Nearly everywhere, inner must be non-null, however in places where
5712 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5713 pub inner: *mut nativeUnsignedNodeAnnouncement,
5714 /// Indicates that this is the only struct which contains the same pointer.
5716 /// Rust functions which take ownership of an object provided via an argument require
5717 /// this to be true and invalidate the object pointed to by inner.
5721 impl Drop for UnsignedNodeAnnouncement {
5722 fn drop(&mut self) {
5723 if self.is_owned && !<*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) {
5724 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5728 /// Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL.
5730 pub extern "C" fn UnsignedNodeAnnouncement_free(this_obj: UnsignedNodeAnnouncement) { }
5732 /// Used only if an object of this type is returned as a trait impl by a method
5733 pub(crate) extern "C" fn UnsignedNodeAnnouncement_free_void(this_ptr: *mut c_void) {
5734 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedNodeAnnouncement) };
5737 impl UnsignedNodeAnnouncement {
5738 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedNodeAnnouncement {
5739 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5741 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedNodeAnnouncement {
5742 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5744 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5745 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedNodeAnnouncement {
5746 assert!(self.is_owned);
5747 let ret = ObjOps::untweak_ptr(self.inner);
5748 self.inner = core::ptr::null_mut();
5752 /// The advertised features
5754 pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::ln::features::NodeFeatures {
5755 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
5756 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 }
5758 /// The advertised features
5760 pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::ln::features::NodeFeatures) {
5761 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
5763 /// A strictly monotonic announcement counter, with gaps allowed
5765 pub extern "C" fn UnsignedNodeAnnouncement_get_timestamp(this_ptr: &UnsignedNodeAnnouncement) -> u32 {
5766 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
5769 /// A strictly monotonic announcement counter, with gaps allowed
5771 pub extern "C" fn UnsignedNodeAnnouncement_set_timestamp(this_ptr: &mut UnsignedNodeAnnouncement, mut val: u32) {
5772 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
5774 /// The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back
5777 pub extern "C" fn UnsignedNodeAnnouncement_get_node_id(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::routing::gossip::NodeId {
5778 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id;
5779 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 }
5781 /// The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back
5784 pub extern "C" fn UnsignedNodeAnnouncement_set_node_id(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
5785 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id = *unsafe { Box::from_raw(val.take_inner()) };
5787 /// An RGB color for UI purposes
5789 pub extern "C" fn UnsignedNodeAnnouncement_get_rgb(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 3] {
5790 let mut inner_val = &mut this_ptr.get_native_mut_ref().rgb;
5793 /// An RGB color for UI purposes
5795 pub extern "C" fn UnsignedNodeAnnouncement_set_rgb(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThreeBytes) {
5796 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.rgb = val.data;
5798 /// An alias, for UI purposes.
5800 /// This should be sanitized before use. There is no guarantee of uniqueness.
5802 pub extern "C" fn UnsignedNodeAnnouncement_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::routing::gossip::NodeAlias {
5803 let mut inner_val = &mut this_ptr.get_native_mut_ref().alias;
5804 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 }
5806 /// An alias, for UI purposes.
5808 /// This should be sanitized before use. There is no guarantee of uniqueness.
5810 pub extern "C" fn UnsignedNodeAnnouncement_set_alias(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::routing::gossip::NodeAlias) {
5811 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.alias = *unsafe { Box::from_raw(val.take_inner()) };
5813 /// List of addresses on which this node is reachable
5815 /// Returns a copy of the field.
5817 pub extern "C" fn UnsignedNodeAnnouncement_get_addresses(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_NetAddressZ {
5818 let mut inner_val = this_ptr.get_native_mut_ref().addresses.clone();
5819 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { crate::lightning::ln::msgs::NetAddress::native_into(item) }); };
5820 local_inner_val.into()
5822 /// List of addresses on which this node is reachable
5824 pub extern "C" fn UnsignedNodeAnnouncement_set_addresses(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_NetAddressZ) {
5825 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
5826 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.addresses = local_val;
5828 impl Clone for UnsignedNodeAnnouncement {
5829 fn clone(&self) -> Self {
5831 inner: if <*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
5832 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5838 /// Used only if an object of this type is returned as a trait impl by a method
5839 pub(crate) extern "C" fn UnsignedNodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
5840 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedNodeAnnouncement)).clone() })) as *mut c_void
5843 /// Creates a copy of the UnsignedNodeAnnouncement
5844 pub extern "C" fn UnsignedNodeAnnouncement_clone(orig: &UnsignedNodeAnnouncement) -> UnsignedNodeAnnouncement {
5847 /// Checks if two UnsignedNodeAnnouncements contain equal inner contents.
5848 /// This ignores pointers and is_owned flags and looks at the values in fields.
5849 /// Two objects with NULL inner values will be considered "equal" here.
5851 pub extern "C" fn UnsignedNodeAnnouncement_eq(a: &UnsignedNodeAnnouncement, b: &UnsignedNodeAnnouncement) -> bool {
5852 if a.inner == b.inner { return true; }
5853 if a.inner.is_null() || b.inner.is_null() { return false; }
5854 if a.get_native_ref() == b.get_native_ref() { true } else { false }
5857 use lightning::ln::msgs::NodeAnnouncement as nativeNodeAnnouncementImport;
5858 pub(crate) type nativeNodeAnnouncement = nativeNodeAnnouncementImport;
5860 /// A [`node_announcement`] message to be sent to or received from a peer.
5862 /// [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message
5865 pub struct NodeAnnouncement {
5866 /// A pointer to the opaque Rust object.
5868 /// Nearly everywhere, inner must be non-null, however in places where
5869 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5870 pub inner: *mut nativeNodeAnnouncement,
5871 /// Indicates that this is the only struct which contains the same pointer.
5873 /// Rust functions which take ownership of an object provided via an argument require
5874 /// this to be true and invalidate the object pointed to by inner.
5878 impl Drop for NodeAnnouncement {
5879 fn drop(&mut self) {
5880 if self.is_owned && !<*mut nativeNodeAnnouncement>::is_null(self.inner) {
5881 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5885 /// Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL.
5887 pub extern "C" fn NodeAnnouncement_free(this_obj: NodeAnnouncement) { }
5889 /// Used only if an object of this type is returned as a trait impl by a method
5890 pub(crate) extern "C" fn NodeAnnouncement_free_void(this_ptr: *mut c_void) {
5891 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeNodeAnnouncement) };
5894 impl NodeAnnouncement {
5895 pub(crate) fn get_native_ref(&self) -> &'static nativeNodeAnnouncement {
5896 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5898 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeAnnouncement {
5899 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5901 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5902 pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncement {
5903 assert!(self.is_owned);
5904 let ret = ObjOps::untweak_ptr(self.inner);
5905 self.inner = core::ptr::null_mut();
5909 /// The signature by the node key
5911 pub extern "C" fn NodeAnnouncement_get_signature(this_ptr: &NodeAnnouncement) -> crate::c_types::Signature {
5912 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
5913 crate::c_types::Signature::from_rust(&inner_val)
5915 /// The signature by the node key
5917 pub extern "C" fn NodeAnnouncement_set_signature(this_ptr: &mut NodeAnnouncement, mut val: crate::c_types::Signature) {
5918 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
5920 /// The actual content of the announcement
5922 pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> crate::lightning::ln::msgs::UnsignedNodeAnnouncement {
5923 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
5924 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 }
5926 /// The actual content of the announcement
5928 pub extern "C" fn NodeAnnouncement_set_contents(this_ptr: &mut NodeAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) {
5929 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
5931 /// Constructs a new NodeAnnouncement given each field
5934 pub extern "C" fn NodeAnnouncement_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> NodeAnnouncement {
5935 NodeAnnouncement { inner: ObjOps::heap_alloc(nativeNodeAnnouncement {
5936 signature: signature_arg.into_rust(),
5937 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
5938 }), is_owned: true }
5940 impl Clone for NodeAnnouncement {
5941 fn clone(&self) -> Self {
5943 inner: if <*mut nativeNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
5944 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5950 /// Used only if an object of this type is returned as a trait impl by a method
5951 pub(crate) extern "C" fn NodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
5952 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeAnnouncement)).clone() })) as *mut c_void
5955 /// Creates a copy of the NodeAnnouncement
5956 pub extern "C" fn NodeAnnouncement_clone(orig: &NodeAnnouncement) -> NodeAnnouncement {
5959 /// Checks if two NodeAnnouncements contain equal inner contents.
5960 /// This ignores pointers and is_owned flags and looks at the values in fields.
5961 /// Two objects with NULL inner values will be considered "equal" here.
5963 pub extern "C" fn NodeAnnouncement_eq(a: &NodeAnnouncement, b: &NodeAnnouncement) -> bool {
5964 if a.inner == b.inner { return true; }
5965 if a.inner.is_null() || b.inner.is_null() { return false; }
5966 if a.get_native_ref() == b.get_native_ref() { true } else { false }
5969 use lightning::ln::msgs::UnsignedChannelAnnouncement as nativeUnsignedChannelAnnouncementImport;
5970 pub(crate) type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport;
5972 /// The unsigned part of a [`channel_announcement`] message.
5974 /// [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message
5977 pub struct UnsignedChannelAnnouncement {
5978 /// A pointer to the opaque Rust object.
5980 /// Nearly everywhere, inner must be non-null, however in places where
5981 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5982 pub inner: *mut nativeUnsignedChannelAnnouncement,
5983 /// Indicates that this is the only struct which contains the same pointer.
5985 /// Rust functions which take ownership of an object provided via an argument require
5986 /// this to be true and invalidate the object pointed to by inner.
5990 impl Drop for UnsignedChannelAnnouncement {
5991 fn drop(&mut self) {
5992 if self.is_owned && !<*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) {
5993 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5997 /// Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL.
5999 pub extern "C" fn UnsignedChannelAnnouncement_free(this_obj: UnsignedChannelAnnouncement) { }
6001 /// Used only if an object of this type is returned as a trait impl by a method
6002 pub(crate) extern "C" fn UnsignedChannelAnnouncement_free_void(this_ptr: *mut c_void) {
6003 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedChannelAnnouncement) };
6006 impl UnsignedChannelAnnouncement {
6007 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelAnnouncement {
6008 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6010 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelAnnouncement {
6011 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6013 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6014 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelAnnouncement {
6015 assert!(self.is_owned);
6016 let ret = ObjOps::untweak_ptr(self.inner);
6017 self.inner = core::ptr::null_mut();
6021 /// The advertised channel features
6023 pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::ln::features::ChannelFeatures {
6024 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
6025 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 }
6027 /// The advertised channel features
6029 pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::ln::features::ChannelFeatures) {
6030 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
6032 /// The genesis hash of the blockchain where the channel is to be opened
6034 pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &UnsignedChannelAnnouncement) -> *const [u8; 32] {
6035 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
6036 inner_val.as_inner()
6038 /// The genesis hash of the blockchain where the channel is to be opened
6040 pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
6041 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
6043 /// The short channel ID
6045 pub extern "C" fn UnsignedChannelAnnouncement_get_short_channel_id(this_ptr: &UnsignedChannelAnnouncement) -> u64 {
6046 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
6049 /// The short channel ID
6051 pub extern "C" fn UnsignedChannelAnnouncement_set_short_channel_id(this_ptr: &mut UnsignedChannelAnnouncement, mut val: u64) {
6052 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
6054 /// One of the two `node_id`s which are endpoints of this channel
6056 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
6057 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_1;
6058 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 }
6060 /// One of the two `node_id`s which are endpoints of this channel
6062 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
6063 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_1 = *unsafe { Box::from_raw(val.take_inner()) };
6065 /// The other of the two `node_id`s which are endpoints of this channel
6067 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
6068 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_2;
6069 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 }
6071 /// The other of the two `node_id`s which are endpoints of this channel
6073 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
6074 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_2 = *unsafe { Box::from_raw(val.take_inner()) };
6076 /// The funding key for the first node
6078 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
6079 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_1;
6080 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 }
6082 /// The funding key for the first node
6084 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
6085 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_1 = *unsafe { Box::from_raw(val.take_inner()) };
6087 /// The funding key for the second node
6089 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
6090 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_2;
6091 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 }
6093 /// The funding key for the second node
6095 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
6096 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_2 = *unsafe { Box::from_raw(val.take_inner()) };
6098 impl Clone for UnsignedChannelAnnouncement {
6099 fn clone(&self) -> Self {
6101 inner: if <*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
6102 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6108 /// Used only if an object of this type is returned as a trait impl by a method
6109 pub(crate) extern "C" fn UnsignedChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
6110 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelAnnouncement)).clone() })) as *mut c_void
6113 /// Creates a copy of the UnsignedChannelAnnouncement
6114 pub extern "C" fn UnsignedChannelAnnouncement_clone(orig: &UnsignedChannelAnnouncement) -> UnsignedChannelAnnouncement {
6117 /// Checks if two UnsignedChannelAnnouncements contain equal inner contents.
6118 /// This ignores pointers and is_owned flags and looks at the values in fields.
6119 /// Two objects with NULL inner values will be considered "equal" here.
6121 pub extern "C" fn UnsignedChannelAnnouncement_eq(a: &UnsignedChannelAnnouncement, b: &UnsignedChannelAnnouncement) -> bool {
6122 if a.inner == b.inner { return true; }
6123 if a.inner.is_null() || b.inner.is_null() { return false; }
6124 if a.get_native_ref() == b.get_native_ref() { true } else { false }
6127 use lightning::ln::msgs::ChannelAnnouncement as nativeChannelAnnouncementImport;
6128 pub(crate) type nativeChannelAnnouncement = nativeChannelAnnouncementImport;
6130 /// A [`channel_announcement`] message to be sent to or received from a peer.
6132 /// [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message
6135 pub struct ChannelAnnouncement {
6136 /// A pointer to the opaque Rust object.
6138 /// Nearly everywhere, inner must be non-null, however in places where
6139 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6140 pub inner: *mut nativeChannelAnnouncement,
6141 /// Indicates that this is the only struct which contains the same pointer.
6143 /// Rust functions which take ownership of an object provided via an argument require
6144 /// this to be true and invalidate the object pointed to by inner.
6148 impl Drop for ChannelAnnouncement {
6149 fn drop(&mut self) {
6150 if self.is_owned && !<*mut nativeChannelAnnouncement>::is_null(self.inner) {
6151 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6155 /// Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL.
6157 pub extern "C" fn ChannelAnnouncement_free(this_obj: ChannelAnnouncement) { }
6159 /// Used only if an object of this type is returned as a trait impl by a method
6160 pub(crate) extern "C" fn ChannelAnnouncement_free_void(this_ptr: *mut c_void) {
6161 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelAnnouncement) };
6164 impl ChannelAnnouncement {
6165 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelAnnouncement {
6166 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6168 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelAnnouncement {
6169 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6171 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6172 pub(crate) fn take_inner(mut self) -> *mut nativeChannelAnnouncement {
6173 assert!(self.is_owned);
6174 let ret = ObjOps::untweak_ptr(self.inner);
6175 self.inner = core::ptr::null_mut();
6179 /// Authentication of the announcement by the first public node
6181 pub extern "C" fn ChannelAnnouncement_get_node_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
6182 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_1;
6183 crate::c_types::Signature::from_rust(&inner_val)
6185 /// Authentication of the announcement by the first public node
6187 pub extern "C" fn ChannelAnnouncement_set_node_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
6188 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_1 = val.into_rust();
6190 /// Authentication of the announcement by the second public node
6192 pub extern "C" fn ChannelAnnouncement_get_node_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
6193 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_2;
6194 crate::c_types::Signature::from_rust(&inner_val)
6196 /// Authentication of the announcement by the second public node
6198 pub extern "C" fn ChannelAnnouncement_set_node_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
6199 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_2 = val.into_rust();
6201 /// Proof of funding UTXO ownership by the first public node
6203 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
6204 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_1;
6205 crate::c_types::Signature::from_rust(&inner_val)
6207 /// Proof of funding UTXO ownership by the first public node
6209 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
6210 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_1 = val.into_rust();
6212 /// Proof of funding UTXO ownership by the second public node
6214 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
6215 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_2;
6216 crate::c_types::Signature::from_rust(&inner_val)
6218 /// Proof of funding UTXO ownership by the second public node
6220 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
6221 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_2 = val.into_rust();
6223 /// The actual announcement
6225 pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncement) -> crate::lightning::ln::msgs::UnsignedChannelAnnouncement {
6226 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
6227 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 }
6229 /// The actual announcement
6231 pub extern "C" fn ChannelAnnouncement_set_contents(this_ptr: &mut ChannelAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) {
6232 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
6234 /// Constructs a new ChannelAnnouncement given each field
6237 pub extern "C" fn ChannelAnnouncement_new(mut node_signature_1_arg: crate::c_types::Signature, mut node_signature_2_arg: crate::c_types::Signature, mut bitcoin_signature_1_arg: crate::c_types::Signature, mut bitcoin_signature_2_arg: crate::c_types::Signature, mut contents_arg: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> ChannelAnnouncement {
6238 ChannelAnnouncement { inner: ObjOps::heap_alloc(nativeChannelAnnouncement {
6239 node_signature_1: node_signature_1_arg.into_rust(),
6240 node_signature_2: node_signature_2_arg.into_rust(),
6241 bitcoin_signature_1: bitcoin_signature_1_arg.into_rust(),
6242 bitcoin_signature_2: bitcoin_signature_2_arg.into_rust(),
6243 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
6244 }), is_owned: true }
6246 impl Clone for ChannelAnnouncement {
6247 fn clone(&self) -> Self {
6249 inner: if <*mut nativeChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
6250 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6256 /// Used only if an object of this type is returned as a trait impl by a method
6257 pub(crate) extern "C" fn ChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
6258 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelAnnouncement)).clone() })) as *mut c_void
6261 /// Creates a copy of the ChannelAnnouncement
6262 pub extern "C" fn ChannelAnnouncement_clone(orig: &ChannelAnnouncement) -> ChannelAnnouncement {
6265 /// Checks if two ChannelAnnouncements contain equal inner contents.
6266 /// This ignores pointers and is_owned flags and looks at the values in fields.
6267 /// Two objects with NULL inner values will be considered "equal" here.
6269 pub extern "C" fn ChannelAnnouncement_eq(a: &ChannelAnnouncement, b: &ChannelAnnouncement) -> bool {
6270 if a.inner == b.inner { return true; }
6271 if a.inner.is_null() || b.inner.is_null() { return false; }
6272 if a.get_native_ref() == b.get_native_ref() { true } else { false }
6275 use lightning::ln::msgs::UnsignedChannelUpdate as nativeUnsignedChannelUpdateImport;
6276 pub(crate) type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport;
6278 /// The unsigned part of a [`channel_update`] message.
6280 /// [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
6283 pub struct UnsignedChannelUpdate {
6284 /// A pointer to the opaque Rust object.
6286 /// Nearly everywhere, inner must be non-null, however in places where
6287 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6288 pub inner: *mut nativeUnsignedChannelUpdate,
6289 /// Indicates that this is the only struct which contains the same pointer.
6291 /// Rust functions which take ownership of an object provided via an argument require
6292 /// this to be true and invalidate the object pointed to by inner.
6296 impl Drop for UnsignedChannelUpdate {
6297 fn drop(&mut self) {
6298 if self.is_owned && !<*mut nativeUnsignedChannelUpdate>::is_null(self.inner) {
6299 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6303 /// Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL.
6305 pub extern "C" fn UnsignedChannelUpdate_free(this_obj: UnsignedChannelUpdate) { }
6307 /// Used only if an object of this type is returned as a trait impl by a method
6308 pub(crate) extern "C" fn UnsignedChannelUpdate_free_void(this_ptr: *mut c_void) {
6309 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedChannelUpdate) };
6312 impl UnsignedChannelUpdate {
6313 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelUpdate {
6314 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6316 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelUpdate {
6317 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6319 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6320 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelUpdate {
6321 assert!(self.is_owned);
6322 let ret = ObjOps::untweak_ptr(self.inner);
6323 self.inner = core::ptr::null_mut();
6327 /// The genesis hash of the blockchain where the channel is to be opened
6329 pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChannelUpdate) -> *const [u8; 32] {
6330 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
6331 inner_val.as_inner()
6333 /// The genesis hash of the blockchain where the channel is to be opened
6335 pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::ThirtyTwoBytes) {
6336 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
6338 /// The short channel ID
6340 pub extern "C" fn UnsignedChannelUpdate_get_short_channel_id(this_ptr: &UnsignedChannelUpdate) -> u64 {
6341 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
6344 /// The short channel ID
6346 pub extern "C" fn UnsignedChannelUpdate_set_short_channel_id(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
6347 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
6349 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
6351 pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannelUpdate) -> u32 {
6352 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
6355 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
6357 pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
6358 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
6362 pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 {
6363 let mut inner_val = &mut this_ptr.get_native_mut_ref().flags;
6368 pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) {
6369 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.flags = val;
6371 /// The number of blocks such that if:
6372 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
6373 /// then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines
6374 /// the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a
6375 /// `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10,
6376 /// then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before
6377 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
6378 /// constructing the route.
6380 pub extern "C" fn UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr: &UnsignedChannelUpdate) -> u16 {
6381 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
6384 /// The number of blocks such that if:
6385 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
6386 /// then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines
6387 /// the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a
6388 /// `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10,
6389 /// then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before
6390 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
6391 /// constructing the route.
6393 pub extern "C" fn UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr: &mut UnsignedChannelUpdate, mut val: u16) {
6394 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
6396 /// The minimum HTLC size incoming to sender, in milli-satoshi
6398 pub extern "C" fn UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
6399 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
6402 /// The minimum HTLC size incoming to sender, in milli-satoshi
6404 pub extern "C" fn UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
6405 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
6407 /// The maximum HTLC value incoming to sender, in milli-satoshi.
6409 /// This used to be optional.
6411 pub extern "C" fn UnsignedChannelUpdate_get_htlc_maximum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
6412 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat;
6415 /// The maximum HTLC value incoming to sender, in milli-satoshi.
6417 /// This used to be optional.
6419 pub extern "C" fn UnsignedChannelUpdate_set_htlc_maximum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
6420 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = val;
6422 /// The base HTLC fee charged by sender, in milli-satoshi
6424 pub extern "C" fn UnsignedChannelUpdate_get_fee_base_msat(this_ptr: &UnsignedChannelUpdate) -> u32 {
6425 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat;
6428 /// The base HTLC fee charged by sender, in milli-satoshi
6430 pub extern "C" fn UnsignedChannelUpdate_set_fee_base_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
6431 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val;
6433 /// The amount to fee multiplier, in micro-satoshi
6435 pub extern "C" fn UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr: &UnsignedChannelUpdate) -> u32 {
6436 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths;
6439 /// The amount to fee multiplier, in micro-satoshi
6441 pub extern "C" fn UnsignedChannelUpdate_set_fee_proportional_millionths(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
6442 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val;
6444 /// Excess data which was signed as a part of the message which we do not (yet) understand how
6447 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
6449 /// Returns a copy of the field.
6451 pub extern "C" fn UnsignedChannelUpdate_get_excess_data(this_ptr: &UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
6452 let mut inner_val = this_ptr.get_native_mut_ref().excess_data.clone();
6453 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
6454 local_inner_val.into()
6456 /// Excess data which was signed as a part of the message which we do not (yet) understand how
6459 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
6461 pub extern "C" fn UnsignedChannelUpdate_set_excess_data(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::derived::CVec_u8Z) {
6462 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
6463 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_data = local_val;
6465 /// Constructs a new UnsignedChannelUpdate given each field
6468 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 {
6469 let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); };
6470 UnsignedChannelUpdate { inner: ObjOps::heap_alloc(nativeUnsignedChannelUpdate {
6471 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
6472 short_channel_id: short_channel_id_arg,
6473 timestamp: timestamp_arg,
6475 cltv_expiry_delta: cltv_expiry_delta_arg,
6476 htlc_minimum_msat: htlc_minimum_msat_arg,
6477 htlc_maximum_msat: htlc_maximum_msat_arg,
6478 fee_base_msat: fee_base_msat_arg,
6479 fee_proportional_millionths: fee_proportional_millionths_arg,
6480 excess_data: local_excess_data_arg,
6481 }), is_owned: true }
6483 impl Clone for UnsignedChannelUpdate {
6484 fn clone(&self) -> Self {
6486 inner: if <*mut nativeUnsignedChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
6487 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6493 /// Used only if an object of this type is returned as a trait impl by a method
6494 pub(crate) extern "C" fn UnsignedChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
6495 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelUpdate)).clone() })) as *mut c_void
6498 /// Creates a copy of the UnsignedChannelUpdate
6499 pub extern "C" fn UnsignedChannelUpdate_clone(orig: &UnsignedChannelUpdate) -> UnsignedChannelUpdate {
6502 /// Checks if two UnsignedChannelUpdates contain equal inner contents.
6503 /// This ignores pointers and is_owned flags and looks at the values in fields.
6504 /// Two objects with NULL inner values will be considered "equal" here.
6506 pub extern "C" fn UnsignedChannelUpdate_eq(a: &UnsignedChannelUpdate, b: &UnsignedChannelUpdate) -> bool {
6507 if a.inner == b.inner { return true; }
6508 if a.inner.is_null() || b.inner.is_null() { return false; }
6509 if a.get_native_ref() == b.get_native_ref() { true } else { false }
6512 use lightning::ln::msgs::ChannelUpdate as nativeChannelUpdateImport;
6513 pub(crate) type nativeChannelUpdate = nativeChannelUpdateImport;
6515 /// A [`channel_update`] message to be sent to or received from a peer.
6517 /// [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
6520 pub struct ChannelUpdate {
6521 /// A pointer to the opaque Rust object.
6523 /// Nearly everywhere, inner must be non-null, however in places where
6524 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6525 pub inner: *mut nativeChannelUpdate,
6526 /// Indicates that this is the only struct which contains the same pointer.
6528 /// Rust functions which take ownership of an object provided via an argument require
6529 /// this to be true and invalidate the object pointed to by inner.
6533 impl Drop for ChannelUpdate {
6534 fn drop(&mut self) {
6535 if self.is_owned && !<*mut nativeChannelUpdate>::is_null(self.inner) {
6536 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6540 /// Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL.
6542 pub extern "C" fn ChannelUpdate_free(this_obj: ChannelUpdate) { }
6544 /// Used only if an object of this type is returned as a trait impl by a method
6545 pub(crate) extern "C" fn ChannelUpdate_free_void(this_ptr: *mut c_void) {
6546 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelUpdate) };
6549 impl ChannelUpdate {
6550 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelUpdate {
6551 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6553 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelUpdate {
6554 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6556 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6557 pub(crate) fn take_inner(mut self) -> *mut nativeChannelUpdate {
6558 assert!(self.is_owned);
6559 let ret = ObjOps::untweak_ptr(self.inner);
6560 self.inner = core::ptr::null_mut();
6564 /// A signature of the channel update
6566 pub extern "C" fn ChannelUpdate_get_signature(this_ptr: &ChannelUpdate) -> crate::c_types::Signature {
6567 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
6568 crate::c_types::Signature::from_rust(&inner_val)
6570 /// A signature of the channel update
6572 pub extern "C" fn ChannelUpdate_set_signature(this_ptr: &mut ChannelUpdate, mut val: crate::c_types::Signature) {
6573 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
6575 /// The actual channel update
6577 pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate::lightning::ln::msgs::UnsignedChannelUpdate {
6578 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
6579 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 }
6581 /// The actual channel update
6583 pub extern "C" fn ChannelUpdate_set_contents(this_ptr: &mut ChannelUpdate, mut val: crate::lightning::ln::msgs::UnsignedChannelUpdate) {
6584 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
6586 /// Constructs a new ChannelUpdate given each field
6589 pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> ChannelUpdate {
6590 ChannelUpdate { inner: ObjOps::heap_alloc(nativeChannelUpdate {
6591 signature: signature_arg.into_rust(),
6592 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
6593 }), is_owned: true }
6595 impl Clone for ChannelUpdate {
6596 fn clone(&self) -> Self {
6598 inner: if <*mut nativeChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
6599 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6605 /// Used only if an object of this type is returned as a trait impl by a method
6606 pub(crate) extern "C" fn ChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
6607 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelUpdate)).clone() })) as *mut c_void
6610 /// Creates a copy of the ChannelUpdate
6611 pub extern "C" fn ChannelUpdate_clone(orig: &ChannelUpdate) -> ChannelUpdate {
6614 /// Checks if two ChannelUpdates contain equal inner contents.
6615 /// This ignores pointers and is_owned flags and looks at the values in fields.
6616 /// Two objects with NULL inner values will be considered "equal" here.
6618 pub extern "C" fn ChannelUpdate_eq(a: &ChannelUpdate, b: &ChannelUpdate) -> bool {
6619 if a.inner == b.inner { return true; }
6620 if a.inner.is_null() || b.inner.is_null() { return false; }
6621 if a.get_native_ref() == b.get_native_ref() { true } else { false }
6624 use lightning::ln::msgs::QueryChannelRange as nativeQueryChannelRangeImport;
6625 pub(crate) type nativeQueryChannelRange = nativeQueryChannelRangeImport;
6627 /// A [`query_channel_range`] message is used to query a peer for channel
6628 /// UTXOs in a range of blocks. The recipient of a query makes a best
6629 /// effort to reply to the query using one or more [`ReplyChannelRange`]
6632 /// [`query_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages
6635 pub struct QueryChannelRange {
6636 /// A pointer to the opaque Rust object.
6638 /// Nearly everywhere, inner must be non-null, however in places where
6639 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6640 pub inner: *mut nativeQueryChannelRange,
6641 /// Indicates that this is the only struct which contains the same pointer.
6643 /// Rust functions which take ownership of an object provided via an argument require
6644 /// this to be true and invalidate the object pointed to by inner.
6648 impl Drop for QueryChannelRange {
6649 fn drop(&mut self) {
6650 if self.is_owned && !<*mut nativeQueryChannelRange>::is_null(self.inner) {
6651 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6655 /// Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL.
6657 pub extern "C" fn QueryChannelRange_free(this_obj: QueryChannelRange) { }
6659 /// Used only if an object of this type is returned as a trait impl by a method
6660 pub(crate) extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) {
6661 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeQueryChannelRange) };
6664 impl QueryChannelRange {
6665 pub(crate) fn get_native_ref(&self) -> &'static nativeQueryChannelRange {
6666 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6668 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryChannelRange {
6669 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6671 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6672 pub(crate) fn take_inner(mut self) -> *mut nativeQueryChannelRange {
6673 assert!(self.is_owned);
6674 let ret = ObjOps::untweak_ptr(self.inner);
6675 self.inner = core::ptr::null_mut();
6679 /// The genesis hash of the blockchain being queried
6681 pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *const [u8; 32] {
6682 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
6683 inner_val.as_inner()
6685 /// The genesis hash of the blockchain being queried
6687 pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
6688 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
6690 /// The height of the first block for the channel UTXOs being queried
6692 pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 {
6693 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
6696 /// The height of the first block for the channel UTXOs being queried
6698 pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChannelRange, mut val: u32) {
6699 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
6701 /// The number of blocks to include in the query results
6703 pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 {
6704 let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
6707 /// The number of blocks to include in the query results
6709 pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryChannelRange, mut val: u32) {
6710 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
6712 /// Constructs a new QueryChannelRange given each field
6715 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 {
6716 QueryChannelRange { inner: ObjOps::heap_alloc(nativeQueryChannelRange {
6717 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
6718 first_blocknum: first_blocknum_arg,
6719 number_of_blocks: number_of_blocks_arg,
6720 }), is_owned: true }
6722 impl Clone for QueryChannelRange {
6723 fn clone(&self) -> Self {
6725 inner: if <*mut nativeQueryChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
6726 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6732 /// Used only if an object of this type is returned as a trait impl by a method
6733 pub(crate) extern "C" fn QueryChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
6734 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryChannelRange)).clone() })) as *mut c_void
6737 /// Creates a copy of the QueryChannelRange
6738 pub extern "C" fn QueryChannelRange_clone(orig: &QueryChannelRange) -> QueryChannelRange {
6741 /// Checks if two QueryChannelRanges contain equal inner contents.
6742 /// This ignores pointers and is_owned flags and looks at the values in fields.
6743 /// Two objects with NULL inner values will be considered "equal" here.
6745 pub extern "C" fn QueryChannelRange_eq(a: &QueryChannelRange, b: &QueryChannelRange) -> bool {
6746 if a.inner == b.inner { return true; }
6747 if a.inner.is_null() || b.inner.is_null() { return false; }
6748 if a.get_native_ref() == b.get_native_ref() { true } else { false }
6751 use lightning::ln::msgs::ReplyChannelRange as nativeReplyChannelRangeImport;
6752 pub(crate) type nativeReplyChannelRange = nativeReplyChannelRangeImport;
6754 /// A [`reply_channel_range`] message is a reply to a [`QueryChannelRange`]
6757 /// Multiple `reply_channel_range` messages can be sent in reply
6758 /// to a single [`QueryChannelRange`] message. The query recipient makes a
6759 /// best effort to respond based on their local network view which may
6760 /// not be a perfect view of the network. The `short_channel_id`s in the
6761 /// reply are encoded. We only support `encoding_type=0` uncompressed
6762 /// serialization and do not support `encoding_type=1` zlib serialization.
6764 /// [`reply_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages
6767 pub struct ReplyChannelRange {
6768 /// A pointer to the opaque Rust object.
6770 /// Nearly everywhere, inner must be non-null, however in places where
6771 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6772 pub inner: *mut nativeReplyChannelRange,
6773 /// Indicates that this is the only struct which contains the same pointer.
6775 /// Rust functions which take ownership of an object provided via an argument require
6776 /// this to be true and invalidate the object pointed to by inner.
6780 impl Drop for ReplyChannelRange {
6781 fn drop(&mut self) {
6782 if self.is_owned && !<*mut nativeReplyChannelRange>::is_null(self.inner) {
6783 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6787 /// Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL.
6789 pub extern "C" fn ReplyChannelRange_free(this_obj: ReplyChannelRange) { }
6791 /// Used only if an object of this type is returned as a trait impl by a method
6792 pub(crate) extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) {
6793 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeReplyChannelRange) };
6796 impl ReplyChannelRange {
6797 pub(crate) fn get_native_ref(&self) -> &'static nativeReplyChannelRange {
6798 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6800 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyChannelRange {
6801 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6803 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6804 pub(crate) fn take_inner(mut self) -> *mut nativeReplyChannelRange {
6805 assert!(self.is_owned);
6806 let ret = ObjOps::untweak_ptr(self.inner);
6807 self.inner = core::ptr::null_mut();
6811 /// The genesis hash of the blockchain being queried
6813 pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *const [u8; 32] {
6814 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
6815 inner_val.as_inner()
6817 /// The genesis hash of the blockchain being queried
6819 pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
6820 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
6822 /// The height of the first block in the range of the reply
6824 pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 {
6825 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
6828 /// The height of the first block in the range of the reply
6830 pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChannelRange, mut val: u32) {
6831 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
6833 /// The number of blocks included in the range of the reply
6835 pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 {
6836 let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
6839 /// The number of blocks included in the range of the reply
6841 pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyChannelRange, mut val: u32) {
6842 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
6844 /// True when this is the final reply for a query
6846 pub extern "C" fn ReplyChannelRange_get_sync_complete(this_ptr: &ReplyChannelRange) -> bool {
6847 let mut inner_val = &mut this_ptr.get_native_mut_ref().sync_complete;
6850 /// True when this is the final reply for a query
6852 pub extern "C" fn ReplyChannelRange_set_sync_complete(this_ptr: &mut ReplyChannelRange, mut val: bool) {
6853 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sync_complete = val;
6855 /// The `short_channel_id`s in the channel range
6857 /// Returns a copy of the field.
6859 pub extern "C" fn ReplyChannelRange_get_short_channel_ids(this_ptr: &ReplyChannelRange) -> crate::c_types::derived::CVec_u64Z {
6860 let mut inner_val = this_ptr.get_native_mut_ref().short_channel_ids.clone();
6861 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
6862 local_inner_val.into()
6864 /// The `short_channel_id`s in the channel range
6866 pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::derived::CVec_u64Z) {
6867 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
6868 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
6870 /// Constructs a new ReplyChannelRange given each field
6873 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 {
6874 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 }); };
6875 ReplyChannelRange { inner: ObjOps::heap_alloc(nativeReplyChannelRange {
6876 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
6877 first_blocknum: first_blocknum_arg,
6878 number_of_blocks: number_of_blocks_arg,
6879 sync_complete: sync_complete_arg,
6880 short_channel_ids: local_short_channel_ids_arg,
6881 }), is_owned: true }
6883 impl Clone for ReplyChannelRange {
6884 fn clone(&self) -> Self {
6886 inner: if <*mut nativeReplyChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
6887 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6893 /// Used only if an object of this type is returned as a trait impl by a method
6894 pub(crate) extern "C" fn ReplyChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
6895 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyChannelRange)).clone() })) as *mut c_void
6898 /// Creates a copy of the ReplyChannelRange
6899 pub extern "C" fn ReplyChannelRange_clone(orig: &ReplyChannelRange) -> ReplyChannelRange {
6902 /// Checks if two ReplyChannelRanges contain equal inner contents.
6903 /// This ignores pointers and is_owned flags and looks at the values in fields.
6904 /// Two objects with NULL inner values will be considered "equal" here.
6906 pub extern "C" fn ReplyChannelRange_eq(a: &ReplyChannelRange, b: &ReplyChannelRange) -> bool {
6907 if a.inner == b.inner { return true; }
6908 if a.inner.is_null() || b.inner.is_null() { return false; }
6909 if a.get_native_ref() == b.get_native_ref() { true } else { false }
6912 use lightning::ln::msgs::QueryShortChannelIds as nativeQueryShortChannelIdsImport;
6913 pub(crate) type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport;
6915 /// A [`query_short_channel_ids`] message is used to query a peer for
6916 /// routing gossip messages related to one or more `short_channel_id`s.
6918 /// The query recipient will reply with the latest, if available,
6919 /// [`ChannelAnnouncement`], [`ChannelUpdate`] and [`NodeAnnouncement`] messages
6920 /// it maintains for the requested `short_channel_id`s followed by a
6921 /// [`ReplyShortChannelIdsEnd`] message. The `short_channel_id`s sent in
6922 /// this query are encoded. We only support `encoding_type=0` uncompressed
6923 /// serialization and do not support `encoding_type=1` zlib serialization.
6925 /// [`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
6928 pub struct QueryShortChannelIds {
6929 /// A pointer to the opaque Rust object.
6931 /// Nearly everywhere, inner must be non-null, however in places where
6932 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6933 pub inner: *mut nativeQueryShortChannelIds,
6934 /// Indicates that this is the only struct which contains the same pointer.
6936 /// Rust functions which take ownership of an object provided via an argument require
6937 /// this to be true and invalidate the object pointed to by inner.
6941 impl Drop for QueryShortChannelIds {
6942 fn drop(&mut self) {
6943 if self.is_owned && !<*mut nativeQueryShortChannelIds>::is_null(self.inner) {
6944 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6948 /// Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL.
6950 pub extern "C" fn QueryShortChannelIds_free(this_obj: QueryShortChannelIds) { }
6952 /// Used only if an object of this type is returned as a trait impl by a method
6953 pub(crate) extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) {
6954 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeQueryShortChannelIds) };
6957 impl QueryShortChannelIds {
6958 pub(crate) fn get_native_ref(&self) -> &'static nativeQueryShortChannelIds {
6959 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6961 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryShortChannelIds {
6962 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6964 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6965 pub(crate) fn take_inner(mut self) -> *mut nativeQueryShortChannelIds {
6966 assert!(self.is_owned);
6967 let ret = ObjOps::untweak_ptr(self.inner);
6968 self.inner = core::ptr::null_mut();
6972 /// The genesis hash of the blockchain being queried
6974 pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *const [u8; 32] {
6975 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
6976 inner_val.as_inner()
6978 /// The genesis hash of the blockchain being queried
6980 pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::ThirtyTwoBytes) {
6981 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
6983 /// The short_channel_ids that are being queried
6985 /// Returns a copy of the field.
6987 pub extern "C" fn QueryShortChannelIds_get_short_channel_ids(this_ptr: &QueryShortChannelIds) -> crate::c_types::derived::CVec_u64Z {
6988 let mut inner_val = this_ptr.get_native_mut_ref().short_channel_ids.clone();
6989 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
6990 local_inner_val.into()
6992 /// The short_channel_ids that are being queried
6994 pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::derived::CVec_u64Z) {
6995 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
6996 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
6998 /// Constructs a new QueryShortChannelIds given each field
7001 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 {
7002 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 }); };
7003 QueryShortChannelIds { inner: ObjOps::heap_alloc(nativeQueryShortChannelIds {
7004 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
7005 short_channel_ids: local_short_channel_ids_arg,
7006 }), is_owned: true }
7008 impl Clone for QueryShortChannelIds {
7009 fn clone(&self) -> Self {
7011 inner: if <*mut nativeQueryShortChannelIds>::is_null(self.inner) { core::ptr::null_mut() } else {
7012 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7018 /// Used only if an object of this type is returned as a trait impl by a method
7019 pub(crate) extern "C" fn QueryShortChannelIds_clone_void(this_ptr: *const c_void) -> *mut c_void {
7020 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryShortChannelIds)).clone() })) as *mut c_void
7023 /// Creates a copy of the QueryShortChannelIds
7024 pub extern "C" fn QueryShortChannelIds_clone(orig: &QueryShortChannelIds) -> QueryShortChannelIds {
7027 /// Checks if two QueryShortChannelIdss contain equal inner contents.
7028 /// This ignores pointers and is_owned flags and looks at the values in fields.
7029 /// Two objects with NULL inner values will be considered "equal" here.
7031 pub extern "C" fn QueryShortChannelIds_eq(a: &QueryShortChannelIds, b: &QueryShortChannelIds) -> bool {
7032 if a.inner == b.inner { return true; }
7033 if a.inner.is_null() || b.inner.is_null() { return false; }
7034 if a.get_native_ref() == b.get_native_ref() { true } else { false }
7037 use lightning::ln::msgs::ReplyShortChannelIdsEnd as nativeReplyShortChannelIdsEndImport;
7038 pub(crate) type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport;
7040 /// A [`reply_short_channel_ids_end`] message is sent as a reply to a
7041 /// message. The query recipient makes a best
7042 /// effort to respond based on their local network view which may not be
7043 /// a perfect view of the network.
7045 /// [`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
7048 pub struct ReplyShortChannelIdsEnd {
7049 /// A pointer to the opaque Rust object.
7051 /// Nearly everywhere, inner must be non-null, however in places where
7052 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7053 pub inner: *mut nativeReplyShortChannelIdsEnd,
7054 /// Indicates that this is the only struct which contains the same pointer.
7056 /// Rust functions which take ownership of an object provided via an argument require
7057 /// this to be true and invalidate the object pointed to by inner.
7061 impl Drop for ReplyShortChannelIdsEnd {
7062 fn drop(&mut self) {
7063 if self.is_owned && !<*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) {
7064 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7068 /// Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL.
7070 pub extern "C" fn ReplyShortChannelIdsEnd_free(this_obj: ReplyShortChannelIdsEnd) { }
7072 /// Used only if an object of this type is returned as a trait impl by a method
7073 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) {
7074 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeReplyShortChannelIdsEnd) };
7077 impl ReplyShortChannelIdsEnd {
7078 pub(crate) fn get_native_ref(&self) -> &'static nativeReplyShortChannelIdsEnd {
7079 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7081 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyShortChannelIdsEnd {
7082 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7084 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7085 pub(crate) fn take_inner(mut self) -> *mut nativeReplyShortChannelIdsEnd {
7086 assert!(self.is_owned);
7087 let ret = ObjOps::untweak_ptr(self.inner);
7088 self.inner = core::ptr::null_mut();
7092 /// The genesis hash of the blockchain that was queried
7094 pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *const [u8; 32] {
7095 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
7096 inner_val.as_inner()
7098 /// The genesis hash of the blockchain that was queried
7100 pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) {
7101 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
7103 /// Indicates if the query recipient maintains up-to-date channel
7104 /// information for the `chain_hash`
7106 pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool {
7107 let mut inner_val = &mut this_ptr.get_native_mut_ref().full_information;
7110 /// Indicates if the query recipient maintains up-to-date channel
7111 /// information for the `chain_hash`
7113 pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: bool) {
7114 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.full_information = val;
7116 /// Constructs a new ReplyShortChannelIdsEnd given each field
7119 pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd {
7120 ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(nativeReplyShortChannelIdsEnd {
7121 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
7122 full_information: full_information_arg,
7123 }), is_owned: true }
7125 impl Clone for ReplyShortChannelIdsEnd {
7126 fn clone(&self) -> Self {
7128 inner: if <*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) { core::ptr::null_mut() } else {
7129 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7135 /// Used only if an object of this type is returned as a trait impl by a method
7136 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_void) -> *mut c_void {
7137 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyShortChannelIdsEnd)).clone() })) as *mut c_void
7140 /// Creates a copy of the ReplyShortChannelIdsEnd
7141 pub extern "C" fn ReplyShortChannelIdsEnd_clone(orig: &ReplyShortChannelIdsEnd) -> ReplyShortChannelIdsEnd {
7144 /// Checks if two ReplyShortChannelIdsEnds contain equal inner contents.
7145 /// This ignores pointers and is_owned flags and looks at the values in fields.
7146 /// Two objects with NULL inner values will be considered "equal" here.
7148 pub extern "C" fn ReplyShortChannelIdsEnd_eq(a: &ReplyShortChannelIdsEnd, b: &ReplyShortChannelIdsEnd) -> bool {
7149 if a.inner == b.inner { return true; }
7150 if a.inner.is_null() || b.inner.is_null() { return false; }
7151 if a.get_native_ref() == b.get_native_ref() { true } else { false }
7154 use lightning::ln::msgs::GossipTimestampFilter as nativeGossipTimestampFilterImport;
7155 pub(crate) type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport;
7157 /// A [`gossip_timestamp_filter`] message is used by a node to request
7158 /// gossip relay for messages in the requested time range when the
7159 /// `gossip_queries` feature has been negotiated.
7161 /// [`gossip_timestamp_filter`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-gossip_timestamp_filter-message
7164 pub struct GossipTimestampFilter {
7165 /// A pointer to the opaque Rust object.
7167 /// Nearly everywhere, inner must be non-null, however in places where
7168 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7169 pub inner: *mut nativeGossipTimestampFilter,
7170 /// Indicates that this is the only struct which contains the same pointer.
7172 /// Rust functions which take ownership of an object provided via an argument require
7173 /// this to be true and invalidate the object pointed to by inner.
7177 impl Drop for GossipTimestampFilter {
7178 fn drop(&mut self) {
7179 if self.is_owned && !<*mut nativeGossipTimestampFilter>::is_null(self.inner) {
7180 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7184 /// Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL.
7186 pub extern "C" fn GossipTimestampFilter_free(this_obj: GossipTimestampFilter) { }
7188 /// Used only if an object of this type is returned as a trait impl by a method
7189 pub(crate) extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) {
7190 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeGossipTimestampFilter) };
7193 impl GossipTimestampFilter {
7194 pub(crate) fn get_native_ref(&self) -> &'static nativeGossipTimestampFilter {
7195 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7197 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeGossipTimestampFilter {
7198 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7200 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7201 pub(crate) fn take_inner(mut self) -> *mut nativeGossipTimestampFilter {
7202 assert!(self.is_owned);
7203 let ret = ObjOps::untweak_ptr(self.inner);
7204 self.inner = core::ptr::null_mut();
7208 /// The genesis hash of the blockchain for channel and node information
7210 pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *const [u8; 32] {
7211 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
7212 inner_val.as_inner()
7214 /// The genesis hash of the blockchain for channel and node information
7216 pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) {
7217 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
7219 /// The starting unix timestamp
7221 pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 {
7222 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_timestamp;
7225 /// The starting unix timestamp
7227 pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
7228 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_timestamp = val;
7230 /// The range of information in seconds
7232 pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 {
7233 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp_range;
7236 /// The range of information in seconds
7238 pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
7239 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp_range = val;
7241 /// Constructs a new GossipTimestampFilter given each field
7244 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 {
7245 GossipTimestampFilter { inner: ObjOps::heap_alloc(nativeGossipTimestampFilter {
7246 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
7247 first_timestamp: first_timestamp_arg,
7248 timestamp_range: timestamp_range_arg,
7249 }), is_owned: true }
7251 impl Clone for GossipTimestampFilter {
7252 fn clone(&self) -> Self {
7254 inner: if <*mut nativeGossipTimestampFilter>::is_null(self.inner) { core::ptr::null_mut() } else {
7255 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7261 /// Used only if an object of this type is returned as a trait impl by a method
7262 pub(crate) extern "C" fn GossipTimestampFilter_clone_void(this_ptr: *const c_void) -> *mut c_void {
7263 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeGossipTimestampFilter)).clone() })) as *mut c_void
7266 /// Creates a copy of the GossipTimestampFilter
7267 pub extern "C" fn GossipTimestampFilter_clone(orig: &GossipTimestampFilter) -> GossipTimestampFilter {
7270 /// Checks if two GossipTimestampFilters contain equal inner contents.
7271 /// This ignores pointers and is_owned flags and looks at the values in fields.
7272 /// Two objects with NULL inner values will be considered "equal" here.
7274 pub extern "C" fn GossipTimestampFilter_eq(a: &GossipTimestampFilter, b: &GossipTimestampFilter) -> bool {
7275 if a.inner == b.inner { return true; }
7276 if a.inner.is_null() || b.inner.is_null() { return false; }
7277 if a.get_native_ref() == b.get_native_ref() { true } else { false }
7279 /// Used to put an error message in a [`LightningError`].
7283 pub enum ErrorAction {
7284 /// The peer took some action which made us think they were useless. Disconnect them.
7286 /// An error message which we should make an effort to send before we disconnect.
7288 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
7289 msg: crate::lightning::ln::msgs::ErrorMessage,
7291 /// The peer did something incorrect. Tell them without closing any channels and disconnect them.
7292 DisconnectPeerWithWarning {
7293 /// A warning message which we should make an effort to send before we disconnect.
7294 msg: crate::lightning::ln::msgs::WarningMessage,
7296 /// The peer did something harmless that we weren't able to process, just log and ignore
7298 /// The peer did something harmless that we weren't able to meaningfully process.
7299 /// If the error is logged, log it at the given level.
7301 crate::lightning::util::logger::Level),
7302 /// The peer provided us with a gossip message which we'd already seen. In most cases this
7303 /// should be ignored, but it may result in the message being forwarded if it is a duplicate of
7304 /// our own channel announcements.
7305 IgnoreDuplicateGossip,
7306 /// The peer did something incorrect. Tell them.
7308 /// The message to send.
7309 msg: crate::lightning::ln::msgs::ErrorMessage,
7311 /// The peer did something incorrect. Tell them without closing any channels.
7312 SendWarningMessage {
7313 /// The message to send.
7314 msg: crate::lightning::ln::msgs::WarningMessage,
7315 /// The peer may have done something harmless that we weren't able to meaningfully process,
7316 /// though we should still tell them about it.
7317 /// If this event is logged, log it at the given level.
7318 log_level: crate::lightning::util::logger::Level,
7321 use lightning::ln::msgs::ErrorAction as ErrorActionImport;
7322 pub(crate) type nativeErrorAction = ErrorActionImport;
7326 pub(crate) fn to_native(&self) -> nativeErrorAction {
7328 ErrorAction::DisconnectPeer {ref msg, } => {
7329 let mut msg_nonref = Clone::clone(msg);
7330 let mut local_msg_nonref = if msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg_nonref.take_inner()) } }) };
7331 nativeErrorAction::DisconnectPeer {
7332 msg: local_msg_nonref,
7335 ErrorAction::DisconnectPeerWithWarning {ref msg, } => {
7336 let mut msg_nonref = Clone::clone(msg);
7337 nativeErrorAction::DisconnectPeerWithWarning {
7338 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
7341 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
7342 ErrorAction::IgnoreAndLog (ref a, ) => {
7343 let mut a_nonref = Clone::clone(a);
7344 nativeErrorAction::IgnoreAndLog (
7345 a_nonref.into_native(),
7348 ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
7349 ErrorAction::SendErrorMessage {ref msg, } => {
7350 let mut msg_nonref = Clone::clone(msg);
7351 nativeErrorAction::SendErrorMessage {
7352 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
7355 ErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
7356 let mut msg_nonref = Clone::clone(msg);
7357 let mut log_level_nonref = Clone::clone(log_level);
7358 nativeErrorAction::SendWarningMessage {
7359 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
7360 log_level: log_level_nonref.into_native(),
7366 pub(crate) fn into_native(self) -> nativeErrorAction {
7368 ErrorAction::DisconnectPeer {mut msg, } => {
7369 let mut local_msg = if msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg.take_inner()) } }) };
7370 nativeErrorAction::DisconnectPeer {
7374 ErrorAction::DisconnectPeerWithWarning {mut msg, } => {
7375 nativeErrorAction::DisconnectPeerWithWarning {
7376 msg: *unsafe { Box::from_raw(msg.take_inner()) },
7379 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
7380 ErrorAction::IgnoreAndLog (mut a, ) => {
7381 nativeErrorAction::IgnoreAndLog (
7385 ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
7386 ErrorAction::SendErrorMessage {mut msg, } => {
7387 nativeErrorAction::SendErrorMessage {
7388 msg: *unsafe { Box::from_raw(msg.take_inner()) },
7391 ErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
7392 nativeErrorAction::SendWarningMessage {
7393 msg: *unsafe { Box::from_raw(msg.take_inner()) },
7394 log_level: log_level.into_native(),
7400 pub(crate) fn from_native(native: &nativeErrorAction) -> Self {
7402 nativeErrorAction::DisconnectPeer {ref msg, } => {
7403 let mut msg_nonref = Clone::clone(msg);
7404 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 };
7405 ErrorAction::DisconnectPeer {
7406 msg: local_msg_nonref,
7409 nativeErrorAction::DisconnectPeerWithWarning {ref msg, } => {
7410 let mut msg_nonref = Clone::clone(msg);
7411 ErrorAction::DisconnectPeerWithWarning {
7412 msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
7415 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
7416 nativeErrorAction::IgnoreAndLog (ref a, ) => {
7417 let mut a_nonref = Clone::clone(a);
7418 ErrorAction::IgnoreAndLog (
7419 crate::lightning::util::logger::Level::native_into(a_nonref),
7422 nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
7423 nativeErrorAction::SendErrorMessage {ref msg, } => {
7424 let mut msg_nonref = Clone::clone(msg);
7425 ErrorAction::SendErrorMessage {
7426 msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
7429 nativeErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
7430 let mut msg_nonref = Clone::clone(msg);
7431 let mut log_level_nonref = Clone::clone(log_level);
7432 ErrorAction::SendWarningMessage {
7433 msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
7434 log_level: crate::lightning::util::logger::Level::native_into(log_level_nonref),
7440 pub(crate) fn native_into(native: nativeErrorAction) -> Self {
7442 nativeErrorAction::DisconnectPeer {mut msg, } => {
7443 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 };
7444 ErrorAction::DisconnectPeer {
7448 nativeErrorAction::DisconnectPeerWithWarning {mut msg, } => {
7449 ErrorAction::DisconnectPeerWithWarning {
7450 msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
7453 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
7454 nativeErrorAction::IgnoreAndLog (mut a, ) => {
7455 ErrorAction::IgnoreAndLog (
7456 crate::lightning::util::logger::Level::native_into(a),
7459 nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
7460 nativeErrorAction::SendErrorMessage {mut msg, } => {
7461 ErrorAction::SendErrorMessage {
7462 msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
7465 nativeErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
7466 ErrorAction::SendWarningMessage {
7467 msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
7468 log_level: crate::lightning::util::logger::Level::native_into(log_level),
7474 /// Frees any resources used by the ErrorAction
7476 pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { }
7477 /// Creates a copy of the ErrorAction
7479 pub extern "C" fn ErrorAction_clone(orig: &ErrorAction) -> ErrorAction {
7483 /// Utility method to constructs a new DisconnectPeer-variant ErrorAction
7484 pub extern "C" fn ErrorAction_disconnect_peer(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
7485 ErrorAction::DisconnectPeer {
7490 /// Utility method to constructs a new DisconnectPeerWithWarning-variant ErrorAction
7491 pub extern "C" fn ErrorAction_disconnect_peer_with_warning(msg: crate::lightning::ln::msgs::WarningMessage) -> ErrorAction {
7492 ErrorAction::DisconnectPeerWithWarning {
7497 /// Utility method to constructs a new IgnoreError-variant ErrorAction
7498 pub extern "C" fn ErrorAction_ignore_error() -> ErrorAction {
7499 ErrorAction::IgnoreError}
7501 /// Utility method to constructs a new IgnoreAndLog-variant ErrorAction
7502 pub extern "C" fn ErrorAction_ignore_and_log(a: crate::lightning::util::logger::Level) -> ErrorAction {
7503 ErrorAction::IgnoreAndLog(a, )
7506 /// Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction
7507 pub extern "C" fn ErrorAction_ignore_duplicate_gossip() -> ErrorAction {
7508 ErrorAction::IgnoreDuplicateGossip}
7510 /// Utility method to constructs a new SendErrorMessage-variant ErrorAction
7511 pub extern "C" fn ErrorAction_send_error_message(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
7512 ErrorAction::SendErrorMessage {
7517 /// Utility method to constructs a new SendWarningMessage-variant ErrorAction
7518 pub extern "C" fn ErrorAction_send_warning_message(msg: crate::lightning::ln::msgs::WarningMessage, log_level: crate::lightning::util::logger::Level) -> ErrorAction {
7519 ErrorAction::SendWarningMessage {
7525 use lightning::ln::msgs::LightningError as nativeLightningErrorImport;
7526 pub(crate) type nativeLightningError = nativeLightningErrorImport;
7528 /// An Err type for failure to process messages.
7531 pub struct LightningError {
7532 /// A pointer to the opaque Rust object.
7534 /// Nearly everywhere, inner must be non-null, however in places where
7535 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7536 pub inner: *mut nativeLightningError,
7537 /// Indicates that this is the only struct which contains the same pointer.
7539 /// Rust functions which take ownership of an object provided via an argument require
7540 /// this to be true and invalidate the object pointed to by inner.
7544 impl Drop for LightningError {
7545 fn drop(&mut self) {
7546 if self.is_owned && !<*mut nativeLightningError>::is_null(self.inner) {
7547 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7551 /// Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL.
7553 pub extern "C" fn LightningError_free(this_obj: LightningError) { }
7555 /// Used only if an object of this type is returned as a trait impl by a method
7556 pub(crate) extern "C" fn LightningError_free_void(this_ptr: *mut c_void) {
7557 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLightningError) };
7560 impl LightningError {
7561 pub(crate) fn get_native_ref(&self) -> &'static nativeLightningError {
7562 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7564 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLightningError {
7565 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7567 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7568 pub(crate) fn take_inner(mut self) -> *mut nativeLightningError {
7569 assert!(self.is_owned);
7570 let ret = ObjOps::untweak_ptr(self.inner);
7571 self.inner = core::ptr::null_mut();
7575 /// A human-readable message describing the error
7577 pub extern "C" fn LightningError_get_err(this_ptr: &LightningError) -> crate::c_types::Str {
7578 let mut inner_val = &mut this_ptr.get_native_mut_ref().err;
7579 inner_val.as_str().into()
7581 /// A human-readable message describing the error
7583 pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: crate::c_types::Str) {
7584 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.err = val.into_string();
7586 /// The action which should be taken against the offending peer.
7588 pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate::lightning::ln::msgs::ErrorAction {
7589 let mut inner_val = &mut this_ptr.get_native_mut_ref().action;
7590 crate::lightning::ln::msgs::ErrorAction::from_native(inner_val)
7592 /// The action which should be taken against the offending peer.
7594 pub extern "C" fn LightningError_set_action(this_ptr: &mut LightningError, mut val: crate::lightning::ln::msgs::ErrorAction) {
7595 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.action = val.into_native();
7597 /// Constructs a new LightningError given each field
7600 pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::Str, mut action_arg: crate::lightning::ln::msgs::ErrorAction) -> LightningError {
7601 LightningError { inner: ObjOps::heap_alloc(nativeLightningError {
7602 err: err_arg.into_string(),
7603 action: action_arg.into_native(),
7604 }), is_owned: true }
7606 impl Clone for LightningError {
7607 fn clone(&self) -> Self {
7609 inner: if <*mut nativeLightningError>::is_null(self.inner) { core::ptr::null_mut() } else {
7610 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7616 /// Used only if an object of this type is returned as a trait impl by a method
7617 pub(crate) extern "C" fn LightningError_clone_void(this_ptr: *const c_void) -> *mut c_void {
7618 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeLightningError)).clone() })) as *mut c_void
7621 /// Creates a copy of the LightningError
7622 pub extern "C" fn LightningError_clone(orig: &LightningError) -> LightningError {
7626 use lightning::ln::msgs::CommitmentUpdate as nativeCommitmentUpdateImport;
7627 pub(crate) type nativeCommitmentUpdate = nativeCommitmentUpdateImport;
7629 /// Struct used to return values from [`RevokeAndACK`] messages, containing a bunch of commitment
7630 /// transaction updates if they were pending.
7633 pub struct CommitmentUpdate {
7634 /// A pointer to the opaque Rust object.
7636 /// Nearly everywhere, inner must be non-null, however in places where
7637 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7638 pub inner: *mut nativeCommitmentUpdate,
7639 /// Indicates that this is the only struct which contains the same pointer.
7641 /// Rust functions which take ownership of an object provided via an argument require
7642 /// this to be true and invalidate the object pointed to by inner.
7646 impl Drop for CommitmentUpdate {
7647 fn drop(&mut self) {
7648 if self.is_owned && !<*mut nativeCommitmentUpdate>::is_null(self.inner) {
7649 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7653 /// Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL.
7655 pub extern "C" fn CommitmentUpdate_free(this_obj: CommitmentUpdate) { }
7657 /// Used only if an object of this type is returned as a trait impl by a method
7658 pub(crate) extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) {
7659 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCommitmentUpdate) };
7662 impl CommitmentUpdate {
7663 pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentUpdate {
7664 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7666 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentUpdate {
7667 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7669 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7670 pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentUpdate {
7671 assert!(self.is_owned);
7672 let ret = ObjOps::untweak_ptr(self.inner);
7673 self.inner = core::ptr::null_mut();
7677 /// `update_add_htlc` messages which should be sent
7679 pub extern "C" fn CommitmentUpdate_get_update_add_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateAddHTLCZ {
7680 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_add_htlcs;
7681 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 } }); };
7682 local_inner_val.into()
7684 /// `update_add_htlc` messages which should be sent
7686 pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) {
7687 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
7688 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_add_htlcs = local_val;
7690 /// `update_fulfill_htlc` messages which should be sent
7692 pub extern "C" fn CommitmentUpdate_get_update_fulfill_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFulfillHTLCZ {
7693 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fulfill_htlcs;
7694 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 } }); };
7695 local_inner_val.into()
7697 /// `update_fulfill_htlc` messages which should be sent
7699 pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) {
7700 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
7701 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fulfill_htlcs = local_val;
7703 /// `update_fail_htlc` messages which should be sent
7705 pub extern "C" fn CommitmentUpdate_get_update_fail_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailHTLCZ {
7706 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_htlcs;
7707 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 } }); };
7708 local_inner_val.into()
7710 /// `update_fail_htlc` messages which should be sent
7712 pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) {
7713 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
7714 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_htlcs = local_val;
7716 /// `update_fail_malformed_htlc` messages which should be sent
7718 pub extern "C" fn CommitmentUpdate_get_update_fail_malformed_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ {
7719 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_malformed_htlcs;
7720 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 } }); };
7721 local_inner_val.into()
7723 /// `update_fail_malformed_htlc` messages which should be sent
7725 pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) {
7726 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
7727 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_malformed_htlcs = local_val;
7729 /// An `update_fee` message which should be sent
7731 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
7733 pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::UpdateFee {
7734 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fee;
7735 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 };
7738 /// An `update_fee` message which should be sent
7740 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
7742 pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::UpdateFee) {
7743 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
7744 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fee = local_val;
7746 /// A `commitment_signed` message which should be sent
7748 pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::CommitmentSigned {
7749 let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_signed;
7750 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 }
7752 /// A `commitment_signed` message which should be sent
7754 pub extern "C" fn CommitmentUpdate_set_commitment_signed(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::CommitmentSigned) {
7755 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_signed = *unsafe { Box::from_raw(val.take_inner()) };
7757 /// Constructs a new CommitmentUpdate given each field
7760 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 {
7761 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()) } }); };
7762 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()) } }); };
7763 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()) } }); };
7764 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()) } }); };
7765 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()) } }) };
7766 CommitmentUpdate { inner: ObjOps::heap_alloc(nativeCommitmentUpdate {
7767 update_add_htlcs: local_update_add_htlcs_arg,
7768 update_fulfill_htlcs: local_update_fulfill_htlcs_arg,
7769 update_fail_htlcs: local_update_fail_htlcs_arg,
7770 update_fail_malformed_htlcs: local_update_fail_malformed_htlcs_arg,
7771 update_fee: local_update_fee_arg,
7772 commitment_signed: *unsafe { Box::from_raw(commitment_signed_arg.take_inner()) },
7773 }), is_owned: true }
7775 impl Clone for CommitmentUpdate {
7776 fn clone(&self) -> Self {
7778 inner: if <*mut nativeCommitmentUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
7779 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7785 /// Used only if an object of this type is returned as a trait impl by a method
7786 pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
7787 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentUpdate)).clone() })) as *mut c_void
7790 /// Creates a copy of the CommitmentUpdate
7791 pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentUpdate {
7794 /// Checks if two CommitmentUpdates contain equal inner contents.
7795 /// This ignores pointers and is_owned flags and looks at the values in fields.
7796 /// Two objects with NULL inner values will be considered "equal" here.
7798 pub extern "C" fn CommitmentUpdate_eq(a: &CommitmentUpdate, b: &CommitmentUpdate) -> bool {
7799 if a.inner == b.inner { return true; }
7800 if a.inner.is_null() || b.inner.is_null() { return false; }
7801 if a.get_native_ref() == b.get_native_ref() { true } else { false }
7803 /// A trait to describe an object which can receive channel messages.
7805 /// Messages MAY be called in parallel when they originate from different `their_node_ids`, however
7806 /// they MUST NOT be called in parallel when the two calls have the same `their_node_id`.
7808 pub struct ChannelMessageHandler {
7809 /// An opaque pointer which is passed to your function implementations as an argument.
7810 /// This has no meaning in the LDK, and can be NULL or any other value.
7811 pub this_arg: *mut c_void,
7812 /// Handle an incoming `open_channel` message from the given peer.
7813 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),
7814 /// Handle an incoming `open_channel2` message from the given peer.
7815 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),
7816 /// Handle an incoming `accept_channel` message from the given peer.
7817 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),
7818 /// Handle an incoming `accept_channel2` message from the given peer.
7819 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),
7820 /// Handle an incoming `funding_created` message from the given peer.
7821 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),
7822 /// Handle an incoming `funding_signed` message from the given peer.
7823 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),
7824 /// Handle an incoming `channel_ready` message from the given peer.
7825 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),
7826 /// Handle an incoming `shutdown` message from the given peer.
7827 pub handle_shutdown: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Shutdown),
7828 /// Handle an incoming `closing_signed` message from the given peer.
7829 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),
7830 /// Handle an incoming `tx_add_input message` from the given peer.
7831 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),
7832 /// Handle an incoming `tx_add_output` message from the given peer.
7833 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),
7834 /// Handle an incoming `tx_remove_input` message from the given peer.
7835 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),
7836 /// Handle an incoming `tx_remove_output` message from the given peer.
7837 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),
7838 /// Handle an incoming `tx_complete message` from the given peer.
7839 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),
7840 /// Handle an incoming `tx_signatures` message from the given peer.
7841 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),
7842 /// Handle an incoming `tx_init_rbf` message from the given peer.
7843 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),
7844 /// Handle an incoming `tx_ack_rbf` message from the given peer.
7845 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),
7846 /// Handle an incoming `tx_abort message` from the given peer.
7847 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),
7848 /// Handle an incoming `update_add_htlc` message from the given peer.
7849 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),
7850 /// Handle an incoming `update_fulfill_htlc` message from the given peer.
7851 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),
7852 /// Handle an incoming `update_fail_htlc` message from the given peer.
7853 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),
7854 /// Handle an incoming `update_fail_malformed_htlc` message from the given peer.
7855 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),
7856 /// Handle an incoming `commitment_signed` message from the given peer.
7857 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),
7858 /// Handle an incoming `revoke_and_ack` message from the given peer.
7859 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),
7860 /// Handle an incoming `update_fee` message from the given peer.
7861 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),
7862 /// Handle an incoming `announcement_signatures` message from the given peer.
7863 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),
7864 /// Indicates a connection to the peer failed/an existing connection was lost.
7865 pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey),
7866 /// Handle a peer reconnecting, possibly generating `channel_reestablish` message(s).
7868 /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
7869 /// with us. Implementors should be somewhat conservative about doing so, however, as other
7870 /// message handlers may still wish to communicate with this peer.
7871 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,
7872 /// Handle an incoming `channel_reestablish` message from the given peer.
7873 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),
7874 /// Handle an incoming `channel_update` message from the given peer.
7875 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),
7876 /// Handle an incoming `error` message from the given peer.
7877 pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ErrorMessage),
7878 /// Gets the node feature flags which this handler itself supports. All available handlers are
7879 /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
7880 /// which are broadcasted in our [`NodeAnnouncement`] message.
7881 pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
7882 /// Gets the init feature flags which should be sent to the given peer. All available handlers
7883 /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
7884 /// which are sent in our [`Init`] message.
7886 /// Note that this method is called before [`Self::peer_connected`].
7887 pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
7888 /// Gets the genesis hashes for this `ChannelMessageHandler` indicating which chains it supports.
7890 /// If it's `None`, then no particular network chain hash compatibility will be enforced when
7891 /// connecting to peers.
7892 pub get_genesis_hashes: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::COption_CVec_ChainHashZZ,
7893 /// Implementation of MessageSendEventsProvider for this object.
7894 pub MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider,
7895 /// Frees any resources associated with this object given its this_arg pointer.
7896 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
7897 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
7899 unsafe impl Send for ChannelMessageHandler {}
7900 unsafe impl Sync for ChannelMessageHandler {}
7902 pub(crate) extern "C" fn ChannelMessageHandler_clone_fields(orig: &ChannelMessageHandler) -> ChannelMessageHandler {
7903 ChannelMessageHandler {
7904 this_arg: orig.this_arg,
7905 handle_open_channel: Clone::clone(&orig.handle_open_channel),
7906 handle_open_channel_v2: Clone::clone(&orig.handle_open_channel_v2),
7907 handle_accept_channel: Clone::clone(&orig.handle_accept_channel),
7908 handle_accept_channel_v2: Clone::clone(&orig.handle_accept_channel_v2),
7909 handle_funding_created: Clone::clone(&orig.handle_funding_created),
7910 handle_funding_signed: Clone::clone(&orig.handle_funding_signed),
7911 handle_channel_ready: Clone::clone(&orig.handle_channel_ready),
7912 handle_shutdown: Clone::clone(&orig.handle_shutdown),
7913 handle_closing_signed: Clone::clone(&orig.handle_closing_signed),
7914 handle_tx_add_input: Clone::clone(&orig.handle_tx_add_input),
7915 handle_tx_add_output: Clone::clone(&orig.handle_tx_add_output),
7916 handle_tx_remove_input: Clone::clone(&orig.handle_tx_remove_input),
7917 handle_tx_remove_output: Clone::clone(&orig.handle_tx_remove_output),
7918 handle_tx_complete: Clone::clone(&orig.handle_tx_complete),
7919 handle_tx_signatures: Clone::clone(&orig.handle_tx_signatures),
7920 handle_tx_init_rbf: Clone::clone(&orig.handle_tx_init_rbf),
7921 handle_tx_ack_rbf: Clone::clone(&orig.handle_tx_ack_rbf),
7922 handle_tx_abort: Clone::clone(&orig.handle_tx_abort),
7923 handle_update_add_htlc: Clone::clone(&orig.handle_update_add_htlc),
7924 handle_update_fulfill_htlc: Clone::clone(&orig.handle_update_fulfill_htlc),
7925 handle_update_fail_htlc: Clone::clone(&orig.handle_update_fail_htlc),
7926 handle_update_fail_malformed_htlc: Clone::clone(&orig.handle_update_fail_malformed_htlc),
7927 handle_commitment_signed: Clone::clone(&orig.handle_commitment_signed),
7928 handle_revoke_and_ack: Clone::clone(&orig.handle_revoke_and_ack),
7929 handle_update_fee: Clone::clone(&orig.handle_update_fee),
7930 handle_announcement_signatures: Clone::clone(&orig.handle_announcement_signatures),
7931 peer_disconnected: Clone::clone(&orig.peer_disconnected),
7932 peer_connected: Clone::clone(&orig.peer_connected),
7933 handle_channel_reestablish: Clone::clone(&orig.handle_channel_reestablish),
7934 handle_channel_update: Clone::clone(&orig.handle_channel_update),
7935 handle_error: Clone::clone(&orig.handle_error),
7936 provided_node_features: Clone::clone(&orig.provided_node_features),
7937 provided_init_features: Clone::clone(&orig.provided_init_features),
7938 get_genesis_hashes: Clone::clone(&orig.get_genesis_hashes),
7939 MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
7940 free: Clone::clone(&orig.free),
7943 impl lightning::events::MessageSendEventsProvider for ChannelMessageHandler {
7944 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::events::MessageSendEvent> {
7945 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
7946 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
7951 use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler;
7952 impl rustChannelMessageHandler for ChannelMessageHandler {
7953 fn handle_open_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OpenChannel) {
7954 (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 })
7956 fn handle_open_channel_v2(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OpenChannelV2) {
7957 (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 })
7959 fn handle_accept_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AcceptChannel) {
7960 (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 })
7962 fn handle_accept_channel_v2(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AcceptChannelV2) {
7963 (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 })
7965 fn handle_funding_created(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingCreated) {
7966 (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 })
7968 fn handle_funding_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingSigned) {
7969 (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 })
7971 fn handle_channel_ready(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReady) {
7972 (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 })
7974 fn handle_shutdown(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Shutdown) {
7975 (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 })
7977 fn handle_closing_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ClosingSigned) {
7978 (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 })
7980 fn handle_tx_add_input(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAddInput) {
7981 (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 })
7983 fn handle_tx_add_output(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAddOutput) {
7984 (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 })
7986 fn handle_tx_remove_input(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxRemoveInput) {
7987 (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 })
7989 fn handle_tx_remove_output(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxRemoveOutput) {
7990 (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 })
7992 fn handle_tx_complete(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxComplete) {
7993 (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 })
7995 fn handle_tx_signatures(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxSignatures) {
7996 (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 })
7998 fn handle_tx_init_rbf(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxInitRbf) {
7999 (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 })
8001 fn handle_tx_ack_rbf(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAckRbf) {
8002 (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 })
8004 fn handle_tx_abort(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAbort) {
8005 (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 })
8007 fn handle_update_add_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateAddHTLC) {
8008 (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 })
8010 fn handle_update_fulfill_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFulfillHTLC) {
8011 (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 })
8013 fn handle_update_fail_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailHTLC) {
8014 (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 })
8016 fn handle_update_fail_malformed_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) {
8017 (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 })
8019 fn handle_commitment_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::CommitmentSigned) {
8020 (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 })
8022 fn handle_revoke_and_ack(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::RevokeAndACK) {
8023 (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 })
8025 fn handle_update_fee(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFee) {
8026 (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 })
8028 fn handle_announcement_signatures(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AnnouncementSignatures) {
8029 (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 })
8031 fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) {
8032 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id))
8034 fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
8035 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);
8036 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)) })*/ })};
8039 fn handle_channel_reestablish(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReestablish) {
8040 (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 })
8042 fn handle_channel_update(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelUpdate) {
8043 (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 })
8045 fn handle_error(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ErrorMessage) {
8046 (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 })
8048 fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
8049 let mut ret = (self.provided_node_features)(self.this_arg);
8050 *unsafe { Box::from_raw(ret.take_inner()) }
8052 fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
8053 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
8054 *unsafe { Box::from_raw(ret.take_inner()) }
8056 fn get_genesis_hashes(&self) -> Option<Vec<bitcoin::blockdata::constants::ChainHash>> {
8057 let mut ret = (self.get_genesis_hashes)(self.this_arg);
8058 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 }})} };
8063 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
8064 // directly as a Deref trait in higher-level structs:
8065 impl core::ops::Deref for ChannelMessageHandler {
8067 fn deref(&self) -> &Self {
8071 /// Calls the free function if one is set
8073 pub extern "C" fn ChannelMessageHandler_free(this_ptr: ChannelMessageHandler) { }
8074 impl Drop for ChannelMessageHandler {
8075 fn drop(&mut self) {
8076 if let Some(f) = self.free {
8081 /// A trait to describe an object which can receive routing messages.
8083 /// # Implementor DoS Warnings
8085 /// For messages enabled with the `gossip_queries` feature there are potential DoS vectors when
8086 /// handling inbound queries. Implementors using an on-disk network graph should be aware of
8087 /// repeated disk I/O for queries accessing different parts of the network graph.
8089 pub struct RoutingMessageHandler {
8090 /// An opaque pointer which is passed to your function implementations as an argument.
8091 /// This has no meaning in the LDK, and can be NULL or any other value.
8092 pub this_arg: *mut c_void,
8093 /// Handle an incoming `node_announcement` message, returning `true` if it should be forwarded on,
8094 /// `false` or returning an `Err` otherwise.
8095 pub handle_node_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
8096 /// Handle a `channel_announcement` message, returning `true` if it should be forwarded on, `false`
8097 /// or returning an `Err` otherwise.
8098 pub handle_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
8099 /// Handle an incoming `channel_update` message, returning true if it should be forwarded on,
8100 /// `false` or returning an `Err` otherwise.
8101 pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ,
8102 /// Gets channel announcements and updates required to dump our routing table to a remote node,
8103 /// starting at the `short_channel_id` indicated by `starting_point` and including announcements
8104 /// for a single channel.
8105 pub get_next_channel_announcement: extern "C" fn (this_arg: *const c_void, starting_point: u64) -> crate::c_types::derived::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ,
8106 /// Gets a node announcement required to dump our routing table to a remote node, starting at
8107 /// the node *after* the provided pubkey and including up to one announcement immediately
8108 /// higher (as defined by `<PublicKey as Ord>::cmp`) than `starting_point`.
8109 /// If `None` is provided for `starting_point`, we start at the first node.
8111 /// Note that starting_point (or a relevant inner pointer) may be NULL or all-0s to represent None
8112 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
8113 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,
8114 /// Called when a connection is established with a peer. This can be used to
8115 /// perform routing table synchronization using a strategy defined by the
8118 /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
8119 /// with us. Implementors should be somewhat conservative about doing so, however, as other
8120 /// message handlers may still wish to communicate with this peer.
8121 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,
8122 /// Handles the reply of a query we initiated to learn about channels
8123 /// for a given range of blocks. We can expect to receive one or more
8124 /// replies to a single query.
8125 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,
8126 /// Handles the reply of a query we initiated asking for routing gossip
8127 /// messages for a list of channels. We should receive this message when
8128 /// a node has completed its best effort to send us the pertaining routing
8129 /// gossip messages.
8130 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,
8131 /// Handles when a peer asks us to send a list of `short_channel_id`s
8132 /// for the requested range of blocks.
8133 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,
8134 /// Handles when a peer asks us to send routing gossip messages for a
8135 /// list of `short_channel_id`s.
8136 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,
8137 /// Indicates that there are a large number of [`ChannelAnnouncement`] (or other) messages
8138 /// pending some async action. While there is no guarantee of the rate of future messages, the
8139 /// caller should seek to reduce the rate of new gossip messages handled, especially
8140 /// [`ChannelAnnouncement`]s.
8141 pub processing_queue_high: extern "C" fn (this_arg: *const c_void) -> bool,
8142 /// Gets the node feature flags which this handler itself supports. All available handlers are
8143 /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
8144 /// which are broadcasted in our [`NodeAnnouncement`] message.
8145 pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
8146 /// Gets the init feature flags which should be sent to the given peer. All available handlers
8147 /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
8148 /// which are sent in our [`Init`] message.
8150 /// Note that this method is called before [`Self::peer_connected`].
8151 pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
8152 /// Implementation of MessageSendEventsProvider for this object.
8153 pub MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider,
8154 /// Frees any resources associated with this object given its this_arg pointer.
8155 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
8156 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
8158 unsafe impl Send for RoutingMessageHandler {}
8159 unsafe impl Sync for RoutingMessageHandler {}
8161 pub(crate) extern "C" fn RoutingMessageHandler_clone_fields(orig: &RoutingMessageHandler) -> RoutingMessageHandler {
8162 RoutingMessageHandler {
8163 this_arg: orig.this_arg,
8164 handle_node_announcement: Clone::clone(&orig.handle_node_announcement),
8165 handle_channel_announcement: Clone::clone(&orig.handle_channel_announcement),
8166 handle_channel_update: Clone::clone(&orig.handle_channel_update),
8167 get_next_channel_announcement: Clone::clone(&orig.get_next_channel_announcement),
8168 get_next_node_announcement: Clone::clone(&orig.get_next_node_announcement),
8169 peer_connected: Clone::clone(&orig.peer_connected),
8170 handle_reply_channel_range: Clone::clone(&orig.handle_reply_channel_range),
8171 handle_reply_short_channel_ids_end: Clone::clone(&orig.handle_reply_short_channel_ids_end),
8172 handle_query_channel_range: Clone::clone(&orig.handle_query_channel_range),
8173 handle_query_short_channel_ids: Clone::clone(&orig.handle_query_short_channel_ids),
8174 processing_queue_high: Clone::clone(&orig.processing_queue_high),
8175 provided_node_features: Clone::clone(&orig.provided_node_features),
8176 provided_init_features: Clone::clone(&orig.provided_init_features),
8177 MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
8178 free: Clone::clone(&orig.free),
8181 impl lightning::events::MessageSendEventsProvider for RoutingMessageHandler {
8182 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::events::MessageSendEvent> {
8183 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
8184 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
8189 use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler;
8190 impl rustRoutingMessageHandler for RoutingMessageHandler {
8191 fn handle_node_announcement(&self, mut msg: &lightning::ln::msgs::NodeAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
8192 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 });
8193 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()) } })};
8196 fn handle_channel_announcement(&self, mut msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
8197 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 });
8198 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()) } })};
8201 fn handle_channel_update(&self, mut msg: &lightning::ln::msgs::ChannelUpdate) -> Result<bool, lightning::ln::msgs::LightningError> {
8202 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 });
8203 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()) } })};
8206 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>)> {
8207 let mut ret = (self.get_next_channel_announcement)(self.this_arg, starting_point);
8208 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 };
8211 fn get_next_node_announcement(&self, mut starting_point: Option<&lightning::routing::gossip::NodeId>) -> Option<lightning::ln::msgs::NodeAnnouncement> {
8212 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 };
8213 let mut ret = (self.get_next_node_announcement)(self.this_arg, local_starting_point);
8214 let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) };
8217 fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
8218 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);
8219 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)) })*/ })};
8222 fn handle_reply_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::ReplyChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
8223 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 });
8224 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()) } })};
8227 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> {
8228 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 });
8229 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()) } })};
8232 fn handle_query_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::QueryChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
8233 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 });
8234 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()) } })};
8237 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> {
8238 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 });
8239 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()) } })};
8242 fn processing_queue_high(&self) -> bool {
8243 let mut ret = (self.processing_queue_high)(self.this_arg);
8246 fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
8247 let mut ret = (self.provided_node_features)(self.this_arg);
8248 *unsafe { Box::from_raw(ret.take_inner()) }
8250 fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
8251 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
8252 *unsafe { Box::from_raw(ret.take_inner()) }
8256 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
8257 // directly as a Deref trait in higher-level structs:
8258 impl core::ops::Deref for RoutingMessageHandler {
8260 fn deref(&self) -> &Self {
8264 /// Calls the free function if one is set
8266 pub extern "C" fn RoutingMessageHandler_free(this_ptr: RoutingMessageHandler) { }
8267 impl Drop for RoutingMessageHandler {
8268 fn drop(&mut self) {
8269 if let Some(f) = self.free {
8274 /// A trait to describe an object that can receive onion messages.
8276 pub struct OnionMessageHandler {
8277 /// An opaque pointer which is passed to your function implementations as an argument.
8278 /// This has no meaning in the LDK, and can be NULL or any other value.
8279 pub this_arg: *mut c_void,
8280 /// Handle an incoming `onion_message` message from the given peer.
8281 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),
8282 /// Called when a connection is established with a peer. Can be used to track which peers
8283 /// advertise onion message support and are online.
8285 /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
8286 /// with us. Implementors should be somewhat conservative about doing so, however, as other
8287 /// message handlers may still wish to communicate with this peer.
8288 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,
8289 /// Indicates a connection to the peer failed/an existing connection was lost. Allows handlers to
8290 /// drop and refuse to forward onion messages to this peer.
8291 pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey),
8292 /// Gets the node feature flags which this handler itself supports. All available handlers are
8293 /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
8294 /// which are broadcasted in our [`NodeAnnouncement`] message.
8295 pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
8296 /// Gets the init feature flags which should be sent to the given peer. All available handlers
8297 /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
8298 /// which are sent in our [`Init`] message.
8300 /// Note that this method is called before [`Self::peer_connected`].
8301 pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
8302 /// Implementation of OnionMessageProvider for this object.
8303 pub OnionMessageProvider: crate::lightning::events::OnionMessageProvider,
8304 /// Frees any resources associated with this object given its this_arg pointer.
8305 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
8306 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
8308 unsafe impl Send for OnionMessageHandler {}
8309 unsafe impl Sync for OnionMessageHandler {}
8311 pub(crate) extern "C" fn OnionMessageHandler_clone_fields(orig: &OnionMessageHandler) -> OnionMessageHandler {
8312 OnionMessageHandler {
8313 this_arg: orig.this_arg,
8314 handle_onion_message: Clone::clone(&orig.handle_onion_message),
8315 peer_connected: Clone::clone(&orig.peer_connected),
8316 peer_disconnected: Clone::clone(&orig.peer_disconnected),
8317 provided_node_features: Clone::clone(&orig.provided_node_features),
8318 provided_init_features: Clone::clone(&orig.provided_init_features),
8319 OnionMessageProvider: crate::lightning::events::OnionMessageProvider_clone_fields(&orig.OnionMessageProvider),
8320 free: Clone::clone(&orig.free),
8323 impl lightning::events::OnionMessageProvider for OnionMessageHandler {
8324 fn next_onion_message_for_peer(&self, mut peer_node_id: bitcoin::secp256k1::PublicKey) -> Option<lightning::ln::msgs::OnionMessage> {
8325 let mut ret = (self.OnionMessageProvider.next_onion_message_for_peer)(self.OnionMessageProvider.this_arg, crate::c_types::PublicKey::from_rust(&peer_node_id));
8326 let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) };
8331 use lightning::ln::msgs::OnionMessageHandler as rustOnionMessageHandler;
8332 impl rustOnionMessageHandler for OnionMessageHandler {
8333 fn handle_onion_message(&self, mut peer_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OnionMessage) {
8334 (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 })
8336 fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
8337 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);
8338 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)) })*/ })};
8341 fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) {
8342 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id))
8344 fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
8345 let mut ret = (self.provided_node_features)(self.this_arg);
8346 *unsafe { Box::from_raw(ret.take_inner()) }
8348 fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
8349 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
8350 *unsafe { Box::from_raw(ret.take_inner()) }
8354 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
8355 // directly as a Deref trait in higher-level structs:
8356 impl core::ops::Deref for OnionMessageHandler {
8358 fn deref(&self) -> &Self {
8362 /// Calls the free function if one is set
8364 pub extern "C" fn OnionMessageHandler_free(this_ptr: OnionMessageHandler) { }
8365 impl Drop for OnionMessageHandler {
8366 fn drop(&mut self) {
8367 if let Some(f) = self.free {
8372 mod fuzzy_internal_msgs {
8374 use alloc::str::FromStr;
8375 use core::ffi::c_void;
8376 use core::convert::Infallible;
8377 use bitcoin::hashes::Hash;
8378 use crate::c_types::*;
8379 #[cfg(feature="no-std")]
8380 use alloc::{vec::Vec, boxed::Box};
8384 /// Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read
8385 pub extern "C" fn AcceptChannel_write(obj: &crate::lightning::ln::msgs::AcceptChannel) -> crate::c_types::derived::CVec_u8Z {
8386 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8389 pub(crate) extern "C" fn AcceptChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8390 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannel) })
8393 /// Read a AcceptChannel from a byte array, created by AcceptChannel_write
8394 pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelDecodeErrorZ {
8395 let res: Result<lightning::ln::msgs::AcceptChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8396 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() };
8400 /// Serialize the AcceptChannelV2 object into a byte array which can be read by AcceptChannelV2_read
8401 pub extern "C" fn AcceptChannelV2_write(obj: &crate::lightning::ln::msgs::AcceptChannelV2) -> crate::c_types::derived::CVec_u8Z {
8402 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8405 pub(crate) extern "C" fn AcceptChannelV2_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8406 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannelV2) })
8409 /// Read a AcceptChannelV2 from a byte array, created by AcceptChannelV2_write
8410 pub extern "C" fn AcceptChannelV2_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelV2DecodeErrorZ {
8411 let res: Result<lightning::ln::msgs::AcceptChannelV2, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8412 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() };
8416 /// Serialize the TxAddInput object into a byte array which can be read by TxAddInput_read
8417 pub extern "C" fn TxAddInput_write(obj: &crate::lightning::ln::msgs::TxAddInput) -> crate::c_types::derived::CVec_u8Z {
8418 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8421 pub(crate) extern "C" fn TxAddInput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8422 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAddInput) })
8425 /// Read a TxAddInput from a byte array, created by TxAddInput_write
8426 pub extern "C" fn TxAddInput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAddInputDecodeErrorZ {
8427 let res: Result<lightning::ln::msgs::TxAddInput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8428 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() };
8432 /// Serialize the TxAddOutput object into a byte array which can be read by TxAddOutput_read
8433 pub extern "C" fn TxAddOutput_write(obj: &crate::lightning::ln::msgs::TxAddOutput) -> crate::c_types::derived::CVec_u8Z {
8434 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8437 pub(crate) extern "C" fn TxAddOutput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8438 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAddOutput) })
8441 /// Read a TxAddOutput from a byte array, created by TxAddOutput_write
8442 pub extern "C" fn TxAddOutput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAddOutputDecodeErrorZ {
8443 let res: Result<lightning::ln::msgs::TxAddOutput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8444 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() };
8448 /// Serialize the TxRemoveInput object into a byte array which can be read by TxRemoveInput_read
8449 pub extern "C" fn TxRemoveInput_write(obj: &crate::lightning::ln::msgs::TxRemoveInput) -> crate::c_types::derived::CVec_u8Z {
8450 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8453 pub(crate) extern "C" fn TxRemoveInput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8454 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxRemoveInput) })
8457 /// Read a TxRemoveInput from a byte array, created by TxRemoveInput_write
8458 pub extern "C" fn TxRemoveInput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxRemoveInputDecodeErrorZ {
8459 let res: Result<lightning::ln::msgs::TxRemoveInput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8460 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() };
8464 /// Serialize the TxRemoveOutput object into a byte array which can be read by TxRemoveOutput_read
8465 pub extern "C" fn TxRemoveOutput_write(obj: &crate::lightning::ln::msgs::TxRemoveOutput) -> crate::c_types::derived::CVec_u8Z {
8466 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8469 pub(crate) extern "C" fn TxRemoveOutput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8470 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxRemoveOutput) })
8473 /// Read a TxRemoveOutput from a byte array, created by TxRemoveOutput_write
8474 pub extern "C" fn TxRemoveOutput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxRemoveOutputDecodeErrorZ {
8475 let res: Result<lightning::ln::msgs::TxRemoveOutput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8476 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() };
8480 /// Serialize the TxComplete object into a byte array which can be read by TxComplete_read
8481 pub extern "C" fn TxComplete_write(obj: &crate::lightning::ln::msgs::TxComplete) -> crate::c_types::derived::CVec_u8Z {
8482 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8485 pub(crate) extern "C" fn TxComplete_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8486 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxComplete) })
8489 /// Read a TxComplete from a byte array, created by TxComplete_write
8490 pub extern "C" fn TxComplete_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxCompleteDecodeErrorZ {
8491 let res: Result<lightning::ln::msgs::TxComplete, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8492 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() };
8496 /// Serialize the TxSignatures object into a byte array which can be read by TxSignatures_read
8497 pub extern "C" fn TxSignatures_write(obj: &crate::lightning::ln::msgs::TxSignatures) -> crate::c_types::derived::CVec_u8Z {
8498 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8501 pub(crate) extern "C" fn TxSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8502 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxSignatures) })
8505 /// Read a TxSignatures from a byte array, created by TxSignatures_write
8506 pub extern "C" fn TxSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxSignaturesDecodeErrorZ {
8507 let res: Result<lightning::ln::msgs::TxSignatures, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8508 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() };
8512 /// Serialize the TxInitRbf object into a byte array which can be read by TxInitRbf_read
8513 pub extern "C" fn TxInitRbf_write(obj: &crate::lightning::ln::msgs::TxInitRbf) -> crate::c_types::derived::CVec_u8Z {
8514 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8517 pub(crate) extern "C" fn TxInitRbf_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8518 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxInitRbf) })
8521 /// Read a TxInitRbf from a byte array, created by TxInitRbf_write
8522 pub extern "C" fn TxInitRbf_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxInitRbfDecodeErrorZ {
8523 let res: Result<lightning::ln::msgs::TxInitRbf, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8524 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() };
8528 /// Serialize the TxAckRbf object into a byte array which can be read by TxAckRbf_read
8529 pub extern "C" fn TxAckRbf_write(obj: &crate::lightning::ln::msgs::TxAckRbf) -> crate::c_types::derived::CVec_u8Z {
8530 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8533 pub(crate) extern "C" fn TxAckRbf_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8534 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAckRbf) })
8537 /// Read a TxAckRbf from a byte array, created by TxAckRbf_write
8538 pub extern "C" fn TxAckRbf_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAckRbfDecodeErrorZ {
8539 let res: Result<lightning::ln::msgs::TxAckRbf, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8540 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() };
8544 /// Serialize the TxAbort object into a byte array which can be read by TxAbort_read
8545 pub extern "C" fn TxAbort_write(obj: &crate::lightning::ln::msgs::TxAbort) -> crate::c_types::derived::CVec_u8Z {
8546 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8549 pub(crate) extern "C" fn TxAbort_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8550 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAbort) })
8553 /// Read a TxAbort from a byte array, created by TxAbort_write
8554 pub extern "C" fn TxAbort_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAbortDecodeErrorZ {
8555 let res: Result<lightning::ln::msgs::TxAbort, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8556 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() };
8560 /// Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read
8561 pub extern "C" fn AnnouncementSignatures_write(obj: &crate::lightning::ln::msgs::AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z {
8562 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8565 pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8566 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAnnouncementSignatures) })
8569 /// Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write
8570 pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AnnouncementSignaturesDecodeErrorZ {
8571 let res: Result<lightning::ln::msgs::AnnouncementSignatures, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8572 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() };
8576 /// Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read
8577 pub extern "C" fn ChannelReestablish_write(obj: &crate::lightning::ln::msgs::ChannelReestablish) -> crate::c_types::derived::CVec_u8Z {
8578 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8581 pub(crate) extern "C" fn ChannelReestablish_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8582 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReestablish) })
8585 /// Read a ChannelReestablish from a byte array, created by ChannelReestablish_write
8586 pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReestablishDecodeErrorZ {
8587 let res: Result<lightning::ln::msgs::ChannelReestablish, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8588 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() };
8592 /// Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read
8593 pub extern "C" fn ClosingSigned_write(obj: &crate::lightning::ln::msgs::ClosingSigned) -> crate::c_types::derived::CVec_u8Z {
8594 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8597 pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8598 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSigned) })
8601 /// Read a ClosingSigned from a byte array, created by ClosingSigned_write
8602 pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedDecodeErrorZ {
8603 let res: Result<lightning::ln::msgs::ClosingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8604 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() };
8608 /// Serialize the ClosingSignedFeeRange object into a byte array which can be read by ClosingSignedFeeRange_read
8609 pub extern "C" fn ClosingSignedFeeRange_write(obj: &crate::lightning::ln::msgs::ClosingSignedFeeRange) -> crate::c_types::derived::CVec_u8Z {
8610 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8613 pub(crate) extern "C" fn ClosingSignedFeeRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8614 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSignedFeeRange) })
8617 /// Read a ClosingSignedFeeRange from a byte array, created by ClosingSignedFeeRange_write
8618 pub extern "C" fn ClosingSignedFeeRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedFeeRangeDecodeErrorZ {
8619 let res: Result<lightning::ln::msgs::ClosingSignedFeeRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8620 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() };
8624 /// Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read
8625 pub extern "C" fn CommitmentSigned_write(obj: &crate::lightning::ln::msgs::CommitmentSigned) -> crate::c_types::derived::CVec_u8Z {
8626 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8629 pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8630 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentSigned) })
8633 /// Read a CommitmentSigned from a byte array, created by CommitmentSigned_write
8634 pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CommitmentSignedDecodeErrorZ {
8635 let res: Result<lightning::ln::msgs::CommitmentSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8636 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() };
8640 /// Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read
8641 pub extern "C" fn FundingCreated_write(obj: &crate::lightning::ln::msgs::FundingCreated) -> crate::c_types::derived::CVec_u8Z {
8642 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8645 pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8646 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingCreated) })
8649 /// Read a FundingCreated from a byte array, created by FundingCreated_write
8650 pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingCreatedDecodeErrorZ {
8651 let res: Result<lightning::ln::msgs::FundingCreated, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8652 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() };
8656 /// Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read
8657 pub extern "C" fn FundingSigned_write(obj: &crate::lightning::ln::msgs::FundingSigned) -> crate::c_types::derived::CVec_u8Z {
8658 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8661 pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8662 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingSigned) })
8665 /// Read a FundingSigned from a byte array, created by FundingSigned_write
8666 pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingSignedDecodeErrorZ {
8667 let res: Result<lightning::ln::msgs::FundingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8668 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() };
8672 /// Serialize the ChannelReady object into a byte array which can be read by ChannelReady_read
8673 pub extern "C" fn ChannelReady_write(obj: &crate::lightning::ln::msgs::ChannelReady) -> crate::c_types::derived::CVec_u8Z {
8674 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8677 pub(crate) extern "C" fn ChannelReady_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8678 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReady) })
8681 /// Read a ChannelReady from a byte array, created by ChannelReady_write
8682 pub extern "C" fn ChannelReady_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReadyDecodeErrorZ {
8683 let res: Result<lightning::ln::msgs::ChannelReady, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8684 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() };
8688 /// Serialize the Init object into a byte array which can be read by Init_read
8689 pub extern "C" fn Init_write(obj: &crate::lightning::ln::msgs::Init) -> crate::c_types::derived::CVec_u8Z {
8690 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8693 pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8694 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInit) })
8697 /// Read a Init from a byte array, created by Init_write
8698 pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitDecodeErrorZ {
8699 let res: Result<lightning::ln::msgs::Init, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8700 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() };
8704 /// Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read
8705 pub extern "C" fn OpenChannel_write(obj: &crate::lightning::ln::msgs::OpenChannel) -> crate::c_types::derived::CVec_u8Z {
8706 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8709 pub(crate) extern "C" fn OpenChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8710 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannel) })
8713 /// Read a OpenChannel from a byte array, created by OpenChannel_write
8714 pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelDecodeErrorZ {
8715 let res: Result<lightning::ln::msgs::OpenChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8716 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() };
8720 /// Serialize the OpenChannelV2 object into a byte array which can be read by OpenChannelV2_read
8721 pub extern "C" fn OpenChannelV2_write(obj: &crate::lightning::ln::msgs::OpenChannelV2) -> crate::c_types::derived::CVec_u8Z {
8722 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8725 pub(crate) extern "C" fn OpenChannelV2_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8726 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannelV2) })
8729 /// Read a OpenChannelV2 from a byte array, created by OpenChannelV2_write
8730 pub extern "C" fn OpenChannelV2_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelV2DecodeErrorZ {
8731 let res: Result<lightning::ln::msgs::OpenChannelV2, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8732 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() };
8736 /// Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read
8737 pub extern "C" fn RevokeAndACK_write(obj: &crate::lightning::ln::msgs::RevokeAndACK) -> crate::c_types::derived::CVec_u8Z {
8738 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8741 pub(crate) extern "C" fn RevokeAndACK_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8742 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevokeAndACK) })
8745 /// Read a RevokeAndACK from a byte array, created by RevokeAndACK_write
8746 pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RevokeAndACKDecodeErrorZ {
8747 let res: Result<lightning::ln::msgs::RevokeAndACK, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8748 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() };
8752 /// Serialize the Shutdown object into a byte array which can be read by Shutdown_read
8753 pub extern "C" fn Shutdown_write(obj: &crate::lightning::ln::msgs::Shutdown) -> crate::c_types::derived::CVec_u8Z {
8754 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8757 pub(crate) extern "C" fn Shutdown_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8758 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeShutdown) })
8761 /// Read a Shutdown from a byte array, created by Shutdown_write
8762 pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ShutdownDecodeErrorZ {
8763 let res: Result<lightning::ln::msgs::Shutdown, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8764 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() };
8768 /// Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read
8769 pub extern "C" fn UpdateFailHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFailHTLC) -> crate::c_types::derived::CVec_u8Z {
8770 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8773 pub(crate) extern "C" fn UpdateFailHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8774 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailHTLC) })
8777 /// Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write
8778 pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailHTLCDecodeErrorZ {
8779 let res: Result<lightning::ln::msgs::UpdateFailHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8780 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() };
8784 /// Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read
8785 pub extern "C" fn UpdateFailMalformedHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFailMalformedHTLC) -> crate::c_types::derived::CVec_u8Z {
8786 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8789 pub(crate) extern "C" fn UpdateFailMalformedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8790 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailMalformedHTLC) })
8793 /// Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write
8794 pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailMalformedHTLCDecodeErrorZ {
8795 let res: Result<lightning::ln::msgs::UpdateFailMalformedHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8796 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() };
8800 /// Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read
8801 pub extern "C" fn UpdateFee_write(obj: &crate::lightning::ln::msgs::UpdateFee) -> crate::c_types::derived::CVec_u8Z {
8802 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8805 pub(crate) extern "C" fn UpdateFee_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8806 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFee) })
8809 /// Read a UpdateFee from a byte array, created by UpdateFee_write
8810 pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFeeDecodeErrorZ {
8811 let res: Result<lightning::ln::msgs::UpdateFee, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8812 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() };
8816 /// Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read
8817 pub extern "C" fn UpdateFulfillHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFulfillHTLC) -> crate::c_types::derived::CVec_u8Z {
8818 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8821 pub(crate) extern "C" fn UpdateFulfillHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8822 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFulfillHTLC) })
8825 /// Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write
8826 pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFulfillHTLCDecodeErrorZ {
8827 let res: Result<lightning::ln::msgs::UpdateFulfillHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8828 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() };
8832 /// Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read
8833 pub extern "C" fn UpdateAddHTLC_write(obj: &crate::lightning::ln::msgs::UpdateAddHTLC) -> crate::c_types::derived::CVec_u8Z {
8834 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8837 pub(crate) extern "C" fn UpdateAddHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8838 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateAddHTLC) })
8841 /// Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write
8842 pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateAddHTLCDecodeErrorZ {
8843 let res: Result<lightning::ln::msgs::UpdateAddHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8844 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() };
8848 /// Read a OnionMessage from a byte array, created by OnionMessage_write
8849 pub extern "C" fn OnionMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OnionMessageDecodeErrorZ {
8850 let res: Result<lightning::ln::msgs::OnionMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8851 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() };
8855 /// Serialize the OnionMessage object into a byte array which can be read by OnionMessage_read
8856 pub extern "C" fn OnionMessage_write(obj: &crate::lightning::ln::msgs::OnionMessage) -> crate::c_types::derived::CVec_u8Z {
8857 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8860 pub(crate) extern "C" fn OnionMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8861 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOnionMessage) })
8864 /// Serialize the Ping object into a byte array which can be read by Ping_read
8865 pub extern "C" fn Ping_write(obj: &crate::lightning::ln::msgs::Ping) -> crate::c_types::derived::CVec_u8Z {
8866 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8869 pub(crate) extern "C" fn Ping_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8870 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePing) })
8873 /// Read a Ping from a byte array, created by Ping_write
8874 pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PingDecodeErrorZ {
8875 let res: Result<lightning::ln::msgs::Ping, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8876 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() };
8880 /// Serialize the Pong object into a byte array which can be read by Pong_read
8881 pub extern "C" fn Pong_write(obj: &crate::lightning::ln::msgs::Pong) -> crate::c_types::derived::CVec_u8Z {
8882 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8885 pub(crate) extern "C" fn Pong_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8886 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePong) })
8889 /// Read a Pong from a byte array, created by Pong_write
8890 pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PongDecodeErrorZ {
8891 let res: Result<lightning::ln::msgs::Pong, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8892 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() };
8896 /// Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read
8897 pub extern "C" fn UnsignedChannelAnnouncement_write(obj: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
8898 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8901 pub(crate) extern "C" fn UnsignedChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8902 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelAnnouncement) })
8905 /// Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write
8906 pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelAnnouncementDecodeErrorZ {
8907 let res: Result<lightning::ln::msgs::UnsignedChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8908 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() };
8912 /// Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read
8913 pub extern "C" fn ChannelAnnouncement_write(obj: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
8914 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8917 pub(crate) extern "C" fn ChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8918 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelAnnouncement) })
8921 /// Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write
8922 pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelAnnouncementDecodeErrorZ {
8923 let res: Result<lightning::ln::msgs::ChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8924 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() };
8928 /// Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read
8929 pub extern "C" fn UnsignedChannelUpdate_write(obj: &crate::lightning::ln::msgs::UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
8930 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8933 pub(crate) extern "C" fn UnsignedChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8934 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelUpdate) })
8937 /// Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write
8938 pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelUpdateDecodeErrorZ {
8939 let res: Result<lightning::ln::msgs::UnsignedChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8940 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() };
8944 /// Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read
8945 pub extern "C" fn ChannelUpdate_write(obj: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
8946 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8949 pub(crate) extern "C" fn ChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8950 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdate) })
8953 /// Read a ChannelUpdate from a byte array, created by ChannelUpdate_write
8954 pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelUpdateDecodeErrorZ {
8955 let res: Result<lightning::ln::msgs::ChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8956 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() };
8960 /// Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read
8961 pub extern "C" fn ErrorMessage_write(obj: &crate::lightning::ln::msgs::ErrorMessage) -> crate::c_types::derived::CVec_u8Z {
8962 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8965 pub(crate) extern "C" fn ErrorMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8966 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeErrorMessage) })
8969 /// Read a ErrorMessage from a byte array, created by ErrorMessage_write
8970 pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ErrorMessageDecodeErrorZ {
8971 let res: Result<lightning::ln::msgs::ErrorMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8972 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() };
8976 /// Serialize the WarningMessage object into a byte array which can be read by WarningMessage_read
8977 pub extern "C" fn WarningMessage_write(obj: &crate::lightning::ln::msgs::WarningMessage) -> crate::c_types::derived::CVec_u8Z {
8978 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8981 pub(crate) extern "C" fn WarningMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8982 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeWarningMessage) })
8985 /// Read a WarningMessage from a byte array, created by WarningMessage_write
8986 pub extern "C" fn WarningMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_WarningMessageDecodeErrorZ {
8987 let res: Result<lightning::ln::msgs::WarningMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8988 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() };
8992 /// Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read
8993 pub extern "C" fn UnsignedNodeAnnouncement_write(obj: &crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
8994 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8997 pub(crate) extern "C" fn UnsignedNodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8998 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedNodeAnnouncement) })
9001 /// Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write
9002 pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedNodeAnnouncementDecodeErrorZ {
9003 let res: Result<lightning::ln::msgs::UnsignedNodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9004 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() };
9008 /// Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read
9009 pub extern "C" fn NodeAnnouncement_write(obj: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
9010 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9013 pub(crate) extern "C" fn NodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9014 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncement) })
9017 /// Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write
9018 pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementDecodeErrorZ {
9019 let res: Result<lightning::ln::msgs::NodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9020 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() };
9024 /// Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write
9025 pub extern "C" fn QueryShortChannelIds_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryShortChannelIdsDecodeErrorZ {
9026 let res: Result<lightning::ln::msgs::QueryShortChannelIds, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9027 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() };
9031 /// Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read
9032 pub extern "C" fn QueryShortChannelIds_write(obj: &crate::lightning::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CVec_u8Z {
9033 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9036 pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9037 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) })
9040 /// Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read
9041 pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z {
9042 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9045 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9046 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) })
9049 /// Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write
9050 pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyShortChannelIdsEndDecodeErrorZ {
9051 let res: Result<lightning::ln::msgs::ReplyShortChannelIdsEnd, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9052 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() };
9055 /// Calculates the overflow safe ending block height for the query.
9057 /// Overflow returns `0xffffffff`, otherwise returns `first_blocknum + number_of_blocks`.
9060 pub extern "C" fn QueryChannelRange_end_blocknum(this_arg: &crate::lightning::ln::msgs::QueryChannelRange) -> u32 {
9061 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.end_blocknum();
9066 /// Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read
9067 pub extern "C" fn QueryChannelRange_write(obj: &crate::lightning::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CVec_u8Z {
9068 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9071 pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9072 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) })
9075 /// Read a QueryChannelRange from a byte array, created by QueryChannelRange_write
9076 pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ {
9077 let res: Result<lightning::ln::msgs::QueryChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9078 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() };
9082 /// Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write
9083 pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyChannelRangeDecodeErrorZ {
9084 let res: Result<lightning::ln::msgs::ReplyChannelRange, 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::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() };
9089 /// Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read
9090 pub extern "C" fn ReplyChannelRange_write(obj: &crate::lightning::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CVec_u8Z {
9091 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9094 pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9095 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) })
9098 /// Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read
9099 pub extern "C" fn GossipTimestampFilter_write(obj: &crate::lightning::ln::msgs::GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z {
9100 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9103 pub(crate) extern "C" fn GossipTimestampFilter_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9104 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeGossipTimestampFilter) })
9107 /// Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write
9108 pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_GossipTimestampFilterDecodeErrorZ {
9109 let res: Result<lightning::ln::msgs::GossipTimestampFilter, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9110 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() };