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 /// The receipient's network address.
241 /// This adds the option to report a remote IP address back to a connecting peer using the init
242 /// message. A node can decide to use that information to discover a potential update to its
243 /// public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing
246 pub extern "C" fn Init_get_remote_network_address(this_ptr: &Init) -> crate::c_types::derived::COption_NetAddressZ {
247 let mut inner_val = &mut this_ptr.get_native_mut_ref().remote_network_address;
248 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()) }) };
251 /// The receipient's network address.
253 /// This adds the option to report a remote IP address back to a connecting peer using the init
254 /// message. A node can decide to use that information to discover a potential update to its
255 /// public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing
258 pub extern "C" fn Init_set_remote_network_address(this_ptr: &mut Init, mut val: crate::c_types::derived::COption_NetAddressZ) {
259 let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_native() }})} };
260 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.remote_network_address = local_val;
262 /// Constructs a new Init given each field
265 pub extern "C" fn Init_new(mut features_arg: crate::lightning::ln::features::InitFeatures, mut remote_network_address_arg: crate::c_types::derived::COption_NetAddressZ) -> Init {
266 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() }})} };
267 Init { inner: ObjOps::heap_alloc(nativeInit {
268 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
269 remote_network_address: local_remote_network_address_arg,
272 impl Clone for Init {
273 fn clone(&self) -> Self {
275 inner: if <*mut nativeInit>::is_null(self.inner) { core::ptr::null_mut() } else {
276 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
282 /// Used only if an object of this type is returned as a trait impl by a method
283 pub(crate) extern "C" fn Init_clone_void(this_ptr: *const c_void) -> *mut c_void {
284 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInit)).clone() })) as *mut c_void
287 /// Creates a copy of the Init
288 pub extern "C" fn Init_clone(orig: &Init) -> Init {
291 /// Checks if two Inits contain equal inner contents.
292 /// This ignores pointers and is_owned flags and looks at the values in fields.
293 /// Two objects with NULL inner values will be considered "equal" here.
295 pub extern "C" fn Init_eq(a: &Init, b: &Init) -> bool {
296 if a.inner == b.inner { return true; }
297 if a.inner.is_null() || b.inner.is_null() { return false; }
298 if a.get_native_ref() == b.get_native_ref() { true } else { false }
301 use lightning::ln::msgs::ErrorMessage as nativeErrorMessageImport;
302 pub(crate) type nativeErrorMessage = nativeErrorMessageImport;
304 /// An [`error`] message to be sent to or received from a peer.
306 /// [`error`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages
309 pub struct ErrorMessage {
310 /// A pointer to the opaque Rust object.
312 /// Nearly everywhere, inner must be non-null, however in places where
313 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
314 pub inner: *mut nativeErrorMessage,
315 /// Indicates that this is the only struct which contains the same pointer.
317 /// Rust functions which take ownership of an object provided via an argument require
318 /// this to be true and invalidate the object pointed to by inner.
322 impl Drop for ErrorMessage {
324 if self.is_owned && !<*mut nativeErrorMessage>::is_null(self.inner) {
325 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
329 /// Frees any resources used by the ErrorMessage, if is_owned is set and inner is non-NULL.
331 pub extern "C" fn ErrorMessage_free(this_obj: ErrorMessage) { }
333 /// Used only if an object of this type is returned as a trait impl by a method
334 pub(crate) extern "C" fn ErrorMessage_free_void(this_ptr: *mut c_void) {
335 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeErrorMessage) };
339 pub(crate) fn get_native_ref(&self) -> &'static nativeErrorMessage {
340 unsafe { &*ObjOps::untweak_ptr(self.inner) }
342 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeErrorMessage {
343 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
345 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
346 pub(crate) fn take_inner(mut self) -> *mut nativeErrorMessage {
347 assert!(self.is_owned);
348 let ret = ObjOps::untweak_ptr(self.inner);
349 self.inner = core::ptr::null_mut();
353 /// The channel ID involved in the error.
355 /// All-0s indicates a general error unrelated to a specific channel, after which all channels
356 /// with the sending peer should be closed.
358 pub extern "C" fn ErrorMessage_get_channel_id(this_ptr: &ErrorMessage) -> *const [u8; 32] {
359 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
362 /// The channel ID involved in the error.
364 /// All-0s indicates a general error unrelated to a specific channel, after which all channels
365 /// with the sending peer should be closed.
367 pub extern "C" fn ErrorMessage_set_channel_id(this_ptr: &mut ErrorMessage, mut val: crate::c_types::ThirtyTwoBytes) {
368 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
370 /// A possibly human-readable error description.
372 /// The string should be sanitized before it is used (e.g., emitted to logs or printed to
373 /// `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in
374 /// the terminal emulator or the logging subsystem.
376 pub extern "C" fn ErrorMessage_get_data(this_ptr: &ErrorMessage) -> crate::c_types::Str {
377 let mut inner_val = &mut this_ptr.get_native_mut_ref().data;
378 inner_val.as_str().into()
380 /// A possibly human-readable error description.
382 /// The string should be sanitized before it is used (e.g., emitted to logs or printed to
383 /// `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in
384 /// the terminal emulator or the logging subsystem.
386 pub extern "C" fn ErrorMessage_set_data(this_ptr: &mut ErrorMessage, mut val: crate::c_types::Str) {
387 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string();
389 /// Constructs a new ErrorMessage given each field
392 pub extern "C" fn ErrorMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::Str) -> ErrorMessage {
393 ErrorMessage { inner: ObjOps::heap_alloc(nativeErrorMessage {
394 channel_id: channel_id_arg.data,
395 data: data_arg.into_string(),
398 impl Clone for ErrorMessage {
399 fn clone(&self) -> Self {
401 inner: if <*mut nativeErrorMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
402 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
408 /// Used only if an object of this type is returned as a trait impl by a method
409 pub(crate) extern "C" fn ErrorMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
410 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeErrorMessage)).clone() })) as *mut c_void
413 /// Creates a copy of the ErrorMessage
414 pub extern "C" fn ErrorMessage_clone(orig: &ErrorMessage) -> ErrorMessage {
417 /// Checks if two ErrorMessages contain equal inner contents.
418 /// This ignores pointers and is_owned flags and looks at the values in fields.
419 /// Two objects with NULL inner values will be considered "equal" here.
421 pub extern "C" fn ErrorMessage_eq(a: &ErrorMessage, b: &ErrorMessage) -> bool {
422 if a.inner == b.inner { return true; }
423 if a.inner.is_null() || b.inner.is_null() { return false; }
424 if a.get_native_ref() == b.get_native_ref() { true } else { false }
427 use lightning::ln::msgs::WarningMessage as nativeWarningMessageImport;
428 pub(crate) type nativeWarningMessage = nativeWarningMessageImport;
430 /// A [`warning`] message to be sent to or received from a peer.
432 /// [`warning`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages
435 pub struct WarningMessage {
436 /// A pointer to the opaque Rust object.
438 /// Nearly everywhere, inner must be non-null, however in places where
439 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
440 pub inner: *mut nativeWarningMessage,
441 /// Indicates that this is the only struct which contains the same pointer.
443 /// Rust functions which take ownership of an object provided via an argument require
444 /// this to be true and invalidate the object pointed to by inner.
448 impl Drop for WarningMessage {
450 if self.is_owned && !<*mut nativeWarningMessage>::is_null(self.inner) {
451 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
455 /// Frees any resources used by the WarningMessage, if is_owned is set and inner is non-NULL.
457 pub extern "C" fn WarningMessage_free(this_obj: WarningMessage) { }
459 /// Used only if an object of this type is returned as a trait impl by a method
460 pub(crate) extern "C" fn WarningMessage_free_void(this_ptr: *mut c_void) {
461 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeWarningMessage) };
464 impl WarningMessage {
465 pub(crate) fn get_native_ref(&self) -> &'static nativeWarningMessage {
466 unsafe { &*ObjOps::untweak_ptr(self.inner) }
468 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeWarningMessage {
469 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
471 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
472 pub(crate) fn take_inner(mut self) -> *mut nativeWarningMessage {
473 assert!(self.is_owned);
474 let ret = ObjOps::untweak_ptr(self.inner);
475 self.inner = core::ptr::null_mut();
479 /// The channel ID involved in the warning.
481 /// All-0s indicates a warning unrelated to a specific channel.
483 pub extern "C" fn WarningMessage_get_channel_id(this_ptr: &WarningMessage) -> *const [u8; 32] {
484 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
487 /// The channel ID involved in the warning.
489 /// All-0s indicates a warning unrelated to a specific channel.
491 pub extern "C" fn WarningMessage_set_channel_id(this_ptr: &mut WarningMessage, mut val: crate::c_types::ThirtyTwoBytes) {
492 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
494 /// A possibly human-readable warning description.
496 /// The string should be sanitized before it is used (e.g. emitted to logs or printed to
497 /// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
498 /// the terminal emulator or the logging subsystem.
500 pub extern "C" fn WarningMessage_get_data(this_ptr: &WarningMessage) -> crate::c_types::Str {
501 let mut inner_val = &mut this_ptr.get_native_mut_ref().data;
502 inner_val.as_str().into()
504 /// A possibly human-readable warning description.
506 /// The string should be sanitized before it is used (e.g. emitted to logs or printed to
507 /// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
508 /// the terminal emulator or the logging subsystem.
510 pub extern "C" fn WarningMessage_set_data(this_ptr: &mut WarningMessage, mut val: crate::c_types::Str) {
511 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string();
513 /// Constructs a new WarningMessage given each field
516 pub extern "C" fn WarningMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::Str) -> WarningMessage {
517 WarningMessage { inner: ObjOps::heap_alloc(nativeWarningMessage {
518 channel_id: channel_id_arg.data,
519 data: data_arg.into_string(),
522 impl Clone for WarningMessage {
523 fn clone(&self) -> Self {
525 inner: if <*mut nativeWarningMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
526 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
532 /// Used only if an object of this type is returned as a trait impl by a method
533 pub(crate) extern "C" fn WarningMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
534 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeWarningMessage)).clone() })) as *mut c_void
537 /// Creates a copy of the WarningMessage
538 pub extern "C" fn WarningMessage_clone(orig: &WarningMessage) -> WarningMessage {
541 /// Checks if two WarningMessages contain equal inner contents.
542 /// This ignores pointers and is_owned flags and looks at the values in fields.
543 /// Two objects with NULL inner values will be considered "equal" here.
545 pub extern "C" fn WarningMessage_eq(a: &WarningMessage, b: &WarningMessage) -> bool {
546 if a.inner == b.inner { return true; }
547 if a.inner.is_null() || b.inner.is_null() { return false; }
548 if a.get_native_ref() == b.get_native_ref() { true } else { false }
551 use lightning::ln::msgs::Ping as nativePingImport;
552 pub(crate) type nativePing = nativePingImport;
554 /// A [`ping`] message to be sent to or received from a peer.
556 /// [`ping`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-ping-and-pong-messages
560 /// A pointer to the opaque Rust object.
562 /// Nearly everywhere, inner must be non-null, however in places where
563 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
564 pub inner: *mut nativePing,
565 /// Indicates that this is the only struct which contains the same pointer.
567 /// Rust functions which take ownership of an object provided via an argument require
568 /// this to be true and invalidate the object pointed to by inner.
574 if self.is_owned && !<*mut nativePing>::is_null(self.inner) {
575 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
579 /// Frees any resources used by the Ping, if is_owned is set and inner is non-NULL.
581 pub extern "C" fn Ping_free(this_obj: Ping) { }
583 /// Used only if an object of this type is returned as a trait impl by a method
584 pub(crate) extern "C" fn Ping_free_void(this_ptr: *mut c_void) {
585 let _ = unsafe { Box::from_raw(this_ptr as *mut nativePing) };
589 pub(crate) fn get_native_ref(&self) -> &'static nativePing {
590 unsafe { &*ObjOps::untweak_ptr(self.inner) }
592 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePing {
593 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
595 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
596 pub(crate) fn take_inner(mut self) -> *mut nativePing {
597 assert!(self.is_owned);
598 let ret = ObjOps::untweak_ptr(self.inner);
599 self.inner = core::ptr::null_mut();
603 /// The desired response length.
605 pub extern "C" fn Ping_get_ponglen(this_ptr: &Ping) -> u16 {
606 let mut inner_val = &mut this_ptr.get_native_mut_ref().ponglen;
609 /// The desired response length.
611 pub extern "C" fn Ping_set_ponglen(this_ptr: &mut Ping, mut val: u16) {
612 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.ponglen = val;
614 /// The ping packet size.
616 /// This field is not sent on the wire. byteslen zeros are sent.
618 pub extern "C" fn Ping_get_byteslen(this_ptr: &Ping) -> u16 {
619 let mut inner_val = &mut this_ptr.get_native_mut_ref().byteslen;
622 /// The ping packet size.
624 /// This field is not sent on the wire. byteslen zeros are sent.
626 pub extern "C" fn Ping_set_byteslen(this_ptr: &mut Ping, mut val: u16) {
627 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.byteslen = val;
629 /// Constructs a new Ping given each field
632 pub extern "C" fn Ping_new(mut ponglen_arg: u16, mut byteslen_arg: u16) -> Ping {
633 Ping { inner: ObjOps::heap_alloc(nativePing {
634 ponglen: ponglen_arg,
635 byteslen: byteslen_arg,
638 impl Clone for Ping {
639 fn clone(&self) -> Self {
641 inner: if <*mut nativePing>::is_null(self.inner) { core::ptr::null_mut() } else {
642 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
648 /// Used only if an object of this type is returned as a trait impl by a method
649 pub(crate) extern "C" fn Ping_clone_void(this_ptr: *const c_void) -> *mut c_void {
650 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePing)).clone() })) as *mut c_void
653 /// Creates a copy of the Ping
654 pub extern "C" fn Ping_clone(orig: &Ping) -> Ping {
657 /// Checks if two Pings contain equal inner contents.
658 /// This ignores pointers and is_owned flags and looks at the values in fields.
659 /// Two objects with NULL inner values will be considered "equal" here.
661 pub extern "C" fn Ping_eq(a: &Ping, b: &Ping) -> bool {
662 if a.inner == b.inner { return true; }
663 if a.inner.is_null() || b.inner.is_null() { return false; }
664 if a.get_native_ref() == b.get_native_ref() { true } else { false }
667 use lightning::ln::msgs::Pong as nativePongImport;
668 pub(crate) type nativePong = nativePongImport;
670 /// A [`pong`] message to be sent to or received from a peer.
672 /// [`pong`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-ping-and-pong-messages
676 /// A pointer to the opaque Rust object.
678 /// Nearly everywhere, inner must be non-null, however in places where
679 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
680 pub inner: *mut nativePong,
681 /// Indicates that this is the only struct which contains the same pointer.
683 /// Rust functions which take ownership of an object provided via an argument require
684 /// this to be true and invalidate the object pointed to by inner.
690 if self.is_owned && !<*mut nativePong>::is_null(self.inner) {
691 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
695 /// Frees any resources used by the Pong, if is_owned is set and inner is non-NULL.
697 pub extern "C" fn Pong_free(this_obj: Pong) { }
699 /// Used only if an object of this type is returned as a trait impl by a method
700 pub(crate) extern "C" fn Pong_free_void(this_ptr: *mut c_void) {
701 let _ = unsafe { Box::from_raw(this_ptr as *mut nativePong) };
705 pub(crate) fn get_native_ref(&self) -> &'static nativePong {
706 unsafe { &*ObjOps::untweak_ptr(self.inner) }
708 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePong {
709 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
711 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
712 pub(crate) fn take_inner(mut self) -> *mut nativePong {
713 assert!(self.is_owned);
714 let ret = ObjOps::untweak_ptr(self.inner);
715 self.inner = core::ptr::null_mut();
719 /// The pong packet size.
721 /// This field is not sent on the wire. byteslen zeros are sent.
723 pub extern "C" fn Pong_get_byteslen(this_ptr: &Pong) -> u16 {
724 let mut inner_val = &mut this_ptr.get_native_mut_ref().byteslen;
727 /// The pong packet size.
729 /// This field is not sent on the wire. byteslen zeros are sent.
731 pub extern "C" fn Pong_set_byteslen(this_ptr: &mut Pong, mut val: u16) {
732 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.byteslen = val;
734 /// Constructs a new Pong given each field
737 pub extern "C" fn Pong_new(mut byteslen_arg: u16) -> Pong {
738 Pong { inner: ObjOps::heap_alloc(nativePong {
739 byteslen: byteslen_arg,
742 impl Clone for Pong {
743 fn clone(&self) -> Self {
745 inner: if <*mut nativePong>::is_null(self.inner) { core::ptr::null_mut() } else {
746 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
752 /// Used only if an object of this type is returned as a trait impl by a method
753 pub(crate) extern "C" fn Pong_clone_void(this_ptr: *const c_void) -> *mut c_void {
754 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePong)).clone() })) as *mut c_void
757 /// Creates a copy of the Pong
758 pub extern "C" fn Pong_clone(orig: &Pong) -> Pong {
761 /// Checks if two Pongs contain equal inner contents.
762 /// This ignores pointers and is_owned flags and looks at the values in fields.
763 /// Two objects with NULL inner values will be considered "equal" here.
765 pub extern "C" fn Pong_eq(a: &Pong, b: &Pong) -> bool {
766 if a.inner == b.inner { return true; }
767 if a.inner.is_null() || b.inner.is_null() { return false; }
768 if a.get_native_ref() == b.get_native_ref() { true } else { false }
771 use lightning::ln::msgs::OpenChannel as nativeOpenChannelImport;
772 pub(crate) type nativeOpenChannel = nativeOpenChannelImport;
774 /// An [`open_channel`] message to be sent to or received from a peer.
776 /// [`open_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message
779 pub struct OpenChannel {
780 /// A pointer to the opaque Rust object.
782 /// Nearly everywhere, inner must be non-null, however in places where
783 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
784 pub inner: *mut nativeOpenChannel,
785 /// Indicates that this is the only struct which contains the same pointer.
787 /// Rust functions which take ownership of an object provided via an argument require
788 /// this to be true and invalidate the object pointed to by inner.
792 impl Drop for OpenChannel {
794 if self.is_owned && !<*mut nativeOpenChannel>::is_null(self.inner) {
795 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
799 /// Frees any resources used by the OpenChannel, if is_owned is set and inner is non-NULL.
801 pub extern "C" fn OpenChannel_free(this_obj: OpenChannel) { }
803 /// Used only if an object of this type is returned as a trait impl by a method
804 pub(crate) extern "C" fn OpenChannel_free_void(this_ptr: *mut c_void) {
805 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOpenChannel) };
809 pub(crate) fn get_native_ref(&self) -> &'static nativeOpenChannel {
810 unsafe { &*ObjOps::untweak_ptr(self.inner) }
812 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOpenChannel {
813 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
815 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
816 pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannel {
817 assert!(self.is_owned);
818 let ret = ObjOps::untweak_ptr(self.inner);
819 self.inner = core::ptr::null_mut();
823 /// The genesis hash of the blockchain where the channel is to be opened
825 pub extern "C" fn OpenChannel_get_chain_hash(this_ptr: &OpenChannel) -> *const [u8; 32] {
826 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
829 /// The genesis hash of the blockchain where the channel is to be opened
831 pub extern "C" fn OpenChannel_set_chain_hash(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
832 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
834 /// A temporary channel ID, until the funding outpoint is announced
836 pub extern "C" fn OpenChannel_get_temporary_channel_id(this_ptr: &OpenChannel) -> *const [u8; 32] {
837 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
840 /// A temporary channel ID, until the funding outpoint is announced
842 pub extern "C" fn OpenChannel_set_temporary_channel_id(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
843 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
845 /// The channel value
847 pub extern "C" fn OpenChannel_get_funding_satoshis(this_ptr: &OpenChannel) -> u64 {
848 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
851 /// The channel value
853 pub extern "C" fn OpenChannel_set_funding_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
854 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
856 /// The amount to push to the counterparty as part of the open, in milli-satoshi
858 pub extern "C" fn OpenChannel_get_push_msat(this_ptr: &OpenChannel) -> u64 {
859 let mut inner_val = &mut this_ptr.get_native_mut_ref().push_msat;
862 /// The amount to push to the counterparty as part of the open, in milli-satoshi
864 pub extern "C" fn OpenChannel_set_push_msat(this_ptr: &mut OpenChannel, mut val: u64) {
865 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.push_msat = val;
867 /// The threshold below which outputs on transactions broadcast by sender will be omitted
869 pub extern "C" fn OpenChannel_get_dust_limit_satoshis(this_ptr: &OpenChannel) -> u64 {
870 let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
873 /// The threshold below which outputs on transactions broadcast by sender will be omitted
875 pub extern "C" fn OpenChannel_set_dust_limit_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
876 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
878 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
880 pub extern "C" fn OpenChannel_get_max_htlc_value_in_flight_msat(this_ptr: &OpenChannel) -> u64 {
881 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
884 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
886 pub extern "C" fn OpenChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut OpenChannel, mut val: u64) {
887 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
889 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
891 pub extern "C" fn OpenChannel_get_channel_reserve_satoshis(this_ptr: &OpenChannel) -> u64 {
892 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
895 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
897 pub extern "C" fn OpenChannel_set_channel_reserve_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
898 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
900 /// The minimum HTLC size incoming to sender, in milli-satoshi
902 pub extern "C" fn OpenChannel_get_htlc_minimum_msat(this_ptr: &OpenChannel) -> u64 {
903 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
906 /// The minimum HTLC size incoming to sender, in milli-satoshi
908 pub extern "C" fn OpenChannel_set_htlc_minimum_msat(this_ptr: &mut OpenChannel, mut val: u64) {
909 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
911 /// The feerate per 1000-weight of sender generated transactions, until updated by
914 pub extern "C" fn OpenChannel_get_feerate_per_kw(this_ptr: &OpenChannel) -> u32 {
915 let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
918 /// The feerate per 1000-weight of sender generated transactions, until updated by
921 pub extern "C" fn OpenChannel_set_feerate_per_kw(this_ptr: &mut OpenChannel, mut val: u32) {
922 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
924 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if
925 /// they broadcast a commitment transaction
927 pub extern "C" fn OpenChannel_get_to_self_delay(this_ptr: &OpenChannel) -> u16 {
928 let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
931 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if
932 /// they broadcast a commitment transaction
934 pub extern "C" fn OpenChannel_set_to_self_delay(this_ptr: &mut OpenChannel, mut val: u16) {
935 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
937 /// The maximum number of inbound HTLCs towards sender
939 pub extern "C" fn OpenChannel_get_max_accepted_htlcs(this_ptr: &OpenChannel) -> u16 {
940 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
943 /// The maximum number of inbound HTLCs towards sender
945 pub extern "C" fn OpenChannel_set_max_accepted_htlcs(this_ptr: &mut OpenChannel, mut val: u16) {
946 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
948 /// The sender's key controlling the funding transaction
950 pub extern "C" fn OpenChannel_get_funding_pubkey(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
951 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
952 crate::c_types::PublicKey::from_rust(&inner_val)
954 /// The sender's key controlling the funding transaction
956 pub extern "C" fn OpenChannel_set_funding_pubkey(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
957 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
959 /// Used to derive a revocation key for transactions broadcast by counterparty
961 pub extern "C" fn OpenChannel_get_revocation_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
962 let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
963 crate::c_types::PublicKey::from_rust(&inner_val)
965 /// Used to derive a revocation key for transactions broadcast by counterparty
967 pub extern "C" fn OpenChannel_set_revocation_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
968 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
970 /// A payment key to sender for transactions broadcast by counterparty
972 pub extern "C" fn OpenChannel_get_payment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
973 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_point;
974 crate::c_types::PublicKey::from_rust(&inner_val)
976 /// A payment key to sender for transactions broadcast by counterparty
978 pub extern "C" fn OpenChannel_set_payment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
979 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_point = val.into_rust();
981 /// Used to derive a payment key to sender for transactions broadcast by sender
983 pub extern "C" fn OpenChannel_get_delayed_payment_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
984 let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
985 crate::c_types::PublicKey::from_rust(&inner_val)
987 /// Used to derive a payment key to sender for transactions broadcast by sender
989 pub extern "C" fn OpenChannel_set_delayed_payment_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
990 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
992 /// Used to derive an HTLC payment key to sender
994 pub extern "C" fn OpenChannel_get_htlc_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
995 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
996 crate::c_types::PublicKey::from_rust(&inner_val)
998 /// Used to derive an HTLC payment key to sender
1000 pub extern "C" fn OpenChannel_set_htlc_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1001 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
1003 /// The first to-be-broadcast-by-sender transaction's per commitment point
1005 pub extern "C" fn OpenChannel_get_first_per_commitment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
1006 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
1007 crate::c_types::PublicKey::from_rust(&inner_val)
1009 /// The first to-be-broadcast-by-sender transaction's per commitment point
1011 pub extern "C" fn OpenChannel_set_first_per_commitment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1012 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
1014 /// The channel flags to be used
1016 pub extern "C" fn OpenChannel_get_channel_flags(this_ptr: &OpenChannel) -> u8 {
1017 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_flags;
1020 /// The channel flags to be used
1022 pub extern "C" fn OpenChannel_set_channel_flags(this_ptr: &mut OpenChannel, mut val: u8) {
1023 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_flags = val;
1025 /// The channel type that this channel will represent
1027 /// If this is `None`, we derive the channel type from the intersection of our
1028 /// feature bits with our counterparty's feature bits from the [`Init`] message.
1030 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1032 pub extern "C" fn OpenChannel_get_channel_type(this_ptr: &OpenChannel) -> crate::lightning::ln::features::ChannelTypeFeatures {
1033 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1034 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 };
1037 /// The channel type that this channel will represent
1039 /// If this is `None`, we derive the channel type from the intersection of our
1040 /// feature bits with our counterparty's feature bits from the [`Init`] message.
1042 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1044 pub extern "C" fn OpenChannel_set_channel_type(this_ptr: &mut OpenChannel, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1045 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1046 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1048 impl Clone for OpenChannel {
1049 fn clone(&self) -> Self {
1051 inner: if <*mut nativeOpenChannel>::is_null(self.inner) { core::ptr::null_mut() } else {
1052 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1058 /// Used only if an object of this type is returned as a trait impl by a method
1059 pub(crate) extern "C" fn OpenChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
1060 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOpenChannel)).clone() })) as *mut c_void
1063 /// Creates a copy of the OpenChannel
1064 pub extern "C" fn OpenChannel_clone(orig: &OpenChannel) -> OpenChannel {
1067 /// Checks if two OpenChannels contain equal inner contents.
1068 /// This ignores pointers and is_owned flags and looks at the values in fields.
1069 /// Two objects with NULL inner values will be considered "equal" here.
1071 pub extern "C" fn OpenChannel_eq(a: &OpenChannel, b: &OpenChannel) -> bool {
1072 if a.inner == b.inner { return true; }
1073 if a.inner.is_null() || b.inner.is_null() { return false; }
1074 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1077 use lightning::ln::msgs::AcceptChannel as nativeAcceptChannelImport;
1078 pub(crate) type nativeAcceptChannel = nativeAcceptChannelImport;
1080 /// An [`accept_channel`] message to be sent to or received from a peer.
1082 /// [`accept_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-accept_channel-message
1085 pub struct AcceptChannel {
1086 /// A pointer to the opaque Rust object.
1088 /// Nearly everywhere, inner must be non-null, however in places where
1089 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1090 pub inner: *mut nativeAcceptChannel,
1091 /// Indicates that this is the only struct which contains the same pointer.
1093 /// Rust functions which take ownership of an object provided via an argument require
1094 /// this to be true and invalidate the object pointed to by inner.
1098 impl Drop for AcceptChannel {
1099 fn drop(&mut self) {
1100 if self.is_owned && !<*mut nativeAcceptChannel>::is_null(self.inner) {
1101 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1105 /// Frees any resources used by the AcceptChannel, if is_owned is set and inner is non-NULL.
1107 pub extern "C" fn AcceptChannel_free(this_obj: AcceptChannel) { }
1109 /// Used only if an object of this type is returned as a trait impl by a method
1110 pub(crate) extern "C" fn AcceptChannel_free_void(this_ptr: *mut c_void) {
1111 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAcceptChannel) };
1114 impl AcceptChannel {
1115 pub(crate) fn get_native_ref(&self) -> &'static nativeAcceptChannel {
1116 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1118 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAcceptChannel {
1119 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1121 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1122 pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannel {
1123 assert!(self.is_owned);
1124 let ret = ObjOps::untweak_ptr(self.inner);
1125 self.inner = core::ptr::null_mut();
1129 /// A temporary channel ID, until the funding outpoint is announced
1131 pub extern "C" fn AcceptChannel_get_temporary_channel_id(this_ptr: &AcceptChannel) -> *const [u8; 32] {
1132 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
1135 /// A temporary channel ID, until the funding outpoint is announced
1137 pub extern "C" fn AcceptChannel_set_temporary_channel_id(this_ptr: &mut AcceptChannel, mut val: crate::c_types::ThirtyTwoBytes) {
1138 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
1140 /// The threshold below which outputs on transactions broadcast by sender will be omitted
1142 pub extern "C" fn AcceptChannel_get_dust_limit_satoshis(this_ptr: &AcceptChannel) -> u64 {
1143 let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
1146 /// The threshold below which outputs on transactions broadcast by sender will be omitted
1148 pub extern "C" fn AcceptChannel_set_dust_limit_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
1149 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
1151 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
1153 pub extern "C" fn AcceptChannel_get_max_htlc_value_in_flight_msat(this_ptr: &AcceptChannel) -> u64 {
1154 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
1157 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
1159 pub extern "C" fn AcceptChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
1160 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
1162 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1164 pub extern "C" fn AcceptChannel_get_channel_reserve_satoshis(this_ptr: &AcceptChannel) -> u64 {
1165 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
1168 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1170 pub extern "C" fn AcceptChannel_set_channel_reserve_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
1171 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
1173 /// The minimum HTLC size incoming to sender, in milli-satoshi
1175 pub extern "C" fn AcceptChannel_get_htlc_minimum_msat(this_ptr: &AcceptChannel) -> u64 {
1176 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
1179 /// The minimum HTLC size incoming to sender, in milli-satoshi
1181 pub extern "C" fn AcceptChannel_set_htlc_minimum_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
1182 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
1184 /// Minimum depth of the funding transaction before the channel is considered open
1186 pub extern "C" fn AcceptChannel_get_minimum_depth(this_ptr: &AcceptChannel) -> u32 {
1187 let mut inner_val = &mut this_ptr.get_native_mut_ref().minimum_depth;
1190 /// Minimum depth of the funding transaction before the channel is considered open
1192 pub extern "C" fn AcceptChannel_set_minimum_depth(this_ptr: &mut AcceptChannel, mut val: u32) {
1193 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.minimum_depth = val;
1195 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
1197 pub extern "C" fn AcceptChannel_get_to_self_delay(this_ptr: &AcceptChannel) -> u16 {
1198 let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
1201 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
1203 pub extern "C" fn AcceptChannel_set_to_self_delay(this_ptr: &mut AcceptChannel, mut val: u16) {
1204 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
1206 /// The maximum number of inbound HTLCs towards sender
1208 pub extern "C" fn AcceptChannel_get_max_accepted_htlcs(this_ptr: &AcceptChannel) -> u16 {
1209 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
1212 /// The maximum number of inbound HTLCs towards sender
1214 pub extern "C" fn AcceptChannel_set_max_accepted_htlcs(this_ptr: &mut AcceptChannel, mut val: u16) {
1215 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
1217 /// The sender's key controlling the funding transaction
1219 pub extern "C" fn AcceptChannel_get_funding_pubkey(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1220 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
1221 crate::c_types::PublicKey::from_rust(&inner_val)
1223 /// The sender's key controlling the funding transaction
1225 pub extern "C" fn AcceptChannel_set_funding_pubkey(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1226 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
1228 /// Used to derive a revocation key for transactions broadcast by counterparty
1230 pub extern "C" fn AcceptChannel_get_revocation_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1231 let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
1232 crate::c_types::PublicKey::from_rust(&inner_val)
1234 /// Used to derive a revocation key for transactions broadcast by counterparty
1236 pub extern "C" fn AcceptChannel_set_revocation_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1237 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
1239 /// A payment key to sender for transactions broadcast by counterparty
1241 pub extern "C" fn AcceptChannel_get_payment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1242 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_point;
1243 crate::c_types::PublicKey::from_rust(&inner_val)
1245 /// A payment key to sender for transactions broadcast by counterparty
1247 pub extern "C" fn AcceptChannel_set_payment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1248 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_point = val.into_rust();
1250 /// Used to derive a payment key to sender for transactions broadcast by sender
1252 pub extern "C" fn AcceptChannel_get_delayed_payment_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1253 let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
1254 crate::c_types::PublicKey::from_rust(&inner_val)
1256 /// Used to derive a payment key to sender for transactions broadcast by sender
1258 pub extern "C" fn AcceptChannel_set_delayed_payment_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1259 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
1261 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
1263 pub extern "C" fn AcceptChannel_get_htlc_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1264 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
1265 crate::c_types::PublicKey::from_rust(&inner_val)
1267 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
1269 pub extern "C" fn AcceptChannel_set_htlc_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1270 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
1272 /// The first to-be-broadcast-by-sender transaction's per commitment point
1274 pub extern "C" fn AcceptChannel_get_first_per_commitment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1275 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
1276 crate::c_types::PublicKey::from_rust(&inner_val)
1278 /// The first to-be-broadcast-by-sender transaction's per commitment point
1280 pub extern "C" fn AcceptChannel_set_first_per_commitment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1281 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
1283 /// The channel type that this channel will represent.
1285 /// If this is `None`, we derive the channel type from the intersection of
1286 /// our feature bits with our counterparty's feature bits from the [`Init`] message.
1287 /// This is required to match the equivalent field in [`OpenChannel::channel_type`].
1289 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1291 pub extern "C" fn AcceptChannel_get_channel_type(this_ptr: &AcceptChannel) -> crate::lightning::ln::features::ChannelTypeFeatures {
1292 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1293 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 };
1296 /// The channel type that this channel will represent.
1298 /// If this is `None`, we derive the channel type from the intersection of
1299 /// our feature bits with our counterparty's feature bits from the [`Init`] message.
1300 /// This is required to match the equivalent field in [`OpenChannel::channel_type`].
1302 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1304 pub extern "C" fn AcceptChannel_set_channel_type(this_ptr: &mut AcceptChannel, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1305 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1306 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1308 impl Clone for AcceptChannel {
1309 fn clone(&self) -> Self {
1311 inner: if <*mut nativeAcceptChannel>::is_null(self.inner) { core::ptr::null_mut() } else {
1312 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1318 /// Used only if an object of this type is returned as a trait impl by a method
1319 pub(crate) extern "C" fn AcceptChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
1320 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAcceptChannel)).clone() })) as *mut c_void
1323 /// Creates a copy of the AcceptChannel
1324 pub extern "C" fn AcceptChannel_clone(orig: &AcceptChannel) -> AcceptChannel {
1327 /// Checks if two AcceptChannels contain equal inner contents.
1328 /// This ignores pointers and is_owned flags and looks at the values in fields.
1329 /// Two objects with NULL inner values will be considered "equal" here.
1331 pub extern "C" fn AcceptChannel_eq(a: &AcceptChannel, b: &AcceptChannel) -> bool {
1332 if a.inner == b.inner { return true; }
1333 if a.inner.is_null() || b.inner.is_null() { return false; }
1334 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1337 use lightning::ln::msgs::FundingCreated as nativeFundingCreatedImport;
1338 pub(crate) type nativeFundingCreated = nativeFundingCreatedImport;
1340 /// A [`funding_created`] message to be sent to or received from a peer.
1342 /// [`funding_created`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_created-message
1345 pub struct FundingCreated {
1346 /// A pointer to the opaque Rust object.
1348 /// Nearly everywhere, inner must be non-null, however in places where
1349 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1350 pub inner: *mut nativeFundingCreated,
1351 /// Indicates that this is the only struct which contains the same pointer.
1353 /// Rust functions which take ownership of an object provided via an argument require
1354 /// this to be true and invalidate the object pointed to by inner.
1358 impl Drop for FundingCreated {
1359 fn drop(&mut self) {
1360 if self.is_owned && !<*mut nativeFundingCreated>::is_null(self.inner) {
1361 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1365 /// Frees any resources used by the FundingCreated, if is_owned is set and inner is non-NULL.
1367 pub extern "C" fn FundingCreated_free(this_obj: FundingCreated) { }
1369 /// Used only if an object of this type is returned as a trait impl by a method
1370 pub(crate) extern "C" fn FundingCreated_free_void(this_ptr: *mut c_void) {
1371 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeFundingCreated) };
1374 impl FundingCreated {
1375 pub(crate) fn get_native_ref(&self) -> &'static nativeFundingCreated {
1376 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1378 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingCreated {
1379 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1381 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1382 pub(crate) fn take_inner(mut self) -> *mut nativeFundingCreated {
1383 assert!(self.is_owned);
1384 let ret = ObjOps::untweak_ptr(self.inner);
1385 self.inner = core::ptr::null_mut();
1389 /// A temporary channel ID, until the funding is established
1391 pub extern "C" fn FundingCreated_get_temporary_channel_id(this_ptr: &FundingCreated) -> *const [u8; 32] {
1392 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
1395 /// A temporary channel ID, until the funding is established
1397 pub extern "C" fn FundingCreated_set_temporary_channel_id(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
1398 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
1400 /// The funding transaction ID
1402 pub extern "C" fn FundingCreated_get_funding_txid(this_ptr: &FundingCreated) -> *const [u8; 32] {
1403 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_txid;
1404 inner_val.as_inner()
1406 /// The funding transaction ID
1408 pub extern "C" fn FundingCreated_set_funding_txid(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
1409 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_txid = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
1411 /// The specific output index funding this channel
1413 pub extern "C" fn FundingCreated_get_funding_output_index(this_ptr: &FundingCreated) -> u16 {
1414 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_index;
1417 /// The specific output index funding this channel
1419 pub extern "C" fn FundingCreated_set_funding_output_index(this_ptr: &mut FundingCreated, mut val: u16) {
1420 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_index = val;
1422 /// The signature of the channel initiator (funder) on the initial commitment transaction
1424 pub extern "C" fn FundingCreated_get_signature(this_ptr: &FundingCreated) -> crate::c_types::Signature {
1425 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
1426 crate::c_types::Signature::from_rust(&inner_val)
1428 /// The signature of the channel initiator (funder) on the initial commitment transaction
1430 pub extern "C" fn FundingCreated_set_signature(this_ptr: &mut FundingCreated, mut val: crate::c_types::Signature) {
1431 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
1433 /// Constructs a new FundingCreated given each field
1436 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 {
1437 FundingCreated { inner: ObjOps::heap_alloc(nativeFundingCreated {
1438 temporary_channel_id: temporary_channel_id_arg.data,
1439 funding_txid: ::bitcoin::hash_types::Txid::from_slice(&funding_txid_arg.data[..]).unwrap(),
1440 funding_output_index: funding_output_index_arg,
1441 signature: signature_arg.into_rust(),
1442 }), is_owned: true }
1444 impl Clone for FundingCreated {
1445 fn clone(&self) -> Self {
1447 inner: if <*mut nativeFundingCreated>::is_null(self.inner) { core::ptr::null_mut() } else {
1448 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1454 /// Used only if an object of this type is returned as a trait impl by a method
1455 pub(crate) extern "C" fn FundingCreated_clone_void(this_ptr: *const c_void) -> *mut c_void {
1456 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingCreated)).clone() })) as *mut c_void
1459 /// Creates a copy of the FundingCreated
1460 pub extern "C" fn FundingCreated_clone(orig: &FundingCreated) -> FundingCreated {
1463 /// Checks if two FundingCreateds contain equal inner contents.
1464 /// This ignores pointers and is_owned flags and looks at the values in fields.
1465 /// Two objects with NULL inner values will be considered "equal" here.
1467 pub extern "C" fn FundingCreated_eq(a: &FundingCreated, b: &FundingCreated) -> bool {
1468 if a.inner == b.inner { return true; }
1469 if a.inner.is_null() || b.inner.is_null() { return false; }
1470 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1473 use lightning::ln::msgs::FundingSigned as nativeFundingSignedImport;
1474 pub(crate) type nativeFundingSigned = nativeFundingSignedImport;
1476 /// A [`funding_signed`] message to be sent to or received from a peer.
1478 /// [`funding_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_signed-message
1481 pub struct FundingSigned {
1482 /// A pointer to the opaque Rust object.
1484 /// Nearly everywhere, inner must be non-null, however in places where
1485 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1486 pub inner: *mut nativeFundingSigned,
1487 /// Indicates that this is the only struct which contains the same pointer.
1489 /// Rust functions which take ownership of an object provided via an argument require
1490 /// this to be true and invalidate the object pointed to by inner.
1494 impl Drop for FundingSigned {
1495 fn drop(&mut self) {
1496 if self.is_owned && !<*mut nativeFundingSigned>::is_null(self.inner) {
1497 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1501 /// Frees any resources used by the FundingSigned, if is_owned is set and inner is non-NULL.
1503 pub extern "C" fn FundingSigned_free(this_obj: FundingSigned) { }
1505 /// Used only if an object of this type is returned as a trait impl by a method
1506 pub(crate) extern "C" fn FundingSigned_free_void(this_ptr: *mut c_void) {
1507 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeFundingSigned) };
1510 impl FundingSigned {
1511 pub(crate) fn get_native_ref(&self) -> &'static nativeFundingSigned {
1512 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1514 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingSigned {
1515 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1517 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1518 pub(crate) fn take_inner(mut self) -> *mut nativeFundingSigned {
1519 assert!(self.is_owned);
1520 let ret = ObjOps::untweak_ptr(self.inner);
1521 self.inner = core::ptr::null_mut();
1527 pub extern "C" fn FundingSigned_get_channel_id(this_ptr: &FundingSigned) -> *const [u8; 32] {
1528 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1533 pub extern "C" fn FundingSigned_set_channel_id(this_ptr: &mut FundingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
1534 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1536 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
1538 pub extern "C" fn FundingSigned_get_signature(this_ptr: &FundingSigned) -> crate::c_types::Signature {
1539 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
1540 crate::c_types::Signature::from_rust(&inner_val)
1542 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
1544 pub extern "C" fn FundingSigned_set_signature(this_ptr: &mut FundingSigned, mut val: crate::c_types::Signature) {
1545 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
1547 /// Constructs a new FundingSigned given each field
1550 pub extern "C" fn FundingSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut signature_arg: crate::c_types::Signature) -> FundingSigned {
1551 FundingSigned { inner: ObjOps::heap_alloc(nativeFundingSigned {
1552 channel_id: channel_id_arg.data,
1553 signature: signature_arg.into_rust(),
1554 }), is_owned: true }
1556 impl Clone for FundingSigned {
1557 fn clone(&self) -> Self {
1559 inner: if <*mut nativeFundingSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
1560 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1566 /// Used only if an object of this type is returned as a trait impl by a method
1567 pub(crate) extern "C" fn FundingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
1568 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingSigned)).clone() })) as *mut c_void
1571 /// Creates a copy of the FundingSigned
1572 pub extern "C" fn FundingSigned_clone(orig: &FundingSigned) -> FundingSigned {
1575 /// Checks if two FundingSigneds contain equal inner contents.
1576 /// This ignores pointers and is_owned flags and looks at the values in fields.
1577 /// Two objects with NULL inner values will be considered "equal" here.
1579 pub extern "C" fn FundingSigned_eq(a: &FundingSigned, b: &FundingSigned) -> bool {
1580 if a.inner == b.inner { return true; }
1581 if a.inner.is_null() || b.inner.is_null() { return false; }
1582 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1585 use lightning::ln::msgs::ChannelReady as nativeChannelReadyImport;
1586 pub(crate) type nativeChannelReady = nativeChannelReadyImport;
1588 /// A [`channel_ready`] message to be sent to or received from a peer.
1590 /// [`channel_ready`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-channel_ready-message
1593 pub struct ChannelReady {
1594 /// A pointer to the opaque Rust object.
1596 /// Nearly everywhere, inner must be non-null, however in places where
1597 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1598 pub inner: *mut nativeChannelReady,
1599 /// Indicates that this is the only struct which contains the same pointer.
1601 /// Rust functions which take ownership of an object provided via an argument require
1602 /// this to be true and invalidate the object pointed to by inner.
1606 impl Drop for ChannelReady {
1607 fn drop(&mut self) {
1608 if self.is_owned && !<*mut nativeChannelReady>::is_null(self.inner) {
1609 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1613 /// Frees any resources used by the ChannelReady, if is_owned is set and inner is non-NULL.
1615 pub extern "C" fn ChannelReady_free(this_obj: ChannelReady) { }
1617 /// Used only if an object of this type is returned as a trait impl by a method
1618 pub(crate) extern "C" fn ChannelReady_free_void(this_ptr: *mut c_void) {
1619 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelReady) };
1623 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelReady {
1624 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1626 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelReady {
1627 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1629 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1630 pub(crate) fn take_inner(mut self) -> *mut nativeChannelReady {
1631 assert!(self.is_owned);
1632 let ret = ObjOps::untweak_ptr(self.inner);
1633 self.inner = core::ptr::null_mut();
1639 pub extern "C" fn ChannelReady_get_channel_id(this_ptr: &ChannelReady) -> *const [u8; 32] {
1640 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1645 pub extern "C" fn ChannelReady_set_channel_id(this_ptr: &mut ChannelReady, mut val: crate::c_types::ThirtyTwoBytes) {
1646 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1648 /// The per-commitment point of the second commitment transaction
1650 pub extern "C" fn ChannelReady_get_next_per_commitment_point(this_ptr: &ChannelReady) -> crate::c_types::PublicKey {
1651 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
1652 crate::c_types::PublicKey::from_rust(&inner_val)
1654 /// The per-commitment point of the second commitment transaction
1656 pub extern "C" fn ChannelReady_set_next_per_commitment_point(this_ptr: &mut ChannelReady, mut val: crate::c_types::PublicKey) {
1657 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
1659 /// If set, provides a `short_channel_id` alias for this channel.
1661 /// The sender will accept payments to be forwarded over this SCID and forward them to this
1662 /// messages' recipient.
1664 pub extern "C" fn ChannelReady_get_short_channel_id_alias(this_ptr: &ChannelReady) -> crate::c_types::derived::COption_u64Z {
1665 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id_alias;
1666 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() }) };
1669 /// If set, provides a `short_channel_id` alias for this channel.
1671 /// The sender will accept payments to be forwarded over this SCID and forward them to this
1672 /// messages' recipient.
1674 pub extern "C" fn ChannelReady_set_short_channel_id_alias(this_ptr: &mut ChannelReady, mut val: crate::c_types::derived::COption_u64Z) {
1675 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1676 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id_alias = local_val;
1678 /// Constructs a new ChannelReady given each field
1681 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 {
1682 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 };
1683 ChannelReady { inner: ObjOps::heap_alloc(nativeChannelReady {
1684 channel_id: channel_id_arg.data,
1685 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
1686 short_channel_id_alias: local_short_channel_id_alias_arg,
1687 }), is_owned: true }
1689 impl Clone for ChannelReady {
1690 fn clone(&self) -> Self {
1692 inner: if <*mut nativeChannelReady>::is_null(self.inner) { core::ptr::null_mut() } else {
1693 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1699 /// Used only if an object of this type is returned as a trait impl by a method
1700 pub(crate) extern "C" fn ChannelReady_clone_void(this_ptr: *const c_void) -> *mut c_void {
1701 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelReady)).clone() })) as *mut c_void
1704 /// Creates a copy of the ChannelReady
1705 pub extern "C" fn ChannelReady_clone(orig: &ChannelReady) -> ChannelReady {
1708 /// Checks if two ChannelReadys contain equal inner contents.
1709 /// This ignores pointers and is_owned flags and looks at the values in fields.
1710 /// Two objects with NULL inner values will be considered "equal" here.
1712 pub extern "C" fn ChannelReady_eq(a: &ChannelReady, b: &ChannelReady) -> bool {
1713 if a.inner == b.inner { return true; }
1714 if a.inner.is_null() || b.inner.is_null() { return false; }
1715 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1718 use lightning::ln::msgs::Shutdown as nativeShutdownImport;
1719 pub(crate) type nativeShutdown = nativeShutdownImport;
1721 /// A [`shutdown`] message to be sent to or received from a peer.
1723 /// [`shutdown`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-initiation-shutdown
1726 pub struct Shutdown {
1727 /// A pointer to the opaque Rust object.
1729 /// Nearly everywhere, inner must be non-null, however in places where
1730 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1731 pub inner: *mut nativeShutdown,
1732 /// Indicates that this is the only struct which contains the same pointer.
1734 /// Rust functions which take ownership of an object provided via an argument require
1735 /// this to be true and invalidate the object pointed to by inner.
1739 impl Drop for Shutdown {
1740 fn drop(&mut self) {
1741 if self.is_owned && !<*mut nativeShutdown>::is_null(self.inner) {
1742 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1746 /// Frees any resources used by the Shutdown, if is_owned is set and inner is non-NULL.
1748 pub extern "C" fn Shutdown_free(this_obj: Shutdown) { }
1750 /// Used only if an object of this type is returned as a trait impl by a method
1751 pub(crate) extern "C" fn Shutdown_free_void(this_ptr: *mut c_void) {
1752 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeShutdown) };
1756 pub(crate) fn get_native_ref(&self) -> &'static nativeShutdown {
1757 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1759 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeShutdown {
1760 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1762 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1763 pub(crate) fn take_inner(mut self) -> *mut nativeShutdown {
1764 assert!(self.is_owned);
1765 let ret = ObjOps::untweak_ptr(self.inner);
1766 self.inner = core::ptr::null_mut();
1772 pub extern "C" fn Shutdown_get_channel_id(this_ptr: &Shutdown) -> *const [u8; 32] {
1773 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1778 pub extern "C" fn Shutdown_set_channel_id(this_ptr: &mut Shutdown, mut val: crate::c_types::ThirtyTwoBytes) {
1779 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1781 /// The destination of this peer's funds on closing.
1783 /// Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.
1785 pub extern "C" fn Shutdown_get_scriptpubkey(this_ptr: &Shutdown) -> crate::c_types::u8slice {
1786 let mut inner_val = &mut this_ptr.get_native_mut_ref().scriptpubkey;
1787 crate::c_types::u8slice::from_slice(&inner_val[..])
1789 /// The destination of this peer's funds on closing.
1791 /// Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.
1793 pub extern "C" fn Shutdown_set_scriptpubkey(this_ptr: &mut Shutdown, mut val: crate::c_types::derived::CVec_u8Z) {
1794 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.scriptpubkey = ::bitcoin::blockdata::script::Script::from(val.into_rust());
1796 /// Constructs a new Shutdown given each field
1799 pub extern "C" fn Shutdown_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut scriptpubkey_arg: crate::c_types::derived::CVec_u8Z) -> Shutdown {
1800 Shutdown { inner: ObjOps::heap_alloc(nativeShutdown {
1801 channel_id: channel_id_arg.data,
1802 scriptpubkey: ::bitcoin::blockdata::script::Script::from(scriptpubkey_arg.into_rust()),
1803 }), is_owned: true }
1805 impl Clone for Shutdown {
1806 fn clone(&self) -> Self {
1808 inner: if <*mut nativeShutdown>::is_null(self.inner) { core::ptr::null_mut() } else {
1809 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1815 /// Used only if an object of this type is returned as a trait impl by a method
1816 pub(crate) extern "C" fn Shutdown_clone_void(this_ptr: *const c_void) -> *mut c_void {
1817 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeShutdown)).clone() })) as *mut c_void
1820 /// Creates a copy of the Shutdown
1821 pub extern "C" fn Shutdown_clone(orig: &Shutdown) -> Shutdown {
1824 /// Checks if two Shutdowns contain equal inner contents.
1825 /// This ignores pointers and is_owned flags and looks at the values in fields.
1826 /// Two objects with NULL inner values will be considered "equal" here.
1828 pub extern "C" fn Shutdown_eq(a: &Shutdown, b: &Shutdown) -> bool {
1829 if a.inner == b.inner { return true; }
1830 if a.inner.is_null() || b.inner.is_null() { return false; }
1831 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1834 use lightning::ln::msgs::ClosingSignedFeeRange as nativeClosingSignedFeeRangeImport;
1835 pub(crate) type nativeClosingSignedFeeRange = nativeClosingSignedFeeRangeImport;
1837 /// The minimum and maximum fees which the sender is willing to place on the closing transaction.
1839 /// This is provided in [`ClosingSigned`] by both sides to indicate the fee range they are willing
1843 pub struct ClosingSignedFeeRange {
1844 /// A pointer to the opaque Rust object.
1846 /// Nearly everywhere, inner must be non-null, however in places where
1847 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1848 pub inner: *mut nativeClosingSignedFeeRange,
1849 /// Indicates that this is the only struct which contains the same pointer.
1851 /// Rust functions which take ownership of an object provided via an argument require
1852 /// this to be true and invalidate the object pointed to by inner.
1856 impl Drop for ClosingSignedFeeRange {
1857 fn drop(&mut self) {
1858 if self.is_owned && !<*mut nativeClosingSignedFeeRange>::is_null(self.inner) {
1859 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1863 /// Frees any resources used by the ClosingSignedFeeRange, if is_owned is set and inner is non-NULL.
1865 pub extern "C" fn ClosingSignedFeeRange_free(this_obj: ClosingSignedFeeRange) { }
1867 /// Used only if an object of this type is returned as a trait impl by a method
1868 pub(crate) extern "C" fn ClosingSignedFeeRange_free_void(this_ptr: *mut c_void) {
1869 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeClosingSignedFeeRange) };
1872 impl ClosingSignedFeeRange {
1873 pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSignedFeeRange {
1874 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1876 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSignedFeeRange {
1877 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1879 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1880 pub(crate) fn take_inner(mut self) -> *mut nativeClosingSignedFeeRange {
1881 assert!(self.is_owned);
1882 let ret = ObjOps::untweak_ptr(self.inner);
1883 self.inner = core::ptr::null_mut();
1887 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
1890 pub extern "C" fn ClosingSignedFeeRange_get_min_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
1891 let mut inner_val = &mut this_ptr.get_native_mut_ref().min_fee_satoshis;
1894 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
1897 pub extern "C" fn ClosingSignedFeeRange_set_min_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
1898 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_fee_satoshis = val;
1900 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
1903 pub extern "C" fn ClosingSignedFeeRange_get_max_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
1904 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_fee_satoshis;
1907 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
1910 pub extern "C" fn ClosingSignedFeeRange_set_max_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
1911 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_fee_satoshis = val;
1913 /// Constructs a new ClosingSignedFeeRange given each field
1916 pub extern "C" fn ClosingSignedFeeRange_new(mut min_fee_satoshis_arg: u64, mut max_fee_satoshis_arg: u64) -> ClosingSignedFeeRange {
1917 ClosingSignedFeeRange { inner: ObjOps::heap_alloc(nativeClosingSignedFeeRange {
1918 min_fee_satoshis: min_fee_satoshis_arg,
1919 max_fee_satoshis: max_fee_satoshis_arg,
1920 }), is_owned: true }
1922 impl Clone for ClosingSignedFeeRange {
1923 fn clone(&self) -> Self {
1925 inner: if <*mut nativeClosingSignedFeeRange>::is_null(self.inner) { core::ptr::null_mut() } else {
1926 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1932 /// Used only if an object of this type is returned as a trait impl by a method
1933 pub(crate) extern "C" fn ClosingSignedFeeRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
1934 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClosingSignedFeeRange)).clone() })) as *mut c_void
1937 /// Creates a copy of the ClosingSignedFeeRange
1938 pub extern "C" fn ClosingSignedFeeRange_clone(orig: &ClosingSignedFeeRange) -> ClosingSignedFeeRange {
1941 /// Checks if two ClosingSignedFeeRanges contain equal inner contents.
1942 /// This ignores pointers and is_owned flags and looks at the values in fields.
1943 /// Two objects with NULL inner values will be considered "equal" here.
1945 pub extern "C" fn ClosingSignedFeeRange_eq(a: &ClosingSignedFeeRange, b: &ClosingSignedFeeRange) -> bool {
1946 if a.inner == b.inner { return true; }
1947 if a.inner.is_null() || b.inner.is_null() { return false; }
1948 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1951 use lightning::ln::msgs::ClosingSigned as nativeClosingSignedImport;
1952 pub(crate) type nativeClosingSigned = nativeClosingSignedImport;
1954 /// A [`closing_signed`] message to be sent to or received from a peer.
1956 /// [`closing_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-negotiation-closing_signed
1959 pub struct ClosingSigned {
1960 /// A pointer to the opaque Rust object.
1962 /// Nearly everywhere, inner must be non-null, however in places where
1963 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1964 pub inner: *mut nativeClosingSigned,
1965 /// Indicates that this is the only struct which contains the same pointer.
1967 /// Rust functions which take ownership of an object provided via an argument require
1968 /// this to be true and invalidate the object pointed to by inner.
1972 impl Drop for ClosingSigned {
1973 fn drop(&mut self) {
1974 if self.is_owned && !<*mut nativeClosingSigned>::is_null(self.inner) {
1975 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1979 /// Frees any resources used by the ClosingSigned, if is_owned is set and inner is non-NULL.
1981 pub extern "C" fn ClosingSigned_free(this_obj: ClosingSigned) { }
1983 /// Used only if an object of this type is returned as a trait impl by a method
1984 pub(crate) extern "C" fn ClosingSigned_free_void(this_ptr: *mut c_void) {
1985 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeClosingSigned) };
1988 impl ClosingSigned {
1989 pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSigned {
1990 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1992 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSigned {
1993 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1995 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1996 pub(crate) fn take_inner(mut self) -> *mut nativeClosingSigned {
1997 assert!(self.is_owned);
1998 let ret = ObjOps::untweak_ptr(self.inner);
1999 self.inner = core::ptr::null_mut();
2005 pub extern "C" fn ClosingSigned_get_channel_id(this_ptr: &ClosingSigned) -> *const [u8; 32] {
2006 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2011 pub extern "C" fn ClosingSigned_set_channel_id(this_ptr: &mut ClosingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
2012 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2014 /// The proposed total fee for the closing transaction
2016 pub extern "C" fn ClosingSigned_get_fee_satoshis(this_ptr: &ClosingSigned) -> u64 {
2017 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_satoshis;
2020 /// The proposed total fee for the closing transaction
2022 pub extern "C" fn ClosingSigned_set_fee_satoshis(this_ptr: &mut ClosingSigned, mut val: u64) {
2023 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_satoshis = val;
2025 /// A signature on the closing transaction
2027 pub extern "C" fn ClosingSigned_get_signature(this_ptr: &ClosingSigned) -> crate::c_types::Signature {
2028 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
2029 crate::c_types::Signature::from_rust(&inner_val)
2031 /// A signature on the closing transaction
2033 pub extern "C" fn ClosingSigned_set_signature(this_ptr: &mut ClosingSigned, mut val: crate::c_types::Signature) {
2034 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
2036 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
2039 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
2041 pub extern "C" fn ClosingSigned_get_fee_range(this_ptr: &ClosingSigned) -> crate::lightning::ln::msgs::ClosingSignedFeeRange {
2042 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_range;
2043 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 };
2046 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
2049 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
2051 pub extern "C" fn ClosingSigned_set_fee_range(this_ptr: &mut ClosingSigned, mut val: crate::lightning::ln::msgs::ClosingSignedFeeRange) {
2052 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
2053 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_range = local_val;
2055 /// Constructs a new ClosingSigned given each field
2058 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 {
2059 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()) } }) };
2060 ClosingSigned { inner: ObjOps::heap_alloc(nativeClosingSigned {
2061 channel_id: channel_id_arg.data,
2062 fee_satoshis: fee_satoshis_arg,
2063 signature: signature_arg.into_rust(),
2064 fee_range: local_fee_range_arg,
2065 }), is_owned: true }
2067 impl Clone for ClosingSigned {
2068 fn clone(&self) -> Self {
2070 inner: if <*mut nativeClosingSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
2071 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2077 /// Used only if an object of this type is returned as a trait impl by a method
2078 pub(crate) extern "C" fn ClosingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
2079 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClosingSigned)).clone() })) as *mut c_void
2082 /// Creates a copy of the ClosingSigned
2083 pub extern "C" fn ClosingSigned_clone(orig: &ClosingSigned) -> ClosingSigned {
2086 /// Checks if two ClosingSigneds contain equal inner contents.
2087 /// This ignores pointers and is_owned flags and looks at the values in fields.
2088 /// Two objects with NULL inner values will be considered "equal" here.
2090 pub extern "C" fn ClosingSigned_eq(a: &ClosingSigned, b: &ClosingSigned) -> bool {
2091 if a.inner == b.inner { return true; }
2092 if a.inner.is_null() || b.inner.is_null() { return false; }
2093 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2096 use lightning::ln::msgs::UpdateAddHTLC as nativeUpdateAddHTLCImport;
2097 pub(crate) type nativeUpdateAddHTLC = nativeUpdateAddHTLCImport;
2099 /// An [`update_add_htlc`] message to be sent to or received from a peer.
2101 /// [`update_add_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#adding-an-htlc-update_add_htlc
2104 pub struct UpdateAddHTLC {
2105 /// A pointer to the opaque Rust object.
2107 /// Nearly everywhere, inner must be non-null, however in places where
2108 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2109 pub inner: *mut nativeUpdateAddHTLC,
2110 /// Indicates that this is the only struct which contains the same pointer.
2112 /// Rust functions which take ownership of an object provided via an argument require
2113 /// this to be true and invalidate the object pointed to by inner.
2117 impl Drop for UpdateAddHTLC {
2118 fn drop(&mut self) {
2119 if self.is_owned && !<*mut nativeUpdateAddHTLC>::is_null(self.inner) {
2120 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2124 /// Frees any resources used by the UpdateAddHTLC, if is_owned is set and inner is non-NULL.
2126 pub extern "C" fn UpdateAddHTLC_free(this_obj: UpdateAddHTLC) { }
2128 /// Used only if an object of this type is returned as a trait impl by a method
2129 pub(crate) extern "C" fn UpdateAddHTLC_free_void(this_ptr: *mut c_void) {
2130 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateAddHTLC) };
2133 impl UpdateAddHTLC {
2134 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateAddHTLC {
2135 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2137 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateAddHTLC {
2138 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2140 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2141 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateAddHTLC {
2142 assert!(self.is_owned);
2143 let ret = ObjOps::untweak_ptr(self.inner);
2144 self.inner = core::ptr::null_mut();
2150 pub extern "C" fn UpdateAddHTLC_get_channel_id(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
2151 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2156 pub extern "C" fn UpdateAddHTLC_set_channel_id(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
2157 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2161 pub extern "C" fn UpdateAddHTLC_get_htlc_id(this_ptr: &UpdateAddHTLC) -> u64 {
2162 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
2167 pub extern "C" fn UpdateAddHTLC_set_htlc_id(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
2168 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
2170 /// The HTLC value in milli-satoshi
2172 pub extern "C" fn UpdateAddHTLC_get_amount_msat(this_ptr: &UpdateAddHTLC) -> u64 {
2173 let mut inner_val = &mut this_ptr.get_native_mut_ref().amount_msat;
2176 /// The HTLC value in milli-satoshi
2178 pub extern "C" fn UpdateAddHTLC_set_amount_msat(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
2179 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.amount_msat = val;
2181 /// The payment hash, the pre-image of which controls HTLC redemption
2183 pub extern "C" fn UpdateAddHTLC_get_payment_hash(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
2184 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_hash;
2187 /// The payment hash, the pre-image of which controls HTLC redemption
2189 pub extern "C" fn UpdateAddHTLC_set_payment_hash(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
2190 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_hash = ::lightning::ln::PaymentHash(val.data);
2192 /// The expiry height of the HTLC
2194 pub extern "C" fn UpdateAddHTLC_get_cltv_expiry(this_ptr: &UpdateAddHTLC) -> u32 {
2195 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry;
2198 /// The expiry height of the HTLC
2200 pub extern "C" fn UpdateAddHTLC_set_cltv_expiry(this_ptr: &mut UpdateAddHTLC, mut val: u32) {
2201 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry = val;
2203 impl Clone for UpdateAddHTLC {
2204 fn clone(&self) -> Self {
2206 inner: if <*mut nativeUpdateAddHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
2207 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2213 /// Used only if an object of this type is returned as a trait impl by a method
2214 pub(crate) extern "C" fn UpdateAddHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
2215 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateAddHTLC)).clone() })) as *mut c_void
2218 /// Creates a copy of the UpdateAddHTLC
2219 pub extern "C" fn UpdateAddHTLC_clone(orig: &UpdateAddHTLC) -> UpdateAddHTLC {
2222 /// Checks if two UpdateAddHTLCs contain equal inner contents.
2223 /// This ignores pointers and is_owned flags and looks at the values in fields.
2224 /// Two objects with NULL inner values will be considered "equal" here.
2226 pub extern "C" fn UpdateAddHTLC_eq(a: &UpdateAddHTLC, b: &UpdateAddHTLC) -> bool {
2227 if a.inner == b.inner { return true; }
2228 if a.inner.is_null() || b.inner.is_null() { return false; }
2229 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2232 use lightning::ln::msgs::OnionMessage as nativeOnionMessageImport;
2233 pub(crate) type nativeOnionMessage = nativeOnionMessageImport;
2235 /// An onion message to be sent to or received from a peer.
2239 pub struct OnionMessage {
2240 /// A pointer to the opaque Rust object.
2242 /// Nearly everywhere, inner must be non-null, however in places where
2243 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2244 pub inner: *mut nativeOnionMessage,
2245 /// Indicates that this is the only struct which contains the same pointer.
2247 /// Rust functions which take ownership of an object provided via an argument require
2248 /// this to be true and invalidate the object pointed to by inner.
2252 impl Drop for OnionMessage {
2253 fn drop(&mut self) {
2254 if self.is_owned && !<*mut nativeOnionMessage>::is_null(self.inner) {
2255 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2259 /// Frees any resources used by the OnionMessage, if is_owned is set and inner is non-NULL.
2261 pub extern "C" fn OnionMessage_free(this_obj: OnionMessage) { }
2263 /// Used only if an object of this type is returned as a trait impl by a method
2264 pub(crate) extern "C" fn OnionMessage_free_void(this_ptr: *mut c_void) {
2265 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOnionMessage) };
2269 pub(crate) fn get_native_ref(&self) -> &'static nativeOnionMessage {
2270 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2272 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOnionMessage {
2273 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2275 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2276 pub(crate) fn take_inner(mut self) -> *mut nativeOnionMessage {
2277 assert!(self.is_owned);
2278 let ret = ObjOps::untweak_ptr(self.inner);
2279 self.inner = core::ptr::null_mut();
2283 /// Used in decrypting the onion packet's payload.
2285 pub extern "C" fn OnionMessage_get_blinding_point(this_ptr: &OnionMessage) -> crate::c_types::PublicKey {
2286 let mut inner_val = &mut this_ptr.get_native_mut_ref().blinding_point;
2287 crate::c_types::PublicKey::from_rust(&inner_val)
2289 /// Used in decrypting the onion packet's payload.
2291 pub extern "C" fn OnionMessage_set_blinding_point(this_ptr: &mut OnionMessage, mut val: crate::c_types::PublicKey) {
2292 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.blinding_point = val.into_rust();
2294 impl Clone for OnionMessage {
2295 fn clone(&self) -> Self {
2297 inner: if <*mut nativeOnionMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
2298 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2304 /// Used only if an object of this type is returned as a trait impl by a method
2305 pub(crate) extern "C" fn OnionMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
2306 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOnionMessage)).clone() })) as *mut c_void
2309 /// Creates a copy of the OnionMessage
2310 pub extern "C" fn OnionMessage_clone(orig: &OnionMessage) -> OnionMessage {
2313 /// Checks if two OnionMessages contain equal inner contents.
2314 /// This ignores pointers and is_owned flags and looks at the values in fields.
2315 /// Two objects with NULL inner values will be considered "equal" here.
2317 pub extern "C" fn OnionMessage_eq(a: &OnionMessage, b: &OnionMessage) -> bool {
2318 if a.inner == b.inner { return true; }
2319 if a.inner.is_null() || b.inner.is_null() { return false; }
2320 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2323 use lightning::ln::msgs::UpdateFulfillHTLC as nativeUpdateFulfillHTLCImport;
2324 pub(crate) type nativeUpdateFulfillHTLC = nativeUpdateFulfillHTLCImport;
2326 /// An [`update_fulfill_htlc`] message to be sent to or received from a peer.
2328 /// [`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
2331 pub struct UpdateFulfillHTLC {
2332 /// A pointer to the opaque Rust object.
2334 /// Nearly everywhere, inner must be non-null, however in places where
2335 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2336 pub inner: *mut nativeUpdateFulfillHTLC,
2337 /// Indicates that this is the only struct which contains the same pointer.
2339 /// Rust functions which take ownership of an object provided via an argument require
2340 /// this to be true and invalidate the object pointed to by inner.
2344 impl Drop for UpdateFulfillHTLC {
2345 fn drop(&mut self) {
2346 if self.is_owned && !<*mut nativeUpdateFulfillHTLC>::is_null(self.inner) {
2347 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2351 /// Frees any resources used by the UpdateFulfillHTLC, if is_owned is set and inner is non-NULL.
2353 pub extern "C" fn UpdateFulfillHTLC_free(this_obj: UpdateFulfillHTLC) { }
2355 /// Used only if an object of this type is returned as a trait impl by a method
2356 pub(crate) extern "C" fn UpdateFulfillHTLC_free_void(this_ptr: *mut c_void) {
2357 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFulfillHTLC) };
2360 impl UpdateFulfillHTLC {
2361 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFulfillHTLC {
2362 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2364 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFulfillHTLC {
2365 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2367 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2368 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFulfillHTLC {
2369 assert!(self.is_owned);
2370 let ret = ObjOps::untweak_ptr(self.inner);
2371 self.inner = core::ptr::null_mut();
2377 pub extern "C" fn UpdateFulfillHTLC_get_channel_id(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
2378 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2383 pub extern "C" fn UpdateFulfillHTLC_set_channel_id(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
2384 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2388 pub extern "C" fn UpdateFulfillHTLC_get_htlc_id(this_ptr: &UpdateFulfillHTLC) -> u64 {
2389 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
2394 pub extern "C" fn UpdateFulfillHTLC_set_htlc_id(this_ptr: &mut UpdateFulfillHTLC, mut val: u64) {
2395 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
2397 /// The pre-image of the payment hash, allowing HTLC redemption
2399 pub extern "C" fn UpdateFulfillHTLC_get_payment_preimage(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
2400 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_preimage;
2403 /// The pre-image of the payment hash, allowing HTLC redemption
2405 pub extern "C" fn UpdateFulfillHTLC_set_payment_preimage(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
2406 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_preimage = ::lightning::ln::PaymentPreimage(val.data);
2408 /// Constructs a new UpdateFulfillHTLC given each field
2411 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 {
2412 UpdateFulfillHTLC { inner: ObjOps::heap_alloc(nativeUpdateFulfillHTLC {
2413 channel_id: channel_id_arg.data,
2414 htlc_id: htlc_id_arg,
2415 payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_arg.data),
2416 }), is_owned: true }
2418 impl Clone for UpdateFulfillHTLC {
2419 fn clone(&self) -> Self {
2421 inner: if <*mut nativeUpdateFulfillHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
2422 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2428 /// Used only if an object of this type is returned as a trait impl by a method
2429 pub(crate) extern "C" fn UpdateFulfillHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
2430 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFulfillHTLC)).clone() })) as *mut c_void
2433 /// Creates a copy of the UpdateFulfillHTLC
2434 pub extern "C" fn UpdateFulfillHTLC_clone(orig: &UpdateFulfillHTLC) -> UpdateFulfillHTLC {
2437 /// Checks if two UpdateFulfillHTLCs contain equal inner contents.
2438 /// This ignores pointers and is_owned flags and looks at the values in fields.
2439 /// Two objects with NULL inner values will be considered "equal" here.
2441 pub extern "C" fn UpdateFulfillHTLC_eq(a: &UpdateFulfillHTLC, b: &UpdateFulfillHTLC) -> bool {
2442 if a.inner == b.inner { return true; }
2443 if a.inner.is_null() || b.inner.is_null() { return false; }
2444 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2447 use lightning::ln::msgs::UpdateFailHTLC as nativeUpdateFailHTLCImport;
2448 pub(crate) type nativeUpdateFailHTLC = nativeUpdateFailHTLCImport;
2450 /// An [`update_fail_htlc`] message to be sent to or received from a peer.
2452 /// [`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
2455 pub struct UpdateFailHTLC {
2456 /// A pointer to the opaque Rust object.
2458 /// Nearly everywhere, inner must be non-null, however in places where
2459 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2460 pub inner: *mut nativeUpdateFailHTLC,
2461 /// Indicates that this is the only struct which contains the same pointer.
2463 /// Rust functions which take ownership of an object provided via an argument require
2464 /// this to be true and invalidate the object pointed to by inner.
2468 impl Drop for UpdateFailHTLC {
2469 fn drop(&mut self) {
2470 if self.is_owned && !<*mut nativeUpdateFailHTLC>::is_null(self.inner) {
2471 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2475 /// Frees any resources used by the UpdateFailHTLC, if is_owned is set and inner is non-NULL.
2477 pub extern "C" fn UpdateFailHTLC_free(this_obj: UpdateFailHTLC) { }
2479 /// Used only if an object of this type is returned as a trait impl by a method
2480 pub(crate) extern "C" fn UpdateFailHTLC_free_void(this_ptr: *mut c_void) {
2481 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFailHTLC) };
2484 impl UpdateFailHTLC {
2485 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailHTLC {
2486 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2488 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailHTLC {
2489 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2491 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2492 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailHTLC {
2493 assert!(self.is_owned);
2494 let ret = ObjOps::untweak_ptr(self.inner);
2495 self.inner = core::ptr::null_mut();
2501 pub extern "C" fn UpdateFailHTLC_get_channel_id(this_ptr: &UpdateFailHTLC) -> *const [u8; 32] {
2502 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2507 pub extern "C" fn UpdateFailHTLC_set_channel_id(this_ptr: &mut UpdateFailHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
2508 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2512 pub extern "C" fn UpdateFailHTLC_get_htlc_id(this_ptr: &UpdateFailHTLC) -> u64 {
2513 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
2518 pub extern "C" fn UpdateFailHTLC_set_htlc_id(this_ptr: &mut UpdateFailHTLC, mut val: u64) {
2519 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
2521 impl Clone for UpdateFailHTLC {
2522 fn clone(&self) -> Self {
2524 inner: if <*mut nativeUpdateFailHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
2525 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2531 /// Used only if an object of this type is returned as a trait impl by a method
2532 pub(crate) extern "C" fn UpdateFailHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
2533 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailHTLC)).clone() })) as *mut c_void
2536 /// Creates a copy of the UpdateFailHTLC
2537 pub extern "C" fn UpdateFailHTLC_clone(orig: &UpdateFailHTLC) -> UpdateFailHTLC {
2540 /// Checks if two UpdateFailHTLCs contain equal inner contents.
2541 /// This ignores pointers and is_owned flags and looks at the values in fields.
2542 /// Two objects with NULL inner values will be considered "equal" here.
2544 pub extern "C" fn UpdateFailHTLC_eq(a: &UpdateFailHTLC, b: &UpdateFailHTLC) -> bool {
2545 if a.inner == b.inner { return true; }
2546 if a.inner.is_null() || b.inner.is_null() { return false; }
2547 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2550 use lightning::ln::msgs::UpdateFailMalformedHTLC as nativeUpdateFailMalformedHTLCImport;
2551 pub(crate) type nativeUpdateFailMalformedHTLC = nativeUpdateFailMalformedHTLCImport;
2553 /// An [`update_fail_malformed_htlc`] message to be sent to or received from a peer.
2555 /// [`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
2558 pub struct UpdateFailMalformedHTLC {
2559 /// A pointer to the opaque Rust object.
2561 /// Nearly everywhere, inner must be non-null, however in places where
2562 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2563 pub inner: *mut nativeUpdateFailMalformedHTLC,
2564 /// Indicates that this is the only struct which contains the same pointer.
2566 /// Rust functions which take ownership of an object provided via an argument require
2567 /// this to be true and invalidate the object pointed to by inner.
2571 impl Drop for UpdateFailMalformedHTLC {
2572 fn drop(&mut self) {
2573 if self.is_owned && !<*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) {
2574 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2578 /// Frees any resources used by the UpdateFailMalformedHTLC, if is_owned is set and inner is non-NULL.
2580 pub extern "C" fn UpdateFailMalformedHTLC_free(this_obj: UpdateFailMalformedHTLC) { }
2582 /// Used only if an object of this type is returned as a trait impl by a method
2583 pub(crate) extern "C" fn UpdateFailMalformedHTLC_free_void(this_ptr: *mut c_void) {
2584 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFailMalformedHTLC) };
2587 impl UpdateFailMalformedHTLC {
2588 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailMalformedHTLC {
2589 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2591 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailMalformedHTLC {
2592 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2594 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2595 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailMalformedHTLC {
2596 assert!(self.is_owned);
2597 let ret = ObjOps::untweak_ptr(self.inner);
2598 self.inner = core::ptr::null_mut();
2604 pub extern "C" fn UpdateFailMalformedHTLC_get_channel_id(this_ptr: &UpdateFailMalformedHTLC) -> *const [u8; 32] {
2605 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2610 pub extern "C" fn UpdateFailMalformedHTLC_set_channel_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
2611 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2615 pub extern "C" fn UpdateFailMalformedHTLC_get_htlc_id(this_ptr: &UpdateFailMalformedHTLC) -> u64 {
2616 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
2621 pub extern "C" fn UpdateFailMalformedHTLC_set_htlc_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u64) {
2622 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
2624 /// The failure code
2626 pub extern "C" fn UpdateFailMalformedHTLC_get_failure_code(this_ptr: &UpdateFailMalformedHTLC) -> u16 {
2627 let mut inner_val = &mut this_ptr.get_native_mut_ref().failure_code;
2630 /// The failure code
2632 pub extern "C" fn UpdateFailMalformedHTLC_set_failure_code(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u16) {
2633 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.failure_code = val;
2635 impl Clone for UpdateFailMalformedHTLC {
2636 fn clone(&self) -> Self {
2638 inner: if <*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
2639 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2645 /// Used only if an object of this type is returned as a trait impl by a method
2646 pub(crate) extern "C" fn UpdateFailMalformedHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
2647 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailMalformedHTLC)).clone() })) as *mut c_void
2650 /// Creates a copy of the UpdateFailMalformedHTLC
2651 pub extern "C" fn UpdateFailMalformedHTLC_clone(orig: &UpdateFailMalformedHTLC) -> UpdateFailMalformedHTLC {
2654 /// Checks if two UpdateFailMalformedHTLCs contain equal inner contents.
2655 /// This ignores pointers and is_owned flags and looks at the values in fields.
2656 /// Two objects with NULL inner values will be considered "equal" here.
2658 pub extern "C" fn UpdateFailMalformedHTLC_eq(a: &UpdateFailMalformedHTLC, b: &UpdateFailMalformedHTLC) -> bool {
2659 if a.inner == b.inner { return true; }
2660 if a.inner.is_null() || b.inner.is_null() { return false; }
2661 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2664 use lightning::ln::msgs::CommitmentSigned as nativeCommitmentSignedImport;
2665 pub(crate) type nativeCommitmentSigned = nativeCommitmentSignedImport;
2667 /// A [`commitment_signed`] message to be sent to or received from a peer.
2669 /// [`commitment_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#committing-updates-so-far-commitment_signed
2672 pub struct CommitmentSigned {
2673 /// A pointer to the opaque Rust object.
2675 /// Nearly everywhere, inner must be non-null, however in places where
2676 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2677 pub inner: *mut nativeCommitmentSigned,
2678 /// Indicates that this is the only struct which contains the same pointer.
2680 /// Rust functions which take ownership of an object provided via an argument require
2681 /// this to be true and invalidate the object pointed to by inner.
2685 impl Drop for CommitmentSigned {
2686 fn drop(&mut self) {
2687 if self.is_owned && !<*mut nativeCommitmentSigned>::is_null(self.inner) {
2688 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2692 /// Frees any resources used by the CommitmentSigned, if is_owned is set and inner is non-NULL.
2694 pub extern "C" fn CommitmentSigned_free(this_obj: CommitmentSigned) { }
2696 /// Used only if an object of this type is returned as a trait impl by a method
2697 pub(crate) extern "C" fn CommitmentSigned_free_void(this_ptr: *mut c_void) {
2698 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCommitmentSigned) };
2701 impl CommitmentSigned {
2702 pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentSigned {
2703 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2705 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentSigned {
2706 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2708 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2709 pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentSigned {
2710 assert!(self.is_owned);
2711 let ret = ObjOps::untweak_ptr(self.inner);
2712 self.inner = core::ptr::null_mut();
2718 pub extern "C" fn CommitmentSigned_get_channel_id(this_ptr: &CommitmentSigned) -> *const [u8; 32] {
2719 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2724 pub extern "C" fn CommitmentSigned_set_channel_id(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::ThirtyTwoBytes) {
2725 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2727 /// A signature on the commitment transaction
2729 pub extern "C" fn CommitmentSigned_get_signature(this_ptr: &CommitmentSigned) -> crate::c_types::Signature {
2730 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
2731 crate::c_types::Signature::from_rust(&inner_val)
2733 /// A signature on the commitment transaction
2735 pub extern "C" fn CommitmentSigned_set_signature(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::Signature) {
2736 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
2738 /// Signatures on the HTLC transactions
2740 /// Returns a copy of the field.
2742 pub extern "C" fn CommitmentSigned_get_htlc_signatures(this_ptr: &CommitmentSigned) -> crate::c_types::derived::CVec_SignatureZ {
2743 let mut inner_val = this_ptr.get_native_mut_ref().htlc_signatures.clone();
2744 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) }); };
2745 local_inner_val.into()
2747 /// Signatures on the HTLC transactions
2749 pub extern "C" fn CommitmentSigned_set_htlc_signatures(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::derived::CVec_SignatureZ) {
2750 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_rust() }); };
2751 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_signatures = local_val;
2753 /// Constructs a new CommitmentSigned given each field
2756 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 {
2757 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() }); };
2758 CommitmentSigned { inner: ObjOps::heap_alloc(nativeCommitmentSigned {
2759 channel_id: channel_id_arg.data,
2760 signature: signature_arg.into_rust(),
2761 htlc_signatures: local_htlc_signatures_arg,
2762 }), is_owned: true }
2764 impl Clone for CommitmentSigned {
2765 fn clone(&self) -> Self {
2767 inner: if <*mut nativeCommitmentSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
2768 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2774 /// Used only if an object of this type is returned as a trait impl by a method
2775 pub(crate) extern "C" fn CommitmentSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
2776 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentSigned)).clone() })) as *mut c_void
2779 /// Creates a copy of the CommitmentSigned
2780 pub extern "C" fn CommitmentSigned_clone(orig: &CommitmentSigned) -> CommitmentSigned {
2783 /// Checks if two CommitmentSigneds contain equal inner contents.
2784 /// This ignores pointers and is_owned flags and looks at the values in fields.
2785 /// Two objects with NULL inner values will be considered "equal" here.
2787 pub extern "C" fn CommitmentSigned_eq(a: &CommitmentSigned, b: &CommitmentSigned) -> bool {
2788 if a.inner == b.inner { return true; }
2789 if a.inner.is_null() || b.inner.is_null() { return false; }
2790 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2793 use lightning::ln::msgs::RevokeAndACK as nativeRevokeAndACKImport;
2794 pub(crate) type nativeRevokeAndACK = nativeRevokeAndACKImport;
2796 /// A [`revoke_and_ack`] message to be sent to or received from a peer.
2798 /// [`revoke_and_ack`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#completing-the-transition-to-the-updated-state-revoke_and_ack
2801 pub struct RevokeAndACK {
2802 /// A pointer to the opaque Rust object.
2804 /// Nearly everywhere, inner must be non-null, however in places where
2805 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2806 pub inner: *mut nativeRevokeAndACK,
2807 /// Indicates that this is the only struct which contains the same pointer.
2809 /// Rust functions which take ownership of an object provided via an argument require
2810 /// this to be true and invalidate the object pointed to by inner.
2814 impl Drop for RevokeAndACK {
2815 fn drop(&mut self) {
2816 if self.is_owned && !<*mut nativeRevokeAndACK>::is_null(self.inner) {
2817 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2821 /// Frees any resources used by the RevokeAndACK, if is_owned is set and inner is non-NULL.
2823 pub extern "C" fn RevokeAndACK_free(this_obj: RevokeAndACK) { }
2825 /// Used only if an object of this type is returned as a trait impl by a method
2826 pub(crate) extern "C" fn RevokeAndACK_free_void(this_ptr: *mut c_void) {
2827 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRevokeAndACK) };
2831 pub(crate) fn get_native_ref(&self) -> &'static nativeRevokeAndACK {
2832 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2834 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRevokeAndACK {
2835 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2837 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2838 pub(crate) fn take_inner(mut self) -> *mut nativeRevokeAndACK {
2839 assert!(self.is_owned);
2840 let ret = ObjOps::untweak_ptr(self.inner);
2841 self.inner = core::ptr::null_mut();
2847 pub extern "C" fn RevokeAndACK_get_channel_id(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
2848 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2853 pub extern "C" fn RevokeAndACK_set_channel_id(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
2854 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2856 /// The secret corresponding to the per-commitment point
2858 pub extern "C" fn RevokeAndACK_get_per_commitment_secret(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
2859 let mut inner_val = &mut this_ptr.get_native_mut_ref().per_commitment_secret;
2862 /// The secret corresponding to the per-commitment point
2864 pub extern "C" fn RevokeAndACK_set_per_commitment_secret(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
2865 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.per_commitment_secret = val.data;
2867 /// The next sender-broadcast commitment transaction's per-commitment point
2869 pub extern "C" fn RevokeAndACK_get_next_per_commitment_point(this_ptr: &RevokeAndACK) -> crate::c_types::PublicKey {
2870 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
2871 crate::c_types::PublicKey::from_rust(&inner_val)
2873 /// The next sender-broadcast commitment transaction's per-commitment point
2875 pub extern "C" fn RevokeAndACK_set_next_per_commitment_point(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::PublicKey) {
2876 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
2878 /// Constructs a new RevokeAndACK given each field
2881 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 {
2882 RevokeAndACK { inner: ObjOps::heap_alloc(nativeRevokeAndACK {
2883 channel_id: channel_id_arg.data,
2884 per_commitment_secret: per_commitment_secret_arg.data,
2885 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
2886 }), is_owned: true }
2888 impl Clone for RevokeAndACK {
2889 fn clone(&self) -> Self {
2891 inner: if <*mut nativeRevokeAndACK>::is_null(self.inner) { core::ptr::null_mut() } else {
2892 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2898 /// Used only if an object of this type is returned as a trait impl by a method
2899 pub(crate) extern "C" fn RevokeAndACK_clone_void(this_ptr: *const c_void) -> *mut c_void {
2900 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRevokeAndACK)).clone() })) as *mut c_void
2903 /// Creates a copy of the RevokeAndACK
2904 pub extern "C" fn RevokeAndACK_clone(orig: &RevokeAndACK) -> RevokeAndACK {
2907 /// Checks if two RevokeAndACKs contain equal inner contents.
2908 /// This ignores pointers and is_owned flags and looks at the values in fields.
2909 /// Two objects with NULL inner values will be considered "equal" here.
2911 pub extern "C" fn RevokeAndACK_eq(a: &RevokeAndACK, b: &RevokeAndACK) -> bool {
2912 if a.inner == b.inner { return true; }
2913 if a.inner.is_null() || b.inner.is_null() { return false; }
2914 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2917 use lightning::ln::msgs::UpdateFee as nativeUpdateFeeImport;
2918 pub(crate) type nativeUpdateFee = nativeUpdateFeeImport;
2920 /// An [`update_fee`] message to be sent to or received from a peer
2922 /// [`update_fee`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#updating-fees-update_fee
2925 pub struct UpdateFee {
2926 /// A pointer to the opaque Rust object.
2928 /// Nearly everywhere, inner must be non-null, however in places where
2929 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2930 pub inner: *mut nativeUpdateFee,
2931 /// Indicates that this is the only struct which contains the same pointer.
2933 /// Rust functions which take ownership of an object provided via an argument require
2934 /// this to be true and invalidate the object pointed to by inner.
2938 impl Drop for UpdateFee {
2939 fn drop(&mut self) {
2940 if self.is_owned && !<*mut nativeUpdateFee>::is_null(self.inner) {
2941 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2945 /// Frees any resources used by the UpdateFee, if is_owned is set and inner is non-NULL.
2947 pub extern "C" fn UpdateFee_free(this_obj: UpdateFee) { }
2949 /// Used only if an object of this type is returned as a trait impl by a method
2950 pub(crate) extern "C" fn UpdateFee_free_void(this_ptr: *mut c_void) {
2951 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFee) };
2955 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFee {
2956 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2958 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFee {
2959 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2961 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2962 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFee {
2963 assert!(self.is_owned);
2964 let ret = ObjOps::untweak_ptr(self.inner);
2965 self.inner = core::ptr::null_mut();
2971 pub extern "C" fn UpdateFee_get_channel_id(this_ptr: &UpdateFee) -> *const [u8; 32] {
2972 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2977 pub extern "C" fn UpdateFee_set_channel_id(this_ptr: &mut UpdateFee, mut val: crate::c_types::ThirtyTwoBytes) {
2978 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2980 /// Fee rate per 1000-weight of the transaction
2982 pub extern "C" fn UpdateFee_get_feerate_per_kw(this_ptr: &UpdateFee) -> u32 {
2983 let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
2986 /// Fee rate per 1000-weight of the transaction
2988 pub extern "C" fn UpdateFee_set_feerate_per_kw(this_ptr: &mut UpdateFee, mut val: u32) {
2989 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
2991 /// Constructs a new UpdateFee given each field
2994 pub extern "C" fn UpdateFee_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut feerate_per_kw_arg: u32) -> UpdateFee {
2995 UpdateFee { inner: ObjOps::heap_alloc(nativeUpdateFee {
2996 channel_id: channel_id_arg.data,
2997 feerate_per_kw: feerate_per_kw_arg,
2998 }), is_owned: true }
3000 impl Clone for UpdateFee {
3001 fn clone(&self) -> Self {
3003 inner: if <*mut nativeUpdateFee>::is_null(self.inner) { core::ptr::null_mut() } else {
3004 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3010 /// Used only if an object of this type is returned as a trait impl by a method
3011 pub(crate) extern "C" fn UpdateFee_clone_void(this_ptr: *const c_void) -> *mut c_void {
3012 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFee)).clone() })) as *mut c_void
3015 /// Creates a copy of the UpdateFee
3016 pub extern "C" fn UpdateFee_clone(orig: &UpdateFee) -> UpdateFee {
3019 /// Checks if two UpdateFees contain equal inner contents.
3020 /// This ignores pointers and is_owned flags and looks at the values in fields.
3021 /// Two objects with NULL inner values will be considered "equal" here.
3023 pub extern "C" fn UpdateFee_eq(a: &UpdateFee, b: &UpdateFee) -> bool {
3024 if a.inner == b.inner { return true; }
3025 if a.inner.is_null() || b.inner.is_null() { return false; }
3026 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3029 use lightning::ln::msgs::DataLossProtect as nativeDataLossProtectImport;
3030 pub(crate) type nativeDataLossProtect = nativeDataLossProtectImport;
3032 /// Proof that the sender knows the per-commitment secret of the previous commitment transaction.
3034 /// This is used to convince the recipient that the channel is at a certain commitment
3035 /// number even if they lost that data due to a local failure. Of course, the peer may lie
3036 /// and even later commitments may have been revoked.
3039 pub struct DataLossProtect {
3040 /// A pointer to the opaque Rust object.
3042 /// Nearly everywhere, inner must be non-null, however in places where
3043 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3044 pub inner: *mut nativeDataLossProtect,
3045 /// Indicates that this is the only struct which contains the same pointer.
3047 /// Rust functions which take ownership of an object provided via an argument require
3048 /// this to be true and invalidate the object pointed to by inner.
3052 impl Drop for DataLossProtect {
3053 fn drop(&mut self) {
3054 if self.is_owned && !<*mut nativeDataLossProtect>::is_null(self.inner) {
3055 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3059 /// Frees any resources used by the DataLossProtect, if is_owned is set and inner is non-NULL.
3061 pub extern "C" fn DataLossProtect_free(this_obj: DataLossProtect) { }
3063 /// Used only if an object of this type is returned as a trait impl by a method
3064 pub(crate) extern "C" fn DataLossProtect_free_void(this_ptr: *mut c_void) {
3065 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeDataLossProtect) };
3068 impl DataLossProtect {
3069 pub(crate) fn get_native_ref(&self) -> &'static nativeDataLossProtect {
3070 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3072 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeDataLossProtect {
3073 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3075 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3076 pub(crate) fn take_inner(mut self) -> *mut nativeDataLossProtect {
3077 assert!(self.is_owned);
3078 let ret = ObjOps::untweak_ptr(self.inner);
3079 self.inner = core::ptr::null_mut();
3083 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
3084 /// belonging to the recipient
3086 pub extern "C" fn DataLossProtect_get_your_last_per_commitment_secret(this_ptr: &DataLossProtect) -> *const [u8; 32] {
3087 let mut inner_val = &mut this_ptr.get_native_mut_ref().your_last_per_commitment_secret;
3090 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
3091 /// belonging to the recipient
3093 pub extern "C" fn DataLossProtect_set_your_last_per_commitment_secret(this_ptr: &mut DataLossProtect, mut val: crate::c_types::ThirtyTwoBytes) {
3094 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.your_last_per_commitment_secret = val.data;
3096 /// The sender's per-commitment point for their current commitment transaction
3098 pub extern "C" fn DataLossProtect_get_my_current_per_commitment_point(this_ptr: &DataLossProtect) -> crate::c_types::PublicKey {
3099 let mut inner_val = &mut this_ptr.get_native_mut_ref().my_current_per_commitment_point;
3100 crate::c_types::PublicKey::from_rust(&inner_val)
3102 /// The sender's per-commitment point for their current commitment transaction
3104 pub extern "C" fn DataLossProtect_set_my_current_per_commitment_point(this_ptr: &mut DataLossProtect, mut val: crate::c_types::PublicKey) {
3105 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.my_current_per_commitment_point = val.into_rust();
3107 /// Constructs a new DataLossProtect given each field
3110 pub extern "C" fn DataLossProtect_new(mut your_last_per_commitment_secret_arg: crate::c_types::ThirtyTwoBytes, mut my_current_per_commitment_point_arg: crate::c_types::PublicKey) -> DataLossProtect {
3111 DataLossProtect { inner: ObjOps::heap_alloc(nativeDataLossProtect {
3112 your_last_per_commitment_secret: your_last_per_commitment_secret_arg.data,
3113 my_current_per_commitment_point: my_current_per_commitment_point_arg.into_rust(),
3114 }), is_owned: true }
3116 impl Clone for DataLossProtect {
3117 fn clone(&self) -> Self {
3119 inner: if <*mut nativeDataLossProtect>::is_null(self.inner) { core::ptr::null_mut() } else {
3120 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3126 /// Used only if an object of this type is returned as a trait impl by a method
3127 pub(crate) extern "C" fn DataLossProtect_clone_void(this_ptr: *const c_void) -> *mut c_void {
3128 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDataLossProtect)).clone() })) as *mut c_void
3131 /// Creates a copy of the DataLossProtect
3132 pub extern "C" fn DataLossProtect_clone(orig: &DataLossProtect) -> DataLossProtect {
3135 /// Checks if two DataLossProtects contain equal inner contents.
3136 /// This ignores pointers and is_owned flags and looks at the values in fields.
3137 /// Two objects with NULL inner values will be considered "equal" here.
3139 pub extern "C" fn DataLossProtect_eq(a: &DataLossProtect, b: &DataLossProtect) -> bool {
3140 if a.inner == b.inner { return true; }
3141 if a.inner.is_null() || b.inner.is_null() { return false; }
3142 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3145 use lightning::ln::msgs::ChannelReestablish as nativeChannelReestablishImport;
3146 pub(crate) type nativeChannelReestablish = nativeChannelReestablishImport;
3148 /// A [`channel_reestablish`] message to be sent to or received from a peer.
3150 /// [`channel_reestablish`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#message-retransmission
3153 pub struct ChannelReestablish {
3154 /// A pointer to the opaque Rust object.
3156 /// Nearly everywhere, inner must be non-null, however in places where
3157 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3158 pub inner: *mut nativeChannelReestablish,
3159 /// Indicates that this is the only struct which contains the same pointer.
3161 /// Rust functions which take ownership of an object provided via an argument require
3162 /// this to be true and invalidate the object pointed to by inner.
3166 impl Drop for ChannelReestablish {
3167 fn drop(&mut self) {
3168 if self.is_owned && !<*mut nativeChannelReestablish>::is_null(self.inner) {
3169 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3173 /// Frees any resources used by the ChannelReestablish, if is_owned is set and inner is non-NULL.
3175 pub extern "C" fn ChannelReestablish_free(this_obj: ChannelReestablish) { }
3177 /// Used only if an object of this type is returned as a trait impl by a method
3178 pub(crate) extern "C" fn ChannelReestablish_free_void(this_ptr: *mut c_void) {
3179 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelReestablish) };
3182 impl ChannelReestablish {
3183 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelReestablish {
3184 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3186 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelReestablish {
3187 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3189 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3190 pub(crate) fn take_inner(mut self) -> *mut nativeChannelReestablish {
3191 assert!(self.is_owned);
3192 let ret = ObjOps::untweak_ptr(self.inner);
3193 self.inner = core::ptr::null_mut();
3199 pub extern "C" fn ChannelReestablish_get_channel_id(this_ptr: &ChannelReestablish) -> *const [u8; 32] {
3200 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3205 pub extern "C" fn ChannelReestablish_set_channel_id(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) {
3206 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
3208 /// The next commitment number for the sender
3210 pub extern "C" fn ChannelReestablish_get_next_local_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
3211 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_local_commitment_number;
3214 /// The next commitment number for the sender
3216 pub extern "C" fn ChannelReestablish_set_next_local_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
3217 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_local_commitment_number = val;
3219 /// The next commitment number for the recipient
3221 pub extern "C" fn ChannelReestablish_get_next_remote_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
3222 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_remote_commitment_number;
3225 /// The next commitment number for the recipient
3227 pub extern "C" fn ChannelReestablish_set_next_remote_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
3228 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_remote_commitment_number = val;
3230 impl Clone for ChannelReestablish {
3231 fn clone(&self) -> Self {
3233 inner: if <*mut nativeChannelReestablish>::is_null(self.inner) { core::ptr::null_mut() } else {
3234 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3240 /// Used only if an object of this type is returned as a trait impl by a method
3241 pub(crate) extern "C" fn ChannelReestablish_clone_void(this_ptr: *const c_void) -> *mut c_void {
3242 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelReestablish)).clone() })) as *mut c_void
3245 /// Creates a copy of the ChannelReestablish
3246 pub extern "C" fn ChannelReestablish_clone(orig: &ChannelReestablish) -> ChannelReestablish {
3249 /// Checks if two ChannelReestablishs contain equal inner contents.
3250 /// This ignores pointers and is_owned flags and looks at the values in fields.
3251 /// Two objects with NULL inner values will be considered "equal" here.
3253 pub extern "C" fn ChannelReestablish_eq(a: &ChannelReestablish, b: &ChannelReestablish) -> bool {
3254 if a.inner == b.inner { return true; }
3255 if a.inner.is_null() || b.inner.is_null() { return false; }
3256 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3259 use lightning::ln::msgs::AnnouncementSignatures as nativeAnnouncementSignaturesImport;
3260 pub(crate) type nativeAnnouncementSignatures = nativeAnnouncementSignaturesImport;
3262 /// An [`announcement_signatures`] message to be sent to or received from a peer.
3264 /// [`announcement_signatures`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-announcement_signatures-message
3267 pub struct AnnouncementSignatures {
3268 /// A pointer to the opaque Rust object.
3270 /// Nearly everywhere, inner must be non-null, however in places where
3271 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3272 pub inner: *mut nativeAnnouncementSignatures,
3273 /// Indicates that this is the only struct which contains the same pointer.
3275 /// Rust functions which take ownership of an object provided via an argument require
3276 /// this to be true and invalidate the object pointed to by inner.
3280 impl Drop for AnnouncementSignatures {
3281 fn drop(&mut self) {
3282 if self.is_owned && !<*mut nativeAnnouncementSignatures>::is_null(self.inner) {
3283 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3287 /// Frees any resources used by the AnnouncementSignatures, if is_owned is set and inner is non-NULL.
3289 pub extern "C" fn AnnouncementSignatures_free(this_obj: AnnouncementSignatures) { }
3291 /// Used only if an object of this type is returned as a trait impl by a method
3292 pub(crate) extern "C" fn AnnouncementSignatures_free_void(this_ptr: *mut c_void) {
3293 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAnnouncementSignatures) };
3296 impl AnnouncementSignatures {
3297 pub(crate) fn get_native_ref(&self) -> &'static nativeAnnouncementSignatures {
3298 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3300 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAnnouncementSignatures {
3301 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3303 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3304 pub(crate) fn take_inner(mut self) -> *mut nativeAnnouncementSignatures {
3305 assert!(self.is_owned);
3306 let ret = ObjOps::untweak_ptr(self.inner);
3307 self.inner = core::ptr::null_mut();
3313 pub extern "C" fn AnnouncementSignatures_get_channel_id(this_ptr: &AnnouncementSignatures) -> *const [u8; 32] {
3314 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3319 pub extern "C" fn AnnouncementSignatures_set_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
3320 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
3322 /// The short channel ID
3324 pub extern "C" fn AnnouncementSignatures_get_short_channel_id(this_ptr: &AnnouncementSignatures) -> u64 {
3325 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
3328 /// The short channel ID
3330 pub extern "C" fn AnnouncementSignatures_set_short_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: u64) {
3331 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
3333 /// A signature by the node key
3335 pub extern "C" fn AnnouncementSignatures_get_node_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
3336 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature;
3337 crate::c_types::Signature::from_rust(&inner_val)
3339 /// A signature by the node key
3341 pub extern "C" fn AnnouncementSignatures_set_node_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
3342 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature = val.into_rust();
3344 /// A signature by the funding key
3346 pub extern "C" fn AnnouncementSignatures_get_bitcoin_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
3347 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature;
3348 crate::c_types::Signature::from_rust(&inner_val)
3350 /// A signature by the funding key
3352 pub extern "C" fn AnnouncementSignatures_set_bitcoin_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
3353 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature = val.into_rust();
3355 /// Constructs a new AnnouncementSignatures given each field
3358 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 {
3359 AnnouncementSignatures { inner: ObjOps::heap_alloc(nativeAnnouncementSignatures {
3360 channel_id: channel_id_arg.data,
3361 short_channel_id: short_channel_id_arg,
3362 node_signature: node_signature_arg.into_rust(),
3363 bitcoin_signature: bitcoin_signature_arg.into_rust(),
3364 }), is_owned: true }
3366 impl Clone for AnnouncementSignatures {
3367 fn clone(&self) -> Self {
3369 inner: if <*mut nativeAnnouncementSignatures>::is_null(self.inner) { core::ptr::null_mut() } else {
3370 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3376 /// Used only if an object of this type is returned as a trait impl by a method
3377 pub(crate) extern "C" fn AnnouncementSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
3378 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAnnouncementSignatures)).clone() })) as *mut c_void
3381 /// Creates a copy of the AnnouncementSignatures
3382 pub extern "C" fn AnnouncementSignatures_clone(orig: &AnnouncementSignatures) -> AnnouncementSignatures {
3385 /// Checks if two AnnouncementSignaturess contain equal inner contents.
3386 /// This ignores pointers and is_owned flags and looks at the values in fields.
3387 /// Two objects with NULL inner values will be considered "equal" here.
3389 pub extern "C" fn AnnouncementSignatures_eq(a: &AnnouncementSignatures, b: &AnnouncementSignatures) -> bool {
3390 if a.inner == b.inner { return true; }
3391 if a.inner.is_null() || b.inner.is_null() { return false; }
3392 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3394 /// An address which can be used to connect to a remote peer.
3398 pub enum NetAddress {
3399 /// An IPv4 address/port on which the peer is listening.
3401 /// The 4-byte IPv4 address
3402 addr: crate::c_types::FourBytes,
3403 /// The port on which the node is listening
3406 /// An IPv6 address/port on which the peer is listening.
3408 /// The 16-byte IPv6 address
3409 addr: crate::c_types::SixteenBytes,
3410 /// The port on which the node is listening
3413 /// An old-style Tor onion address/port on which the peer is listening.
3415 /// This field is deprecated and the Tor network generally no longer supports V2 Onion
3416 /// addresses. Thus, the details are not parsed here.
3418 crate::c_types::TwelveBytes),
3419 /// A new-style Tor onion address/port on which the peer is listening.
3421 /// To create the human-readable \"hostname\", concatenate the ED25519 pubkey, checksum, and version,
3422 /// wrap as base32 and append \".onion\".
3424 /// The ed25519 long-term public key of the peer
3425 ed25519_pubkey: crate::c_types::ThirtyTwoBytes,
3426 /// The checksum of the pubkey and version, as included in the onion address
3428 /// The version byte, as defined by the Tor Onion v3 spec.
3430 /// The port on which the node is listening
3433 /// A hostname/port on which the peer is listening.
3435 /// The hostname on which the node is listening.
3436 hostname: crate::lightning::util::ser::Hostname,
3437 /// The port on which the node is listening.
3441 use lightning::ln::msgs::NetAddress as NetAddressImport;
3442 pub(crate) type nativeNetAddress = NetAddressImport;
3446 pub(crate) fn to_native(&self) -> nativeNetAddress {
3448 NetAddress::IPv4 {ref addr, ref port, } => {
3449 let mut addr_nonref = Clone::clone(addr);
3450 let mut port_nonref = Clone::clone(port);
3451 nativeNetAddress::IPv4 {
3452 addr: addr_nonref.data,
3456 NetAddress::IPv6 {ref addr, ref port, } => {
3457 let mut addr_nonref = Clone::clone(addr);
3458 let mut port_nonref = Clone::clone(port);
3459 nativeNetAddress::IPv6 {
3460 addr: addr_nonref.data,
3464 NetAddress::OnionV2 (ref a, ) => {
3465 let mut a_nonref = Clone::clone(a);
3466 nativeNetAddress::OnionV2 (
3470 NetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
3471 let mut ed25519_pubkey_nonref = Clone::clone(ed25519_pubkey);
3472 let mut checksum_nonref = Clone::clone(checksum);
3473 let mut version_nonref = Clone::clone(version);
3474 let mut port_nonref = Clone::clone(port);
3475 nativeNetAddress::OnionV3 {
3476 ed25519_pubkey: ed25519_pubkey_nonref.data,
3477 checksum: checksum_nonref,
3478 version: version_nonref,
3482 NetAddress::Hostname {ref hostname, ref port, } => {
3483 let mut hostname_nonref = Clone::clone(hostname);
3484 let mut port_nonref = Clone::clone(port);
3485 nativeNetAddress::Hostname {
3486 hostname: *unsafe { Box::from_raw(hostname_nonref.take_inner()) },
3493 pub(crate) fn into_native(self) -> nativeNetAddress {
3495 NetAddress::IPv4 {mut addr, mut port, } => {
3496 nativeNetAddress::IPv4 {
3501 NetAddress::IPv6 {mut addr, mut port, } => {
3502 nativeNetAddress::IPv6 {
3507 NetAddress::OnionV2 (mut a, ) => {
3508 nativeNetAddress::OnionV2 (
3512 NetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
3513 nativeNetAddress::OnionV3 {
3514 ed25519_pubkey: ed25519_pubkey.data,
3520 NetAddress::Hostname {mut hostname, mut port, } => {
3521 nativeNetAddress::Hostname {
3522 hostname: *unsafe { Box::from_raw(hostname.take_inner()) },
3529 pub(crate) fn from_native(native: &nativeNetAddress) -> Self {
3531 nativeNetAddress::IPv4 {ref addr, ref port, } => {
3532 let mut addr_nonref = Clone::clone(addr);
3533 let mut port_nonref = Clone::clone(port);
3535 addr: crate::c_types::FourBytes { data: addr_nonref },
3539 nativeNetAddress::IPv6 {ref addr, ref port, } => {
3540 let mut addr_nonref = Clone::clone(addr);
3541 let mut port_nonref = Clone::clone(port);
3543 addr: crate::c_types::SixteenBytes { data: addr_nonref },
3547 nativeNetAddress::OnionV2 (ref a, ) => {
3548 let mut a_nonref = Clone::clone(a);
3549 NetAddress::OnionV2 (
3550 crate::c_types::TwelveBytes { data: a_nonref },
3553 nativeNetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
3554 let mut ed25519_pubkey_nonref = Clone::clone(ed25519_pubkey);
3555 let mut checksum_nonref = Clone::clone(checksum);
3556 let mut version_nonref = Clone::clone(version);
3557 let mut port_nonref = Clone::clone(port);
3558 NetAddress::OnionV3 {
3559 ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey_nonref },
3560 checksum: checksum_nonref,
3561 version: version_nonref,
3565 nativeNetAddress::Hostname {ref hostname, ref port, } => {
3566 let mut hostname_nonref = Clone::clone(hostname);
3567 let mut port_nonref = Clone::clone(port);
3568 NetAddress::Hostname {
3569 hostname: crate::lightning::util::ser::Hostname { inner: ObjOps::heap_alloc(hostname_nonref), is_owned: true },
3576 pub(crate) fn native_into(native: nativeNetAddress) -> Self {
3578 nativeNetAddress::IPv4 {mut addr, mut port, } => {
3580 addr: crate::c_types::FourBytes { data: addr },
3584 nativeNetAddress::IPv6 {mut addr, mut port, } => {
3586 addr: crate::c_types::SixteenBytes { data: addr },
3590 nativeNetAddress::OnionV2 (mut a, ) => {
3591 NetAddress::OnionV2 (
3592 crate::c_types::TwelveBytes { data: a },
3595 nativeNetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
3596 NetAddress::OnionV3 {
3597 ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey },
3603 nativeNetAddress::Hostname {mut hostname, mut port, } => {
3604 NetAddress::Hostname {
3605 hostname: crate::lightning::util::ser::Hostname { inner: ObjOps::heap_alloc(hostname), is_owned: true },
3612 /// Frees any resources used by the NetAddress
3614 pub extern "C" fn NetAddress_free(this_ptr: NetAddress) { }
3615 /// Creates a copy of the NetAddress
3617 pub extern "C" fn NetAddress_clone(orig: &NetAddress) -> NetAddress {
3621 /// Utility method to constructs a new IPv4-variant NetAddress
3622 pub extern "C" fn NetAddress_ipv4(addr: crate::c_types::FourBytes, port: u16) -> NetAddress {
3629 /// Utility method to constructs a new IPv6-variant NetAddress
3630 pub extern "C" fn NetAddress_ipv6(addr: crate::c_types::SixteenBytes, port: u16) -> NetAddress {
3637 /// Utility method to constructs a new OnionV2-variant NetAddress
3638 pub extern "C" fn NetAddress_onion_v2(a: crate::c_types::TwelveBytes) -> NetAddress {
3639 NetAddress::OnionV2(a, )
3642 /// Utility method to constructs a new OnionV3-variant NetAddress
3643 pub extern "C" fn NetAddress_onion_v3(ed25519_pubkey: crate::c_types::ThirtyTwoBytes, checksum: u16, version: u8, port: u16) -> NetAddress {
3644 NetAddress::OnionV3 {
3652 /// Utility method to constructs a new Hostname-variant NetAddress
3653 pub extern "C" fn NetAddress_hostname(hostname: crate::lightning::util::ser::Hostname, port: u16) -> NetAddress {
3654 NetAddress::Hostname {
3659 /// Checks if two NetAddresss contain equal inner contents.
3660 /// This ignores pointers and is_owned flags and looks at the values in fields.
3662 pub extern "C" fn NetAddress_eq(a: &NetAddress, b: &NetAddress) -> bool {
3663 if &a.to_native() == &b.to_native() { true } else { false }
3666 /// Serialize the NetAddress object into a byte array which can be read by NetAddress_read
3667 pub extern "C" fn NetAddress_write(obj: &crate::lightning::ln::msgs::NetAddress) -> crate::c_types::derived::CVec_u8Z {
3668 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
3671 /// Read a NetAddress from a byte array, created by NetAddress_write
3672 pub extern "C" fn NetAddress_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NetAddressDecodeErrorZ {
3673 let res: Result<lightning::ln::msgs::NetAddress, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
3674 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() };
3677 /// Represents the set of gossip messages that require a signature from a node's identity key.
3681 pub enum UnsignedGossipMessage {
3682 /// An unsigned channel announcement.
3683 ChannelAnnouncement(
3684 crate::lightning::ln::msgs::UnsignedChannelAnnouncement),
3685 /// An unsigned channel update.
3687 crate::lightning::ln::msgs::UnsignedChannelUpdate),
3688 /// An unsigned node announcement.
3690 crate::lightning::ln::msgs::UnsignedNodeAnnouncement),
3692 use lightning::ln::msgs::UnsignedGossipMessage as UnsignedGossipMessageImport;
3693 pub(crate) type nativeUnsignedGossipMessage = UnsignedGossipMessageImport;
3695 impl UnsignedGossipMessage {
3697 pub(crate) fn to_native(&self) -> nativeUnsignedGossipMessage {
3699 UnsignedGossipMessage::ChannelAnnouncement (ref a, ) => {
3700 let mut a_nonref = Clone::clone(a);
3701 nativeUnsignedGossipMessage::ChannelAnnouncement (
3702 *unsafe { Box::from_raw(a_nonref.take_inner()) },
3705 UnsignedGossipMessage::ChannelUpdate (ref a, ) => {
3706 let mut a_nonref = Clone::clone(a);
3707 nativeUnsignedGossipMessage::ChannelUpdate (
3708 *unsafe { Box::from_raw(a_nonref.take_inner()) },
3711 UnsignedGossipMessage::NodeAnnouncement (ref a, ) => {
3712 let mut a_nonref = Clone::clone(a);
3713 nativeUnsignedGossipMessage::NodeAnnouncement (
3714 *unsafe { Box::from_raw(a_nonref.take_inner()) },
3720 pub(crate) fn into_native(self) -> nativeUnsignedGossipMessage {
3722 UnsignedGossipMessage::ChannelAnnouncement (mut a, ) => {
3723 nativeUnsignedGossipMessage::ChannelAnnouncement (
3724 *unsafe { Box::from_raw(a.take_inner()) },
3727 UnsignedGossipMessage::ChannelUpdate (mut a, ) => {
3728 nativeUnsignedGossipMessage::ChannelUpdate (
3729 *unsafe { Box::from_raw(a.take_inner()) },
3732 UnsignedGossipMessage::NodeAnnouncement (mut a, ) => {
3733 nativeUnsignedGossipMessage::NodeAnnouncement (
3734 *unsafe { Box::from_raw(a.take_inner()) },
3740 pub(crate) fn from_native(native: &nativeUnsignedGossipMessage) -> Self {
3742 nativeUnsignedGossipMessage::ChannelAnnouncement (ref a, ) => {
3743 let mut a_nonref = Clone::clone(a);
3744 UnsignedGossipMessage::ChannelAnnouncement (
3745 crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
3748 nativeUnsignedGossipMessage::ChannelUpdate (ref a, ) => {
3749 let mut a_nonref = Clone::clone(a);
3750 UnsignedGossipMessage::ChannelUpdate (
3751 crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
3754 nativeUnsignedGossipMessage::NodeAnnouncement (ref a, ) => {
3755 let mut a_nonref = Clone::clone(a);
3756 UnsignedGossipMessage::NodeAnnouncement (
3757 crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
3763 pub(crate) fn native_into(native: nativeUnsignedGossipMessage) -> Self {
3765 nativeUnsignedGossipMessage::ChannelAnnouncement (mut a, ) => {
3766 UnsignedGossipMessage::ChannelAnnouncement (
3767 crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(a), is_owned: true },
3770 nativeUnsignedGossipMessage::ChannelUpdate (mut a, ) => {
3771 UnsignedGossipMessage::ChannelUpdate (
3772 crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: ObjOps::heap_alloc(a), is_owned: true },
3775 nativeUnsignedGossipMessage::NodeAnnouncement (mut a, ) => {
3776 UnsignedGossipMessage::NodeAnnouncement (
3777 crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: ObjOps::heap_alloc(a), is_owned: true },
3783 /// Frees any resources used by the UnsignedGossipMessage
3785 pub extern "C" fn UnsignedGossipMessage_free(this_ptr: UnsignedGossipMessage) { }
3786 /// Creates a copy of the UnsignedGossipMessage
3788 pub extern "C" fn UnsignedGossipMessage_clone(orig: &UnsignedGossipMessage) -> UnsignedGossipMessage {
3792 /// Utility method to constructs a new ChannelAnnouncement-variant UnsignedGossipMessage
3793 pub extern "C" fn UnsignedGossipMessage_channel_announcement(a: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> UnsignedGossipMessage {
3794 UnsignedGossipMessage::ChannelAnnouncement(a, )
3797 /// Utility method to constructs a new ChannelUpdate-variant UnsignedGossipMessage
3798 pub extern "C" fn UnsignedGossipMessage_channel_update(a: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> UnsignedGossipMessage {
3799 UnsignedGossipMessage::ChannelUpdate(a, )
3802 /// Utility method to constructs a new NodeAnnouncement-variant UnsignedGossipMessage
3803 pub extern "C" fn UnsignedGossipMessage_node_announcement(a: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> UnsignedGossipMessage {
3804 UnsignedGossipMessage::NodeAnnouncement(a, )
3807 /// Serialize the UnsignedGossipMessage object into a byte array which can be read by UnsignedGossipMessage_read
3808 pub extern "C" fn UnsignedGossipMessage_write(obj: &crate::lightning::ln::msgs::UnsignedGossipMessage) -> crate::c_types::derived::CVec_u8Z {
3809 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
3812 use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport;
3813 pub(crate) type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport;
3815 /// The unsigned part of a [`node_announcement`] message.
3817 /// [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message
3820 pub struct UnsignedNodeAnnouncement {
3821 /// A pointer to the opaque Rust object.
3823 /// Nearly everywhere, inner must be non-null, however in places where
3824 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3825 pub inner: *mut nativeUnsignedNodeAnnouncement,
3826 /// Indicates that this is the only struct which contains the same pointer.
3828 /// Rust functions which take ownership of an object provided via an argument require
3829 /// this to be true and invalidate the object pointed to by inner.
3833 impl Drop for UnsignedNodeAnnouncement {
3834 fn drop(&mut self) {
3835 if self.is_owned && !<*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) {
3836 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3840 /// Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL.
3842 pub extern "C" fn UnsignedNodeAnnouncement_free(this_obj: UnsignedNodeAnnouncement) { }
3844 /// Used only if an object of this type is returned as a trait impl by a method
3845 pub(crate) extern "C" fn UnsignedNodeAnnouncement_free_void(this_ptr: *mut c_void) {
3846 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedNodeAnnouncement) };
3849 impl UnsignedNodeAnnouncement {
3850 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedNodeAnnouncement {
3851 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3853 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedNodeAnnouncement {
3854 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3856 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3857 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedNodeAnnouncement {
3858 assert!(self.is_owned);
3859 let ret = ObjOps::untweak_ptr(self.inner);
3860 self.inner = core::ptr::null_mut();
3864 /// The advertised features
3866 pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::ln::features::NodeFeatures {
3867 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
3868 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 }
3870 /// The advertised features
3872 pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::ln::features::NodeFeatures) {
3873 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
3875 /// A strictly monotonic announcement counter, with gaps allowed
3877 pub extern "C" fn UnsignedNodeAnnouncement_get_timestamp(this_ptr: &UnsignedNodeAnnouncement) -> u32 {
3878 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
3881 /// A strictly monotonic announcement counter, with gaps allowed
3883 pub extern "C" fn UnsignedNodeAnnouncement_set_timestamp(this_ptr: &mut UnsignedNodeAnnouncement, mut val: u32) {
3884 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
3886 /// The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back
3889 pub extern "C" fn UnsignedNodeAnnouncement_get_node_id(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::routing::gossip::NodeId {
3890 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id;
3891 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 }
3893 /// The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back
3896 pub extern "C" fn UnsignedNodeAnnouncement_set_node_id(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
3897 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id = *unsafe { Box::from_raw(val.take_inner()) };
3899 /// An RGB color for UI purposes
3901 pub extern "C" fn UnsignedNodeAnnouncement_get_rgb(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 3] {
3902 let mut inner_val = &mut this_ptr.get_native_mut_ref().rgb;
3905 /// An RGB color for UI purposes
3907 pub extern "C" fn UnsignedNodeAnnouncement_set_rgb(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThreeBytes) {
3908 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.rgb = val.data;
3910 /// An alias, for UI purposes.
3912 /// This should be sanitized before use. There is no guarantee of uniqueness.
3914 pub extern "C" fn UnsignedNodeAnnouncement_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::routing::gossip::NodeAlias {
3915 let mut inner_val = &mut this_ptr.get_native_mut_ref().alias;
3916 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 }
3918 /// An alias, for UI purposes.
3920 /// This should be sanitized before use. There is no guarantee of uniqueness.
3922 pub extern "C" fn UnsignedNodeAnnouncement_set_alias(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::routing::gossip::NodeAlias) {
3923 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.alias = *unsafe { Box::from_raw(val.take_inner()) };
3925 /// List of addresses on which this node is reachable
3927 /// Returns a copy of the field.
3929 pub extern "C" fn UnsignedNodeAnnouncement_get_addresses(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_NetAddressZ {
3930 let mut inner_val = this_ptr.get_native_mut_ref().addresses.clone();
3931 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) }); };
3932 local_inner_val.into()
3934 /// List of addresses on which this node is reachable
3936 pub extern "C" fn UnsignedNodeAnnouncement_set_addresses(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_NetAddressZ) {
3937 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
3938 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.addresses = local_val;
3940 impl Clone for UnsignedNodeAnnouncement {
3941 fn clone(&self) -> Self {
3943 inner: if <*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
3944 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3950 /// Used only if an object of this type is returned as a trait impl by a method
3951 pub(crate) extern "C" fn UnsignedNodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3952 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedNodeAnnouncement)).clone() })) as *mut c_void
3955 /// Creates a copy of the UnsignedNodeAnnouncement
3956 pub extern "C" fn UnsignedNodeAnnouncement_clone(orig: &UnsignedNodeAnnouncement) -> UnsignedNodeAnnouncement {
3959 /// Checks if two UnsignedNodeAnnouncements contain equal inner contents.
3960 /// This ignores pointers and is_owned flags and looks at the values in fields.
3961 /// Two objects with NULL inner values will be considered "equal" here.
3963 pub extern "C" fn UnsignedNodeAnnouncement_eq(a: &UnsignedNodeAnnouncement, b: &UnsignedNodeAnnouncement) -> bool {
3964 if a.inner == b.inner { return true; }
3965 if a.inner.is_null() || b.inner.is_null() { return false; }
3966 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3969 use lightning::ln::msgs::NodeAnnouncement as nativeNodeAnnouncementImport;
3970 pub(crate) type nativeNodeAnnouncement = nativeNodeAnnouncementImport;
3972 /// A [`node_announcement`] message to be sent to or received from a peer.
3974 /// [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message
3977 pub struct NodeAnnouncement {
3978 /// A pointer to the opaque Rust object.
3980 /// Nearly everywhere, inner must be non-null, however in places where
3981 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3982 pub inner: *mut nativeNodeAnnouncement,
3983 /// Indicates that this is the only struct which contains the same pointer.
3985 /// Rust functions which take ownership of an object provided via an argument require
3986 /// this to be true and invalidate the object pointed to by inner.
3990 impl Drop for NodeAnnouncement {
3991 fn drop(&mut self) {
3992 if self.is_owned && !<*mut nativeNodeAnnouncement>::is_null(self.inner) {
3993 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3997 /// Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL.
3999 pub extern "C" fn NodeAnnouncement_free(this_obj: NodeAnnouncement) { }
4001 /// Used only if an object of this type is returned as a trait impl by a method
4002 pub(crate) extern "C" fn NodeAnnouncement_free_void(this_ptr: *mut c_void) {
4003 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeNodeAnnouncement) };
4006 impl NodeAnnouncement {
4007 pub(crate) fn get_native_ref(&self) -> &'static nativeNodeAnnouncement {
4008 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4010 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeAnnouncement {
4011 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4013 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4014 pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncement {
4015 assert!(self.is_owned);
4016 let ret = ObjOps::untweak_ptr(self.inner);
4017 self.inner = core::ptr::null_mut();
4021 /// The signature by the node key
4023 pub extern "C" fn NodeAnnouncement_get_signature(this_ptr: &NodeAnnouncement) -> crate::c_types::Signature {
4024 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
4025 crate::c_types::Signature::from_rust(&inner_val)
4027 /// The signature by the node key
4029 pub extern "C" fn NodeAnnouncement_set_signature(this_ptr: &mut NodeAnnouncement, mut val: crate::c_types::Signature) {
4030 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
4032 /// The actual content of the announcement
4034 pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> crate::lightning::ln::msgs::UnsignedNodeAnnouncement {
4035 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
4036 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 }
4038 /// The actual content of the announcement
4040 pub extern "C" fn NodeAnnouncement_set_contents(this_ptr: &mut NodeAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) {
4041 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
4043 /// Constructs a new NodeAnnouncement given each field
4046 pub extern "C" fn NodeAnnouncement_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> NodeAnnouncement {
4047 NodeAnnouncement { inner: ObjOps::heap_alloc(nativeNodeAnnouncement {
4048 signature: signature_arg.into_rust(),
4049 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
4050 }), is_owned: true }
4052 impl Clone for NodeAnnouncement {
4053 fn clone(&self) -> Self {
4055 inner: if <*mut nativeNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
4056 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4062 /// Used only if an object of this type is returned as a trait impl by a method
4063 pub(crate) extern "C" fn NodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
4064 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeAnnouncement)).clone() })) as *mut c_void
4067 /// Creates a copy of the NodeAnnouncement
4068 pub extern "C" fn NodeAnnouncement_clone(orig: &NodeAnnouncement) -> NodeAnnouncement {
4071 /// Checks if two NodeAnnouncements contain equal inner contents.
4072 /// This ignores pointers and is_owned flags and looks at the values in fields.
4073 /// Two objects with NULL inner values will be considered "equal" here.
4075 pub extern "C" fn NodeAnnouncement_eq(a: &NodeAnnouncement, b: &NodeAnnouncement) -> bool {
4076 if a.inner == b.inner { return true; }
4077 if a.inner.is_null() || b.inner.is_null() { return false; }
4078 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4081 use lightning::ln::msgs::UnsignedChannelAnnouncement as nativeUnsignedChannelAnnouncementImport;
4082 pub(crate) type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport;
4084 /// The unsigned part of a [`channel_announcement`] message.
4086 /// [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message
4089 pub struct UnsignedChannelAnnouncement {
4090 /// A pointer to the opaque Rust object.
4092 /// Nearly everywhere, inner must be non-null, however in places where
4093 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4094 pub inner: *mut nativeUnsignedChannelAnnouncement,
4095 /// Indicates that this is the only struct which contains the same pointer.
4097 /// Rust functions which take ownership of an object provided via an argument require
4098 /// this to be true and invalidate the object pointed to by inner.
4102 impl Drop for UnsignedChannelAnnouncement {
4103 fn drop(&mut self) {
4104 if self.is_owned && !<*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) {
4105 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4109 /// Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL.
4111 pub extern "C" fn UnsignedChannelAnnouncement_free(this_obj: UnsignedChannelAnnouncement) { }
4113 /// Used only if an object of this type is returned as a trait impl by a method
4114 pub(crate) extern "C" fn UnsignedChannelAnnouncement_free_void(this_ptr: *mut c_void) {
4115 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedChannelAnnouncement) };
4118 impl UnsignedChannelAnnouncement {
4119 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelAnnouncement {
4120 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4122 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelAnnouncement {
4123 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4125 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4126 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelAnnouncement {
4127 assert!(self.is_owned);
4128 let ret = ObjOps::untweak_ptr(self.inner);
4129 self.inner = core::ptr::null_mut();
4133 /// The advertised channel features
4135 pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::ln::features::ChannelFeatures {
4136 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
4137 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 }
4139 /// The advertised channel features
4141 pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::ln::features::ChannelFeatures) {
4142 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
4144 /// The genesis hash of the blockchain where the channel is to be opened
4146 pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &UnsignedChannelAnnouncement) -> *const [u8; 32] {
4147 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4148 inner_val.as_inner()
4150 /// The genesis hash of the blockchain where the channel is to be opened
4152 pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
4153 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4155 /// The short channel ID
4157 pub extern "C" fn UnsignedChannelAnnouncement_get_short_channel_id(this_ptr: &UnsignedChannelAnnouncement) -> u64 {
4158 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
4161 /// The short channel ID
4163 pub extern "C" fn UnsignedChannelAnnouncement_set_short_channel_id(this_ptr: &mut UnsignedChannelAnnouncement, mut val: u64) {
4164 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
4166 /// One of the two `node_id`s which are endpoints of this channel
4168 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
4169 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_1;
4170 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 }
4172 /// One of the two `node_id`s which are endpoints of this channel
4174 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
4175 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_1 = *unsafe { Box::from_raw(val.take_inner()) };
4177 /// The other of the two `node_id`s which are endpoints of this channel
4179 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
4180 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_2;
4181 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 }
4183 /// The other of the two `node_id`s which are endpoints of this channel
4185 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
4186 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_2 = *unsafe { Box::from_raw(val.take_inner()) };
4188 /// The funding key for the first node
4190 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
4191 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_1;
4192 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 }
4194 /// The funding key for the first node
4196 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
4197 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_1 = *unsafe { Box::from_raw(val.take_inner()) };
4199 /// The funding key for the second node
4201 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
4202 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_2;
4203 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 }
4205 /// The funding key for the second node
4207 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
4208 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_2 = *unsafe { Box::from_raw(val.take_inner()) };
4210 impl Clone for UnsignedChannelAnnouncement {
4211 fn clone(&self) -> Self {
4213 inner: if <*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
4214 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4220 /// Used only if an object of this type is returned as a trait impl by a method
4221 pub(crate) extern "C" fn UnsignedChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
4222 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelAnnouncement)).clone() })) as *mut c_void
4225 /// Creates a copy of the UnsignedChannelAnnouncement
4226 pub extern "C" fn UnsignedChannelAnnouncement_clone(orig: &UnsignedChannelAnnouncement) -> UnsignedChannelAnnouncement {
4229 /// Checks if two UnsignedChannelAnnouncements contain equal inner contents.
4230 /// This ignores pointers and is_owned flags and looks at the values in fields.
4231 /// Two objects with NULL inner values will be considered "equal" here.
4233 pub extern "C" fn UnsignedChannelAnnouncement_eq(a: &UnsignedChannelAnnouncement, b: &UnsignedChannelAnnouncement) -> bool {
4234 if a.inner == b.inner { return true; }
4235 if a.inner.is_null() || b.inner.is_null() { return false; }
4236 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4239 use lightning::ln::msgs::ChannelAnnouncement as nativeChannelAnnouncementImport;
4240 pub(crate) type nativeChannelAnnouncement = nativeChannelAnnouncementImport;
4242 /// A [`channel_announcement`] message to be sent to or received from a peer.
4244 /// [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message
4247 pub struct ChannelAnnouncement {
4248 /// A pointer to the opaque Rust object.
4250 /// Nearly everywhere, inner must be non-null, however in places where
4251 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4252 pub inner: *mut nativeChannelAnnouncement,
4253 /// Indicates that this is the only struct which contains the same pointer.
4255 /// Rust functions which take ownership of an object provided via an argument require
4256 /// this to be true and invalidate the object pointed to by inner.
4260 impl Drop for ChannelAnnouncement {
4261 fn drop(&mut self) {
4262 if self.is_owned && !<*mut nativeChannelAnnouncement>::is_null(self.inner) {
4263 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4267 /// Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL.
4269 pub extern "C" fn ChannelAnnouncement_free(this_obj: ChannelAnnouncement) { }
4271 /// Used only if an object of this type is returned as a trait impl by a method
4272 pub(crate) extern "C" fn ChannelAnnouncement_free_void(this_ptr: *mut c_void) {
4273 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelAnnouncement) };
4276 impl ChannelAnnouncement {
4277 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelAnnouncement {
4278 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4280 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelAnnouncement {
4281 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4283 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4284 pub(crate) fn take_inner(mut self) -> *mut nativeChannelAnnouncement {
4285 assert!(self.is_owned);
4286 let ret = ObjOps::untweak_ptr(self.inner);
4287 self.inner = core::ptr::null_mut();
4291 /// Authentication of the announcement by the first public node
4293 pub extern "C" fn ChannelAnnouncement_get_node_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
4294 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_1;
4295 crate::c_types::Signature::from_rust(&inner_val)
4297 /// Authentication of the announcement by the first public node
4299 pub extern "C" fn ChannelAnnouncement_set_node_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
4300 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_1 = val.into_rust();
4302 /// Authentication of the announcement by the second public node
4304 pub extern "C" fn ChannelAnnouncement_get_node_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
4305 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_2;
4306 crate::c_types::Signature::from_rust(&inner_val)
4308 /// Authentication of the announcement by the second public node
4310 pub extern "C" fn ChannelAnnouncement_set_node_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
4311 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_2 = val.into_rust();
4313 /// Proof of funding UTXO ownership by the first public node
4315 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
4316 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_1;
4317 crate::c_types::Signature::from_rust(&inner_val)
4319 /// Proof of funding UTXO ownership by the first public node
4321 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
4322 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_1 = val.into_rust();
4324 /// Proof of funding UTXO ownership by the second public node
4326 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
4327 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_2;
4328 crate::c_types::Signature::from_rust(&inner_val)
4330 /// Proof of funding UTXO ownership by the second public node
4332 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
4333 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_2 = val.into_rust();
4335 /// The actual announcement
4337 pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncement) -> crate::lightning::ln::msgs::UnsignedChannelAnnouncement {
4338 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
4339 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 }
4341 /// The actual announcement
4343 pub extern "C" fn ChannelAnnouncement_set_contents(this_ptr: &mut ChannelAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) {
4344 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
4346 /// Constructs a new ChannelAnnouncement given each field
4349 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 {
4350 ChannelAnnouncement { inner: ObjOps::heap_alloc(nativeChannelAnnouncement {
4351 node_signature_1: node_signature_1_arg.into_rust(),
4352 node_signature_2: node_signature_2_arg.into_rust(),
4353 bitcoin_signature_1: bitcoin_signature_1_arg.into_rust(),
4354 bitcoin_signature_2: bitcoin_signature_2_arg.into_rust(),
4355 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
4356 }), is_owned: true }
4358 impl Clone for ChannelAnnouncement {
4359 fn clone(&self) -> Self {
4361 inner: if <*mut nativeChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
4362 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4368 /// Used only if an object of this type is returned as a trait impl by a method
4369 pub(crate) extern "C" fn ChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
4370 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelAnnouncement)).clone() })) as *mut c_void
4373 /// Creates a copy of the ChannelAnnouncement
4374 pub extern "C" fn ChannelAnnouncement_clone(orig: &ChannelAnnouncement) -> ChannelAnnouncement {
4377 /// Checks if two ChannelAnnouncements contain equal inner contents.
4378 /// This ignores pointers and is_owned flags and looks at the values in fields.
4379 /// Two objects with NULL inner values will be considered "equal" here.
4381 pub extern "C" fn ChannelAnnouncement_eq(a: &ChannelAnnouncement, b: &ChannelAnnouncement) -> bool {
4382 if a.inner == b.inner { return true; }
4383 if a.inner.is_null() || b.inner.is_null() { return false; }
4384 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4387 use lightning::ln::msgs::UnsignedChannelUpdate as nativeUnsignedChannelUpdateImport;
4388 pub(crate) type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport;
4390 /// The unsigned part of a [`channel_update`] message.
4392 /// [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
4395 pub struct UnsignedChannelUpdate {
4396 /// A pointer to the opaque Rust object.
4398 /// Nearly everywhere, inner must be non-null, however in places where
4399 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4400 pub inner: *mut nativeUnsignedChannelUpdate,
4401 /// Indicates that this is the only struct which contains the same pointer.
4403 /// Rust functions which take ownership of an object provided via an argument require
4404 /// this to be true and invalidate the object pointed to by inner.
4408 impl Drop for UnsignedChannelUpdate {
4409 fn drop(&mut self) {
4410 if self.is_owned && !<*mut nativeUnsignedChannelUpdate>::is_null(self.inner) {
4411 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4415 /// Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL.
4417 pub extern "C" fn UnsignedChannelUpdate_free(this_obj: UnsignedChannelUpdate) { }
4419 /// Used only if an object of this type is returned as a trait impl by a method
4420 pub(crate) extern "C" fn UnsignedChannelUpdate_free_void(this_ptr: *mut c_void) {
4421 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedChannelUpdate) };
4424 impl UnsignedChannelUpdate {
4425 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelUpdate {
4426 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4428 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelUpdate {
4429 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4431 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4432 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelUpdate {
4433 assert!(self.is_owned);
4434 let ret = ObjOps::untweak_ptr(self.inner);
4435 self.inner = core::ptr::null_mut();
4439 /// The genesis hash of the blockchain where the channel is to be opened
4441 pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChannelUpdate) -> *const [u8; 32] {
4442 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4443 inner_val.as_inner()
4445 /// The genesis hash of the blockchain where the channel is to be opened
4447 pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::ThirtyTwoBytes) {
4448 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4450 /// The short channel ID
4452 pub extern "C" fn UnsignedChannelUpdate_get_short_channel_id(this_ptr: &UnsignedChannelUpdate) -> u64 {
4453 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
4456 /// The short channel ID
4458 pub extern "C" fn UnsignedChannelUpdate_set_short_channel_id(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
4459 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
4461 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
4463 pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannelUpdate) -> u32 {
4464 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
4467 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
4469 pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
4470 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
4474 pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 {
4475 let mut inner_val = &mut this_ptr.get_native_mut_ref().flags;
4480 pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) {
4481 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.flags = val;
4483 /// The number of blocks such that if:
4484 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
4485 /// then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines
4486 /// the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a
4487 /// `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10,
4488 /// then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before
4489 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
4490 /// constructing the route.
4492 pub extern "C" fn UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr: &UnsignedChannelUpdate) -> u16 {
4493 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
4496 /// The number of blocks such that if:
4497 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
4498 /// then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines
4499 /// the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a
4500 /// `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10,
4501 /// then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before
4502 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
4503 /// constructing the route.
4505 pub extern "C" fn UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr: &mut UnsignedChannelUpdate, mut val: u16) {
4506 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
4508 /// The minimum HTLC size incoming to sender, in milli-satoshi
4510 pub extern "C" fn UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
4511 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
4514 /// The minimum HTLC size incoming to sender, in milli-satoshi
4516 pub extern "C" fn UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
4517 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
4519 /// The maximum HTLC value incoming to sender, in milli-satoshi.
4521 /// This used to be optional.
4523 pub extern "C" fn UnsignedChannelUpdate_get_htlc_maximum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
4524 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat;
4527 /// The maximum HTLC value incoming to sender, in milli-satoshi.
4529 /// This used to be optional.
4531 pub extern "C" fn UnsignedChannelUpdate_set_htlc_maximum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
4532 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = val;
4534 /// The base HTLC fee charged by sender, in milli-satoshi
4536 pub extern "C" fn UnsignedChannelUpdate_get_fee_base_msat(this_ptr: &UnsignedChannelUpdate) -> u32 {
4537 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat;
4540 /// The base HTLC fee charged by sender, in milli-satoshi
4542 pub extern "C" fn UnsignedChannelUpdate_set_fee_base_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
4543 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val;
4545 /// The amount to fee multiplier, in micro-satoshi
4547 pub extern "C" fn UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr: &UnsignedChannelUpdate) -> u32 {
4548 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths;
4551 /// The amount to fee multiplier, in micro-satoshi
4553 pub extern "C" fn UnsignedChannelUpdate_set_fee_proportional_millionths(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
4554 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val;
4556 /// Excess data which was signed as a part of the message which we do not (yet) understand how
4559 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
4561 /// Returns a copy of the field.
4563 pub extern "C" fn UnsignedChannelUpdate_get_excess_data(this_ptr: &UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
4564 let mut inner_val = this_ptr.get_native_mut_ref().excess_data.clone();
4565 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
4566 local_inner_val.into()
4568 /// Excess data which was signed as a part of the message which we do not (yet) understand how
4571 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
4573 pub extern "C" fn UnsignedChannelUpdate_set_excess_data(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::derived::CVec_u8Z) {
4574 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
4575 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_data = local_val;
4577 /// Constructs a new UnsignedChannelUpdate given each field
4580 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 {
4581 let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); };
4582 UnsignedChannelUpdate { inner: ObjOps::heap_alloc(nativeUnsignedChannelUpdate {
4583 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4584 short_channel_id: short_channel_id_arg,
4585 timestamp: timestamp_arg,
4587 cltv_expiry_delta: cltv_expiry_delta_arg,
4588 htlc_minimum_msat: htlc_minimum_msat_arg,
4589 htlc_maximum_msat: htlc_maximum_msat_arg,
4590 fee_base_msat: fee_base_msat_arg,
4591 fee_proportional_millionths: fee_proportional_millionths_arg,
4592 excess_data: local_excess_data_arg,
4593 }), is_owned: true }
4595 impl Clone for UnsignedChannelUpdate {
4596 fn clone(&self) -> Self {
4598 inner: if <*mut nativeUnsignedChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
4599 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4605 /// Used only if an object of this type is returned as a trait impl by a method
4606 pub(crate) extern "C" fn UnsignedChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
4607 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelUpdate)).clone() })) as *mut c_void
4610 /// Creates a copy of the UnsignedChannelUpdate
4611 pub extern "C" fn UnsignedChannelUpdate_clone(orig: &UnsignedChannelUpdate) -> UnsignedChannelUpdate {
4614 /// Checks if two UnsignedChannelUpdates contain equal inner contents.
4615 /// This ignores pointers and is_owned flags and looks at the values in fields.
4616 /// Two objects with NULL inner values will be considered "equal" here.
4618 pub extern "C" fn UnsignedChannelUpdate_eq(a: &UnsignedChannelUpdate, b: &UnsignedChannelUpdate) -> bool {
4619 if a.inner == b.inner { return true; }
4620 if a.inner.is_null() || b.inner.is_null() { return false; }
4621 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4624 use lightning::ln::msgs::ChannelUpdate as nativeChannelUpdateImport;
4625 pub(crate) type nativeChannelUpdate = nativeChannelUpdateImport;
4627 /// A [`channel_update`] message to be sent to or received from a peer.
4629 /// [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
4632 pub struct ChannelUpdate {
4633 /// A pointer to the opaque Rust object.
4635 /// Nearly everywhere, inner must be non-null, however in places where
4636 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4637 pub inner: *mut nativeChannelUpdate,
4638 /// Indicates that this is the only struct which contains the same pointer.
4640 /// Rust functions which take ownership of an object provided via an argument require
4641 /// this to be true and invalidate the object pointed to by inner.
4645 impl Drop for ChannelUpdate {
4646 fn drop(&mut self) {
4647 if self.is_owned && !<*mut nativeChannelUpdate>::is_null(self.inner) {
4648 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4652 /// Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL.
4654 pub extern "C" fn ChannelUpdate_free(this_obj: ChannelUpdate) { }
4656 /// Used only if an object of this type is returned as a trait impl by a method
4657 pub(crate) extern "C" fn ChannelUpdate_free_void(this_ptr: *mut c_void) {
4658 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelUpdate) };
4661 impl ChannelUpdate {
4662 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelUpdate {
4663 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4665 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelUpdate {
4666 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4668 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4669 pub(crate) fn take_inner(mut self) -> *mut nativeChannelUpdate {
4670 assert!(self.is_owned);
4671 let ret = ObjOps::untweak_ptr(self.inner);
4672 self.inner = core::ptr::null_mut();
4676 /// A signature of the channel update
4678 pub extern "C" fn ChannelUpdate_get_signature(this_ptr: &ChannelUpdate) -> crate::c_types::Signature {
4679 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
4680 crate::c_types::Signature::from_rust(&inner_val)
4682 /// A signature of the channel update
4684 pub extern "C" fn ChannelUpdate_set_signature(this_ptr: &mut ChannelUpdate, mut val: crate::c_types::Signature) {
4685 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
4687 /// The actual channel update
4689 pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate::lightning::ln::msgs::UnsignedChannelUpdate {
4690 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
4691 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 }
4693 /// The actual channel update
4695 pub extern "C" fn ChannelUpdate_set_contents(this_ptr: &mut ChannelUpdate, mut val: crate::lightning::ln::msgs::UnsignedChannelUpdate) {
4696 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
4698 /// Constructs a new ChannelUpdate given each field
4701 pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> ChannelUpdate {
4702 ChannelUpdate { inner: ObjOps::heap_alloc(nativeChannelUpdate {
4703 signature: signature_arg.into_rust(),
4704 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
4705 }), is_owned: true }
4707 impl Clone for ChannelUpdate {
4708 fn clone(&self) -> Self {
4710 inner: if <*mut nativeChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
4711 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4717 /// Used only if an object of this type is returned as a trait impl by a method
4718 pub(crate) extern "C" fn ChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
4719 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelUpdate)).clone() })) as *mut c_void
4722 /// Creates a copy of the ChannelUpdate
4723 pub extern "C" fn ChannelUpdate_clone(orig: &ChannelUpdate) -> ChannelUpdate {
4726 /// Checks if two ChannelUpdates contain equal inner contents.
4727 /// This ignores pointers and is_owned flags and looks at the values in fields.
4728 /// Two objects with NULL inner values will be considered "equal" here.
4730 pub extern "C" fn ChannelUpdate_eq(a: &ChannelUpdate, b: &ChannelUpdate) -> bool {
4731 if a.inner == b.inner { return true; }
4732 if a.inner.is_null() || b.inner.is_null() { return false; }
4733 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4736 use lightning::ln::msgs::QueryChannelRange as nativeQueryChannelRangeImport;
4737 pub(crate) type nativeQueryChannelRange = nativeQueryChannelRangeImport;
4739 /// A [`query_channel_range`] message is used to query a peer for channel
4740 /// UTXOs in a range of blocks. The recipient of a query makes a best
4741 /// effort to reply to the query using one or more [`ReplyChannelRange`]
4744 /// [`query_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages
4747 pub struct QueryChannelRange {
4748 /// A pointer to the opaque Rust object.
4750 /// Nearly everywhere, inner must be non-null, however in places where
4751 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4752 pub inner: *mut nativeQueryChannelRange,
4753 /// Indicates that this is the only struct which contains the same pointer.
4755 /// Rust functions which take ownership of an object provided via an argument require
4756 /// this to be true and invalidate the object pointed to by inner.
4760 impl Drop for QueryChannelRange {
4761 fn drop(&mut self) {
4762 if self.is_owned && !<*mut nativeQueryChannelRange>::is_null(self.inner) {
4763 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4767 /// Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL.
4769 pub extern "C" fn QueryChannelRange_free(this_obj: QueryChannelRange) { }
4771 /// Used only if an object of this type is returned as a trait impl by a method
4772 pub(crate) extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) {
4773 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeQueryChannelRange) };
4776 impl QueryChannelRange {
4777 pub(crate) fn get_native_ref(&self) -> &'static nativeQueryChannelRange {
4778 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4780 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryChannelRange {
4781 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4783 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4784 pub(crate) fn take_inner(mut self) -> *mut nativeQueryChannelRange {
4785 assert!(self.is_owned);
4786 let ret = ObjOps::untweak_ptr(self.inner);
4787 self.inner = core::ptr::null_mut();
4791 /// The genesis hash of the blockchain being queried
4793 pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *const [u8; 32] {
4794 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4795 inner_val.as_inner()
4797 /// The genesis hash of the blockchain being queried
4799 pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
4800 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4802 /// The height of the first block for the channel UTXOs being queried
4804 pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 {
4805 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
4808 /// The height of the first block for the channel UTXOs being queried
4810 pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChannelRange, mut val: u32) {
4811 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
4813 /// The number of blocks to include in the query results
4815 pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 {
4816 let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
4819 /// The number of blocks to include in the query results
4821 pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryChannelRange, mut val: u32) {
4822 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
4824 /// Constructs a new QueryChannelRange given each field
4827 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 {
4828 QueryChannelRange { inner: ObjOps::heap_alloc(nativeQueryChannelRange {
4829 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4830 first_blocknum: first_blocknum_arg,
4831 number_of_blocks: number_of_blocks_arg,
4832 }), is_owned: true }
4834 impl Clone for QueryChannelRange {
4835 fn clone(&self) -> Self {
4837 inner: if <*mut nativeQueryChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
4838 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4844 /// Used only if an object of this type is returned as a trait impl by a method
4845 pub(crate) extern "C" fn QueryChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
4846 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryChannelRange)).clone() })) as *mut c_void
4849 /// Creates a copy of the QueryChannelRange
4850 pub extern "C" fn QueryChannelRange_clone(orig: &QueryChannelRange) -> QueryChannelRange {
4853 /// Checks if two QueryChannelRanges contain equal inner contents.
4854 /// This ignores pointers and is_owned flags and looks at the values in fields.
4855 /// Two objects with NULL inner values will be considered "equal" here.
4857 pub extern "C" fn QueryChannelRange_eq(a: &QueryChannelRange, b: &QueryChannelRange) -> bool {
4858 if a.inner == b.inner { return true; }
4859 if a.inner.is_null() || b.inner.is_null() { return false; }
4860 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4863 use lightning::ln::msgs::ReplyChannelRange as nativeReplyChannelRangeImport;
4864 pub(crate) type nativeReplyChannelRange = nativeReplyChannelRangeImport;
4866 /// A [`reply_channel_range`] message is a reply to a [`QueryChannelRange`]
4869 /// Multiple `reply_channel_range` messages can be sent in reply
4870 /// to a single [`QueryChannelRange`] message. The query recipient makes a
4871 /// best effort to respond based on their local network view which may
4872 /// not be a perfect view of the network. The `short_channel_id`s in the
4873 /// reply are encoded. We only support `encoding_type=0` uncompressed
4874 /// serialization and do not support `encoding_type=1` zlib serialization.
4876 /// [`reply_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages
4879 pub struct ReplyChannelRange {
4880 /// A pointer to the opaque Rust object.
4882 /// Nearly everywhere, inner must be non-null, however in places where
4883 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4884 pub inner: *mut nativeReplyChannelRange,
4885 /// Indicates that this is the only struct which contains the same pointer.
4887 /// Rust functions which take ownership of an object provided via an argument require
4888 /// this to be true and invalidate the object pointed to by inner.
4892 impl Drop for ReplyChannelRange {
4893 fn drop(&mut self) {
4894 if self.is_owned && !<*mut nativeReplyChannelRange>::is_null(self.inner) {
4895 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4899 /// Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL.
4901 pub extern "C" fn ReplyChannelRange_free(this_obj: ReplyChannelRange) { }
4903 /// Used only if an object of this type is returned as a trait impl by a method
4904 pub(crate) extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) {
4905 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeReplyChannelRange) };
4908 impl ReplyChannelRange {
4909 pub(crate) fn get_native_ref(&self) -> &'static nativeReplyChannelRange {
4910 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4912 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyChannelRange {
4913 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4915 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4916 pub(crate) fn take_inner(mut self) -> *mut nativeReplyChannelRange {
4917 assert!(self.is_owned);
4918 let ret = ObjOps::untweak_ptr(self.inner);
4919 self.inner = core::ptr::null_mut();
4923 /// The genesis hash of the blockchain being queried
4925 pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *const [u8; 32] {
4926 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4927 inner_val.as_inner()
4929 /// The genesis hash of the blockchain being queried
4931 pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
4932 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4934 /// The height of the first block in the range of the reply
4936 pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 {
4937 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
4940 /// The height of the first block in the range of the reply
4942 pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChannelRange, mut val: u32) {
4943 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
4945 /// The number of blocks included in the range of the reply
4947 pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 {
4948 let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
4951 /// The number of blocks included in the range of the reply
4953 pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyChannelRange, mut val: u32) {
4954 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
4956 /// True when this is the final reply for a query
4958 pub extern "C" fn ReplyChannelRange_get_sync_complete(this_ptr: &ReplyChannelRange) -> bool {
4959 let mut inner_val = &mut this_ptr.get_native_mut_ref().sync_complete;
4962 /// True when this is the final reply for a query
4964 pub extern "C" fn ReplyChannelRange_set_sync_complete(this_ptr: &mut ReplyChannelRange, mut val: bool) {
4965 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sync_complete = val;
4967 /// The `short_channel_id`s in the channel range
4969 /// Returns a copy of the field.
4971 pub extern "C" fn ReplyChannelRange_get_short_channel_ids(this_ptr: &ReplyChannelRange) -> crate::c_types::derived::CVec_u64Z {
4972 let mut inner_val = this_ptr.get_native_mut_ref().short_channel_ids.clone();
4973 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
4974 local_inner_val.into()
4976 /// The `short_channel_id`s in the channel range
4978 pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::derived::CVec_u64Z) {
4979 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
4980 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
4982 /// Constructs a new ReplyChannelRange given each field
4985 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 {
4986 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 }); };
4987 ReplyChannelRange { inner: ObjOps::heap_alloc(nativeReplyChannelRange {
4988 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4989 first_blocknum: first_blocknum_arg,
4990 number_of_blocks: number_of_blocks_arg,
4991 sync_complete: sync_complete_arg,
4992 short_channel_ids: local_short_channel_ids_arg,
4993 }), is_owned: true }
4995 impl Clone for ReplyChannelRange {
4996 fn clone(&self) -> Self {
4998 inner: if <*mut nativeReplyChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
4999 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5005 /// Used only if an object of this type is returned as a trait impl by a method
5006 pub(crate) extern "C" fn ReplyChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
5007 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyChannelRange)).clone() })) as *mut c_void
5010 /// Creates a copy of the ReplyChannelRange
5011 pub extern "C" fn ReplyChannelRange_clone(orig: &ReplyChannelRange) -> ReplyChannelRange {
5014 /// Checks if two ReplyChannelRanges contain equal inner contents.
5015 /// This ignores pointers and is_owned flags and looks at the values in fields.
5016 /// Two objects with NULL inner values will be considered "equal" here.
5018 pub extern "C" fn ReplyChannelRange_eq(a: &ReplyChannelRange, b: &ReplyChannelRange) -> bool {
5019 if a.inner == b.inner { return true; }
5020 if a.inner.is_null() || b.inner.is_null() { return false; }
5021 if a.get_native_ref() == b.get_native_ref() { true } else { false }
5024 use lightning::ln::msgs::QueryShortChannelIds as nativeQueryShortChannelIdsImport;
5025 pub(crate) type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport;
5027 /// A [`query_short_channel_ids`] message is used to query a peer for
5028 /// routing gossip messages related to one or more `short_channel_id`s.
5030 /// The query recipient will reply with the latest, if available,
5031 /// [`ChannelAnnouncement`], [`ChannelUpdate`] and [`NodeAnnouncement`] messages
5032 /// it maintains for the requested `short_channel_id`s followed by a
5033 /// [`ReplyShortChannelIdsEnd`] message. The `short_channel_id`s sent in
5034 /// this query are encoded. We only support `encoding_type=0` uncompressed
5035 /// serialization and do not support `encoding_type=1` zlib serialization.
5037 /// [`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
5040 pub struct QueryShortChannelIds {
5041 /// A pointer to the opaque Rust object.
5043 /// Nearly everywhere, inner must be non-null, however in places where
5044 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5045 pub inner: *mut nativeQueryShortChannelIds,
5046 /// Indicates that this is the only struct which contains the same pointer.
5048 /// Rust functions which take ownership of an object provided via an argument require
5049 /// this to be true and invalidate the object pointed to by inner.
5053 impl Drop for QueryShortChannelIds {
5054 fn drop(&mut self) {
5055 if self.is_owned && !<*mut nativeQueryShortChannelIds>::is_null(self.inner) {
5056 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5060 /// Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL.
5062 pub extern "C" fn QueryShortChannelIds_free(this_obj: QueryShortChannelIds) { }
5064 /// Used only if an object of this type is returned as a trait impl by a method
5065 pub(crate) extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) {
5066 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeQueryShortChannelIds) };
5069 impl QueryShortChannelIds {
5070 pub(crate) fn get_native_ref(&self) -> &'static nativeQueryShortChannelIds {
5071 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5073 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryShortChannelIds {
5074 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5076 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5077 pub(crate) fn take_inner(mut self) -> *mut nativeQueryShortChannelIds {
5078 assert!(self.is_owned);
5079 let ret = ObjOps::untweak_ptr(self.inner);
5080 self.inner = core::ptr::null_mut();
5084 /// The genesis hash of the blockchain being queried
5086 pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *const [u8; 32] {
5087 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
5088 inner_val.as_inner()
5090 /// The genesis hash of the blockchain being queried
5092 pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::ThirtyTwoBytes) {
5093 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
5095 /// The short_channel_ids that are being queried
5097 /// Returns a copy of the field.
5099 pub extern "C" fn QueryShortChannelIds_get_short_channel_ids(this_ptr: &QueryShortChannelIds) -> crate::c_types::derived::CVec_u64Z {
5100 let mut inner_val = this_ptr.get_native_mut_ref().short_channel_ids.clone();
5101 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
5102 local_inner_val.into()
5104 /// The short_channel_ids that are being queried
5106 pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::derived::CVec_u64Z) {
5107 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
5108 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
5110 /// Constructs a new QueryShortChannelIds given each field
5113 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 {
5114 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 }); };
5115 QueryShortChannelIds { inner: ObjOps::heap_alloc(nativeQueryShortChannelIds {
5116 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
5117 short_channel_ids: local_short_channel_ids_arg,
5118 }), is_owned: true }
5120 impl Clone for QueryShortChannelIds {
5121 fn clone(&self) -> Self {
5123 inner: if <*mut nativeQueryShortChannelIds>::is_null(self.inner) { core::ptr::null_mut() } else {
5124 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5130 /// Used only if an object of this type is returned as a trait impl by a method
5131 pub(crate) extern "C" fn QueryShortChannelIds_clone_void(this_ptr: *const c_void) -> *mut c_void {
5132 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryShortChannelIds)).clone() })) as *mut c_void
5135 /// Creates a copy of the QueryShortChannelIds
5136 pub extern "C" fn QueryShortChannelIds_clone(orig: &QueryShortChannelIds) -> QueryShortChannelIds {
5139 /// Checks if two QueryShortChannelIdss contain equal inner contents.
5140 /// This ignores pointers and is_owned flags and looks at the values in fields.
5141 /// Two objects with NULL inner values will be considered "equal" here.
5143 pub extern "C" fn QueryShortChannelIds_eq(a: &QueryShortChannelIds, b: &QueryShortChannelIds) -> bool {
5144 if a.inner == b.inner { return true; }
5145 if a.inner.is_null() || b.inner.is_null() { return false; }
5146 if a.get_native_ref() == b.get_native_ref() { true } else { false }
5149 use lightning::ln::msgs::ReplyShortChannelIdsEnd as nativeReplyShortChannelIdsEndImport;
5150 pub(crate) type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport;
5152 /// A [`reply_short_channel_ids_end`] message is sent as a reply to a
5153 /// message. The query recipient makes a best
5154 /// effort to respond based on their local network view which may not be
5155 /// a perfect view of the network.
5157 /// [`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
5160 pub struct ReplyShortChannelIdsEnd {
5161 /// A pointer to the opaque Rust object.
5163 /// Nearly everywhere, inner must be non-null, however in places where
5164 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5165 pub inner: *mut nativeReplyShortChannelIdsEnd,
5166 /// Indicates that this is the only struct which contains the same pointer.
5168 /// Rust functions which take ownership of an object provided via an argument require
5169 /// this to be true and invalidate the object pointed to by inner.
5173 impl Drop for ReplyShortChannelIdsEnd {
5174 fn drop(&mut self) {
5175 if self.is_owned && !<*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) {
5176 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5180 /// Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL.
5182 pub extern "C" fn ReplyShortChannelIdsEnd_free(this_obj: ReplyShortChannelIdsEnd) { }
5184 /// Used only if an object of this type is returned as a trait impl by a method
5185 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) {
5186 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeReplyShortChannelIdsEnd) };
5189 impl ReplyShortChannelIdsEnd {
5190 pub(crate) fn get_native_ref(&self) -> &'static nativeReplyShortChannelIdsEnd {
5191 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5193 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyShortChannelIdsEnd {
5194 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5196 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5197 pub(crate) fn take_inner(mut self) -> *mut nativeReplyShortChannelIdsEnd {
5198 assert!(self.is_owned);
5199 let ret = ObjOps::untweak_ptr(self.inner);
5200 self.inner = core::ptr::null_mut();
5204 /// The genesis hash of the blockchain that was queried
5206 pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *const [u8; 32] {
5207 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
5208 inner_val.as_inner()
5210 /// The genesis hash of the blockchain that was queried
5212 pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) {
5213 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
5215 /// Indicates if the query recipient maintains up-to-date channel
5216 /// information for the `chain_hash`
5218 pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool {
5219 let mut inner_val = &mut this_ptr.get_native_mut_ref().full_information;
5222 /// Indicates if the query recipient maintains up-to-date channel
5223 /// information for the `chain_hash`
5225 pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: bool) {
5226 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.full_information = val;
5228 /// Constructs a new ReplyShortChannelIdsEnd given each field
5231 pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd {
5232 ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(nativeReplyShortChannelIdsEnd {
5233 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
5234 full_information: full_information_arg,
5235 }), is_owned: true }
5237 impl Clone for ReplyShortChannelIdsEnd {
5238 fn clone(&self) -> Self {
5240 inner: if <*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) { core::ptr::null_mut() } else {
5241 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5247 /// Used only if an object of this type is returned as a trait impl by a method
5248 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_void) -> *mut c_void {
5249 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyShortChannelIdsEnd)).clone() })) as *mut c_void
5252 /// Creates a copy of the ReplyShortChannelIdsEnd
5253 pub extern "C" fn ReplyShortChannelIdsEnd_clone(orig: &ReplyShortChannelIdsEnd) -> ReplyShortChannelIdsEnd {
5256 /// Checks if two ReplyShortChannelIdsEnds contain equal inner contents.
5257 /// This ignores pointers and is_owned flags and looks at the values in fields.
5258 /// Two objects with NULL inner values will be considered "equal" here.
5260 pub extern "C" fn ReplyShortChannelIdsEnd_eq(a: &ReplyShortChannelIdsEnd, b: &ReplyShortChannelIdsEnd) -> bool {
5261 if a.inner == b.inner { return true; }
5262 if a.inner.is_null() || b.inner.is_null() { return false; }
5263 if a.get_native_ref() == b.get_native_ref() { true } else { false }
5266 use lightning::ln::msgs::GossipTimestampFilter as nativeGossipTimestampFilterImport;
5267 pub(crate) type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport;
5269 /// A [`gossip_timestamp_filter`] message is used by a node to request
5270 /// gossip relay for messages in the requested time range when the
5271 /// `gossip_queries` feature has been negotiated.
5273 /// [`gossip_timestamp_filter`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-gossip_timestamp_filter-message
5276 pub struct GossipTimestampFilter {
5277 /// A pointer to the opaque Rust object.
5279 /// Nearly everywhere, inner must be non-null, however in places where
5280 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5281 pub inner: *mut nativeGossipTimestampFilter,
5282 /// Indicates that this is the only struct which contains the same pointer.
5284 /// Rust functions which take ownership of an object provided via an argument require
5285 /// this to be true and invalidate the object pointed to by inner.
5289 impl Drop for GossipTimestampFilter {
5290 fn drop(&mut self) {
5291 if self.is_owned && !<*mut nativeGossipTimestampFilter>::is_null(self.inner) {
5292 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5296 /// Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL.
5298 pub extern "C" fn GossipTimestampFilter_free(this_obj: GossipTimestampFilter) { }
5300 /// Used only if an object of this type is returned as a trait impl by a method
5301 pub(crate) extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) {
5302 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeGossipTimestampFilter) };
5305 impl GossipTimestampFilter {
5306 pub(crate) fn get_native_ref(&self) -> &'static nativeGossipTimestampFilter {
5307 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5309 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeGossipTimestampFilter {
5310 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5312 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5313 pub(crate) fn take_inner(mut self) -> *mut nativeGossipTimestampFilter {
5314 assert!(self.is_owned);
5315 let ret = ObjOps::untweak_ptr(self.inner);
5316 self.inner = core::ptr::null_mut();
5320 /// The genesis hash of the blockchain for channel and node information
5322 pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *const [u8; 32] {
5323 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
5324 inner_val.as_inner()
5326 /// The genesis hash of the blockchain for channel and node information
5328 pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) {
5329 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
5331 /// The starting unix timestamp
5333 pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 {
5334 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_timestamp;
5337 /// The starting unix timestamp
5339 pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
5340 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_timestamp = val;
5342 /// The range of information in seconds
5344 pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 {
5345 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp_range;
5348 /// The range of information in seconds
5350 pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
5351 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp_range = val;
5353 /// Constructs a new GossipTimestampFilter given each field
5356 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 {
5357 GossipTimestampFilter { inner: ObjOps::heap_alloc(nativeGossipTimestampFilter {
5358 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
5359 first_timestamp: first_timestamp_arg,
5360 timestamp_range: timestamp_range_arg,
5361 }), is_owned: true }
5363 impl Clone for GossipTimestampFilter {
5364 fn clone(&self) -> Self {
5366 inner: if <*mut nativeGossipTimestampFilter>::is_null(self.inner) { core::ptr::null_mut() } else {
5367 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5373 /// Used only if an object of this type is returned as a trait impl by a method
5374 pub(crate) extern "C" fn GossipTimestampFilter_clone_void(this_ptr: *const c_void) -> *mut c_void {
5375 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeGossipTimestampFilter)).clone() })) as *mut c_void
5378 /// Creates a copy of the GossipTimestampFilter
5379 pub extern "C" fn GossipTimestampFilter_clone(orig: &GossipTimestampFilter) -> GossipTimestampFilter {
5382 /// Checks if two GossipTimestampFilters contain equal inner contents.
5383 /// This ignores pointers and is_owned flags and looks at the values in fields.
5384 /// Two objects with NULL inner values will be considered "equal" here.
5386 pub extern "C" fn GossipTimestampFilter_eq(a: &GossipTimestampFilter, b: &GossipTimestampFilter) -> bool {
5387 if a.inner == b.inner { return true; }
5388 if a.inner.is_null() || b.inner.is_null() { return false; }
5389 if a.get_native_ref() == b.get_native_ref() { true } else { false }
5391 /// Used to put an error message in a [`LightningError`].
5395 pub enum ErrorAction {
5396 /// The peer took some action which made us think they were useless. Disconnect them.
5398 /// An error message which we should make an effort to send before we disconnect.
5400 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
5401 msg: crate::lightning::ln::msgs::ErrorMessage,
5403 /// The peer did something harmless that we weren't able to process, just log and ignore
5405 /// The peer did something harmless that we weren't able to meaningfully process.
5406 /// If the error is logged, log it at the given level.
5408 crate::lightning::util::logger::Level),
5409 /// The peer provided us with a gossip message which we'd already seen. In most cases this
5410 /// should be ignored, but it may result in the message being forwarded if it is a duplicate of
5411 /// our own channel announcements.
5412 IgnoreDuplicateGossip,
5413 /// The peer did something incorrect. Tell them.
5415 /// The message to send.
5416 msg: crate::lightning::ln::msgs::ErrorMessage,
5418 /// The peer did something incorrect. Tell them without closing any channels.
5419 SendWarningMessage {
5420 /// The message to send.
5421 msg: crate::lightning::ln::msgs::WarningMessage,
5422 /// The peer may have done something harmless that we weren't able to meaningfully process,
5423 /// though we should still tell them about it.
5424 /// If this event is logged, log it at the given level.
5425 log_level: crate::lightning::util::logger::Level,
5428 use lightning::ln::msgs::ErrorAction as ErrorActionImport;
5429 pub(crate) type nativeErrorAction = ErrorActionImport;
5433 pub(crate) fn to_native(&self) -> nativeErrorAction {
5435 ErrorAction::DisconnectPeer {ref msg, } => {
5436 let mut msg_nonref = Clone::clone(msg);
5437 let mut local_msg_nonref = if msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg_nonref.take_inner()) } }) };
5438 nativeErrorAction::DisconnectPeer {
5439 msg: local_msg_nonref,
5442 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
5443 ErrorAction::IgnoreAndLog (ref a, ) => {
5444 let mut a_nonref = Clone::clone(a);
5445 nativeErrorAction::IgnoreAndLog (
5446 a_nonref.into_native(),
5449 ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
5450 ErrorAction::SendErrorMessage {ref msg, } => {
5451 let mut msg_nonref = Clone::clone(msg);
5452 nativeErrorAction::SendErrorMessage {
5453 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
5456 ErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
5457 let mut msg_nonref = Clone::clone(msg);
5458 let mut log_level_nonref = Clone::clone(log_level);
5459 nativeErrorAction::SendWarningMessage {
5460 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
5461 log_level: log_level_nonref.into_native(),
5467 pub(crate) fn into_native(self) -> nativeErrorAction {
5469 ErrorAction::DisconnectPeer {mut msg, } => {
5470 let mut local_msg = if msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg.take_inner()) } }) };
5471 nativeErrorAction::DisconnectPeer {
5475 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
5476 ErrorAction::IgnoreAndLog (mut a, ) => {
5477 nativeErrorAction::IgnoreAndLog (
5481 ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
5482 ErrorAction::SendErrorMessage {mut msg, } => {
5483 nativeErrorAction::SendErrorMessage {
5484 msg: *unsafe { Box::from_raw(msg.take_inner()) },
5487 ErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
5488 nativeErrorAction::SendWarningMessage {
5489 msg: *unsafe { Box::from_raw(msg.take_inner()) },
5490 log_level: log_level.into_native(),
5496 pub(crate) fn from_native(native: &nativeErrorAction) -> Self {
5498 nativeErrorAction::DisconnectPeer {ref msg, } => {
5499 let mut msg_nonref = Clone::clone(msg);
5500 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 };
5501 ErrorAction::DisconnectPeer {
5502 msg: local_msg_nonref,
5505 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
5506 nativeErrorAction::IgnoreAndLog (ref a, ) => {
5507 let mut a_nonref = Clone::clone(a);
5508 ErrorAction::IgnoreAndLog (
5509 crate::lightning::util::logger::Level::native_into(a_nonref),
5512 nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
5513 nativeErrorAction::SendErrorMessage {ref msg, } => {
5514 let mut msg_nonref = Clone::clone(msg);
5515 ErrorAction::SendErrorMessage {
5516 msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
5519 nativeErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
5520 let mut msg_nonref = Clone::clone(msg);
5521 let mut log_level_nonref = Clone::clone(log_level);
5522 ErrorAction::SendWarningMessage {
5523 msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
5524 log_level: crate::lightning::util::logger::Level::native_into(log_level_nonref),
5530 pub(crate) fn native_into(native: nativeErrorAction) -> Self {
5532 nativeErrorAction::DisconnectPeer {mut msg, } => {
5533 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 };
5534 ErrorAction::DisconnectPeer {
5538 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
5539 nativeErrorAction::IgnoreAndLog (mut a, ) => {
5540 ErrorAction::IgnoreAndLog (
5541 crate::lightning::util::logger::Level::native_into(a),
5544 nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
5545 nativeErrorAction::SendErrorMessage {mut msg, } => {
5546 ErrorAction::SendErrorMessage {
5547 msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
5550 nativeErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
5551 ErrorAction::SendWarningMessage {
5552 msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
5553 log_level: crate::lightning::util::logger::Level::native_into(log_level),
5559 /// Frees any resources used by the ErrorAction
5561 pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { }
5562 /// Creates a copy of the ErrorAction
5564 pub extern "C" fn ErrorAction_clone(orig: &ErrorAction) -> ErrorAction {
5568 /// Utility method to constructs a new DisconnectPeer-variant ErrorAction
5569 pub extern "C" fn ErrorAction_disconnect_peer(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
5570 ErrorAction::DisconnectPeer {
5575 /// Utility method to constructs a new IgnoreError-variant ErrorAction
5576 pub extern "C" fn ErrorAction_ignore_error() -> ErrorAction {
5577 ErrorAction::IgnoreError}
5579 /// Utility method to constructs a new IgnoreAndLog-variant ErrorAction
5580 pub extern "C" fn ErrorAction_ignore_and_log(a: crate::lightning::util::logger::Level) -> ErrorAction {
5581 ErrorAction::IgnoreAndLog(a, )
5584 /// Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction
5585 pub extern "C" fn ErrorAction_ignore_duplicate_gossip() -> ErrorAction {
5586 ErrorAction::IgnoreDuplicateGossip}
5588 /// Utility method to constructs a new SendErrorMessage-variant ErrorAction
5589 pub extern "C" fn ErrorAction_send_error_message(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
5590 ErrorAction::SendErrorMessage {
5595 /// Utility method to constructs a new SendWarningMessage-variant ErrorAction
5596 pub extern "C" fn ErrorAction_send_warning_message(msg: crate::lightning::ln::msgs::WarningMessage, log_level: crate::lightning::util::logger::Level) -> ErrorAction {
5597 ErrorAction::SendWarningMessage {
5603 use lightning::ln::msgs::LightningError as nativeLightningErrorImport;
5604 pub(crate) type nativeLightningError = nativeLightningErrorImport;
5606 /// An Err type for failure to process messages.
5609 pub struct LightningError {
5610 /// A pointer to the opaque Rust object.
5612 /// Nearly everywhere, inner must be non-null, however in places where
5613 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5614 pub inner: *mut nativeLightningError,
5615 /// Indicates that this is the only struct which contains the same pointer.
5617 /// Rust functions which take ownership of an object provided via an argument require
5618 /// this to be true and invalidate the object pointed to by inner.
5622 impl Drop for LightningError {
5623 fn drop(&mut self) {
5624 if self.is_owned && !<*mut nativeLightningError>::is_null(self.inner) {
5625 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5629 /// Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL.
5631 pub extern "C" fn LightningError_free(this_obj: LightningError) { }
5633 /// Used only if an object of this type is returned as a trait impl by a method
5634 pub(crate) extern "C" fn LightningError_free_void(this_ptr: *mut c_void) {
5635 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLightningError) };
5638 impl LightningError {
5639 pub(crate) fn get_native_ref(&self) -> &'static nativeLightningError {
5640 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5642 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLightningError {
5643 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5645 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5646 pub(crate) fn take_inner(mut self) -> *mut nativeLightningError {
5647 assert!(self.is_owned);
5648 let ret = ObjOps::untweak_ptr(self.inner);
5649 self.inner = core::ptr::null_mut();
5653 /// A human-readable message describing the error
5655 pub extern "C" fn LightningError_get_err(this_ptr: &LightningError) -> crate::c_types::Str {
5656 let mut inner_val = &mut this_ptr.get_native_mut_ref().err;
5657 inner_val.as_str().into()
5659 /// A human-readable message describing the error
5661 pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: crate::c_types::Str) {
5662 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.err = val.into_string();
5664 /// The action which should be taken against the offending peer.
5666 pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate::lightning::ln::msgs::ErrorAction {
5667 let mut inner_val = &mut this_ptr.get_native_mut_ref().action;
5668 crate::lightning::ln::msgs::ErrorAction::from_native(inner_val)
5670 /// The action which should be taken against the offending peer.
5672 pub extern "C" fn LightningError_set_action(this_ptr: &mut LightningError, mut val: crate::lightning::ln::msgs::ErrorAction) {
5673 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.action = val.into_native();
5675 /// Constructs a new LightningError given each field
5678 pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::Str, mut action_arg: crate::lightning::ln::msgs::ErrorAction) -> LightningError {
5679 LightningError { inner: ObjOps::heap_alloc(nativeLightningError {
5680 err: err_arg.into_string(),
5681 action: action_arg.into_native(),
5682 }), is_owned: true }
5684 impl Clone for LightningError {
5685 fn clone(&self) -> Self {
5687 inner: if <*mut nativeLightningError>::is_null(self.inner) { core::ptr::null_mut() } else {
5688 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5694 /// Used only if an object of this type is returned as a trait impl by a method
5695 pub(crate) extern "C" fn LightningError_clone_void(this_ptr: *const c_void) -> *mut c_void {
5696 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeLightningError)).clone() })) as *mut c_void
5699 /// Creates a copy of the LightningError
5700 pub extern "C" fn LightningError_clone(orig: &LightningError) -> LightningError {
5704 use lightning::ln::msgs::CommitmentUpdate as nativeCommitmentUpdateImport;
5705 pub(crate) type nativeCommitmentUpdate = nativeCommitmentUpdateImport;
5707 /// Struct used to return values from [`RevokeAndACK`] messages, containing a bunch of commitment
5708 /// transaction updates if they were pending.
5711 pub struct CommitmentUpdate {
5712 /// A pointer to the opaque Rust object.
5714 /// Nearly everywhere, inner must be non-null, however in places where
5715 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5716 pub inner: *mut nativeCommitmentUpdate,
5717 /// Indicates that this is the only struct which contains the same pointer.
5719 /// Rust functions which take ownership of an object provided via an argument require
5720 /// this to be true and invalidate the object pointed to by inner.
5724 impl Drop for CommitmentUpdate {
5725 fn drop(&mut self) {
5726 if self.is_owned && !<*mut nativeCommitmentUpdate>::is_null(self.inner) {
5727 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5731 /// Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL.
5733 pub extern "C" fn CommitmentUpdate_free(this_obj: CommitmentUpdate) { }
5735 /// Used only if an object of this type is returned as a trait impl by a method
5736 pub(crate) extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) {
5737 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCommitmentUpdate) };
5740 impl CommitmentUpdate {
5741 pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentUpdate {
5742 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5744 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentUpdate {
5745 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5747 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5748 pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentUpdate {
5749 assert!(self.is_owned);
5750 let ret = ObjOps::untweak_ptr(self.inner);
5751 self.inner = core::ptr::null_mut();
5755 /// `update_add_htlc` messages which should be sent
5757 pub extern "C" fn CommitmentUpdate_get_update_add_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateAddHTLCZ {
5758 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_add_htlcs;
5759 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 } }); };
5760 local_inner_val.into()
5762 /// `update_add_htlc` messages which should be sent
5764 pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) {
5765 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
5766 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_add_htlcs = local_val;
5768 /// `update_fulfill_htlc` messages which should be sent
5770 pub extern "C" fn CommitmentUpdate_get_update_fulfill_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFulfillHTLCZ {
5771 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fulfill_htlcs;
5772 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 } }); };
5773 local_inner_val.into()
5775 /// `update_fulfill_htlc` messages which should be sent
5777 pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) {
5778 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
5779 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fulfill_htlcs = local_val;
5781 /// `update_fail_htlc` messages which should be sent
5783 pub extern "C" fn CommitmentUpdate_get_update_fail_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailHTLCZ {
5784 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_htlcs;
5785 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 } }); };
5786 local_inner_val.into()
5788 /// `update_fail_htlc` messages which should be sent
5790 pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) {
5791 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
5792 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_htlcs = local_val;
5794 /// `update_fail_malformed_htlc` messages which should be sent
5796 pub extern "C" fn CommitmentUpdate_get_update_fail_malformed_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ {
5797 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_malformed_htlcs;
5798 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 } }); };
5799 local_inner_val.into()
5801 /// `update_fail_malformed_htlc` messages which should be sent
5803 pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) {
5804 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
5805 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_malformed_htlcs = local_val;
5807 /// An `update_fee` message which should be sent
5809 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
5811 pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::UpdateFee {
5812 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fee;
5813 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 };
5816 /// An `update_fee` message which should be sent
5818 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
5820 pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::UpdateFee) {
5821 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
5822 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fee = local_val;
5824 /// A `commitment_signed` message which should be sent
5826 pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::CommitmentSigned {
5827 let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_signed;
5828 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 }
5830 /// A `commitment_signed` message which should be sent
5832 pub extern "C" fn CommitmentUpdate_set_commitment_signed(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::CommitmentSigned) {
5833 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_signed = *unsafe { Box::from_raw(val.take_inner()) };
5835 /// Constructs a new CommitmentUpdate given each field
5838 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 {
5839 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()) } }); };
5840 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()) } }); };
5841 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()) } }); };
5842 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()) } }); };
5843 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()) } }) };
5844 CommitmentUpdate { inner: ObjOps::heap_alloc(nativeCommitmentUpdate {
5845 update_add_htlcs: local_update_add_htlcs_arg,
5846 update_fulfill_htlcs: local_update_fulfill_htlcs_arg,
5847 update_fail_htlcs: local_update_fail_htlcs_arg,
5848 update_fail_malformed_htlcs: local_update_fail_malformed_htlcs_arg,
5849 update_fee: local_update_fee_arg,
5850 commitment_signed: *unsafe { Box::from_raw(commitment_signed_arg.take_inner()) },
5851 }), is_owned: true }
5853 impl Clone for CommitmentUpdate {
5854 fn clone(&self) -> Self {
5856 inner: if <*mut nativeCommitmentUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
5857 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5863 /// Used only if an object of this type is returned as a trait impl by a method
5864 pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
5865 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentUpdate)).clone() })) as *mut c_void
5868 /// Creates a copy of the CommitmentUpdate
5869 pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentUpdate {
5872 /// Checks if two CommitmentUpdates contain equal inner contents.
5873 /// This ignores pointers and is_owned flags and looks at the values in fields.
5874 /// Two objects with NULL inner values will be considered "equal" here.
5876 pub extern "C" fn CommitmentUpdate_eq(a: &CommitmentUpdate, b: &CommitmentUpdate) -> bool {
5877 if a.inner == b.inner { return true; }
5878 if a.inner.is_null() || b.inner.is_null() { return false; }
5879 if a.get_native_ref() == b.get_native_ref() { true } else { false }
5881 /// A trait to describe an object which can receive channel messages.
5883 /// Messages MAY be called in parallel when they originate from different `their_node_ids`, however
5884 /// they MUST NOT be called in parallel when the two calls have the same `their_node_id`.
5886 pub struct ChannelMessageHandler {
5887 /// An opaque pointer which is passed to your function implementations as an argument.
5888 /// This has no meaning in the LDK, and can be NULL or any other value.
5889 pub this_arg: *mut c_void,
5890 /// Handle an incoming `open_channel` message from the given peer.
5891 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),
5892 /// Handle an incoming `accept_channel` message from the given peer.
5893 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),
5894 /// Handle an incoming `funding_created` message from the given peer.
5895 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),
5896 /// Handle an incoming `funding_signed` message from the given peer.
5897 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),
5898 /// Handle an incoming `channel_ready` message from the given peer.
5899 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),
5900 /// Handle an incoming `shutdown` message from the given peer.
5901 pub handle_shutdown: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Shutdown),
5902 /// Handle an incoming `closing_signed` message from the given peer.
5903 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),
5904 /// Handle an incoming `update_add_htlc` message from the given peer.
5905 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),
5906 /// Handle an incoming `update_fulfill_htlc` message from the given peer.
5907 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),
5908 /// Handle an incoming `update_fail_htlc` message from the given peer.
5909 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),
5910 /// Handle an incoming `update_fail_malformed_htlc` message from the given peer.
5911 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),
5912 /// Handle an incoming `commitment_signed` message from the given peer.
5913 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),
5914 /// Handle an incoming `revoke_and_ack` message from the given peer.
5915 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),
5916 /// Handle an incoming `update_fee` message from the given peer.
5917 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),
5918 /// Handle an incoming `announcement_signatures` message from the given peer.
5919 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),
5920 /// Indicates a connection to the peer failed/an existing connection was lost.
5921 pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey),
5922 /// Handle a peer reconnecting, possibly generating `channel_reestablish` message(s).
5924 /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
5925 /// with us. Implementors should be somewhat conservative about doing so, however, as other
5926 /// message handlers may still wish to communicate with this peer.
5928 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,
5929 /// Handle an incoming `channel_reestablish` message from the given peer.
5930 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),
5931 /// Handle an incoming `channel_update` message from the given peer.
5932 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),
5933 /// Handle an incoming `error` message from the given peer.
5934 pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ErrorMessage),
5935 /// Gets the node feature flags which this handler itself supports. All available handlers are
5936 /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
5937 /// which are broadcasted in our [`NodeAnnouncement`] message.
5939 pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
5940 /// Gets the init feature flags which should be sent to the given peer. All available handlers
5941 /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
5942 /// which are sent in our [`Init`] message.
5944 /// Note that this method is called before [`Self::peer_connected`].
5946 pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
5947 /// Implementation of MessageSendEventsProvider for this object.
5948 pub MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider,
5949 /// Frees any resources associated with this object given its this_arg pointer.
5950 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
5951 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
5953 unsafe impl Send for ChannelMessageHandler {}
5954 unsafe impl Sync for ChannelMessageHandler {}
5956 pub(crate) extern "C" fn ChannelMessageHandler_clone_fields(orig: &ChannelMessageHandler) -> ChannelMessageHandler {
5957 ChannelMessageHandler {
5958 this_arg: orig.this_arg,
5959 handle_open_channel: Clone::clone(&orig.handle_open_channel),
5960 handle_accept_channel: Clone::clone(&orig.handle_accept_channel),
5961 handle_funding_created: Clone::clone(&orig.handle_funding_created),
5962 handle_funding_signed: Clone::clone(&orig.handle_funding_signed),
5963 handle_channel_ready: Clone::clone(&orig.handle_channel_ready),
5964 handle_shutdown: Clone::clone(&orig.handle_shutdown),
5965 handle_closing_signed: Clone::clone(&orig.handle_closing_signed),
5966 handle_update_add_htlc: Clone::clone(&orig.handle_update_add_htlc),
5967 handle_update_fulfill_htlc: Clone::clone(&orig.handle_update_fulfill_htlc),
5968 handle_update_fail_htlc: Clone::clone(&orig.handle_update_fail_htlc),
5969 handle_update_fail_malformed_htlc: Clone::clone(&orig.handle_update_fail_malformed_htlc),
5970 handle_commitment_signed: Clone::clone(&orig.handle_commitment_signed),
5971 handle_revoke_and_ack: Clone::clone(&orig.handle_revoke_and_ack),
5972 handle_update_fee: Clone::clone(&orig.handle_update_fee),
5973 handle_announcement_signatures: Clone::clone(&orig.handle_announcement_signatures),
5974 peer_disconnected: Clone::clone(&orig.peer_disconnected),
5975 peer_connected: Clone::clone(&orig.peer_connected),
5976 handle_channel_reestablish: Clone::clone(&orig.handle_channel_reestablish),
5977 handle_channel_update: Clone::clone(&orig.handle_channel_update),
5978 handle_error: Clone::clone(&orig.handle_error),
5979 provided_node_features: Clone::clone(&orig.provided_node_features),
5980 provided_init_features: Clone::clone(&orig.provided_init_features),
5981 MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
5982 free: Clone::clone(&orig.free),
5985 impl lightning::events::MessageSendEventsProvider for ChannelMessageHandler {
5986 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::events::MessageSendEvent> {
5987 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
5988 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
5993 use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler;
5994 impl rustChannelMessageHandler for ChannelMessageHandler {
5995 fn handle_open_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OpenChannel) {
5996 (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 })
5998 fn handle_accept_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AcceptChannel) {
5999 (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 })
6001 fn handle_funding_created(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingCreated) {
6002 (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 })
6004 fn handle_funding_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingSigned) {
6005 (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 })
6007 fn handle_channel_ready(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReady) {
6008 (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 })
6010 fn handle_shutdown(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Shutdown) {
6011 (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 })
6013 fn handle_closing_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ClosingSigned) {
6014 (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 })
6016 fn handle_update_add_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateAddHTLC) {
6017 (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 })
6019 fn handle_update_fulfill_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFulfillHTLC) {
6020 (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 })
6022 fn handle_update_fail_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailHTLC) {
6023 (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 })
6025 fn handle_update_fail_malformed_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) {
6026 (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 })
6028 fn handle_commitment_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::CommitmentSigned) {
6029 (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 })
6031 fn handle_revoke_and_ack(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::RevokeAndACK) {
6032 (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 })
6034 fn handle_update_fee(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFee) {
6035 (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 })
6037 fn handle_announcement_signatures(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AnnouncementSignatures) {
6038 (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 })
6040 fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) {
6041 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id))
6043 fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
6044 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);
6045 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)) })*/ })};
6048 fn handle_channel_reestablish(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReestablish) {
6049 (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 })
6051 fn handle_channel_update(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelUpdate) {
6052 (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 })
6054 fn handle_error(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ErrorMessage) {
6055 (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 })
6057 fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
6058 let mut ret = (self.provided_node_features)(self.this_arg);
6059 *unsafe { Box::from_raw(ret.take_inner()) }
6061 fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
6062 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
6063 *unsafe { Box::from_raw(ret.take_inner()) }
6067 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
6068 // directly as a Deref trait in higher-level structs:
6069 impl core::ops::Deref for ChannelMessageHandler {
6071 fn deref(&self) -> &Self {
6075 /// Calls the free function if one is set
6077 pub extern "C" fn ChannelMessageHandler_free(this_ptr: ChannelMessageHandler) { }
6078 impl Drop for ChannelMessageHandler {
6079 fn drop(&mut self) {
6080 if let Some(f) = self.free {
6085 /// A trait to describe an object which can receive routing messages.
6087 /// # Implementor DoS Warnings
6089 /// For messages enabled with the `gossip_queries` feature there are potential DoS vectors when
6090 /// handling inbound queries. Implementors using an on-disk network graph should be aware of
6091 /// repeated disk I/O for queries accessing different parts of the network graph.
6093 pub struct RoutingMessageHandler {
6094 /// An opaque pointer which is passed to your function implementations as an argument.
6095 /// This has no meaning in the LDK, and can be NULL or any other value.
6096 pub this_arg: *mut c_void,
6097 /// Handle an incoming `node_announcement` message, returning `true` if it should be forwarded on,
6098 /// `false` or returning an `Err` otherwise.
6100 pub handle_node_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
6101 /// Handle a `channel_announcement` message, returning `true` if it should be forwarded on, `false`
6102 /// or returning an `Err` otherwise.
6104 pub handle_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
6105 /// Handle an incoming `channel_update` message, returning true if it should be forwarded on,
6106 /// `false` or returning an `Err` otherwise.
6108 pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ,
6109 /// Gets channel announcements and updates required to dump our routing table to a remote node,
6110 /// starting at the `short_channel_id` indicated by `starting_point` and including announcements
6111 /// for a single channel.
6113 pub get_next_channel_announcement: extern "C" fn (this_arg: *const c_void, starting_point: u64) -> crate::c_types::derived::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ,
6114 /// Gets a node announcement required to dump our routing table to a remote node, starting at
6115 /// the node *after* the provided pubkey and including up to one announcement immediately
6116 /// higher (as defined by `<PublicKey as Ord>::cmp`) than `starting_point`.
6117 /// If `None` is provided for `starting_point`, we start at the first node.
6119 /// Note that starting_point (or a relevant inner pointer) may be NULL or all-0s to represent None
6120 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
6122 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,
6123 /// Called when a connection is established with a peer. This can be used to
6124 /// perform routing table synchronization using a strategy defined by the
6127 /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
6128 /// with us. Implementors should be somewhat conservative about doing so, however, as other
6129 /// message handlers may still wish to communicate with this peer.
6131 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,
6132 /// Handles the reply of a query we initiated to learn about channels
6133 /// for a given range of blocks. We can expect to receive one or more
6134 /// replies to a single query.
6136 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,
6137 /// Handles the reply of a query we initiated asking for routing gossip
6138 /// messages for a list of channels. We should receive this message when
6139 /// a node has completed its best effort to send us the pertaining routing
6140 /// gossip messages.
6142 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,
6143 /// Handles when a peer asks us to send a list of `short_channel_id`s
6144 /// for the requested range of blocks.
6146 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,
6147 /// Handles when a peer asks us to send routing gossip messages for a
6148 /// list of `short_channel_id`s.
6150 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,
6151 /// Indicates that there are a large number of [`ChannelAnnouncement`] (or other) messages
6152 /// pending some async action. While there is no guarantee of the rate of future messages, the
6153 /// caller should seek to reduce the rate of new gossip messages handled, especially
6154 /// [`ChannelAnnouncement`]s.
6156 pub processing_queue_high: extern "C" fn (this_arg: *const c_void) -> bool,
6157 /// Gets the node feature flags which this handler itself supports. All available handlers are
6158 /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
6159 /// which are broadcasted in our [`NodeAnnouncement`] message.
6161 pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
6162 /// Gets the init feature flags which should be sent to the given peer. All available handlers
6163 /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
6164 /// which are sent in our [`Init`] message.
6166 /// Note that this method is called before [`Self::peer_connected`].
6168 pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
6169 /// Implementation of MessageSendEventsProvider for this object.
6170 pub MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider,
6171 /// Frees any resources associated with this object given its this_arg pointer.
6172 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
6173 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
6175 unsafe impl Send for RoutingMessageHandler {}
6176 unsafe impl Sync for RoutingMessageHandler {}
6178 pub(crate) extern "C" fn RoutingMessageHandler_clone_fields(orig: &RoutingMessageHandler) -> RoutingMessageHandler {
6179 RoutingMessageHandler {
6180 this_arg: orig.this_arg,
6181 handle_node_announcement: Clone::clone(&orig.handle_node_announcement),
6182 handle_channel_announcement: Clone::clone(&orig.handle_channel_announcement),
6183 handle_channel_update: Clone::clone(&orig.handle_channel_update),
6184 get_next_channel_announcement: Clone::clone(&orig.get_next_channel_announcement),
6185 get_next_node_announcement: Clone::clone(&orig.get_next_node_announcement),
6186 peer_connected: Clone::clone(&orig.peer_connected),
6187 handle_reply_channel_range: Clone::clone(&orig.handle_reply_channel_range),
6188 handle_reply_short_channel_ids_end: Clone::clone(&orig.handle_reply_short_channel_ids_end),
6189 handle_query_channel_range: Clone::clone(&orig.handle_query_channel_range),
6190 handle_query_short_channel_ids: Clone::clone(&orig.handle_query_short_channel_ids),
6191 processing_queue_high: Clone::clone(&orig.processing_queue_high),
6192 provided_node_features: Clone::clone(&orig.provided_node_features),
6193 provided_init_features: Clone::clone(&orig.provided_init_features),
6194 MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
6195 free: Clone::clone(&orig.free),
6198 impl lightning::events::MessageSendEventsProvider for RoutingMessageHandler {
6199 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::events::MessageSendEvent> {
6200 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
6201 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
6206 use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler;
6207 impl rustRoutingMessageHandler for RoutingMessageHandler {
6208 fn handle_node_announcement(&self, mut msg: &lightning::ln::msgs::NodeAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
6209 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 });
6210 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()) } })};
6213 fn handle_channel_announcement(&self, mut msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
6214 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 });
6215 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()) } })};
6218 fn handle_channel_update(&self, mut msg: &lightning::ln::msgs::ChannelUpdate) -> Result<bool, lightning::ln::msgs::LightningError> {
6219 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 });
6220 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()) } })};
6223 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>)> {
6224 let mut ret = (self.get_next_channel_announcement)(self.this_arg, starting_point);
6225 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 };
6228 fn get_next_node_announcement(&self, mut starting_point: Option<&lightning::routing::gossip::NodeId>) -> Option<lightning::ln::msgs::NodeAnnouncement> {
6229 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 };
6230 let mut ret = (self.get_next_node_announcement)(self.this_arg, local_starting_point);
6231 let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) };
6234 fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
6235 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);
6236 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)) })*/ })};
6239 fn handle_reply_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::ReplyChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
6240 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 });
6241 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()) } })};
6244 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> {
6245 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 });
6246 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()) } })};
6249 fn handle_query_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::QueryChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
6250 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 });
6251 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()) } })};
6254 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> {
6255 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 });
6256 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()) } })};
6259 fn processing_queue_high(&self) -> bool {
6260 let mut ret = (self.processing_queue_high)(self.this_arg);
6263 fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
6264 let mut ret = (self.provided_node_features)(self.this_arg);
6265 *unsafe { Box::from_raw(ret.take_inner()) }
6267 fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
6268 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
6269 *unsafe { Box::from_raw(ret.take_inner()) }
6273 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
6274 // directly as a Deref trait in higher-level structs:
6275 impl core::ops::Deref for RoutingMessageHandler {
6277 fn deref(&self) -> &Self {
6281 /// Calls the free function if one is set
6283 pub extern "C" fn RoutingMessageHandler_free(this_ptr: RoutingMessageHandler) { }
6284 impl Drop for RoutingMessageHandler {
6285 fn drop(&mut self) {
6286 if let Some(f) = self.free {
6291 /// A trait to describe an object that can receive onion messages.
6293 pub struct OnionMessageHandler {
6294 /// An opaque pointer which is passed to your function implementations as an argument.
6295 /// This has no meaning in the LDK, and can be NULL or any other value.
6296 pub this_arg: *mut c_void,
6297 /// Handle an incoming `onion_message` message from the given peer.
6298 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),
6299 /// Called when a connection is established with a peer. Can be used to track which peers
6300 /// advertise onion message support and are online.
6302 /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
6303 /// with us. Implementors should be somewhat conservative about doing so, however, as other
6304 /// message handlers may still wish to communicate with this peer.
6306 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,
6307 /// Indicates a connection to the peer failed/an existing connection was lost. Allows handlers to
6308 /// drop and refuse to forward onion messages to this peer.
6309 pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey),
6310 /// Gets the node feature flags which this handler itself supports. All available handlers are
6311 /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
6312 /// which are broadcasted in our [`NodeAnnouncement`] message.
6314 pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
6315 /// Gets the init feature flags which should be sent to the given peer. All available handlers
6316 /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
6317 /// which are sent in our [`Init`] message.
6319 /// Note that this method is called before [`Self::peer_connected`].
6321 pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
6322 /// Implementation of OnionMessageProvider for this object.
6323 pub OnionMessageProvider: crate::lightning::events::OnionMessageProvider,
6324 /// Frees any resources associated with this object given its this_arg pointer.
6325 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
6326 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
6328 unsafe impl Send for OnionMessageHandler {}
6329 unsafe impl Sync for OnionMessageHandler {}
6331 pub(crate) extern "C" fn OnionMessageHandler_clone_fields(orig: &OnionMessageHandler) -> OnionMessageHandler {
6332 OnionMessageHandler {
6333 this_arg: orig.this_arg,
6334 handle_onion_message: Clone::clone(&orig.handle_onion_message),
6335 peer_connected: Clone::clone(&orig.peer_connected),
6336 peer_disconnected: Clone::clone(&orig.peer_disconnected),
6337 provided_node_features: Clone::clone(&orig.provided_node_features),
6338 provided_init_features: Clone::clone(&orig.provided_init_features),
6339 OnionMessageProvider: crate::lightning::events::OnionMessageProvider_clone_fields(&orig.OnionMessageProvider),
6340 free: Clone::clone(&orig.free),
6343 impl lightning::events::OnionMessageProvider for OnionMessageHandler {
6344 fn next_onion_message_for_peer(&self, mut peer_node_id: bitcoin::secp256k1::PublicKey) -> Option<lightning::ln::msgs::OnionMessage> {
6345 let mut ret = (self.OnionMessageProvider.next_onion_message_for_peer)(self.OnionMessageProvider.this_arg, crate::c_types::PublicKey::from_rust(&peer_node_id));
6346 let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) };
6351 use lightning::ln::msgs::OnionMessageHandler as rustOnionMessageHandler;
6352 impl rustOnionMessageHandler for OnionMessageHandler {
6353 fn handle_onion_message(&self, mut peer_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OnionMessage) {
6354 (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 })
6356 fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
6357 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);
6358 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)) })*/ })};
6361 fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) {
6362 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id))
6364 fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
6365 let mut ret = (self.provided_node_features)(self.this_arg);
6366 *unsafe { Box::from_raw(ret.take_inner()) }
6368 fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
6369 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
6370 *unsafe { Box::from_raw(ret.take_inner()) }
6374 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
6375 // directly as a Deref trait in higher-level structs:
6376 impl core::ops::Deref for OnionMessageHandler {
6378 fn deref(&self) -> &Self {
6382 /// Calls the free function if one is set
6384 pub extern "C" fn OnionMessageHandler_free(this_ptr: OnionMessageHandler) { }
6385 impl Drop for OnionMessageHandler {
6386 fn drop(&mut self) {
6387 if let Some(f) = self.free {
6392 mod fuzzy_internal_msgs {
6394 use alloc::str::FromStr;
6395 use core::ffi::c_void;
6396 use core::convert::Infallible;
6397 use bitcoin::hashes::Hash;
6398 use crate::c_types::*;
6399 #[cfg(feature="no-std")]
6400 use alloc::{vec::Vec, boxed::Box};
6404 /// Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read
6405 pub extern "C" fn AcceptChannel_write(obj: &crate::lightning::ln::msgs::AcceptChannel) -> crate::c_types::derived::CVec_u8Z {
6406 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6409 pub(crate) extern "C" fn AcceptChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6410 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannel) })
6413 /// Read a AcceptChannel from a byte array, created by AcceptChannel_write
6414 pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelDecodeErrorZ {
6415 let res: Result<lightning::ln::msgs::AcceptChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6416 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() };
6420 /// Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read
6421 pub extern "C" fn AnnouncementSignatures_write(obj: &crate::lightning::ln::msgs::AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z {
6422 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6425 pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6426 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAnnouncementSignatures) })
6429 /// Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write
6430 pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AnnouncementSignaturesDecodeErrorZ {
6431 let res: Result<lightning::ln::msgs::AnnouncementSignatures, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6432 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() };
6436 /// Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read
6437 pub extern "C" fn ChannelReestablish_write(obj: &crate::lightning::ln::msgs::ChannelReestablish) -> crate::c_types::derived::CVec_u8Z {
6438 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6441 pub(crate) extern "C" fn ChannelReestablish_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6442 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReestablish) })
6445 /// Read a ChannelReestablish from a byte array, created by ChannelReestablish_write
6446 pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReestablishDecodeErrorZ {
6447 let res: Result<lightning::ln::msgs::ChannelReestablish, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6448 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() };
6452 /// Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read
6453 pub extern "C" fn ClosingSigned_write(obj: &crate::lightning::ln::msgs::ClosingSigned) -> crate::c_types::derived::CVec_u8Z {
6454 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6457 pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6458 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSigned) })
6461 /// Read a ClosingSigned from a byte array, created by ClosingSigned_write
6462 pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedDecodeErrorZ {
6463 let res: Result<lightning::ln::msgs::ClosingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6464 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() };
6468 /// Serialize the ClosingSignedFeeRange object into a byte array which can be read by ClosingSignedFeeRange_read
6469 pub extern "C" fn ClosingSignedFeeRange_write(obj: &crate::lightning::ln::msgs::ClosingSignedFeeRange) -> crate::c_types::derived::CVec_u8Z {
6470 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6473 pub(crate) extern "C" fn ClosingSignedFeeRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6474 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSignedFeeRange) })
6477 /// Read a ClosingSignedFeeRange from a byte array, created by ClosingSignedFeeRange_write
6478 pub extern "C" fn ClosingSignedFeeRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedFeeRangeDecodeErrorZ {
6479 let res: Result<lightning::ln::msgs::ClosingSignedFeeRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6480 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() };
6484 /// Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read
6485 pub extern "C" fn CommitmentSigned_write(obj: &crate::lightning::ln::msgs::CommitmentSigned) -> crate::c_types::derived::CVec_u8Z {
6486 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6489 pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6490 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentSigned) })
6493 /// Read a CommitmentSigned from a byte array, created by CommitmentSigned_write
6494 pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CommitmentSignedDecodeErrorZ {
6495 let res: Result<lightning::ln::msgs::CommitmentSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6496 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() };
6500 /// Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read
6501 pub extern "C" fn FundingCreated_write(obj: &crate::lightning::ln::msgs::FundingCreated) -> crate::c_types::derived::CVec_u8Z {
6502 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6505 pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6506 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingCreated) })
6509 /// Read a FundingCreated from a byte array, created by FundingCreated_write
6510 pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingCreatedDecodeErrorZ {
6511 let res: Result<lightning::ln::msgs::FundingCreated, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6512 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() };
6516 /// Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read
6517 pub extern "C" fn FundingSigned_write(obj: &crate::lightning::ln::msgs::FundingSigned) -> crate::c_types::derived::CVec_u8Z {
6518 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6521 pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6522 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingSigned) })
6525 /// Read a FundingSigned from a byte array, created by FundingSigned_write
6526 pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingSignedDecodeErrorZ {
6527 let res: Result<lightning::ln::msgs::FundingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6528 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() };
6532 /// Serialize the ChannelReady object into a byte array which can be read by ChannelReady_read
6533 pub extern "C" fn ChannelReady_write(obj: &crate::lightning::ln::msgs::ChannelReady) -> crate::c_types::derived::CVec_u8Z {
6534 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6537 pub(crate) extern "C" fn ChannelReady_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6538 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReady) })
6541 /// Read a ChannelReady from a byte array, created by ChannelReady_write
6542 pub extern "C" fn ChannelReady_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReadyDecodeErrorZ {
6543 let res: Result<lightning::ln::msgs::ChannelReady, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6544 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() };
6548 /// Serialize the Init object into a byte array which can be read by Init_read
6549 pub extern "C" fn Init_write(obj: &crate::lightning::ln::msgs::Init) -> crate::c_types::derived::CVec_u8Z {
6550 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6553 pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6554 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInit) })
6557 /// Read a Init from a byte array, created by Init_write
6558 pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitDecodeErrorZ {
6559 let res: Result<lightning::ln::msgs::Init, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6560 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() };
6564 /// Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read
6565 pub extern "C" fn OpenChannel_write(obj: &crate::lightning::ln::msgs::OpenChannel) -> crate::c_types::derived::CVec_u8Z {
6566 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6569 pub(crate) extern "C" fn OpenChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6570 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannel) })
6573 /// Read a OpenChannel from a byte array, created by OpenChannel_write
6574 pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelDecodeErrorZ {
6575 let res: Result<lightning::ln::msgs::OpenChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6576 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() };
6580 /// Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read
6581 pub extern "C" fn RevokeAndACK_write(obj: &crate::lightning::ln::msgs::RevokeAndACK) -> crate::c_types::derived::CVec_u8Z {
6582 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6585 pub(crate) extern "C" fn RevokeAndACK_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6586 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevokeAndACK) })
6589 /// Read a RevokeAndACK from a byte array, created by RevokeAndACK_write
6590 pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RevokeAndACKDecodeErrorZ {
6591 let res: Result<lightning::ln::msgs::RevokeAndACK, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6592 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() };
6596 /// Serialize the Shutdown object into a byte array which can be read by Shutdown_read
6597 pub extern "C" fn Shutdown_write(obj: &crate::lightning::ln::msgs::Shutdown) -> crate::c_types::derived::CVec_u8Z {
6598 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6601 pub(crate) extern "C" fn Shutdown_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6602 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeShutdown) })
6605 /// Read a Shutdown from a byte array, created by Shutdown_write
6606 pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ShutdownDecodeErrorZ {
6607 let res: Result<lightning::ln::msgs::Shutdown, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6608 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() };
6612 /// Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read
6613 pub extern "C" fn UpdateFailHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFailHTLC) -> crate::c_types::derived::CVec_u8Z {
6614 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6617 pub(crate) extern "C" fn UpdateFailHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6618 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailHTLC) })
6621 /// Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write
6622 pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailHTLCDecodeErrorZ {
6623 let res: Result<lightning::ln::msgs::UpdateFailHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6624 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() };
6628 /// Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read
6629 pub extern "C" fn UpdateFailMalformedHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFailMalformedHTLC) -> crate::c_types::derived::CVec_u8Z {
6630 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6633 pub(crate) extern "C" fn UpdateFailMalformedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6634 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailMalformedHTLC) })
6637 /// Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write
6638 pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailMalformedHTLCDecodeErrorZ {
6639 let res: Result<lightning::ln::msgs::UpdateFailMalformedHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6640 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() };
6644 /// Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read
6645 pub extern "C" fn UpdateFee_write(obj: &crate::lightning::ln::msgs::UpdateFee) -> crate::c_types::derived::CVec_u8Z {
6646 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6649 pub(crate) extern "C" fn UpdateFee_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6650 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFee) })
6653 /// Read a UpdateFee from a byte array, created by UpdateFee_write
6654 pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFeeDecodeErrorZ {
6655 let res: Result<lightning::ln::msgs::UpdateFee, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6656 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() };
6660 /// Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read
6661 pub extern "C" fn UpdateFulfillHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFulfillHTLC) -> crate::c_types::derived::CVec_u8Z {
6662 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6665 pub(crate) extern "C" fn UpdateFulfillHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6666 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFulfillHTLC) })
6669 /// Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write
6670 pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFulfillHTLCDecodeErrorZ {
6671 let res: Result<lightning::ln::msgs::UpdateFulfillHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6672 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() };
6676 /// Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read
6677 pub extern "C" fn UpdateAddHTLC_write(obj: &crate::lightning::ln::msgs::UpdateAddHTLC) -> crate::c_types::derived::CVec_u8Z {
6678 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6681 pub(crate) extern "C" fn UpdateAddHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6682 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateAddHTLC) })
6685 /// Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write
6686 pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateAddHTLCDecodeErrorZ {
6687 let res: Result<lightning::ln::msgs::UpdateAddHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6688 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() };
6692 /// Read a OnionMessage from a byte array, created by OnionMessage_write
6693 pub extern "C" fn OnionMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OnionMessageDecodeErrorZ {
6694 let res: Result<lightning::ln::msgs::OnionMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6695 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() };
6699 /// Serialize the OnionMessage object into a byte array which can be read by OnionMessage_read
6700 pub extern "C" fn OnionMessage_write(obj: &crate::lightning::ln::msgs::OnionMessage) -> crate::c_types::derived::CVec_u8Z {
6701 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6704 pub(crate) extern "C" fn OnionMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6705 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOnionMessage) })
6708 /// Serialize the Ping object into a byte array which can be read by Ping_read
6709 pub extern "C" fn Ping_write(obj: &crate::lightning::ln::msgs::Ping) -> crate::c_types::derived::CVec_u8Z {
6710 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6713 pub(crate) extern "C" fn Ping_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6714 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePing) })
6717 /// Read a Ping from a byte array, created by Ping_write
6718 pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PingDecodeErrorZ {
6719 let res: Result<lightning::ln::msgs::Ping, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6720 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() };
6724 /// Serialize the Pong object into a byte array which can be read by Pong_read
6725 pub extern "C" fn Pong_write(obj: &crate::lightning::ln::msgs::Pong) -> crate::c_types::derived::CVec_u8Z {
6726 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6729 pub(crate) extern "C" fn Pong_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6730 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePong) })
6733 /// Read a Pong from a byte array, created by Pong_write
6734 pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PongDecodeErrorZ {
6735 let res: Result<lightning::ln::msgs::Pong, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6736 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() };
6740 /// Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read
6741 pub extern "C" fn UnsignedChannelAnnouncement_write(obj: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
6742 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6745 pub(crate) extern "C" fn UnsignedChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6746 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelAnnouncement) })
6749 /// Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write
6750 pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelAnnouncementDecodeErrorZ {
6751 let res: Result<lightning::ln::msgs::UnsignedChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6752 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() };
6756 /// Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read
6757 pub extern "C" fn ChannelAnnouncement_write(obj: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
6758 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6761 pub(crate) extern "C" fn ChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6762 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelAnnouncement) })
6765 /// Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write
6766 pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelAnnouncementDecodeErrorZ {
6767 let res: Result<lightning::ln::msgs::ChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6768 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() };
6772 /// Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read
6773 pub extern "C" fn UnsignedChannelUpdate_write(obj: &crate::lightning::ln::msgs::UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
6774 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6777 pub(crate) extern "C" fn UnsignedChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6778 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelUpdate) })
6781 /// Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write
6782 pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelUpdateDecodeErrorZ {
6783 let res: Result<lightning::ln::msgs::UnsignedChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6784 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() };
6788 /// Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read
6789 pub extern "C" fn ChannelUpdate_write(obj: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
6790 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6793 pub(crate) extern "C" fn ChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6794 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdate) })
6797 /// Read a ChannelUpdate from a byte array, created by ChannelUpdate_write
6798 pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelUpdateDecodeErrorZ {
6799 let res: Result<lightning::ln::msgs::ChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6800 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() };
6804 /// Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read
6805 pub extern "C" fn ErrorMessage_write(obj: &crate::lightning::ln::msgs::ErrorMessage) -> crate::c_types::derived::CVec_u8Z {
6806 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6809 pub(crate) extern "C" fn ErrorMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6810 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeErrorMessage) })
6813 /// Read a ErrorMessage from a byte array, created by ErrorMessage_write
6814 pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ErrorMessageDecodeErrorZ {
6815 let res: Result<lightning::ln::msgs::ErrorMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6816 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() };
6820 /// Serialize the WarningMessage object into a byte array which can be read by WarningMessage_read
6821 pub extern "C" fn WarningMessage_write(obj: &crate::lightning::ln::msgs::WarningMessage) -> crate::c_types::derived::CVec_u8Z {
6822 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6825 pub(crate) extern "C" fn WarningMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6826 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeWarningMessage) })
6829 /// Read a WarningMessage from a byte array, created by WarningMessage_write
6830 pub extern "C" fn WarningMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_WarningMessageDecodeErrorZ {
6831 let res: Result<lightning::ln::msgs::WarningMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6832 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() };
6836 /// Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read
6837 pub extern "C" fn UnsignedNodeAnnouncement_write(obj: &crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
6838 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6841 pub(crate) extern "C" fn UnsignedNodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6842 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedNodeAnnouncement) })
6845 /// Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write
6846 pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedNodeAnnouncementDecodeErrorZ {
6847 let res: Result<lightning::ln::msgs::UnsignedNodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6848 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() };
6852 /// Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read
6853 pub extern "C" fn NodeAnnouncement_write(obj: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
6854 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6857 pub(crate) extern "C" fn NodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6858 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncement) })
6861 /// Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write
6862 pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementDecodeErrorZ {
6863 let res: Result<lightning::ln::msgs::NodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6864 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() };
6868 /// Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write
6869 pub extern "C" fn QueryShortChannelIds_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryShortChannelIdsDecodeErrorZ {
6870 let res: Result<lightning::ln::msgs::QueryShortChannelIds, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6871 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() };
6875 /// Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read
6876 pub extern "C" fn QueryShortChannelIds_write(obj: &crate::lightning::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CVec_u8Z {
6877 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6880 pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6881 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) })
6884 /// Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read
6885 pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z {
6886 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6889 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6890 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) })
6893 /// Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write
6894 pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyShortChannelIdsEndDecodeErrorZ {
6895 let res: Result<lightning::ln::msgs::ReplyShortChannelIdsEnd, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6896 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() };
6899 /// Calculates the overflow safe ending block height for the query.
6901 /// Overflow returns `0xffffffff`, otherwise returns `first_blocknum + number_of_blocks`.
6904 pub extern "C" fn QueryChannelRange_end_blocknum(this_arg: &crate::lightning::ln::msgs::QueryChannelRange) -> u32 {
6905 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.end_blocknum();
6910 /// Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read
6911 pub extern "C" fn QueryChannelRange_write(obj: &crate::lightning::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CVec_u8Z {
6912 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6915 pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6916 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) })
6919 /// Read a QueryChannelRange from a byte array, created by QueryChannelRange_write
6920 pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ {
6921 let res: Result<lightning::ln::msgs::QueryChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6922 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() };
6926 /// Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write
6927 pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyChannelRangeDecodeErrorZ {
6928 let res: Result<lightning::ln::msgs::ReplyChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6929 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() };
6933 /// Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read
6934 pub extern "C" fn ReplyChannelRange_write(obj: &crate::lightning::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CVec_u8Z {
6935 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6938 pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6939 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) })
6942 /// Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read
6943 pub extern "C" fn GossipTimestampFilter_write(obj: &crate::lightning::ln::msgs::GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z {
6944 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6947 pub(crate) extern "C" fn GossipTimestampFilter_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6948 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeGossipTimestampFilter) })
6951 /// Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write
6952 pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_GossipTimestampFilterDecodeErrorZ {
6953 let res: Result<lightning::ln::msgs::GossipTimestampFilter, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6954 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() };