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.
40 /// Includes unknown realm byte in an OnionHopData packet
42 /// Unknown feature mandating we fail to parse message (eg TLV with an even, unknown type)
43 UnknownRequiredFeature,
44 /// Value was invalid, eg a byte which was supposed to be a bool was something other than a 0
45 /// or 1, a public key/private key/signature was invalid, text wasn't UTF-8, TLV was
46 /// syntactically incorrect, etc
50 /// A length descriptor in the packet didn't describe the later data correctly
52 /// Error from std::io
54 crate::c_types::IOError),
55 /// The message included zlib-compressed values, which we don't support.
56 UnsupportedCompression,
58 use lightning::ln::msgs::DecodeError as DecodeErrorImport;
59 pub(crate) type nativeDecodeError = DecodeErrorImport;
63 pub(crate) fn to_native(&self) -> nativeDecodeError {
65 DecodeError::UnknownVersion => nativeDecodeError::UnknownVersion,
66 DecodeError::UnknownRequiredFeature => nativeDecodeError::UnknownRequiredFeature,
67 DecodeError::InvalidValue => nativeDecodeError::InvalidValue,
68 DecodeError::ShortRead => nativeDecodeError::ShortRead,
69 DecodeError::BadLengthDescriptor => nativeDecodeError::BadLengthDescriptor,
70 DecodeError::Io (ref a, ) => {
71 let mut a_nonref = (*a).clone();
72 nativeDecodeError::Io (
73 a_nonref.to_rust_kind(),
76 DecodeError::UnsupportedCompression => nativeDecodeError::UnsupportedCompression,
80 pub(crate) fn into_native(self) -> nativeDecodeError {
82 DecodeError::UnknownVersion => nativeDecodeError::UnknownVersion,
83 DecodeError::UnknownRequiredFeature => nativeDecodeError::UnknownRequiredFeature,
84 DecodeError::InvalidValue => nativeDecodeError::InvalidValue,
85 DecodeError::ShortRead => nativeDecodeError::ShortRead,
86 DecodeError::BadLengthDescriptor => nativeDecodeError::BadLengthDescriptor,
87 DecodeError::Io (mut a, ) => {
88 nativeDecodeError::Io (
92 DecodeError::UnsupportedCompression => nativeDecodeError::UnsupportedCompression,
96 pub(crate) fn from_native(native: &nativeDecodeError) -> Self {
98 nativeDecodeError::UnknownVersion => DecodeError::UnknownVersion,
99 nativeDecodeError::UnknownRequiredFeature => DecodeError::UnknownRequiredFeature,
100 nativeDecodeError::InvalidValue => DecodeError::InvalidValue,
101 nativeDecodeError::ShortRead => DecodeError::ShortRead,
102 nativeDecodeError::BadLengthDescriptor => DecodeError::BadLengthDescriptor,
103 nativeDecodeError::Io (ref a, ) => {
104 let mut a_nonref = (*a).clone();
106 crate::c_types::IOError::from_rust_kind(a_nonref),
109 nativeDecodeError::UnsupportedCompression => DecodeError::UnsupportedCompression,
113 pub(crate) fn native_into(native: nativeDecodeError) -> Self {
115 nativeDecodeError::UnknownVersion => DecodeError::UnknownVersion,
116 nativeDecodeError::UnknownRequiredFeature => DecodeError::UnknownRequiredFeature,
117 nativeDecodeError::InvalidValue => DecodeError::InvalidValue,
118 nativeDecodeError::ShortRead => DecodeError::ShortRead,
119 nativeDecodeError::BadLengthDescriptor => DecodeError::BadLengthDescriptor,
120 nativeDecodeError::Io (mut a, ) => {
122 crate::c_types::IOError::from_rust_kind(a),
125 nativeDecodeError::UnsupportedCompression => DecodeError::UnsupportedCompression,
129 /// Frees any resources used by the DecodeError
131 pub extern "C" fn DecodeError_free(this_ptr: DecodeError) { }
132 /// Creates a copy of the DecodeError
134 pub extern "C" fn DecodeError_clone(orig: &DecodeError) -> DecodeError {
138 /// Utility method to constructs a new UnknownVersion-variant DecodeError
139 pub extern "C" fn DecodeError_unknown_version() -> DecodeError {
140 DecodeError::UnknownVersion}
142 /// Utility method to constructs a new UnknownRequiredFeature-variant DecodeError
143 pub extern "C" fn DecodeError_unknown_required_feature() -> DecodeError {
144 DecodeError::UnknownRequiredFeature}
146 /// Utility method to constructs a new InvalidValue-variant DecodeError
147 pub extern "C" fn DecodeError_invalid_value() -> DecodeError {
148 DecodeError::InvalidValue}
150 /// Utility method to constructs a new ShortRead-variant DecodeError
151 pub extern "C" fn DecodeError_short_read() -> DecodeError {
152 DecodeError::ShortRead}
154 /// Utility method to constructs a new BadLengthDescriptor-variant DecodeError
155 pub extern "C" fn DecodeError_bad_length_descriptor() -> DecodeError {
156 DecodeError::BadLengthDescriptor}
158 /// Utility method to constructs a new Io-variant DecodeError
159 pub extern "C" fn DecodeError_io(a: crate::c_types::IOError) -> DecodeError {
163 /// Utility method to constructs a new UnsupportedCompression-variant DecodeError
164 pub extern "C" fn DecodeError_unsupported_compression() -> DecodeError {
165 DecodeError::UnsupportedCompression}
166 /// Checks if two DecodeErrors contain equal inner contents.
167 /// This ignores pointers and is_owned flags and looks at the values in fields.
169 pub extern "C" fn DecodeError_eq(a: &DecodeError, b: &DecodeError) -> bool {
170 if &a.to_native() == &b.to_native() { true } else { false }
173 use lightning::ln::msgs::Init as nativeInitImport;
174 pub(crate) type nativeInit = nativeInitImport;
176 /// An init message to be sent or received from a peer
180 /// A pointer to the opaque Rust object.
182 /// Nearly everywhere, inner must be non-null, however in places where
183 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
184 pub inner: *mut nativeInit,
185 /// Indicates that this is the only struct which contains the same pointer.
187 /// Rust functions which take ownership of an object provided via an argument require
188 /// this to be true and invalidate the object pointed to by inner.
194 if self.is_owned && !<*mut nativeInit>::is_null(self.inner) {
195 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
199 /// Frees any resources used by the Init, if is_owned is set and inner is non-NULL.
201 pub extern "C" fn Init_free(this_obj: Init) { }
203 /// Used only if an object of this type is returned as a trait impl by a method
204 pub(crate) extern "C" fn Init_free_void(this_ptr: *mut c_void) {
205 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeInit); }
209 pub(crate) fn get_native_ref(&self) -> &'static nativeInit {
210 unsafe { &*ObjOps::untweak_ptr(self.inner) }
212 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInit {
213 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
215 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
216 pub(crate) fn take_inner(mut self) -> *mut nativeInit {
217 assert!(self.is_owned);
218 let ret = ObjOps::untweak_ptr(self.inner);
219 self.inner = core::ptr::null_mut();
223 /// The relevant features which the sender supports
225 pub extern "C" fn Init_get_features(this_ptr: &Init) -> crate::lightning::ln::features::InitFeatures {
226 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
227 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 }
229 /// The relevant features which the sender supports
231 pub extern "C" fn Init_set_features(this_ptr: &mut Init, mut val: crate::lightning::ln::features::InitFeatures) {
232 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
234 /// The receipient's network address. This adds the option to report a remote IP address
235 /// back to a connecting peer using the init message. A node can decide to use that information
236 /// to discover a potential update to its public IPv4 address (NAT) and use
237 /// that for a node_announcement update message containing the new address.
239 pub extern "C" fn Init_get_remote_network_address(this_ptr: &Init) -> crate::c_types::derived::COption_NetAddressZ {
240 let mut inner_val = &mut this_ptr.get_native_mut_ref().remote_network_address;
241 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.clone().unwrap()) }) };
244 /// The receipient's network address. This adds the option to report a remote IP address
245 /// back to a connecting peer using the init message. A node can decide to use that information
246 /// to discover a potential update to its public IPv4 address (NAT) and use
247 /// that for a node_announcement update message containing the new address.
249 pub extern "C" fn Init_set_remote_network_address(this_ptr: &mut Init, mut val: crate::c_types::derived::COption_NetAddressZ) {
250 let mut local_val = { /* val*/ let val_opt = val; { } if val_opt.is_none() { None } else { Some({ val_opt.take().into_native() }) } };
251 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.remote_network_address = local_val;
253 /// Constructs a new Init given each field
256 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 {
257 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() }) } };
258 Init { inner: ObjOps::heap_alloc(nativeInit {
259 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
260 remote_network_address: local_remote_network_address_arg,
263 impl Clone for Init {
264 fn clone(&self) -> Self {
266 inner: if <*mut nativeInit>::is_null(self.inner) { core::ptr::null_mut() } else {
267 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
273 /// Used only if an object of this type is returned as a trait impl by a method
274 pub(crate) extern "C" fn Init_clone_void(this_ptr: *const c_void) -> *mut c_void {
275 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInit)).clone() })) as *mut c_void
278 /// Creates a copy of the Init
279 pub extern "C" fn Init_clone(orig: &Init) -> Init {
282 /// Checks if two Inits contain equal inner contents.
283 /// This ignores pointers and is_owned flags and looks at the values in fields.
284 /// Two objects with NULL inner values will be considered "equal" here.
286 pub extern "C" fn Init_eq(a: &Init, b: &Init) -> bool {
287 if a.inner == b.inner { return true; }
288 if a.inner.is_null() || b.inner.is_null() { return false; }
289 if a.get_native_ref() == b.get_native_ref() { true } else { false }
292 use lightning::ln::msgs::ErrorMessage as nativeErrorMessageImport;
293 pub(crate) type nativeErrorMessage = nativeErrorMessageImport;
295 /// An error message to be sent or received from a peer
298 pub struct ErrorMessage {
299 /// A pointer to the opaque Rust object.
301 /// Nearly everywhere, inner must be non-null, however in places where
302 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
303 pub inner: *mut nativeErrorMessage,
304 /// Indicates that this is the only struct which contains the same pointer.
306 /// Rust functions which take ownership of an object provided via an argument require
307 /// this to be true and invalidate the object pointed to by inner.
311 impl Drop for ErrorMessage {
313 if self.is_owned && !<*mut nativeErrorMessage>::is_null(self.inner) {
314 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
318 /// Frees any resources used by the ErrorMessage, if is_owned is set and inner is non-NULL.
320 pub extern "C" fn ErrorMessage_free(this_obj: ErrorMessage) { }
322 /// Used only if an object of this type is returned as a trait impl by a method
323 pub(crate) extern "C" fn ErrorMessage_free_void(this_ptr: *mut c_void) {
324 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeErrorMessage); }
328 pub(crate) fn get_native_ref(&self) -> &'static nativeErrorMessage {
329 unsafe { &*ObjOps::untweak_ptr(self.inner) }
331 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeErrorMessage {
332 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
334 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
335 pub(crate) fn take_inner(mut self) -> *mut nativeErrorMessage {
336 assert!(self.is_owned);
337 let ret = ObjOps::untweak_ptr(self.inner);
338 self.inner = core::ptr::null_mut();
342 /// The channel ID involved in the error.
344 /// All-0s indicates a general error unrelated to a specific channel, after which all channels
345 /// with the sending peer should be closed.
347 pub extern "C" fn ErrorMessage_get_channel_id(this_ptr: &ErrorMessage) -> *const [u8; 32] {
348 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
351 /// The channel ID involved in the error.
353 /// All-0s indicates a general error unrelated to a specific channel, after which all channels
354 /// with the sending peer should be closed.
356 pub extern "C" fn ErrorMessage_set_channel_id(this_ptr: &mut ErrorMessage, mut val: crate::c_types::ThirtyTwoBytes) {
357 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
359 /// A possibly human-readable error description.
360 /// The string should be sanitized before it is used (e.g. emitted to logs or printed to
361 /// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
362 /// the terminal emulator or the logging subsystem.
364 pub extern "C" fn ErrorMessage_get_data(this_ptr: &ErrorMessage) -> crate::c_types::Str {
365 let mut inner_val = &mut this_ptr.get_native_mut_ref().data;
366 inner_val.as_str().into()
368 /// A possibly human-readable error description.
369 /// The string should be sanitized before it is used (e.g. emitted to logs or printed to
370 /// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
371 /// the terminal emulator or the logging subsystem.
373 pub extern "C" fn ErrorMessage_set_data(this_ptr: &mut ErrorMessage, mut val: crate::c_types::Str) {
374 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string();
376 /// Constructs a new ErrorMessage given each field
379 pub extern "C" fn ErrorMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::Str) -> ErrorMessage {
380 ErrorMessage { inner: ObjOps::heap_alloc(nativeErrorMessage {
381 channel_id: channel_id_arg.data,
382 data: data_arg.into_string(),
385 impl Clone for ErrorMessage {
386 fn clone(&self) -> Self {
388 inner: if <*mut nativeErrorMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
389 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
395 /// Used only if an object of this type is returned as a trait impl by a method
396 pub(crate) extern "C" fn ErrorMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
397 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeErrorMessage)).clone() })) as *mut c_void
400 /// Creates a copy of the ErrorMessage
401 pub extern "C" fn ErrorMessage_clone(orig: &ErrorMessage) -> ErrorMessage {
404 /// Checks if two ErrorMessages contain equal inner contents.
405 /// This ignores pointers and is_owned flags and looks at the values in fields.
406 /// Two objects with NULL inner values will be considered "equal" here.
408 pub extern "C" fn ErrorMessage_eq(a: &ErrorMessage, b: &ErrorMessage) -> bool {
409 if a.inner == b.inner { return true; }
410 if a.inner.is_null() || b.inner.is_null() { return false; }
411 if a.get_native_ref() == b.get_native_ref() { true } else { false }
414 use lightning::ln::msgs::WarningMessage as nativeWarningMessageImport;
415 pub(crate) type nativeWarningMessage = nativeWarningMessageImport;
417 /// A warning message to be sent or received from a peer
420 pub struct WarningMessage {
421 /// A pointer to the opaque Rust object.
423 /// Nearly everywhere, inner must be non-null, however in places where
424 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
425 pub inner: *mut nativeWarningMessage,
426 /// Indicates that this is the only struct which contains the same pointer.
428 /// Rust functions which take ownership of an object provided via an argument require
429 /// this to be true and invalidate the object pointed to by inner.
433 impl Drop for WarningMessage {
435 if self.is_owned && !<*mut nativeWarningMessage>::is_null(self.inner) {
436 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
440 /// Frees any resources used by the WarningMessage, if is_owned is set and inner is non-NULL.
442 pub extern "C" fn WarningMessage_free(this_obj: WarningMessage) { }
444 /// Used only if an object of this type is returned as a trait impl by a method
445 pub(crate) extern "C" fn WarningMessage_free_void(this_ptr: *mut c_void) {
446 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeWarningMessage); }
449 impl WarningMessage {
450 pub(crate) fn get_native_ref(&self) -> &'static nativeWarningMessage {
451 unsafe { &*ObjOps::untweak_ptr(self.inner) }
453 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeWarningMessage {
454 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
456 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
457 pub(crate) fn take_inner(mut self) -> *mut nativeWarningMessage {
458 assert!(self.is_owned);
459 let ret = ObjOps::untweak_ptr(self.inner);
460 self.inner = core::ptr::null_mut();
464 /// The channel ID involved in the warning.
466 /// All-0s indicates a warning unrelated to a specific channel.
468 pub extern "C" fn WarningMessage_get_channel_id(this_ptr: &WarningMessage) -> *const [u8; 32] {
469 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
472 /// The channel ID involved in the warning.
474 /// All-0s indicates a warning unrelated to a specific channel.
476 pub extern "C" fn WarningMessage_set_channel_id(this_ptr: &mut WarningMessage, mut val: crate::c_types::ThirtyTwoBytes) {
477 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
479 /// A possibly human-readable warning description.
480 /// The string should be sanitized before it is used (e.g. emitted to logs or printed to
481 /// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
482 /// the terminal emulator or the logging subsystem.
484 pub extern "C" fn WarningMessage_get_data(this_ptr: &WarningMessage) -> crate::c_types::Str {
485 let mut inner_val = &mut this_ptr.get_native_mut_ref().data;
486 inner_val.as_str().into()
488 /// A possibly human-readable warning description.
489 /// The string should be sanitized before it is used (e.g. emitted to logs or printed to
490 /// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
491 /// the terminal emulator or the logging subsystem.
493 pub extern "C" fn WarningMessage_set_data(this_ptr: &mut WarningMessage, mut val: crate::c_types::Str) {
494 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string();
496 /// Constructs a new WarningMessage given each field
499 pub extern "C" fn WarningMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::Str) -> WarningMessage {
500 WarningMessage { inner: ObjOps::heap_alloc(nativeWarningMessage {
501 channel_id: channel_id_arg.data,
502 data: data_arg.into_string(),
505 impl Clone for WarningMessage {
506 fn clone(&self) -> Self {
508 inner: if <*mut nativeWarningMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
509 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
515 /// Used only if an object of this type is returned as a trait impl by a method
516 pub(crate) extern "C" fn WarningMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
517 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeWarningMessage)).clone() })) as *mut c_void
520 /// Creates a copy of the WarningMessage
521 pub extern "C" fn WarningMessage_clone(orig: &WarningMessage) -> WarningMessage {
524 /// Checks if two WarningMessages contain equal inner contents.
525 /// This ignores pointers and is_owned flags and looks at the values in fields.
526 /// Two objects with NULL inner values will be considered "equal" here.
528 pub extern "C" fn WarningMessage_eq(a: &WarningMessage, b: &WarningMessage) -> bool {
529 if a.inner == b.inner { return true; }
530 if a.inner.is_null() || b.inner.is_null() { return false; }
531 if a.get_native_ref() == b.get_native_ref() { true } else { false }
534 use lightning::ln::msgs::Ping as nativePingImport;
535 pub(crate) type nativePing = nativePingImport;
537 /// A ping message to be sent or received from a peer
541 /// A pointer to the opaque Rust object.
543 /// Nearly everywhere, inner must be non-null, however in places where
544 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
545 pub inner: *mut nativePing,
546 /// Indicates that this is the only struct which contains the same pointer.
548 /// Rust functions which take ownership of an object provided via an argument require
549 /// this to be true and invalidate the object pointed to by inner.
555 if self.is_owned && !<*mut nativePing>::is_null(self.inner) {
556 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
560 /// Frees any resources used by the Ping, if is_owned is set and inner is non-NULL.
562 pub extern "C" fn Ping_free(this_obj: Ping) { }
564 /// Used only if an object of this type is returned as a trait impl by a method
565 pub(crate) extern "C" fn Ping_free_void(this_ptr: *mut c_void) {
566 unsafe { let _ = Box::from_raw(this_ptr as *mut nativePing); }
570 pub(crate) fn get_native_ref(&self) -> &'static nativePing {
571 unsafe { &*ObjOps::untweak_ptr(self.inner) }
573 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePing {
574 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
576 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
577 pub(crate) fn take_inner(mut self) -> *mut nativePing {
578 assert!(self.is_owned);
579 let ret = ObjOps::untweak_ptr(self.inner);
580 self.inner = core::ptr::null_mut();
584 /// The desired response length
586 pub extern "C" fn Ping_get_ponglen(this_ptr: &Ping) -> u16 {
587 let mut inner_val = &mut this_ptr.get_native_mut_ref().ponglen;
590 /// The desired response length
592 pub extern "C" fn Ping_set_ponglen(this_ptr: &mut Ping, mut val: u16) {
593 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.ponglen = val;
595 /// The ping packet size.
596 /// This field is not sent on the wire. byteslen zeros are sent.
598 pub extern "C" fn Ping_get_byteslen(this_ptr: &Ping) -> u16 {
599 let mut inner_val = &mut this_ptr.get_native_mut_ref().byteslen;
602 /// The ping packet size.
603 /// This field is not sent on the wire. byteslen zeros are sent.
605 pub extern "C" fn Ping_set_byteslen(this_ptr: &mut Ping, mut val: u16) {
606 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.byteslen = val;
608 /// Constructs a new Ping given each field
611 pub extern "C" fn Ping_new(mut ponglen_arg: u16, mut byteslen_arg: u16) -> Ping {
612 Ping { inner: ObjOps::heap_alloc(nativePing {
613 ponglen: ponglen_arg,
614 byteslen: byteslen_arg,
617 impl Clone for Ping {
618 fn clone(&self) -> Self {
620 inner: if <*mut nativePing>::is_null(self.inner) { core::ptr::null_mut() } else {
621 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
627 /// Used only if an object of this type is returned as a trait impl by a method
628 pub(crate) extern "C" fn Ping_clone_void(this_ptr: *const c_void) -> *mut c_void {
629 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePing)).clone() })) as *mut c_void
632 /// Creates a copy of the Ping
633 pub extern "C" fn Ping_clone(orig: &Ping) -> Ping {
636 /// Checks if two Pings contain equal inner contents.
637 /// This ignores pointers and is_owned flags and looks at the values in fields.
638 /// Two objects with NULL inner values will be considered "equal" here.
640 pub extern "C" fn Ping_eq(a: &Ping, b: &Ping) -> bool {
641 if a.inner == b.inner { return true; }
642 if a.inner.is_null() || b.inner.is_null() { return false; }
643 if a.get_native_ref() == b.get_native_ref() { true } else { false }
646 use lightning::ln::msgs::Pong as nativePongImport;
647 pub(crate) type nativePong = nativePongImport;
649 /// A pong message to be sent or received from a peer
653 /// A pointer to the opaque Rust object.
655 /// Nearly everywhere, inner must be non-null, however in places where
656 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
657 pub inner: *mut nativePong,
658 /// Indicates that this is the only struct which contains the same pointer.
660 /// Rust functions which take ownership of an object provided via an argument require
661 /// this to be true and invalidate the object pointed to by inner.
667 if self.is_owned && !<*mut nativePong>::is_null(self.inner) {
668 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
672 /// Frees any resources used by the Pong, if is_owned is set and inner is non-NULL.
674 pub extern "C" fn Pong_free(this_obj: Pong) { }
676 /// Used only if an object of this type is returned as a trait impl by a method
677 pub(crate) extern "C" fn Pong_free_void(this_ptr: *mut c_void) {
678 unsafe { let _ = Box::from_raw(this_ptr as *mut nativePong); }
682 pub(crate) fn get_native_ref(&self) -> &'static nativePong {
683 unsafe { &*ObjOps::untweak_ptr(self.inner) }
685 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePong {
686 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
688 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
689 pub(crate) fn take_inner(mut self) -> *mut nativePong {
690 assert!(self.is_owned);
691 let ret = ObjOps::untweak_ptr(self.inner);
692 self.inner = core::ptr::null_mut();
696 /// The pong packet size.
697 /// This field is not sent on the wire. byteslen zeros are sent.
699 pub extern "C" fn Pong_get_byteslen(this_ptr: &Pong) -> u16 {
700 let mut inner_val = &mut this_ptr.get_native_mut_ref().byteslen;
703 /// The pong packet size.
704 /// This field is not sent on the wire. byteslen zeros are sent.
706 pub extern "C" fn Pong_set_byteslen(this_ptr: &mut Pong, mut val: u16) {
707 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.byteslen = val;
709 /// Constructs a new Pong given each field
712 pub extern "C" fn Pong_new(mut byteslen_arg: u16) -> Pong {
713 Pong { inner: ObjOps::heap_alloc(nativePong {
714 byteslen: byteslen_arg,
717 impl Clone for Pong {
718 fn clone(&self) -> Self {
720 inner: if <*mut nativePong>::is_null(self.inner) { core::ptr::null_mut() } else {
721 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
727 /// Used only if an object of this type is returned as a trait impl by a method
728 pub(crate) extern "C" fn Pong_clone_void(this_ptr: *const c_void) -> *mut c_void {
729 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePong)).clone() })) as *mut c_void
732 /// Creates a copy of the Pong
733 pub extern "C" fn Pong_clone(orig: &Pong) -> Pong {
736 /// Checks if two Pongs contain equal inner contents.
737 /// This ignores pointers and is_owned flags and looks at the values in fields.
738 /// Two objects with NULL inner values will be considered "equal" here.
740 pub extern "C" fn Pong_eq(a: &Pong, b: &Pong) -> bool {
741 if a.inner == b.inner { return true; }
742 if a.inner.is_null() || b.inner.is_null() { return false; }
743 if a.get_native_ref() == b.get_native_ref() { true } else { false }
746 use lightning::ln::msgs::OpenChannel as nativeOpenChannelImport;
747 pub(crate) type nativeOpenChannel = nativeOpenChannelImport;
749 /// An open_channel message to be sent or received from a peer
752 pub struct OpenChannel {
753 /// A pointer to the opaque Rust object.
755 /// Nearly everywhere, inner must be non-null, however in places where
756 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
757 pub inner: *mut nativeOpenChannel,
758 /// Indicates that this is the only struct which contains the same pointer.
760 /// Rust functions which take ownership of an object provided via an argument require
761 /// this to be true and invalidate the object pointed to by inner.
765 impl Drop for OpenChannel {
767 if self.is_owned && !<*mut nativeOpenChannel>::is_null(self.inner) {
768 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
772 /// Frees any resources used by the OpenChannel, if is_owned is set and inner is non-NULL.
774 pub extern "C" fn OpenChannel_free(this_obj: OpenChannel) { }
776 /// Used only if an object of this type is returned as a trait impl by a method
777 pub(crate) extern "C" fn OpenChannel_free_void(this_ptr: *mut c_void) {
778 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeOpenChannel); }
782 pub(crate) fn get_native_ref(&self) -> &'static nativeOpenChannel {
783 unsafe { &*ObjOps::untweak_ptr(self.inner) }
785 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOpenChannel {
786 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
788 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
789 pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannel {
790 assert!(self.is_owned);
791 let ret = ObjOps::untweak_ptr(self.inner);
792 self.inner = core::ptr::null_mut();
796 /// The genesis hash of the blockchain where the channel is to be opened
798 pub extern "C" fn OpenChannel_get_chain_hash(this_ptr: &OpenChannel) -> *const [u8; 32] {
799 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
802 /// The genesis hash of the blockchain where the channel is to be opened
804 pub extern "C" fn OpenChannel_set_chain_hash(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
805 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
807 /// A temporary channel ID, until the funding outpoint is announced
809 pub extern "C" fn OpenChannel_get_temporary_channel_id(this_ptr: &OpenChannel) -> *const [u8; 32] {
810 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
813 /// A temporary channel ID, until the funding outpoint is announced
815 pub extern "C" fn OpenChannel_set_temporary_channel_id(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
816 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
818 /// The channel value
820 pub extern "C" fn OpenChannel_get_funding_satoshis(this_ptr: &OpenChannel) -> u64 {
821 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
824 /// The channel value
826 pub extern "C" fn OpenChannel_set_funding_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
827 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
829 /// The amount to push to the counterparty as part of the open, in milli-satoshi
831 pub extern "C" fn OpenChannel_get_push_msat(this_ptr: &OpenChannel) -> u64 {
832 let mut inner_val = &mut this_ptr.get_native_mut_ref().push_msat;
835 /// The amount to push to the counterparty as part of the open, in milli-satoshi
837 pub extern "C" fn OpenChannel_set_push_msat(this_ptr: &mut OpenChannel, mut val: u64) {
838 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.push_msat = val;
840 /// The threshold below which outputs on transactions broadcast by sender will be omitted
842 pub extern "C" fn OpenChannel_get_dust_limit_satoshis(this_ptr: &OpenChannel) -> u64 {
843 let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
846 /// The threshold below which outputs on transactions broadcast by sender will be omitted
848 pub extern "C" fn OpenChannel_set_dust_limit_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
849 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
851 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
853 pub extern "C" fn OpenChannel_get_max_htlc_value_in_flight_msat(this_ptr: &OpenChannel) -> u64 {
854 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
857 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
859 pub extern "C" fn OpenChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut OpenChannel, mut val: u64) {
860 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
862 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
864 pub extern "C" fn OpenChannel_get_channel_reserve_satoshis(this_ptr: &OpenChannel) -> u64 {
865 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
868 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
870 pub extern "C" fn OpenChannel_set_channel_reserve_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
871 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
873 /// The minimum HTLC size incoming to sender, in milli-satoshi
875 pub extern "C" fn OpenChannel_get_htlc_minimum_msat(this_ptr: &OpenChannel) -> u64 {
876 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
879 /// The minimum HTLC size incoming to sender, in milli-satoshi
881 pub extern "C" fn OpenChannel_set_htlc_minimum_msat(this_ptr: &mut OpenChannel, mut val: u64) {
882 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
884 /// The feerate per 1000-weight of sender generated transactions, until updated by update_fee
886 pub extern "C" fn OpenChannel_get_feerate_per_kw(this_ptr: &OpenChannel) -> u32 {
887 let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
890 /// The feerate per 1000-weight of sender generated transactions, until updated by update_fee
892 pub extern "C" fn OpenChannel_set_feerate_per_kw(this_ptr: &mut OpenChannel, mut val: u32) {
893 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
895 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
897 pub extern "C" fn OpenChannel_get_to_self_delay(this_ptr: &OpenChannel) -> u16 {
898 let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
901 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
903 pub extern "C" fn OpenChannel_set_to_self_delay(this_ptr: &mut OpenChannel, mut val: u16) {
904 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
906 /// The maximum number of inbound HTLCs towards sender
908 pub extern "C" fn OpenChannel_get_max_accepted_htlcs(this_ptr: &OpenChannel) -> u16 {
909 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
912 /// The maximum number of inbound HTLCs towards sender
914 pub extern "C" fn OpenChannel_set_max_accepted_htlcs(this_ptr: &mut OpenChannel, mut val: u16) {
915 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
917 /// The sender's key controlling the funding transaction
919 pub extern "C" fn OpenChannel_get_funding_pubkey(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
920 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
921 crate::c_types::PublicKey::from_rust(&inner_val)
923 /// The sender's key controlling the funding transaction
925 pub extern "C" fn OpenChannel_set_funding_pubkey(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
926 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
928 /// Used to derive a revocation key for transactions broadcast by counterparty
930 pub extern "C" fn OpenChannel_get_revocation_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
931 let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
932 crate::c_types::PublicKey::from_rust(&inner_val)
934 /// Used to derive a revocation key for transactions broadcast by counterparty
936 pub extern "C" fn OpenChannel_set_revocation_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
937 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
939 /// A payment key to sender for transactions broadcast by counterparty
941 pub extern "C" fn OpenChannel_get_payment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
942 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_point;
943 crate::c_types::PublicKey::from_rust(&inner_val)
945 /// A payment key to sender for transactions broadcast by counterparty
947 pub extern "C" fn OpenChannel_set_payment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
948 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_point = val.into_rust();
950 /// Used to derive a payment key to sender for transactions broadcast by sender
952 pub extern "C" fn OpenChannel_get_delayed_payment_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
953 let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
954 crate::c_types::PublicKey::from_rust(&inner_val)
956 /// Used to derive a payment key to sender for transactions broadcast by sender
958 pub extern "C" fn OpenChannel_set_delayed_payment_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
959 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
961 /// Used to derive an HTLC payment key to sender
963 pub extern "C" fn OpenChannel_get_htlc_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
964 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
965 crate::c_types::PublicKey::from_rust(&inner_val)
967 /// Used to derive an HTLC payment key to sender
969 pub extern "C" fn OpenChannel_set_htlc_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
970 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
972 /// The first to-be-broadcast-by-sender transaction's per commitment point
974 pub extern "C" fn OpenChannel_get_first_per_commitment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
975 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
976 crate::c_types::PublicKey::from_rust(&inner_val)
978 /// The first to-be-broadcast-by-sender transaction's per commitment point
980 pub extern "C" fn OpenChannel_set_first_per_commitment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
981 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
985 pub extern "C" fn OpenChannel_get_channel_flags(this_ptr: &OpenChannel) -> u8 {
986 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_flags;
991 pub extern "C" fn OpenChannel_set_channel_flags(this_ptr: &mut OpenChannel, mut val: u8) {
992 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_flags = val;
994 /// The channel type that this channel will represent. If none is set, we derive the channel
995 /// type from the intersection of our feature bits with our counterparty's feature bits from
996 /// the Init message.
998 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1000 pub extern "C" fn OpenChannel_get_channel_type(this_ptr: &OpenChannel) -> crate::lightning::ln::features::ChannelTypeFeatures {
1001 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1002 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 };
1005 /// The channel type that this channel will represent. If none is set, we derive the channel
1006 /// type from the intersection of our feature bits with our counterparty's feature bits from
1007 /// the Init message.
1009 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1011 pub extern "C" fn OpenChannel_set_channel_type(this_ptr: &mut OpenChannel, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1012 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1013 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1015 impl Clone for OpenChannel {
1016 fn clone(&self) -> Self {
1018 inner: if <*mut nativeOpenChannel>::is_null(self.inner) { core::ptr::null_mut() } else {
1019 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1025 /// Used only if an object of this type is returned as a trait impl by a method
1026 pub(crate) extern "C" fn OpenChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
1027 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOpenChannel)).clone() })) as *mut c_void
1030 /// Creates a copy of the OpenChannel
1031 pub extern "C" fn OpenChannel_clone(orig: &OpenChannel) -> OpenChannel {
1034 /// Checks if two OpenChannels contain equal inner contents.
1035 /// This ignores pointers and is_owned flags and looks at the values in fields.
1036 /// Two objects with NULL inner values will be considered "equal" here.
1038 pub extern "C" fn OpenChannel_eq(a: &OpenChannel, b: &OpenChannel) -> bool {
1039 if a.inner == b.inner { return true; }
1040 if a.inner.is_null() || b.inner.is_null() { return false; }
1041 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1044 use lightning::ln::msgs::AcceptChannel as nativeAcceptChannelImport;
1045 pub(crate) type nativeAcceptChannel = nativeAcceptChannelImport;
1047 /// An accept_channel message to be sent or received from a peer
1050 pub struct AcceptChannel {
1051 /// A pointer to the opaque Rust object.
1053 /// Nearly everywhere, inner must be non-null, however in places where
1054 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1055 pub inner: *mut nativeAcceptChannel,
1056 /// Indicates that this is the only struct which contains the same pointer.
1058 /// Rust functions which take ownership of an object provided via an argument require
1059 /// this to be true and invalidate the object pointed to by inner.
1063 impl Drop for AcceptChannel {
1064 fn drop(&mut self) {
1065 if self.is_owned && !<*mut nativeAcceptChannel>::is_null(self.inner) {
1066 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1070 /// Frees any resources used by the AcceptChannel, if is_owned is set and inner is non-NULL.
1072 pub extern "C" fn AcceptChannel_free(this_obj: AcceptChannel) { }
1074 /// Used only if an object of this type is returned as a trait impl by a method
1075 pub(crate) extern "C" fn AcceptChannel_free_void(this_ptr: *mut c_void) {
1076 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeAcceptChannel); }
1079 impl AcceptChannel {
1080 pub(crate) fn get_native_ref(&self) -> &'static nativeAcceptChannel {
1081 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1083 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAcceptChannel {
1084 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1086 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1087 pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannel {
1088 assert!(self.is_owned);
1089 let ret = ObjOps::untweak_ptr(self.inner);
1090 self.inner = core::ptr::null_mut();
1094 /// A temporary channel ID, until the funding outpoint is announced
1096 pub extern "C" fn AcceptChannel_get_temporary_channel_id(this_ptr: &AcceptChannel) -> *const [u8; 32] {
1097 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
1100 /// A temporary channel ID, until the funding outpoint is announced
1102 pub extern "C" fn AcceptChannel_set_temporary_channel_id(this_ptr: &mut AcceptChannel, mut val: crate::c_types::ThirtyTwoBytes) {
1103 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
1105 /// The threshold below which outputs on transactions broadcast by sender will be omitted
1107 pub extern "C" fn AcceptChannel_get_dust_limit_satoshis(this_ptr: &AcceptChannel) -> u64 {
1108 let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
1111 /// The threshold below which outputs on transactions broadcast by sender will be omitted
1113 pub extern "C" fn AcceptChannel_set_dust_limit_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
1114 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
1116 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
1118 pub extern "C" fn AcceptChannel_get_max_htlc_value_in_flight_msat(this_ptr: &AcceptChannel) -> u64 {
1119 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
1122 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
1124 pub extern "C" fn AcceptChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
1125 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
1127 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1129 pub extern "C" fn AcceptChannel_get_channel_reserve_satoshis(this_ptr: &AcceptChannel) -> u64 {
1130 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
1133 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1135 pub extern "C" fn AcceptChannel_set_channel_reserve_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
1136 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
1138 /// The minimum HTLC size incoming to sender, in milli-satoshi
1140 pub extern "C" fn AcceptChannel_get_htlc_minimum_msat(this_ptr: &AcceptChannel) -> u64 {
1141 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
1144 /// The minimum HTLC size incoming to sender, in milli-satoshi
1146 pub extern "C" fn AcceptChannel_set_htlc_minimum_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
1147 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
1149 /// Minimum depth of the funding transaction before the channel is considered open
1151 pub extern "C" fn AcceptChannel_get_minimum_depth(this_ptr: &AcceptChannel) -> u32 {
1152 let mut inner_val = &mut this_ptr.get_native_mut_ref().minimum_depth;
1155 /// Minimum depth of the funding transaction before the channel is considered open
1157 pub extern "C" fn AcceptChannel_set_minimum_depth(this_ptr: &mut AcceptChannel, mut val: u32) {
1158 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.minimum_depth = val;
1160 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
1162 pub extern "C" fn AcceptChannel_get_to_self_delay(this_ptr: &AcceptChannel) -> u16 {
1163 let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
1166 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
1168 pub extern "C" fn AcceptChannel_set_to_self_delay(this_ptr: &mut AcceptChannel, mut val: u16) {
1169 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
1171 /// The maximum number of inbound HTLCs towards sender
1173 pub extern "C" fn AcceptChannel_get_max_accepted_htlcs(this_ptr: &AcceptChannel) -> u16 {
1174 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
1177 /// The maximum number of inbound HTLCs towards sender
1179 pub extern "C" fn AcceptChannel_set_max_accepted_htlcs(this_ptr: &mut AcceptChannel, mut val: u16) {
1180 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
1182 /// The sender's key controlling the funding transaction
1184 pub extern "C" fn AcceptChannel_get_funding_pubkey(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1185 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
1186 crate::c_types::PublicKey::from_rust(&inner_val)
1188 /// The sender's key controlling the funding transaction
1190 pub extern "C" fn AcceptChannel_set_funding_pubkey(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1191 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
1193 /// Used to derive a revocation key for transactions broadcast by counterparty
1195 pub extern "C" fn AcceptChannel_get_revocation_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1196 let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
1197 crate::c_types::PublicKey::from_rust(&inner_val)
1199 /// Used to derive a revocation key for transactions broadcast by counterparty
1201 pub extern "C" fn AcceptChannel_set_revocation_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1202 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
1204 /// A payment key to sender for transactions broadcast by counterparty
1206 pub extern "C" fn AcceptChannel_get_payment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1207 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_point;
1208 crate::c_types::PublicKey::from_rust(&inner_val)
1210 /// A payment key to sender for transactions broadcast by counterparty
1212 pub extern "C" fn AcceptChannel_set_payment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1213 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_point = val.into_rust();
1215 /// Used to derive a payment key to sender for transactions broadcast by sender
1217 pub extern "C" fn AcceptChannel_get_delayed_payment_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1218 let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
1219 crate::c_types::PublicKey::from_rust(&inner_val)
1221 /// Used to derive a payment key to sender for transactions broadcast by sender
1223 pub extern "C" fn AcceptChannel_set_delayed_payment_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1224 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
1226 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
1228 pub extern "C" fn AcceptChannel_get_htlc_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1229 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
1230 crate::c_types::PublicKey::from_rust(&inner_val)
1232 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
1234 pub extern "C" fn AcceptChannel_set_htlc_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1235 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
1237 /// The first to-be-broadcast-by-sender transaction's per commitment point
1239 pub extern "C" fn AcceptChannel_get_first_per_commitment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1240 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
1241 crate::c_types::PublicKey::from_rust(&inner_val)
1243 /// The first to-be-broadcast-by-sender transaction's per commitment point
1245 pub extern "C" fn AcceptChannel_set_first_per_commitment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1246 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
1248 /// The channel type that this channel will represent. If none is set, we derive the channel
1249 /// type from the intersection of our feature bits with our counterparty's feature bits from
1250 /// the Init message.
1252 /// This is required to match the equivalent field in [`OpenChannel::channel_type`].
1254 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1256 pub extern "C" fn AcceptChannel_get_channel_type(this_ptr: &AcceptChannel) -> crate::lightning::ln::features::ChannelTypeFeatures {
1257 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1258 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 };
1261 /// The channel type that this channel will represent. If none is set, we derive the channel
1262 /// type from the intersection of our feature bits with our counterparty's feature bits from
1263 /// the Init message.
1265 /// This is required to match the equivalent field in [`OpenChannel::channel_type`].
1267 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1269 pub extern "C" fn AcceptChannel_set_channel_type(this_ptr: &mut AcceptChannel, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1270 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1271 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1273 impl Clone for AcceptChannel {
1274 fn clone(&self) -> Self {
1276 inner: if <*mut nativeAcceptChannel>::is_null(self.inner) { core::ptr::null_mut() } else {
1277 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1283 /// Used only if an object of this type is returned as a trait impl by a method
1284 pub(crate) extern "C" fn AcceptChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
1285 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAcceptChannel)).clone() })) as *mut c_void
1288 /// Creates a copy of the AcceptChannel
1289 pub extern "C" fn AcceptChannel_clone(orig: &AcceptChannel) -> AcceptChannel {
1292 /// Checks if two AcceptChannels contain equal inner contents.
1293 /// This ignores pointers and is_owned flags and looks at the values in fields.
1294 /// Two objects with NULL inner values will be considered "equal" here.
1296 pub extern "C" fn AcceptChannel_eq(a: &AcceptChannel, b: &AcceptChannel) -> bool {
1297 if a.inner == b.inner { return true; }
1298 if a.inner.is_null() || b.inner.is_null() { return false; }
1299 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1302 use lightning::ln::msgs::FundingCreated as nativeFundingCreatedImport;
1303 pub(crate) type nativeFundingCreated = nativeFundingCreatedImport;
1305 /// A funding_created message to be sent or received from a peer
1308 pub struct FundingCreated {
1309 /// A pointer to the opaque Rust object.
1311 /// Nearly everywhere, inner must be non-null, however in places where
1312 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1313 pub inner: *mut nativeFundingCreated,
1314 /// Indicates that this is the only struct which contains the same pointer.
1316 /// Rust functions which take ownership of an object provided via an argument require
1317 /// this to be true and invalidate the object pointed to by inner.
1321 impl Drop for FundingCreated {
1322 fn drop(&mut self) {
1323 if self.is_owned && !<*mut nativeFundingCreated>::is_null(self.inner) {
1324 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1328 /// Frees any resources used by the FundingCreated, if is_owned is set and inner is non-NULL.
1330 pub extern "C" fn FundingCreated_free(this_obj: FundingCreated) { }
1332 /// Used only if an object of this type is returned as a trait impl by a method
1333 pub(crate) extern "C" fn FundingCreated_free_void(this_ptr: *mut c_void) {
1334 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingCreated); }
1337 impl FundingCreated {
1338 pub(crate) fn get_native_ref(&self) -> &'static nativeFundingCreated {
1339 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1341 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingCreated {
1342 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1344 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1345 pub(crate) fn take_inner(mut self) -> *mut nativeFundingCreated {
1346 assert!(self.is_owned);
1347 let ret = ObjOps::untweak_ptr(self.inner);
1348 self.inner = core::ptr::null_mut();
1352 /// A temporary channel ID, until the funding is established
1354 pub extern "C" fn FundingCreated_get_temporary_channel_id(this_ptr: &FundingCreated) -> *const [u8; 32] {
1355 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
1358 /// A temporary channel ID, until the funding is established
1360 pub extern "C" fn FundingCreated_set_temporary_channel_id(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
1361 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
1363 /// The funding transaction ID
1365 pub extern "C" fn FundingCreated_get_funding_txid(this_ptr: &FundingCreated) -> *const [u8; 32] {
1366 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_txid;
1367 inner_val.as_inner()
1369 /// The funding transaction ID
1371 pub extern "C" fn FundingCreated_set_funding_txid(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
1372 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_txid = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
1374 /// The specific output index funding this channel
1376 pub extern "C" fn FundingCreated_get_funding_output_index(this_ptr: &FundingCreated) -> u16 {
1377 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_index;
1380 /// The specific output index funding this channel
1382 pub extern "C" fn FundingCreated_set_funding_output_index(this_ptr: &mut FundingCreated, mut val: u16) {
1383 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_index = val;
1385 /// The signature of the channel initiator (funder) on the initial commitment transaction
1387 pub extern "C" fn FundingCreated_get_signature(this_ptr: &FundingCreated) -> crate::c_types::Signature {
1388 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
1389 crate::c_types::Signature::from_rust(&inner_val)
1391 /// The signature of the channel initiator (funder) on the initial commitment transaction
1393 pub extern "C" fn FundingCreated_set_signature(this_ptr: &mut FundingCreated, mut val: crate::c_types::Signature) {
1394 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
1396 /// Constructs a new FundingCreated given each field
1399 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 {
1400 FundingCreated { inner: ObjOps::heap_alloc(nativeFundingCreated {
1401 temporary_channel_id: temporary_channel_id_arg.data,
1402 funding_txid: ::bitcoin::hash_types::Txid::from_slice(&funding_txid_arg.data[..]).unwrap(),
1403 funding_output_index: funding_output_index_arg,
1404 signature: signature_arg.into_rust(),
1405 }), is_owned: true }
1407 impl Clone for FundingCreated {
1408 fn clone(&self) -> Self {
1410 inner: if <*mut nativeFundingCreated>::is_null(self.inner) { core::ptr::null_mut() } else {
1411 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1417 /// Used only if an object of this type is returned as a trait impl by a method
1418 pub(crate) extern "C" fn FundingCreated_clone_void(this_ptr: *const c_void) -> *mut c_void {
1419 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingCreated)).clone() })) as *mut c_void
1422 /// Creates a copy of the FundingCreated
1423 pub extern "C" fn FundingCreated_clone(orig: &FundingCreated) -> FundingCreated {
1426 /// Checks if two FundingCreateds contain equal inner contents.
1427 /// This ignores pointers and is_owned flags and looks at the values in fields.
1428 /// Two objects with NULL inner values will be considered "equal" here.
1430 pub extern "C" fn FundingCreated_eq(a: &FundingCreated, b: &FundingCreated) -> bool {
1431 if a.inner == b.inner { return true; }
1432 if a.inner.is_null() || b.inner.is_null() { return false; }
1433 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1436 use lightning::ln::msgs::FundingSigned as nativeFundingSignedImport;
1437 pub(crate) type nativeFundingSigned = nativeFundingSignedImport;
1439 /// A funding_signed message to be sent or received from a peer
1442 pub struct FundingSigned {
1443 /// A pointer to the opaque Rust object.
1445 /// Nearly everywhere, inner must be non-null, however in places where
1446 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1447 pub inner: *mut nativeFundingSigned,
1448 /// Indicates that this is the only struct which contains the same pointer.
1450 /// Rust functions which take ownership of an object provided via an argument require
1451 /// this to be true and invalidate the object pointed to by inner.
1455 impl Drop for FundingSigned {
1456 fn drop(&mut self) {
1457 if self.is_owned && !<*mut nativeFundingSigned>::is_null(self.inner) {
1458 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1462 /// Frees any resources used by the FundingSigned, if is_owned is set and inner is non-NULL.
1464 pub extern "C" fn FundingSigned_free(this_obj: FundingSigned) { }
1466 /// Used only if an object of this type is returned as a trait impl by a method
1467 pub(crate) extern "C" fn FundingSigned_free_void(this_ptr: *mut c_void) {
1468 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingSigned); }
1471 impl FundingSigned {
1472 pub(crate) fn get_native_ref(&self) -> &'static nativeFundingSigned {
1473 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1475 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingSigned {
1476 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1478 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1479 pub(crate) fn take_inner(mut self) -> *mut nativeFundingSigned {
1480 assert!(self.is_owned);
1481 let ret = ObjOps::untweak_ptr(self.inner);
1482 self.inner = core::ptr::null_mut();
1488 pub extern "C" fn FundingSigned_get_channel_id(this_ptr: &FundingSigned) -> *const [u8; 32] {
1489 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1494 pub extern "C" fn FundingSigned_set_channel_id(this_ptr: &mut FundingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
1495 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1497 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
1499 pub extern "C" fn FundingSigned_get_signature(this_ptr: &FundingSigned) -> crate::c_types::Signature {
1500 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
1501 crate::c_types::Signature::from_rust(&inner_val)
1503 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
1505 pub extern "C" fn FundingSigned_set_signature(this_ptr: &mut FundingSigned, mut val: crate::c_types::Signature) {
1506 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
1508 /// Constructs a new FundingSigned given each field
1511 pub extern "C" fn FundingSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut signature_arg: crate::c_types::Signature) -> FundingSigned {
1512 FundingSigned { inner: ObjOps::heap_alloc(nativeFundingSigned {
1513 channel_id: channel_id_arg.data,
1514 signature: signature_arg.into_rust(),
1515 }), is_owned: true }
1517 impl Clone for FundingSigned {
1518 fn clone(&self) -> Self {
1520 inner: if <*mut nativeFundingSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
1521 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1527 /// Used only if an object of this type is returned as a trait impl by a method
1528 pub(crate) extern "C" fn FundingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
1529 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingSigned)).clone() })) as *mut c_void
1532 /// Creates a copy of the FundingSigned
1533 pub extern "C" fn FundingSigned_clone(orig: &FundingSigned) -> FundingSigned {
1536 /// Checks if two FundingSigneds contain equal inner contents.
1537 /// This ignores pointers and is_owned flags and looks at the values in fields.
1538 /// Two objects with NULL inner values will be considered "equal" here.
1540 pub extern "C" fn FundingSigned_eq(a: &FundingSigned, b: &FundingSigned) -> bool {
1541 if a.inner == b.inner { return true; }
1542 if a.inner.is_null() || b.inner.is_null() { return false; }
1543 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1546 use lightning::ln::msgs::ChannelReady as nativeChannelReadyImport;
1547 pub(crate) type nativeChannelReady = nativeChannelReadyImport;
1549 /// A channel_ready message to be sent or received from a peer
1552 pub struct ChannelReady {
1553 /// A pointer to the opaque Rust object.
1555 /// Nearly everywhere, inner must be non-null, however in places where
1556 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1557 pub inner: *mut nativeChannelReady,
1558 /// Indicates that this is the only struct which contains the same pointer.
1560 /// Rust functions which take ownership of an object provided via an argument require
1561 /// this to be true and invalidate the object pointed to by inner.
1565 impl Drop for ChannelReady {
1566 fn drop(&mut self) {
1567 if self.is_owned && !<*mut nativeChannelReady>::is_null(self.inner) {
1568 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1572 /// Frees any resources used by the ChannelReady, if is_owned is set and inner is non-NULL.
1574 pub extern "C" fn ChannelReady_free(this_obj: ChannelReady) { }
1576 /// Used only if an object of this type is returned as a trait impl by a method
1577 pub(crate) extern "C" fn ChannelReady_free_void(this_ptr: *mut c_void) {
1578 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelReady); }
1582 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelReady {
1583 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1585 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelReady {
1586 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1588 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1589 pub(crate) fn take_inner(mut self) -> *mut nativeChannelReady {
1590 assert!(self.is_owned);
1591 let ret = ObjOps::untweak_ptr(self.inner);
1592 self.inner = core::ptr::null_mut();
1598 pub extern "C" fn ChannelReady_get_channel_id(this_ptr: &ChannelReady) -> *const [u8; 32] {
1599 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1604 pub extern "C" fn ChannelReady_set_channel_id(this_ptr: &mut ChannelReady, mut val: crate::c_types::ThirtyTwoBytes) {
1605 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1607 /// The per-commitment point of the second commitment transaction
1609 pub extern "C" fn ChannelReady_get_next_per_commitment_point(this_ptr: &ChannelReady) -> crate::c_types::PublicKey {
1610 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
1611 crate::c_types::PublicKey::from_rust(&inner_val)
1613 /// The per-commitment point of the second commitment transaction
1615 pub extern "C" fn ChannelReady_set_next_per_commitment_point(this_ptr: &mut ChannelReady, mut val: crate::c_types::PublicKey) {
1616 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
1618 /// If set, provides a short_channel_id alias for this channel. The sender will accept payments
1619 /// to be forwarded over this SCID and forward them to this messages' recipient.
1621 pub extern "C" fn ChannelReady_get_short_channel_id_alias(this_ptr: &ChannelReady) -> crate::c_types::derived::COption_u64Z {
1622 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id_alias;
1623 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() }) };
1626 /// If set, provides a short_channel_id alias for this channel. The sender will accept payments
1627 /// to be forwarded over this SCID and forward them to this messages' recipient.
1629 pub extern "C" fn ChannelReady_set_short_channel_id_alias(this_ptr: &mut ChannelReady, mut val: crate::c_types::derived::COption_u64Z) {
1630 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1631 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id_alias = local_val;
1633 /// Constructs a new ChannelReady given each field
1636 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 {
1637 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 };
1638 ChannelReady { inner: ObjOps::heap_alloc(nativeChannelReady {
1639 channel_id: channel_id_arg.data,
1640 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
1641 short_channel_id_alias: local_short_channel_id_alias_arg,
1642 }), is_owned: true }
1644 impl Clone for ChannelReady {
1645 fn clone(&self) -> Self {
1647 inner: if <*mut nativeChannelReady>::is_null(self.inner) { core::ptr::null_mut() } else {
1648 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1654 /// Used only if an object of this type is returned as a trait impl by a method
1655 pub(crate) extern "C" fn ChannelReady_clone_void(this_ptr: *const c_void) -> *mut c_void {
1656 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelReady)).clone() })) as *mut c_void
1659 /// Creates a copy of the ChannelReady
1660 pub extern "C" fn ChannelReady_clone(orig: &ChannelReady) -> ChannelReady {
1663 /// Checks if two ChannelReadys contain equal inner contents.
1664 /// This ignores pointers and is_owned flags and looks at the values in fields.
1665 /// Two objects with NULL inner values will be considered "equal" here.
1667 pub extern "C" fn ChannelReady_eq(a: &ChannelReady, b: &ChannelReady) -> bool {
1668 if a.inner == b.inner { return true; }
1669 if a.inner.is_null() || b.inner.is_null() { return false; }
1670 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1673 use lightning::ln::msgs::Shutdown as nativeShutdownImport;
1674 pub(crate) type nativeShutdown = nativeShutdownImport;
1676 /// A shutdown message to be sent or received from a peer
1679 pub struct Shutdown {
1680 /// A pointer to the opaque Rust object.
1682 /// Nearly everywhere, inner must be non-null, however in places where
1683 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1684 pub inner: *mut nativeShutdown,
1685 /// Indicates that this is the only struct which contains the same pointer.
1687 /// Rust functions which take ownership of an object provided via an argument require
1688 /// this to be true and invalidate the object pointed to by inner.
1692 impl Drop for Shutdown {
1693 fn drop(&mut self) {
1694 if self.is_owned && !<*mut nativeShutdown>::is_null(self.inner) {
1695 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1699 /// Frees any resources used by the Shutdown, if is_owned is set and inner is non-NULL.
1701 pub extern "C" fn Shutdown_free(this_obj: Shutdown) { }
1703 /// Used only if an object of this type is returned as a trait impl by a method
1704 pub(crate) extern "C" fn Shutdown_free_void(this_ptr: *mut c_void) {
1705 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeShutdown); }
1709 pub(crate) fn get_native_ref(&self) -> &'static nativeShutdown {
1710 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1712 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeShutdown {
1713 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1715 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1716 pub(crate) fn take_inner(mut self) -> *mut nativeShutdown {
1717 assert!(self.is_owned);
1718 let ret = ObjOps::untweak_ptr(self.inner);
1719 self.inner = core::ptr::null_mut();
1725 pub extern "C" fn Shutdown_get_channel_id(this_ptr: &Shutdown) -> *const [u8; 32] {
1726 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1731 pub extern "C" fn Shutdown_set_channel_id(this_ptr: &mut Shutdown, mut val: crate::c_types::ThirtyTwoBytes) {
1732 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1734 /// The destination of this peer's funds on closing.
1735 /// Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
1737 pub extern "C" fn Shutdown_get_scriptpubkey(this_ptr: &Shutdown) -> crate::c_types::u8slice {
1738 let mut inner_val = &mut this_ptr.get_native_mut_ref().scriptpubkey;
1739 crate::c_types::u8slice::from_slice(&inner_val[..])
1741 /// The destination of this peer's funds on closing.
1742 /// Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
1744 pub extern "C" fn Shutdown_set_scriptpubkey(this_ptr: &mut Shutdown, mut val: crate::c_types::derived::CVec_u8Z) {
1745 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.scriptpubkey = ::bitcoin::blockdata::script::Script::from(val.into_rust());
1747 /// Constructs a new Shutdown given each field
1750 pub extern "C" fn Shutdown_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut scriptpubkey_arg: crate::c_types::derived::CVec_u8Z) -> Shutdown {
1751 Shutdown { inner: ObjOps::heap_alloc(nativeShutdown {
1752 channel_id: channel_id_arg.data,
1753 scriptpubkey: ::bitcoin::blockdata::script::Script::from(scriptpubkey_arg.into_rust()),
1754 }), is_owned: true }
1756 impl Clone for Shutdown {
1757 fn clone(&self) -> Self {
1759 inner: if <*mut nativeShutdown>::is_null(self.inner) { core::ptr::null_mut() } else {
1760 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1766 /// Used only if an object of this type is returned as a trait impl by a method
1767 pub(crate) extern "C" fn Shutdown_clone_void(this_ptr: *const c_void) -> *mut c_void {
1768 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeShutdown)).clone() })) as *mut c_void
1771 /// Creates a copy of the Shutdown
1772 pub extern "C" fn Shutdown_clone(orig: &Shutdown) -> Shutdown {
1775 /// Checks if two Shutdowns contain equal inner contents.
1776 /// This ignores pointers and is_owned flags and looks at the values in fields.
1777 /// Two objects with NULL inner values will be considered "equal" here.
1779 pub extern "C" fn Shutdown_eq(a: &Shutdown, b: &Shutdown) -> bool {
1780 if a.inner == b.inner { return true; }
1781 if a.inner.is_null() || b.inner.is_null() { return false; }
1782 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1785 use lightning::ln::msgs::ClosingSignedFeeRange as nativeClosingSignedFeeRangeImport;
1786 pub(crate) type nativeClosingSignedFeeRange = nativeClosingSignedFeeRangeImport;
1788 /// The minimum and maximum fees which the sender is willing to place on the closing transaction.
1789 /// This is provided in [`ClosingSigned`] by both sides to indicate the fee range they are willing
1793 pub struct ClosingSignedFeeRange {
1794 /// A pointer to the opaque Rust object.
1796 /// Nearly everywhere, inner must be non-null, however in places where
1797 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1798 pub inner: *mut nativeClosingSignedFeeRange,
1799 /// Indicates that this is the only struct which contains the same pointer.
1801 /// Rust functions which take ownership of an object provided via an argument require
1802 /// this to be true and invalidate the object pointed to by inner.
1806 impl Drop for ClosingSignedFeeRange {
1807 fn drop(&mut self) {
1808 if self.is_owned && !<*mut nativeClosingSignedFeeRange>::is_null(self.inner) {
1809 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1813 /// Frees any resources used by the ClosingSignedFeeRange, if is_owned is set and inner is non-NULL.
1815 pub extern "C" fn ClosingSignedFeeRange_free(this_obj: ClosingSignedFeeRange) { }
1817 /// Used only if an object of this type is returned as a trait impl by a method
1818 pub(crate) extern "C" fn ClosingSignedFeeRange_free_void(this_ptr: *mut c_void) {
1819 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeClosingSignedFeeRange); }
1822 impl ClosingSignedFeeRange {
1823 pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSignedFeeRange {
1824 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1826 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSignedFeeRange {
1827 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1829 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1830 pub(crate) fn take_inner(mut self) -> *mut nativeClosingSignedFeeRange {
1831 assert!(self.is_owned);
1832 let ret = ObjOps::untweak_ptr(self.inner);
1833 self.inner = core::ptr::null_mut();
1837 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
1840 pub extern "C" fn ClosingSignedFeeRange_get_min_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
1841 let mut inner_val = &mut this_ptr.get_native_mut_ref().min_fee_satoshis;
1844 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
1847 pub extern "C" fn ClosingSignedFeeRange_set_min_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
1848 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_fee_satoshis = val;
1850 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
1853 pub extern "C" fn ClosingSignedFeeRange_get_max_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
1854 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_fee_satoshis;
1857 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
1860 pub extern "C" fn ClosingSignedFeeRange_set_max_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
1861 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_fee_satoshis = val;
1863 /// Constructs a new ClosingSignedFeeRange given each field
1866 pub extern "C" fn ClosingSignedFeeRange_new(mut min_fee_satoshis_arg: u64, mut max_fee_satoshis_arg: u64) -> ClosingSignedFeeRange {
1867 ClosingSignedFeeRange { inner: ObjOps::heap_alloc(nativeClosingSignedFeeRange {
1868 min_fee_satoshis: min_fee_satoshis_arg,
1869 max_fee_satoshis: max_fee_satoshis_arg,
1870 }), is_owned: true }
1872 impl Clone for ClosingSignedFeeRange {
1873 fn clone(&self) -> Self {
1875 inner: if <*mut nativeClosingSignedFeeRange>::is_null(self.inner) { core::ptr::null_mut() } else {
1876 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1882 /// Used only if an object of this type is returned as a trait impl by a method
1883 pub(crate) extern "C" fn ClosingSignedFeeRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
1884 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClosingSignedFeeRange)).clone() })) as *mut c_void
1887 /// Creates a copy of the ClosingSignedFeeRange
1888 pub extern "C" fn ClosingSignedFeeRange_clone(orig: &ClosingSignedFeeRange) -> ClosingSignedFeeRange {
1891 /// Checks if two ClosingSignedFeeRanges contain equal inner contents.
1892 /// This ignores pointers and is_owned flags and looks at the values in fields.
1893 /// Two objects with NULL inner values will be considered "equal" here.
1895 pub extern "C" fn ClosingSignedFeeRange_eq(a: &ClosingSignedFeeRange, b: &ClosingSignedFeeRange) -> bool {
1896 if a.inner == b.inner { return true; }
1897 if a.inner.is_null() || b.inner.is_null() { return false; }
1898 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1901 use lightning::ln::msgs::ClosingSigned as nativeClosingSignedImport;
1902 pub(crate) type nativeClosingSigned = nativeClosingSignedImport;
1904 /// A closing_signed message to be sent or received from a peer
1907 pub struct ClosingSigned {
1908 /// A pointer to the opaque Rust object.
1910 /// Nearly everywhere, inner must be non-null, however in places where
1911 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1912 pub inner: *mut nativeClosingSigned,
1913 /// Indicates that this is the only struct which contains the same pointer.
1915 /// Rust functions which take ownership of an object provided via an argument require
1916 /// this to be true and invalidate the object pointed to by inner.
1920 impl Drop for ClosingSigned {
1921 fn drop(&mut self) {
1922 if self.is_owned && !<*mut nativeClosingSigned>::is_null(self.inner) {
1923 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1927 /// Frees any resources used by the ClosingSigned, if is_owned is set and inner is non-NULL.
1929 pub extern "C" fn ClosingSigned_free(this_obj: ClosingSigned) { }
1931 /// Used only if an object of this type is returned as a trait impl by a method
1932 pub(crate) extern "C" fn ClosingSigned_free_void(this_ptr: *mut c_void) {
1933 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeClosingSigned); }
1936 impl ClosingSigned {
1937 pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSigned {
1938 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1940 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSigned {
1941 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1943 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1944 pub(crate) fn take_inner(mut self) -> *mut nativeClosingSigned {
1945 assert!(self.is_owned);
1946 let ret = ObjOps::untweak_ptr(self.inner);
1947 self.inner = core::ptr::null_mut();
1953 pub extern "C" fn ClosingSigned_get_channel_id(this_ptr: &ClosingSigned) -> *const [u8; 32] {
1954 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1959 pub extern "C" fn ClosingSigned_set_channel_id(this_ptr: &mut ClosingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
1960 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1962 /// The proposed total fee for the closing transaction
1964 pub extern "C" fn ClosingSigned_get_fee_satoshis(this_ptr: &ClosingSigned) -> u64 {
1965 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_satoshis;
1968 /// The proposed total fee for the closing transaction
1970 pub extern "C" fn ClosingSigned_set_fee_satoshis(this_ptr: &mut ClosingSigned, mut val: u64) {
1971 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_satoshis = val;
1973 /// A signature on the closing transaction
1975 pub extern "C" fn ClosingSigned_get_signature(this_ptr: &ClosingSigned) -> crate::c_types::Signature {
1976 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
1977 crate::c_types::Signature::from_rust(&inner_val)
1979 /// A signature on the closing transaction
1981 pub extern "C" fn ClosingSigned_set_signature(this_ptr: &mut ClosingSigned, mut val: crate::c_types::Signature) {
1982 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
1984 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
1987 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1989 pub extern "C" fn ClosingSigned_get_fee_range(this_ptr: &ClosingSigned) -> crate::lightning::ln::msgs::ClosingSignedFeeRange {
1990 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_range;
1991 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 };
1994 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
1997 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1999 pub extern "C" fn ClosingSigned_set_fee_range(this_ptr: &mut ClosingSigned, mut val: crate::lightning::ln::msgs::ClosingSignedFeeRange) {
2000 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
2001 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_range = local_val;
2003 /// Constructs a new ClosingSigned given each field
2006 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 {
2007 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()) } }) };
2008 ClosingSigned { inner: ObjOps::heap_alloc(nativeClosingSigned {
2009 channel_id: channel_id_arg.data,
2010 fee_satoshis: fee_satoshis_arg,
2011 signature: signature_arg.into_rust(),
2012 fee_range: local_fee_range_arg,
2013 }), is_owned: true }
2015 impl Clone for ClosingSigned {
2016 fn clone(&self) -> Self {
2018 inner: if <*mut nativeClosingSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
2019 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2025 /// Used only if an object of this type is returned as a trait impl by a method
2026 pub(crate) extern "C" fn ClosingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
2027 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClosingSigned)).clone() })) as *mut c_void
2030 /// Creates a copy of the ClosingSigned
2031 pub extern "C" fn ClosingSigned_clone(orig: &ClosingSigned) -> ClosingSigned {
2034 /// Checks if two ClosingSigneds contain equal inner contents.
2035 /// This ignores pointers and is_owned flags and looks at the values in fields.
2036 /// Two objects with NULL inner values will be considered "equal" here.
2038 pub extern "C" fn ClosingSigned_eq(a: &ClosingSigned, b: &ClosingSigned) -> bool {
2039 if a.inner == b.inner { return true; }
2040 if a.inner.is_null() || b.inner.is_null() { return false; }
2041 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2044 use lightning::ln::msgs::UpdateAddHTLC as nativeUpdateAddHTLCImport;
2045 pub(crate) type nativeUpdateAddHTLC = nativeUpdateAddHTLCImport;
2047 /// An update_add_htlc message to be sent or received from a peer
2050 pub struct UpdateAddHTLC {
2051 /// A pointer to the opaque Rust object.
2053 /// Nearly everywhere, inner must be non-null, however in places where
2054 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2055 pub inner: *mut nativeUpdateAddHTLC,
2056 /// Indicates that this is the only struct which contains the same pointer.
2058 /// Rust functions which take ownership of an object provided via an argument require
2059 /// this to be true and invalidate the object pointed to by inner.
2063 impl Drop for UpdateAddHTLC {
2064 fn drop(&mut self) {
2065 if self.is_owned && !<*mut nativeUpdateAddHTLC>::is_null(self.inner) {
2066 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2070 /// Frees any resources used by the UpdateAddHTLC, if is_owned is set and inner is non-NULL.
2072 pub extern "C" fn UpdateAddHTLC_free(this_obj: UpdateAddHTLC) { }
2074 /// Used only if an object of this type is returned as a trait impl by a method
2075 pub(crate) extern "C" fn UpdateAddHTLC_free_void(this_ptr: *mut c_void) {
2076 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateAddHTLC); }
2079 impl UpdateAddHTLC {
2080 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateAddHTLC {
2081 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2083 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateAddHTLC {
2084 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2086 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2087 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateAddHTLC {
2088 assert!(self.is_owned);
2089 let ret = ObjOps::untweak_ptr(self.inner);
2090 self.inner = core::ptr::null_mut();
2096 pub extern "C" fn UpdateAddHTLC_get_channel_id(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
2097 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2102 pub extern "C" fn UpdateAddHTLC_set_channel_id(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
2103 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2107 pub extern "C" fn UpdateAddHTLC_get_htlc_id(this_ptr: &UpdateAddHTLC) -> u64 {
2108 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
2113 pub extern "C" fn UpdateAddHTLC_set_htlc_id(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
2114 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
2116 /// The HTLC value in milli-satoshi
2118 pub extern "C" fn UpdateAddHTLC_get_amount_msat(this_ptr: &UpdateAddHTLC) -> u64 {
2119 let mut inner_val = &mut this_ptr.get_native_mut_ref().amount_msat;
2122 /// The HTLC value in milli-satoshi
2124 pub extern "C" fn UpdateAddHTLC_set_amount_msat(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
2125 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.amount_msat = val;
2127 /// The payment hash, the pre-image of which controls HTLC redemption
2129 pub extern "C" fn UpdateAddHTLC_get_payment_hash(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
2130 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_hash;
2133 /// The payment hash, the pre-image of which controls HTLC redemption
2135 pub extern "C" fn UpdateAddHTLC_set_payment_hash(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
2136 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_hash = ::lightning::ln::PaymentHash(val.data);
2138 /// The expiry height of the HTLC
2140 pub extern "C" fn UpdateAddHTLC_get_cltv_expiry(this_ptr: &UpdateAddHTLC) -> u32 {
2141 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry;
2144 /// The expiry height of the HTLC
2146 pub extern "C" fn UpdateAddHTLC_set_cltv_expiry(this_ptr: &mut UpdateAddHTLC, mut val: u32) {
2147 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry = val;
2149 impl Clone for UpdateAddHTLC {
2150 fn clone(&self) -> Self {
2152 inner: if <*mut nativeUpdateAddHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
2153 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2159 /// Used only if an object of this type is returned as a trait impl by a method
2160 pub(crate) extern "C" fn UpdateAddHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
2161 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateAddHTLC)).clone() })) as *mut c_void
2164 /// Creates a copy of the UpdateAddHTLC
2165 pub extern "C" fn UpdateAddHTLC_clone(orig: &UpdateAddHTLC) -> UpdateAddHTLC {
2168 /// Checks if two UpdateAddHTLCs contain equal inner contents.
2169 /// This ignores pointers and is_owned flags and looks at the values in fields.
2170 /// Two objects with NULL inner values will be considered "equal" here.
2172 pub extern "C" fn UpdateAddHTLC_eq(a: &UpdateAddHTLC, b: &UpdateAddHTLC) -> bool {
2173 if a.inner == b.inner { return true; }
2174 if a.inner.is_null() || b.inner.is_null() { return false; }
2175 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2178 use lightning::ln::msgs::OnionMessage as nativeOnionMessageImport;
2179 pub(crate) type nativeOnionMessage = nativeOnionMessageImport;
2181 /// An onion message to be sent or received from a peer
2184 pub struct OnionMessage {
2185 /// A pointer to the opaque Rust object.
2187 /// Nearly everywhere, inner must be non-null, however in places where
2188 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2189 pub inner: *mut nativeOnionMessage,
2190 /// Indicates that this is the only struct which contains the same pointer.
2192 /// Rust functions which take ownership of an object provided via an argument require
2193 /// this to be true and invalidate the object pointed to by inner.
2197 impl Drop for OnionMessage {
2198 fn drop(&mut self) {
2199 if self.is_owned && !<*mut nativeOnionMessage>::is_null(self.inner) {
2200 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2204 /// Frees any resources used by the OnionMessage, if is_owned is set and inner is non-NULL.
2206 pub extern "C" fn OnionMessage_free(this_obj: OnionMessage) { }
2208 /// Used only if an object of this type is returned as a trait impl by a method
2209 pub(crate) extern "C" fn OnionMessage_free_void(this_ptr: *mut c_void) {
2210 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeOnionMessage); }
2214 pub(crate) fn get_native_ref(&self) -> &'static nativeOnionMessage {
2215 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2217 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOnionMessage {
2218 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2220 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2221 pub(crate) fn take_inner(mut self) -> *mut nativeOnionMessage {
2222 assert!(self.is_owned);
2223 let ret = ObjOps::untweak_ptr(self.inner);
2224 self.inner = core::ptr::null_mut();
2228 /// Used in decrypting the onion packet's payload.
2230 pub extern "C" fn OnionMessage_get_blinding_point(this_ptr: &OnionMessage) -> crate::c_types::PublicKey {
2231 let mut inner_val = &mut this_ptr.get_native_mut_ref().blinding_point;
2232 crate::c_types::PublicKey::from_rust(&inner_val)
2234 /// Used in decrypting the onion packet's payload.
2236 pub extern "C" fn OnionMessage_set_blinding_point(this_ptr: &mut OnionMessage, mut val: crate::c_types::PublicKey) {
2237 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.blinding_point = val.into_rust();
2239 impl Clone for OnionMessage {
2240 fn clone(&self) -> Self {
2242 inner: if <*mut nativeOnionMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
2243 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2249 /// Used only if an object of this type is returned as a trait impl by a method
2250 pub(crate) extern "C" fn OnionMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
2251 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOnionMessage)).clone() })) as *mut c_void
2254 /// Creates a copy of the OnionMessage
2255 pub extern "C" fn OnionMessage_clone(orig: &OnionMessage) -> OnionMessage {
2258 /// Checks if two OnionMessages contain equal inner contents.
2259 /// This ignores pointers and is_owned flags and looks at the values in fields.
2260 /// Two objects with NULL inner values will be considered "equal" here.
2262 pub extern "C" fn OnionMessage_eq(a: &OnionMessage, b: &OnionMessage) -> bool {
2263 if a.inner == b.inner { return true; }
2264 if a.inner.is_null() || b.inner.is_null() { return false; }
2265 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2268 use lightning::ln::msgs::UpdateFulfillHTLC as nativeUpdateFulfillHTLCImport;
2269 pub(crate) type nativeUpdateFulfillHTLC = nativeUpdateFulfillHTLCImport;
2271 /// An update_fulfill_htlc message to be sent or received from a peer
2274 pub struct UpdateFulfillHTLC {
2275 /// A pointer to the opaque Rust object.
2277 /// Nearly everywhere, inner must be non-null, however in places where
2278 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2279 pub inner: *mut nativeUpdateFulfillHTLC,
2280 /// Indicates that this is the only struct which contains the same pointer.
2282 /// Rust functions which take ownership of an object provided via an argument require
2283 /// this to be true and invalidate the object pointed to by inner.
2287 impl Drop for UpdateFulfillHTLC {
2288 fn drop(&mut self) {
2289 if self.is_owned && !<*mut nativeUpdateFulfillHTLC>::is_null(self.inner) {
2290 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2294 /// Frees any resources used by the UpdateFulfillHTLC, if is_owned is set and inner is non-NULL.
2296 pub extern "C" fn UpdateFulfillHTLC_free(this_obj: UpdateFulfillHTLC) { }
2298 /// Used only if an object of this type is returned as a trait impl by a method
2299 pub(crate) extern "C" fn UpdateFulfillHTLC_free_void(this_ptr: *mut c_void) {
2300 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFulfillHTLC); }
2303 impl UpdateFulfillHTLC {
2304 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFulfillHTLC {
2305 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2307 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFulfillHTLC {
2308 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2310 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2311 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFulfillHTLC {
2312 assert!(self.is_owned);
2313 let ret = ObjOps::untweak_ptr(self.inner);
2314 self.inner = core::ptr::null_mut();
2320 pub extern "C" fn UpdateFulfillHTLC_get_channel_id(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
2321 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2326 pub extern "C" fn UpdateFulfillHTLC_set_channel_id(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
2327 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2331 pub extern "C" fn UpdateFulfillHTLC_get_htlc_id(this_ptr: &UpdateFulfillHTLC) -> u64 {
2332 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
2337 pub extern "C" fn UpdateFulfillHTLC_set_htlc_id(this_ptr: &mut UpdateFulfillHTLC, mut val: u64) {
2338 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
2340 /// The pre-image of the payment hash, allowing HTLC redemption
2342 pub extern "C" fn UpdateFulfillHTLC_get_payment_preimage(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
2343 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_preimage;
2346 /// The pre-image of the payment hash, allowing HTLC redemption
2348 pub extern "C" fn UpdateFulfillHTLC_set_payment_preimage(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
2349 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_preimage = ::lightning::ln::PaymentPreimage(val.data);
2351 /// Constructs a new UpdateFulfillHTLC given each field
2354 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 {
2355 UpdateFulfillHTLC { inner: ObjOps::heap_alloc(nativeUpdateFulfillHTLC {
2356 channel_id: channel_id_arg.data,
2357 htlc_id: htlc_id_arg,
2358 payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_arg.data),
2359 }), is_owned: true }
2361 impl Clone for UpdateFulfillHTLC {
2362 fn clone(&self) -> Self {
2364 inner: if <*mut nativeUpdateFulfillHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
2365 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2371 /// Used only if an object of this type is returned as a trait impl by a method
2372 pub(crate) extern "C" fn UpdateFulfillHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
2373 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFulfillHTLC)).clone() })) as *mut c_void
2376 /// Creates a copy of the UpdateFulfillHTLC
2377 pub extern "C" fn UpdateFulfillHTLC_clone(orig: &UpdateFulfillHTLC) -> UpdateFulfillHTLC {
2380 /// Checks if two UpdateFulfillHTLCs contain equal inner contents.
2381 /// This ignores pointers and is_owned flags and looks at the values in fields.
2382 /// Two objects with NULL inner values will be considered "equal" here.
2384 pub extern "C" fn UpdateFulfillHTLC_eq(a: &UpdateFulfillHTLC, b: &UpdateFulfillHTLC) -> bool {
2385 if a.inner == b.inner { return true; }
2386 if a.inner.is_null() || b.inner.is_null() { return false; }
2387 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2390 use lightning::ln::msgs::UpdateFailHTLC as nativeUpdateFailHTLCImport;
2391 pub(crate) type nativeUpdateFailHTLC = nativeUpdateFailHTLCImport;
2393 /// An update_fail_htlc message to be sent or received from a peer
2396 pub struct UpdateFailHTLC {
2397 /// A pointer to the opaque Rust object.
2399 /// Nearly everywhere, inner must be non-null, however in places where
2400 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2401 pub inner: *mut nativeUpdateFailHTLC,
2402 /// Indicates that this is the only struct which contains the same pointer.
2404 /// Rust functions which take ownership of an object provided via an argument require
2405 /// this to be true and invalidate the object pointed to by inner.
2409 impl Drop for UpdateFailHTLC {
2410 fn drop(&mut self) {
2411 if self.is_owned && !<*mut nativeUpdateFailHTLC>::is_null(self.inner) {
2412 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2416 /// Frees any resources used by the UpdateFailHTLC, if is_owned is set and inner is non-NULL.
2418 pub extern "C" fn UpdateFailHTLC_free(this_obj: UpdateFailHTLC) { }
2420 /// Used only if an object of this type is returned as a trait impl by a method
2421 pub(crate) extern "C" fn UpdateFailHTLC_free_void(this_ptr: *mut c_void) {
2422 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFailHTLC); }
2425 impl UpdateFailHTLC {
2426 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailHTLC {
2427 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2429 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailHTLC {
2430 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2432 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2433 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailHTLC {
2434 assert!(self.is_owned);
2435 let ret = ObjOps::untweak_ptr(self.inner);
2436 self.inner = core::ptr::null_mut();
2442 pub extern "C" fn UpdateFailHTLC_get_channel_id(this_ptr: &UpdateFailHTLC) -> *const [u8; 32] {
2443 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2448 pub extern "C" fn UpdateFailHTLC_set_channel_id(this_ptr: &mut UpdateFailHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
2449 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2453 pub extern "C" fn UpdateFailHTLC_get_htlc_id(this_ptr: &UpdateFailHTLC) -> u64 {
2454 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
2459 pub extern "C" fn UpdateFailHTLC_set_htlc_id(this_ptr: &mut UpdateFailHTLC, mut val: u64) {
2460 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
2462 impl Clone for UpdateFailHTLC {
2463 fn clone(&self) -> Self {
2465 inner: if <*mut nativeUpdateFailHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
2466 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2472 /// Used only if an object of this type is returned as a trait impl by a method
2473 pub(crate) extern "C" fn UpdateFailHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
2474 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailHTLC)).clone() })) as *mut c_void
2477 /// Creates a copy of the UpdateFailHTLC
2478 pub extern "C" fn UpdateFailHTLC_clone(orig: &UpdateFailHTLC) -> UpdateFailHTLC {
2481 /// Checks if two UpdateFailHTLCs contain equal inner contents.
2482 /// This ignores pointers and is_owned flags and looks at the values in fields.
2483 /// Two objects with NULL inner values will be considered "equal" here.
2485 pub extern "C" fn UpdateFailHTLC_eq(a: &UpdateFailHTLC, b: &UpdateFailHTLC) -> bool {
2486 if a.inner == b.inner { return true; }
2487 if a.inner.is_null() || b.inner.is_null() { return false; }
2488 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2491 use lightning::ln::msgs::UpdateFailMalformedHTLC as nativeUpdateFailMalformedHTLCImport;
2492 pub(crate) type nativeUpdateFailMalformedHTLC = nativeUpdateFailMalformedHTLCImport;
2494 /// An update_fail_malformed_htlc message to be sent or received from a peer
2497 pub struct UpdateFailMalformedHTLC {
2498 /// A pointer to the opaque Rust object.
2500 /// Nearly everywhere, inner must be non-null, however in places where
2501 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2502 pub inner: *mut nativeUpdateFailMalformedHTLC,
2503 /// Indicates that this is the only struct which contains the same pointer.
2505 /// Rust functions which take ownership of an object provided via an argument require
2506 /// this to be true and invalidate the object pointed to by inner.
2510 impl Drop for UpdateFailMalformedHTLC {
2511 fn drop(&mut self) {
2512 if self.is_owned && !<*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) {
2513 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2517 /// Frees any resources used by the UpdateFailMalformedHTLC, if is_owned is set and inner is non-NULL.
2519 pub extern "C" fn UpdateFailMalformedHTLC_free(this_obj: UpdateFailMalformedHTLC) { }
2521 /// Used only if an object of this type is returned as a trait impl by a method
2522 pub(crate) extern "C" fn UpdateFailMalformedHTLC_free_void(this_ptr: *mut c_void) {
2523 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFailMalformedHTLC); }
2526 impl UpdateFailMalformedHTLC {
2527 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailMalformedHTLC {
2528 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2530 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailMalformedHTLC {
2531 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2533 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2534 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailMalformedHTLC {
2535 assert!(self.is_owned);
2536 let ret = ObjOps::untweak_ptr(self.inner);
2537 self.inner = core::ptr::null_mut();
2543 pub extern "C" fn UpdateFailMalformedHTLC_get_channel_id(this_ptr: &UpdateFailMalformedHTLC) -> *const [u8; 32] {
2544 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2549 pub extern "C" fn UpdateFailMalformedHTLC_set_channel_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
2550 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2554 pub extern "C" fn UpdateFailMalformedHTLC_get_htlc_id(this_ptr: &UpdateFailMalformedHTLC) -> u64 {
2555 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
2560 pub extern "C" fn UpdateFailMalformedHTLC_set_htlc_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u64) {
2561 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
2563 /// The failure code
2565 pub extern "C" fn UpdateFailMalformedHTLC_get_failure_code(this_ptr: &UpdateFailMalformedHTLC) -> u16 {
2566 let mut inner_val = &mut this_ptr.get_native_mut_ref().failure_code;
2569 /// The failure code
2571 pub extern "C" fn UpdateFailMalformedHTLC_set_failure_code(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u16) {
2572 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.failure_code = val;
2574 impl Clone for UpdateFailMalformedHTLC {
2575 fn clone(&self) -> Self {
2577 inner: if <*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
2578 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2584 /// Used only if an object of this type is returned as a trait impl by a method
2585 pub(crate) extern "C" fn UpdateFailMalformedHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
2586 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailMalformedHTLC)).clone() })) as *mut c_void
2589 /// Creates a copy of the UpdateFailMalformedHTLC
2590 pub extern "C" fn UpdateFailMalformedHTLC_clone(orig: &UpdateFailMalformedHTLC) -> UpdateFailMalformedHTLC {
2593 /// Checks if two UpdateFailMalformedHTLCs contain equal inner contents.
2594 /// This ignores pointers and is_owned flags and looks at the values in fields.
2595 /// Two objects with NULL inner values will be considered "equal" here.
2597 pub extern "C" fn UpdateFailMalformedHTLC_eq(a: &UpdateFailMalformedHTLC, b: &UpdateFailMalformedHTLC) -> bool {
2598 if a.inner == b.inner { return true; }
2599 if a.inner.is_null() || b.inner.is_null() { return false; }
2600 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2603 use lightning::ln::msgs::CommitmentSigned as nativeCommitmentSignedImport;
2604 pub(crate) type nativeCommitmentSigned = nativeCommitmentSignedImport;
2606 /// A commitment_signed message to be sent or received from a peer
2609 pub struct CommitmentSigned {
2610 /// A pointer to the opaque Rust object.
2612 /// Nearly everywhere, inner must be non-null, however in places where
2613 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2614 pub inner: *mut nativeCommitmentSigned,
2615 /// Indicates that this is the only struct which contains the same pointer.
2617 /// Rust functions which take ownership of an object provided via an argument require
2618 /// this to be true and invalidate the object pointed to by inner.
2622 impl Drop for CommitmentSigned {
2623 fn drop(&mut self) {
2624 if self.is_owned && !<*mut nativeCommitmentSigned>::is_null(self.inner) {
2625 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2629 /// Frees any resources used by the CommitmentSigned, if is_owned is set and inner is non-NULL.
2631 pub extern "C" fn CommitmentSigned_free(this_obj: CommitmentSigned) { }
2633 /// Used only if an object of this type is returned as a trait impl by a method
2634 pub(crate) extern "C" fn CommitmentSigned_free_void(this_ptr: *mut c_void) {
2635 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentSigned); }
2638 impl CommitmentSigned {
2639 pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentSigned {
2640 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2642 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentSigned {
2643 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2645 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2646 pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentSigned {
2647 assert!(self.is_owned);
2648 let ret = ObjOps::untweak_ptr(self.inner);
2649 self.inner = core::ptr::null_mut();
2655 pub extern "C" fn CommitmentSigned_get_channel_id(this_ptr: &CommitmentSigned) -> *const [u8; 32] {
2656 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2661 pub extern "C" fn CommitmentSigned_set_channel_id(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::ThirtyTwoBytes) {
2662 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2664 /// A signature on the commitment transaction
2666 pub extern "C" fn CommitmentSigned_get_signature(this_ptr: &CommitmentSigned) -> crate::c_types::Signature {
2667 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
2668 crate::c_types::Signature::from_rust(&inner_val)
2670 /// A signature on the commitment transaction
2672 pub extern "C" fn CommitmentSigned_set_signature(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::Signature) {
2673 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
2675 /// Signatures on the HTLC transactions
2677 /// Returns a copy of the field.
2679 pub extern "C" fn CommitmentSigned_get_htlc_signatures(this_ptr: &CommitmentSigned) -> crate::c_types::derived::CVec_SignatureZ {
2680 let mut inner_val = this_ptr.get_native_mut_ref().htlc_signatures.clone();
2681 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) }); };
2682 local_inner_val.into()
2684 /// Signatures on the HTLC transactions
2686 pub extern "C" fn CommitmentSigned_set_htlc_signatures(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::derived::CVec_SignatureZ) {
2687 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_rust() }); };
2688 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_signatures = local_val;
2690 /// Constructs a new CommitmentSigned given each field
2693 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 {
2694 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() }); };
2695 CommitmentSigned { inner: ObjOps::heap_alloc(nativeCommitmentSigned {
2696 channel_id: channel_id_arg.data,
2697 signature: signature_arg.into_rust(),
2698 htlc_signatures: local_htlc_signatures_arg,
2699 }), is_owned: true }
2701 impl Clone for CommitmentSigned {
2702 fn clone(&self) -> Self {
2704 inner: if <*mut nativeCommitmentSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
2705 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2711 /// Used only if an object of this type is returned as a trait impl by a method
2712 pub(crate) extern "C" fn CommitmentSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
2713 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentSigned)).clone() })) as *mut c_void
2716 /// Creates a copy of the CommitmentSigned
2717 pub extern "C" fn CommitmentSigned_clone(orig: &CommitmentSigned) -> CommitmentSigned {
2720 /// Checks if two CommitmentSigneds contain equal inner contents.
2721 /// This ignores pointers and is_owned flags and looks at the values in fields.
2722 /// Two objects with NULL inner values will be considered "equal" here.
2724 pub extern "C" fn CommitmentSigned_eq(a: &CommitmentSigned, b: &CommitmentSigned) -> bool {
2725 if a.inner == b.inner { return true; }
2726 if a.inner.is_null() || b.inner.is_null() { return false; }
2727 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2730 use lightning::ln::msgs::RevokeAndACK as nativeRevokeAndACKImport;
2731 pub(crate) type nativeRevokeAndACK = nativeRevokeAndACKImport;
2733 /// A revoke_and_ack message to be sent or received from a peer
2736 pub struct RevokeAndACK {
2737 /// A pointer to the opaque Rust object.
2739 /// Nearly everywhere, inner must be non-null, however in places where
2740 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2741 pub inner: *mut nativeRevokeAndACK,
2742 /// Indicates that this is the only struct which contains the same pointer.
2744 /// Rust functions which take ownership of an object provided via an argument require
2745 /// this to be true and invalidate the object pointed to by inner.
2749 impl Drop for RevokeAndACK {
2750 fn drop(&mut self) {
2751 if self.is_owned && !<*mut nativeRevokeAndACK>::is_null(self.inner) {
2752 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2756 /// Frees any resources used by the RevokeAndACK, if is_owned is set and inner is non-NULL.
2758 pub extern "C" fn RevokeAndACK_free(this_obj: RevokeAndACK) { }
2760 /// Used only if an object of this type is returned as a trait impl by a method
2761 pub(crate) extern "C" fn RevokeAndACK_free_void(this_ptr: *mut c_void) {
2762 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRevokeAndACK); }
2766 pub(crate) fn get_native_ref(&self) -> &'static nativeRevokeAndACK {
2767 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2769 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRevokeAndACK {
2770 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2772 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2773 pub(crate) fn take_inner(mut self) -> *mut nativeRevokeAndACK {
2774 assert!(self.is_owned);
2775 let ret = ObjOps::untweak_ptr(self.inner);
2776 self.inner = core::ptr::null_mut();
2782 pub extern "C" fn RevokeAndACK_get_channel_id(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
2783 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2788 pub extern "C" fn RevokeAndACK_set_channel_id(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
2789 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2791 /// The secret corresponding to the per-commitment point
2793 pub extern "C" fn RevokeAndACK_get_per_commitment_secret(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
2794 let mut inner_val = &mut this_ptr.get_native_mut_ref().per_commitment_secret;
2797 /// The secret corresponding to the per-commitment point
2799 pub extern "C" fn RevokeAndACK_set_per_commitment_secret(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
2800 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.per_commitment_secret = val.data;
2802 /// The next sender-broadcast commitment transaction's per-commitment point
2804 pub extern "C" fn RevokeAndACK_get_next_per_commitment_point(this_ptr: &RevokeAndACK) -> crate::c_types::PublicKey {
2805 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
2806 crate::c_types::PublicKey::from_rust(&inner_val)
2808 /// The next sender-broadcast commitment transaction's per-commitment point
2810 pub extern "C" fn RevokeAndACK_set_next_per_commitment_point(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::PublicKey) {
2811 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
2813 /// Constructs a new RevokeAndACK given each field
2816 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 {
2817 RevokeAndACK { inner: ObjOps::heap_alloc(nativeRevokeAndACK {
2818 channel_id: channel_id_arg.data,
2819 per_commitment_secret: per_commitment_secret_arg.data,
2820 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
2821 }), is_owned: true }
2823 impl Clone for RevokeAndACK {
2824 fn clone(&self) -> Self {
2826 inner: if <*mut nativeRevokeAndACK>::is_null(self.inner) { core::ptr::null_mut() } else {
2827 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2833 /// Used only if an object of this type is returned as a trait impl by a method
2834 pub(crate) extern "C" fn RevokeAndACK_clone_void(this_ptr: *const c_void) -> *mut c_void {
2835 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRevokeAndACK)).clone() })) as *mut c_void
2838 /// Creates a copy of the RevokeAndACK
2839 pub extern "C" fn RevokeAndACK_clone(orig: &RevokeAndACK) -> RevokeAndACK {
2842 /// Checks if two RevokeAndACKs contain equal inner contents.
2843 /// This ignores pointers and is_owned flags and looks at the values in fields.
2844 /// Two objects with NULL inner values will be considered "equal" here.
2846 pub extern "C" fn RevokeAndACK_eq(a: &RevokeAndACK, b: &RevokeAndACK) -> bool {
2847 if a.inner == b.inner { return true; }
2848 if a.inner.is_null() || b.inner.is_null() { return false; }
2849 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2852 use lightning::ln::msgs::UpdateFee as nativeUpdateFeeImport;
2853 pub(crate) type nativeUpdateFee = nativeUpdateFeeImport;
2855 /// An update_fee message to be sent or received from a peer
2858 pub struct UpdateFee {
2859 /// A pointer to the opaque Rust object.
2861 /// Nearly everywhere, inner must be non-null, however in places where
2862 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2863 pub inner: *mut nativeUpdateFee,
2864 /// Indicates that this is the only struct which contains the same pointer.
2866 /// Rust functions which take ownership of an object provided via an argument require
2867 /// this to be true and invalidate the object pointed to by inner.
2871 impl Drop for UpdateFee {
2872 fn drop(&mut self) {
2873 if self.is_owned && !<*mut nativeUpdateFee>::is_null(self.inner) {
2874 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2878 /// Frees any resources used by the UpdateFee, if is_owned is set and inner is non-NULL.
2880 pub extern "C" fn UpdateFee_free(this_obj: UpdateFee) { }
2882 /// Used only if an object of this type is returned as a trait impl by a method
2883 pub(crate) extern "C" fn UpdateFee_free_void(this_ptr: *mut c_void) {
2884 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFee); }
2888 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFee {
2889 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2891 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFee {
2892 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2894 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2895 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFee {
2896 assert!(self.is_owned);
2897 let ret = ObjOps::untweak_ptr(self.inner);
2898 self.inner = core::ptr::null_mut();
2904 pub extern "C" fn UpdateFee_get_channel_id(this_ptr: &UpdateFee) -> *const [u8; 32] {
2905 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2910 pub extern "C" fn UpdateFee_set_channel_id(this_ptr: &mut UpdateFee, mut val: crate::c_types::ThirtyTwoBytes) {
2911 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2913 /// Fee rate per 1000-weight of the transaction
2915 pub extern "C" fn UpdateFee_get_feerate_per_kw(this_ptr: &UpdateFee) -> u32 {
2916 let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
2919 /// Fee rate per 1000-weight of the transaction
2921 pub extern "C" fn UpdateFee_set_feerate_per_kw(this_ptr: &mut UpdateFee, mut val: u32) {
2922 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
2924 /// Constructs a new UpdateFee given each field
2927 pub extern "C" fn UpdateFee_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut feerate_per_kw_arg: u32) -> UpdateFee {
2928 UpdateFee { inner: ObjOps::heap_alloc(nativeUpdateFee {
2929 channel_id: channel_id_arg.data,
2930 feerate_per_kw: feerate_per_kw_arg,
2931 }), is_owned: true }
2933 impl Clone for UpdateFee {
2934 fn clone(&self) -> Self {
2936 inner: if <*mut nativeUpdateFee>::is_null(self.inner) { core::ptr::null_mut() } else {
2937 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2943 /// Used only if an object of this type is returned as a trait impl by a method
2944 pub(crate) extern "C" fn UpdateFee_clone_void(this_ptr: *const c_void) -> *mut c_void {
2945 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFee)).clone() })) as *mut c_void
2948 /// Creates a copy of the UpdateFee
2949 pub extern "C" fn UpdateFee_clone(orig: &UpdateFee) -> UpdateFee {
2952 /// Checks if two UpdateFees contain equal inner contents.
2953 /// This ignores pointers and is_owned flags and looks at the values in fields.
2954 /// Two objects with NULL inner values will be considered "equal" here.
2956 pub extern "C" fn UpdateFee_eq(a: &UpdateFee, b: &UpdateFee) -> bool {
2957 if a.inner == b.inner { return true; }
2958 if a.inner.is_null() || b.inner.is_null() { return false; }
2959 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2962 use lightning::ln::msgs::DataLossProtect as nativeDataLossProtectImport;
2963 pub(crate) type nativeDataLossProtect = nativeDataLossProtectImport;
2965 /// Proof that the sender knows the per-commitment secret of the previous commitment transaction.
2966 /// This is used to convince the recipient that the channel is at a certain commitment
2967 /// number even if they lost that data due to a local failure. Of course, the peer may lie
2968 /// and even later commitments may have been revoked.
2971 pub struct DataLossProtect {
2972 /// A pointer to the opaque Rust object.
2974 /// Nearly everywhere, inner must be non-null, however in places where
2975 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2976 pub inner: *mut nativeDataLossProtect,
2977 /// Indicates that this is the only struct which contains the same pointer.
2979 /// Rust functions which take ownership of an object provided via an argument require
2980 /// this to be true and invalidate the object pointed to by inner.
2984 impl Drop for DataLossProtect {
2985 fn drop(&mut self) {
2986 if self.is_owned && !<*mut nativeDataLossProtect>::is_null(self.inner) {
2987 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2991 /// Frees any resources used by the DataLossProtect, if is_owned is set and inner is non-NULL.
2993 pub extern "C" fn DataLossProtect_free(this_obj: DataLossProtect) { }
2995 /// Used only if an object of this type is returned as a trait impl by a method
2996 pub(crate) extern "C" fn DataLossProtect_free_void(this_ptr: *mut c_void) {
2997 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDataLossProtect); }
3000 impl DataLossProtect {
3001 pub(crate) fn get_native_ref(&self) -> &'static nativeDataLossProtect {
3002 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3004 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeDataLossProtect {
3005 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3007 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3008 pub(crate) fn take_inner(mut self) -> *mut nativeDataLossProtect {
3009 assert!(self.is_owned);
3010 let ret = ObjOps::untweak_ptr(self.inner);
3011 self.inner = core::ptr::null_mut();
3015 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
3016 /// belonging to the recipient
3018 pub extern "C" fn DataLossProtect_get_your_last_per_commitment_secret(this_ptr: &DataLossProtect) -> *const [u8; 32] {
3019 let mut inner_val = &mut this_ptr.get_native_mut_ref().your_last_per_commitment_secret;
3022 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
3023 /// belonging to the recipient
3025 pub extern "C" fn DataLossProtect_set_your_last_per_commitment_secret(this_ptr: &mut DataLossProtect, mut val: crate::c_types::ThirtyTwoBytes) {
3026 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.your_last_per_commitment_secret = val.data;
3028 /// The sender's per-commitment point for their current commitment transaction
3030 pub extern "C" fn DataLossProtect_get_my_current_per_commitment_point(this_ptr: &DataLossProtect) -> crate::c_types::PublicKey {
3031 let mut inner_val = &mut this_ptr.get_native_mut_ref().my_current_per_commitment_point;
3032 crate::c_types::PublicKey::from_rust(&inner_val)
3034 /// The sender's per-commitment point for their current commitment transaction
3036 pub extern "C" fn DataLossProtect_set_my_current_per_commitment_point(this_ptr: &mut DataLossProtect, mut val: crate::c_types::PublicKey) {
3037 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.my_current_per_commitment_point = val.into_rust();
3039 /// Constructs a new DataLossProtect given each field
3042 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 {
3043 DataLossProtect { inner: ObjOps::heap_alloc(nativeDataLossProtect {
3044 your_last_per_commitment_secret: your_last_per_commitment_secret_arg.data,
3045 my_current_per_commitment_point: my_current_per_commitment_point_arg.into_rust(),
3046 }), is_owned: true }
3048 impl Clone for DataLossProtect {
3049 fn clone(&self) -> Self {
3051 inner: if <*mut nativeDataLossProtect>::is_null(self.inner) { core::ptr::null_mut() } else {
3052 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3058 /// Used only if an object of this type is returned as a trait impl by a method
3059 pub(crate) extern "C" fn DataLossProtect_clone_void(this_ptr: *const c_void) -> *mut c_void {
3060 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDataLossProtect)).clone() })) as *mut c_void
3063 /// Creates a copy of the DataLossProtect
3064 pub extern "C" fn DataLossProtect_clone(orig: &DataLossProtect) -> DataLossProtect {
3067 /// Checks if two DataLossProtects contain equal inner contents.
3068 /// This ignores pointers and is_owned flags and looks at the values in fields.
3069 /// Two objects with NULL inner values will be considered "equal" here.
3071 pub extern "C" fn DataLossProtect_eq(a: &DataLossProtect, b: &DataLossProtect) -> bool {
3072 if a.inner == b.inner { return true; }
3073 if a.inner.is_null() || b.inner.is_null() { return false; }
3074 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3077 use lightning::ln::msgs::ChannelReestablish as nativeChannelReestablishImport;
3078 pub(crate) type nativeChannelReestablish = nativeChannelReestablishImport;
3080 /// A channel_reestablish message to be sent or received from a peer
3083 pub struct ChannelReestablish {
3084 /// A pointer to the opaque Rust object.
3086 /// Nearly everywhere, inner must be non-null, however in places where
3087 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3088 pub inner: *mut nativeChannelReestablish,
3089 /// Indicates that this is the only struct which contains the same pointer.
3091 /// Rust functions which take ownership of an object provided via an argument require
3092 /// this to be true and invalidate the object pointed to by inner.
3096 impl Drop for ChannelReestablish {
3097 fn drop(&mut self) {
3098 if self.is_owned && !<*mut nativeChannelReestablish>::is_null(self.inner) {
3099 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3103 /// Frees any resources used by the ChannelReestablish, if is_owned is set and inner is non-NULL.
3105 pub extern "C" fn ChannelReestablish_free(this_obj: ChannelReestablish) { }
3107 /// Used only if an object of this type is returned as a trait impl by a method
3108 pub(crate) extern "C" fn ChannelReestablish_free_void(this_ptr: *mut c_void) {
3109 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelReestablish); }
3112 impl ChannelReestablish {
3113 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelReestablish {
3114 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3116 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelReestablish {
3117 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3119 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3120 pub(crate) fn take_inner(mut self) -> *mut nativeChannelReestablish {
3121 assert!(self.is_owned);
3122 let ret = ObjOps::untweak_ptr(self.inner);
3123 self.inner = core::ptr::null_mut();
3129 pub extern "C" fn ChannelReestablish_get_channel_id(this_ptr: &ChannelReestablish) -> *const [u8; 32] {
3130 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3135 pub extern "C" fn ChannelReestablish_set_channel_id(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) {
3136 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
3138 /// The next commitment number for the sender
3140 pub extern "C" fn ChannelReestablish_get_next_local_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
3141 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_local_commitment_number;
3144 /// The next commitment number for the sender
3146 pub extern "C" fn ChannelReestablish_set_next_local_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
3147 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_local_commitment_number = val;
3149 /// The next commitment number for the recipient
3151 pub extern "C" fn ChannelReestablish_get_next_remote_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
3152 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_remote_commitment_number;
3155 /// The next commitment number for the recipient
3157 pub extern "C" fn ChannelReestablish_set_next_remote_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
3158 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_remote_commitment_number = val;
3160 impl Clone for ChannelReestablish {
3161 fn clone(&self) -> Self {
3163 inner: if <*mut nativeChannelReestablish>::is_null(self.inner) { core::ptr::null_mut() } else {
3164 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3170 /// Used only if an object of this type is returned as a trait impl by a method
3171 pub(crate) extern "C" fn ChannelReestablish_clone_void(this_ptr: *const c_void) -> *mut c_void {
3172 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelReestablish)).clone() })) as *mut c_void
3175 /// Creates a copy of the ChannelReestablish
3176 pub extern "C" fn ChannelReestablish_clone(orig: &ChannelReestablish) -> ChannelReestablish {
3179 /// Checks if two ChannelReestablishs contain equal inner contents.
3180 /// This ignores pointers and is_owned flags and looks at the values in fields.
3181 /// Two objects with NULL inner values will be considered "equal" here.
3183 pub extern "C" fn ChannelReestablish_eq(a: &ChannelReestablish, b: &ChannelReestablish) -> bool {
3184 if a.inner == b.inner { return true; }
3185 if a.inner.is_null() || b.inner.is_null() { return false; }
3186 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3189 use lightning::ln::msgs::AnnouncementSignatures as nativeAnnouncementSignaturesImport;
3190 pub(crate) type nativeAnnouncementSignatures = nativeAnnouncementSignaturesImport;
3192 /// An announcement_signatures message to be sent or received from a peer
3195 pub struct AnnouncementSignatures {
3196 /// A pointer to the opaque Rust object.
3198 /// Nearly everywhere, inner must be non-null, however in places where
3199 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3200 pub inner: *mut nativeAnnouncementSignatures,
3201 /// Indicates that this is the only struct which contains the same pointer.
3203 /// Rust functions which take ownership of an object provided via an argument require
3204 /// this to be true and invalidate the object pointed to by inner.
3208 impl Drop for AnnouncementSignatures {
3209 fn drop(&mut self) {
3210 if self.is_owned && !<*mut nativeAnnouncementSignatures>::is_null(self.inner) {
3211 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3215 /// Frees any resources used by the AnnouncementSignatures, if is_owned is set and inner is non-NULL.
3217 pub extern "C" fn AnnouncementSignatures_free(this_obj: AnnouncementSignatures) { }
3219 /// Used only if an object of this type is returned as a trait impl by a method
3220 pub(crate) extern "C" fn AnnouncementSignatures_free_void(this_ptr: *mut c_void) {
3221 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeAnnouncementSignatures); }
3224 impl AnnouncementSignatures {
3225 pub(crate) fn get_native_ref(&self) -> &'static nativeAnnouncementSignatures {
3226 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3228 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAnnouncementSignatures {
3229 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3231 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3232 pub(crate) fn take_inner(mut self) -> *mut nativeAnnouncementSignatures {
3233 assert!(self.is_owned);
3234 let ret = ObjOps::untweak_ptr(self.inner);
3235 self.inner = core::ptr::null_mut();
3241 pub extern "C" fn AnnouncementSignatures_get_channel_id(this_ptr: &AnnouncementSignatures) -> *const [u8; 32] {
3242 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3247 pub extern "C" fn AnnouncementSignatures_set_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
3248 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
3250 /// The short channel ID
3252 pub extern "C" fn AnnouncementSignatures_get_short_channel_id(this_ptr: &AnnouncementSignatures) -> u64 {
3253 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
3256 /// The short channel ID
3258 pub extern "C" fn AnnouncementSignatures_set_short_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: u64) {
3259 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
3261 /// A signature by the node key
3263 pub extern "C" fn AnnouncementSignatures_get_node_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
3264 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature;
3265 crate::c_types::Signature::from_rust(&inner_val)
3267 /// A signature by the node key
3269 pub extern "C" fn AnnouncementSignatures_set_node_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
3270 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature = val.into_rust();
3272 /// A signature by the funding key
3274 pub extern "C" fn AnnouncementSignatures_get_bitcoin_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
3275 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature;
3276 crate::c_types::Signature::from_rust(&inner_val)
3278 /// A signature by the funding key
3280 pub extern "C" fn AnnouncementSignatures_set_bitcoin_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
3281 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature = val.into_rust();
3283 /// Constructs a new AnnouncementSignatures given each field
3286 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 {
3287 AnnouncementSignatures { inner: ObjOps::heap_alloc(nativeAnnouncementSignatures {
3288 channel_id: channel_id_arg.data,
3289 short_channel_id: short_channel_id_arg,
3290 node_signature: node_signature_arg.into_rust(),
3291 bitcoin_signature: bitcoin_signature_arg.into_rust(),
3292 }), is_owned: true }
3294 impl Clone for AnnouncementSignatures {
3295 fn clone(&self) -> Self {
3297 inner: if <*mut nativeAnnouncementSignatures>::is_null(self.inner) { core::ptr::null_mut() } else {
3298 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3304 /// Used only if an object of this type is returned as a trait impl by a method
3305 pub(crate) extern "C" fn AnnouncementSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
3306 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAnnouncementSignatures)).clone() })) as *mut c_void
3309 /// Creates a copy of the AnnouncementSignatures
3310 pub extern "C" fn AnnouncementSignatures_clone(orig: &AnnouncementSignatures) -> AnnouncementSignatures {
3313 /// Checks if two AnnouncementSignaturess contain equal inner contents.
3314 /// This ignores pointers and is_owned flags and looks at the values in fields.
3315 /// Two objects with NULL inner values will be considered "equal" here.
3317 pub extern "C" fn AnnouncementSignatures_eq(a: &AnnouncementSignatures, b: &AnnouncementSignatures) -> bool {
3318 if a.inner == b.inner { return true; }
3319 if a.inner.is_null() || b.inner.is_null() { return false; }
3320 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3322 /// An address which can be used to connect to a remote peer
3326 pub enum NetAddress {
3327 /// An IPv4 address/port on which the peer is listening.
3329 /// The 4-byte IPv4 address
3330 addr: crate::c_types::FourBytes,
3331 /// The port on which the node is listening
3334 /// An IPv6 address/port on which the peer is listening.
3336 /// The 16-byte IPv6 address
3337 addr: crate::c_types::SixteenBytes,
3338 /// The port on which the node is listening
3341 /// An old-style Tor onion address/port on which the peer is listening.
3343 /// This field is deprecated and the Tor network generally no longer supports V2 Onion
3344 /// addresses. Thus, the details are not parsed here.
3346 crate::c_types::TwelveBytes),
3347 /// A new-style Tor onion address/port on which the peer is listening.
3348 /// To create the human-readable \"hostname\", concatenate ed25519_pubkey, checksum, and version,
3349 /// wrap as base32 and append \".onion\".
3351 /// The ed25519 long-term public key of the peer
3352 ed25519_pubkey: crate::c_types::ThirtyTwoBytes,
3353 /// The checksum of the pubkey and version, as included in the onion address
3355 /// The version byte, as defined by the Tor Onion v3 spec.
3357 /// The port on which the node is listening
3360 /// A hostname/port on which the peer is listening.
3362 /// The hostname on which the node is listening.
3363 hostname: crate::lightning::util::ser::Hostname,
3364 /// The port on which the node is listening.
3368 use lightning::ln::msgs::NetAddress as NetAddressImport;
3369 pub(crate) type nativeNetAddress = NetAddressImport;
3373 pub(crate) fn to_native(&self) -> nativeNetAddress {
3375 NetAddress::IPv4 {ref addr, ref port, } => {
3376 let mut addr_nonref = (*addr).clone();
3377 let mut port_nonref = (*port).clone();
3378 nativeNetAddress::IPv4 {
3379 addr: addr_nonref.data,
3383 NetAddress::IPv6 {ref addr, ref port, } => {
3384 let mut addr_nonref = (*addr).clone();
3385 let mut port_nonref = (*port).clone();
3386 nativeNetAddress::IPv6 {
3387 addr: addr_nonref.data,
3391 NetAddress::OnionV2 (ref a, ) => {
3392 let mut a_nonref = (*a).clone();
3393 nativeNetAddress::OnionV2 (
3397 NetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
3398 let mut ed25519_pubkey_nonref = (*ed25519_pubkey).clone();
3399 let mut checksum_nonref = (*checksum).clone();
3400 let mut version_nonref = (*version).clone();
3401 let mut port_nonref = (*port).clone();
3402 nativeNetAddress::OnionV3 {
3403 ed25519_pubkey: ed25519_pubkey_nonref.data,
3404 checksum: checksum_nonref,
3405 version: version_nonref,
3409 NetAddress::Hostname {ref hostname, ref port, } => {
3410 let mut hostname_nonref = (*hostname).clone();
3411 let mut port_nonref = (*port).clone();
3412 nativeNetAddress::Hostname {
3413 hostname: *unsafe { Box::from_raw(hostname_nonref.take_inner()) },
3420 pub(crate) fn into_native(self) -> nativeNetAddress {
3422 NetAddress::IPv4 {mut addr, mut port, } => {
3423 nativeNetAddress::IPv4 {
3428 NetAddress::IPv6 {mut addr, mut port, } => {
3429 nativeNetAddress::IPv6 {
3434 NetAddress::OnionV2 (mut a, ) => {
3435 nativeNetAddress::OnionV2 (
3439 NetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
3440 nativeNetAddress::OnionV3 {
3441 ed25519_pubkey: ed25519_pubkey.data,
3447 NetAddress::Hostname {mut hostname, mut port, } => {
3448 nativeNetAddress::Hostname {
3449 hostname: *unsafe { Box::from_raw(hostname.take_inner()) },
3456 pub(crate) fn from_native(native: &nativeNetAddress) -> Self {
3458 nativeNetAddress::IPv4 {ref addr, ref port, } => {
3459 let mut addr_nonref = (*addr).clone();
3460 let mut port_nonref = (*port).clone();
3462 addr: crate::c_types::FourBytes { data: addr_nonref },
3466 nativeNetAddress::IPv6 {ref addr, ref port, } => {
3467 let mut addr_nonref = (*addr).clone();
3468 let mut port_nonref = (*port).clone();
3470 addr: crate::c_types::SixteenBytes { data: addr_nonref },
3474 nativeNetAddress::OnionV2 (ref a, ) => {
3475 let mut a_nonref = (*a).clone();
3476 NetAddress::OnionV2 (
3477 crate::c_types::TwelveBytes { data: a_nonref },
3480 nativeNetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
3481 let mut ed25519_pubkey_nonref = (*ed25519_pubkey).clone();
3482 let mut checksum_nonref = (*checksum).clone();
3483 let mut version_nonref = (*version).clone();
3484 let mut port_nonref = (*port).clone();
3485 NetAddress::OnionV3 {
3486 ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey_nonref },
3487 checksum: checksum_nonref,
3488 version: version_nonref,
3492 nativeNetAddress::Hostname {ref hostname, ref port, } => {
3493 let mut hostname_nonref = (*hostname).clone();
3494 let mut port_nonref = (*port).clone();
3495 NetAddress::Hostname {
3496 hostname: crate::lightning::util::ser::Hostname { inner: ObjOps::heap_alloc(hostname_nonref), is_owned: true },
3503 pub(crate) fn native_into(native: nativeNetAddress) -> Self {
3505 nativeNetAddress::IPv4 {mut addr, mut port, } => {
3507 addr: crate::c_types::FourBytes { data: addr },
3511 nativeNetAddress::IPv6 {mut addr, mut port, } => {
3513 addr: crate::c_types::SixteenBytes { data: addr },
3517 nativeNetAddress::OnionV2 (mut a, ) => {
3518 NetAddress::OnionV2 (
3519 crate::c_types::TwelveBytes { data: a },
3522 nativeNetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
3523 NetAddress::OnionV3 {
3524 ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey },
3530 nativeNetAddress::Hostname {mut hostname, mut port, } => {
3531 NetAddress::Hostname {
3532 hostname: crate::lightning::util::ser::Hostname { inner: ObjOps::heap_alloc(hostname), is_owned: true },
3539 /// Frees any resources used by the NetAddress
3541 pub extern "C" fn NetAddress_free(this_ptr: NetAddress) { }
3542 /// Creates a copy of the NetAddress
3544 pub extern "C" fn NetAddress_clone(orig: &NetAddress) -> NetAddress {
3548 /// Utility method to constructs a new IPv4-variant NetAddress
3549 pub extern "C" fn NetAddress_ipv4(addr: crate::c_types::FourBytes, port: u16) -> NetAddress {
3556 /// Utility method to constructs a new IPv6-variant NetAddress
3557 pub extern "C" fn NetAddress_ipv6(addr: crate::c_types::SixteenBytes, port: u16) -> NetAddress {
3564 /// Utility method to constructs a new OnionV2-variant NetAddress
3565 pub extern "C" fn NetAddress_onion_v2(a: crate::c_types::TwelveBytes) -> NetAddress {
3566 NetAddress::OnionV2(a, )
3569 /// Utility method to constructs a new OnionV3-variant NetAddress
3570 pub extern "C" fn NetAddress_onion_v3(ed25519_pubkey: crate::c_types::ThirtyTwoBytes, checksum: u16, version: u8, port: u16) -> NetAddress {
3571 NetAddress::OnionV3 {
3579 /// Utility method to constructs a new Hostname-variant NetAddress
3580 pub extern "C" fn NetAddress_hostname(hostname: crate::lightning::util::ser::Hostname, port: u16) -> NetAddress {
3581 NetAddress::Hostname {
3586 /// Checks if two NetAddresss contain equal inner contents.
3587 /// This ignores pointers and is_owned flags and looks at the values in fields.
3589 pub extern "C" fn NetAddress_eq(a: &NetAddress, b: &NetAddress) -> bool {
3590 if &a.to_native() == &b.to_native() { true } else { false }
3593 /// Serialize the NetAddress object into a byte array which can be read by NetAddress_read
3594 pub extern "C" fn NetAddress_write(obj: &crate::lightning::ln::msgs::NetAddress) -> crate::c_types::derived::CVec_u8Z {
3595 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
3598 /// Read a NetAddress from a byte array, created by NetAddress_write
3599 pub extern "C" fn NetAddress_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NetAddressDecodeErrorZ {
3600 let res: Result<lightning::ln::msgs::NetAddress, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
3601 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() };
3605 use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport;
3606 pub(crate) type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport;
3608 /// The unsigned part of a node_announcement
3611 pub struct UnsignedNodeAnnouncement {
3612 /// A pointer to the opaque Rust object.
3614 /// Nearly everywhere, inner must be non-null, however in places where
3615 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3616 pub inner: *mut nativeUnsignedNodeAnnouncement,
3617 /// Indicates that this is the only struct which contains the same pointer.
3619 /// Rust functions which take ownership of an object provided via an argument require
3620 /// this to be true and invalidate the object pointed to by inner.
3624 impl Drop for UnsignedNodeAnnouncement {
3625 fn drop(&mut self) {
3626 if self.is_owned && !<*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) {
3627 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3631 /// Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL.
3633 pub extern "C" fn UnsignedNodeAnnouncement_free(this_obj: UnsignedNodeAnnouncement) { }
3635 /// Used only if an object of this type is returned as a trait impl by a method
3636 pub(crate) extern "C" fn UnsignedNodeAnnouncement_free_void(this_ptr: *mut c_void) {
3637 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedNodeAnnouncement); }
3640 impl UnsignedNodeAnnouncement {
3641 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedNodeAnnouncement {
3642 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3644 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedNodeAnnouncement {
3645 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3647 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3648 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedNodeAnnouncement {
3649 assert!(self.is_owned);
3650 let ret = ObjOps::untweak_ptr(self.inner);
3651 self.inner = core::ptr::null_mut();
3655 /// The advertised features
3657 pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::ln::features::NodeFeatures {
3658 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
3659 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 }
3661 /// The advertised features
3663 pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::ln::features::NodeFeatures) {
3664 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
3666 /// A strictly monotonic announcement counter, with gaps allowed
3668 pub extern "C" fn UnsignedNodeAnnouncement_get_timestamp(this_ptr: &UnsignedNodeAnnouncement) -> u32 {
3669 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
3672 /// A strictly monotonic announcement counter, with gaps allowed
3674 pub extern "C" fn UnsignedNodeAnnouncement_set_timestamp(this_ptr: &mut UnsignedNodeAnnouncement, mut val: u32) {
3675 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
3677 /// The node_id this announcement originated from (don't rebroadcast the node_announcement back
3680 pub extern "C" fn UnsignedNodeAnnouncement_get_node_id(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::PublicKey {
3681 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id;
3682 crate::c_types::PublicKey::from_rust(&inner_val)
3684 /// The node_id this announcement originated from (don't rebroadcast the node_announcement back
3687 pub extern "C" fn UnsignedNodeAnnouncement_set_node_id(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::PublicKey) {
3688 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id = val.into_rust();
3690 /// An RGB color for UI purposes
3692 pub extern "C" fn UnsignedNodeAnnouncement_get_rgb(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 3] {
3693 let mut inner_val = &mut this_ptr.get_native_mut_ref().rgb;
3696 /// An RGB color for UI purposes
3698 pub extern "C" fn UnsignedNodeAnnouncement_set_rgb(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThreeBytes) {
3699 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.rgb = val.data;
3701 /// An alias, for UI purposes. This should be sanitized before use. There is no guarantee
3704 pub extern "C" fn UnsignedNodeAnnouncement_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 32] {
3705 let mut inner_val = &mut this_ptr.get_native_mut_ref().alias;
3708 /// An alias, for UI purposes. This should be sanitized before use. There is no guarantee
3711 pub extern "C" fn UnsignedNodeAnnouncement_set_alias(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
3712 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.alias = val.data;
3714 /// List of addresses on which this node is reachable
3716 /// Returns a copy of the field.
3718 pub extern "C" fn UnsignedNodeAnnouncement_get_addresses(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_NetAddressZ {
3719 let mut inner_val = this_ptr.get_native_mut_ref().addresses.clone();
3720 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) }); };
3721 local_inner_val.into()
3723 /// List of addresses on which this node is reachable
3725 pub extern "C" fn UnsignedNodeAnnouncement_set_addresses(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_NetAddressZ) {
3726 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
3727 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.addresses = local_val;
3729 impl Clone for UnsignedNodeAnnouncement {
3730 fn clone(&self) -> Self {
3732 inner: if <*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
3733 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3739 /// Used only if an object of this type is returned as a trait impl by a method
3740 pub(crate) extern "C" fn UnsignedNodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3741 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedNodeAnnouncement)).clone() })) as *mut c_void
3744 /// Creates a copy of the UnsignedNodeAnnouncement
3745 pub extern "C" fn UnsignedNodeAnnouncement_clone(orig: &UnsignedNodeAnnouncement) -> UnsignedNodeAnnouncement {
3748 /// Checks if two UnsignedNodeAnnouncements contain equal inner contents.
3749 /// This ignores pointers and is_owned flags and looks at the values in fields.
3750 /// Two objects with NULL inner values will be considered "equal" here.
3752 pub extern "C" fn UnsignedNodeAnnouncement_eq(a: &UnsignedNodeAnnouncement, b: &UnsignedNodeAnnouncement) -> bool {
3753 if a.inner == b.inner { return true; }
3754 if a.inner.is_null() || b.inner.is_null() { return false; }
3755 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3758 use lightning::ln::msgs::NodeAnnouncement as nativeNodeAnnouncementImport;
3759 pub(crate) type nativeNodeAnnouncement = nativeNodeAnnouncementImport;
3761 /// A node_announcement message to be sent or received from a peer
3764 pub struct NodeAnnouncement {
3765 /// A pointer to the opaque Rust object.
3767 /// Nearly everywhere, inner must be non-null, however in places where
3768 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3769 pub inner: *mut nativeNodeAnnouncement,
3770 /// Indicates that this is the only struct which contains the same pointer.
3772 /// Rust functions which take ownership of an object provided via an argument require
3773 /// this to be true and invalidate the object pointed to by inner.
3777 impl Drop for NodeAnnouncement {
3778 fn drop(&mut self) {
3779 if self.is_owned && !<*mut nativeNodeAnnouncement>::is_null(self.inner) {
3780 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3784 /// Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL.
3786 pub extern "C" fn NodeAnnouncement_free(this_obj: NodeAnnouncement) { }
3788 /// Used only if an object of this type is returned as a trait impl by a method
3789 pub(crate) extern "C" fn NodeAnnouncement_free_void(this_ptr: *mut c_void) {
3790 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeAnnouncement); }
3793 impl NodeAnnouncement {
3794 pub(crate) fn get_native_ref(&self) -> &'static nativeNodeAnnouncement {
3795 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3797 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeAnnouncement {
3798 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3800 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3801 pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncement {
3802 assert!(self.is_owned);
3803 let ret = ObjOps::untweak_ptr(self.inner);
3804 self.inner = core::ptr::null_mut();
3808 /// The signature by the node key
3810 pub extern "C" fn NodeAnnouncement_get_signature(this_ptr: &NodeAnnouncement) -> crate::c_types::Signature {
3811 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
3812 crate::c_types::Signature::from_rust(&inner_val)
3814 /// The signature by the node key
3816 pub extern "C" fn NodeAnnouncement_set_signature(this_ptr: &mut NodeAnnouncement, mut val: crate::c_types::Signature) {
3817 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
3819 /// The actual content of the announcement
3821 pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> crate::lightning::ln::msgs::UnsignedNodeAnnouncement {
3822 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
3823 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 }
3825 /// The actual content of the announcement
3827 pub extern "C" fn NodeAnnouncement_set_contents(this_ptr: &mut NodeAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) {
3828 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
3830 /// Constructs a new NodeAnnouncement given each field
3833 pub extern "C" fn NodeAnnouncement_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> NodeAnnouncement {
3834 NodeAnnouncement { inner: ObjOps::heap_alloc(nativeNodeAnnouncement {
3835 signature: signature_arg.into_rust(),
3836 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
3837 }), is_owned: true }
3839 impl Clone for NodeAnnouncement {
3840 fn clone(&self) -> Self {
3842 inner: if <*mut nativeNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
3843 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3849 /// Used only if an object of this type is returned as a trait impl by a method
3850 pub(crate) extern "C" fn NodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3851 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeAnnouncement)).clone() })) as *mut c_void
3854 /// Creates a copy of the NodeAnnouncement
3855 pub extern "C" fn NodeAnnouncement_clone(orig: &NodeAnnouncement) -> NodeAnnouncement {
3858 /// Checks if two NodeAnnouncements contain equal inner contents.
3859 /// This ignores pointers and is_owned flags and looks at the values in fields.
3860 /// Two objects with NULL inner values will be considered "equal" here.
3862 pub extern "C" fn NodeAnnouncement_eq(a: &NodeAnnouncement, b: &NodeAnnouncement) -> bool {
3863 if a.inner == b.inner { return true; }
3864 if a.inner.is_null() || b.inner.is_null() { return false; }
3865 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3868 use lightning::ln::msgs::UnsignedChannelAnnouncement as nativeUnsignedChannelAnnouncementImport;
3869 pub(crate) type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport;
3871 /// The unsigned part of a channel_announcement
3874 pub struct UnsignedChannelAnnouncement {
3875 /// A pointer to the opaque Rust object.
3877 /// Nearly everywhere, inner must be non-null, however in places where
3878 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3879 pub inner: *mut nativeUnsignedChannelAnnouncement,
3880 /// Indicates that this is the only struct which contains the same pointer.
3882 /// Rust functions which take ownership of an object provided via an argument require
3883 /// this to be true and invalidate the object pointed to by inner.
3887 impl Drop for UnsignedChannelAnnouncement {
3888 fn drop(&mut self) {
3889 if self.is_owned && !<*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) {
3890 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3894 /// Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL.
3896 pub extern "C" fn UnsignedChannelAnnouncement_free(this_obj: UnsignedChannelAnnouncement) { }
3898 /// Used only if an object of this type is returned as a trait impl by a method
3899 pub(crate) extern "C" fn UnsignedChannelAnnouncement_free_void(this_ptr: *mut c_void) {
3900 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelAnnouncement); }
3903 impl UnsignedChannelAnnouncement {
3904 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelAnnouncement {
3905 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3907 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelAnnouncement {
3908 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3910 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3911 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelAnnouncement {
3912 assert!(self.is_owned);
3913 let ret = ObjOps::untweak_ptr(self.inner);
3914 self.inner = core::ptr::null_mut();
3918 /// The advertised channel features
3920 pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::ln::features::ChannelFeatures {
3921 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
3922 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 }
3924 /// The advertised channel features
3926 pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::ln::features::ChannelFeatures) {
3927 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
3929 /// The genesis hash of the blockchain where the channel is to be opened
3931 pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &UnsignedChannelAnnouncement) -> *const [u8; 32] {
3932 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
3933 inner_val.as_inner()
3935 /// The genesis hash of the blockchain where the channel is to be opened
3937 pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
3938 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3940 /// The short channel ID
3942 pub extern "C" fn UnsignedChannelAnnouncement_get_short_channel_id(this_ptr: &UnsignedChannelAnnouncement) -> u64 {
3943 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
3946 /// The short channel ID
3948 pub extern "C" fn UnsignedChannelAnnouncement_set_short_channel_id(this_ptr: &mut UnsignedChannelAnnouncement, mut val: u64) {
3949 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
3951 /// One of the two node_ids which are endpoints of this channel
3953 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3954 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_1;
3955 crate::c_types::PublicKey::from_rust(&inner_val)
3957 /// One of the two node_ids which are endpoints of this channel
3959 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3960 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_1 = val.into_rust();
3962 /// The other of the two node_ids which are endpoints of this channel
3964 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3965 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_2;
3966 crate::c_types::PublicKey::from_rust(&inner_val)
3968 /// The other of the two node_ids which are endpoints of this channel
3970 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3971 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_2 = val.into_rust();
3973 /// The funding key for the first node
3975 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3976 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_1;
3977 crate::c_types::PublicKey::from_rust(&inner_val)
3979 /// The funding key for the first node
3981 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3982 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_1 = val.into_rust();
3984 /// The funding key for the second node
3986 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3987 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_2;
3988 crate::c_types::PublicKey::from_rust(&inner_val)
3990 /// The funding key for the second node
3992 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3993 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_2 = val.into_rust();
3995 impl Clone for UnsignedChannelAnnouncement {
3996 fn clone(&self) -> Self {
3998 inner: if <*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
3999 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4005 /// Used only if an object of this type is returned as a trait impl by a method
4006 pub(crate) extern "C" fn UnsignedChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
4007 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelAnnouncement)).clone() })) as *mut c_void
4010 /// Creates a copy of the UnsignedChannelAnnouncement
4011 pub extern "C" fn UnsignedChannelAnnouncement_clone(orig: &UnsignedChannelAnnouncement) -> UnsignedChannelAnnouncement {
4014 /// Checks if two UnsignedChannelAnnouncements contain equal inner contents.
4015 /// This ignores pointers and is_owned flags and looks at the values in fields.
4016 /// Two objects with NULL inner values will be considered "equal" here.
4018 pub extern "C" fn UnsignedChannelAnnouncement_eq(a: &UnsignedChannelAnnouncement, b: &UnsignedChannelAnnouncement) -> bool {
4019 if a.inner == b.inner { return true; }
4020 if a.inner.is_null() || b.inner.is_null() { return false; }
4021 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4024 use lightning::ln::msgs::ChannelAnnouncement as nativeChannelAnnouncementImport;
4025 pub(crate) type nativeChannelAnnouncement = nativeChannelAnnouncementImport;
4027 /// A channel_announcement message to be sent or received from a peer
4030 pub struct ChannelAnnouncement {
4031 /// A pointer to the opaque Rust object.
4033 /// Nearly everywhere, inner must be non-null, however in places where
4034 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4035 pub inner: *mut nativeChannelAnnouncement,
4036 /// Indicates that this is the only struct which contains the same pointer.
4038 /// Rust functions which take ownership of an object provided via an argument require
4039 /// this to be true and invalidate the object pointed to by inner.
4043 impl Drop for ChannelAnnouncement {
4044 fn drop(&mut self) {
4045 if self.is_owned && !<*mut nativeChannelAnnouncement>::is_null(self.inner) {
4046 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4050 /// Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL.
4052 pub extern "C" fn ChannelAnnouncement_free(this_obj: ChannelAnnouncement) { }
4054 /// Used only if an object of this type is returned as a trait impl by a method
4055 pub(crate) extern "C" fn ChannelAnnouncement_free_void(this_ptr: *mut c_void) {
4056 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelAnnouncement); }
4059 impl ChannelAnnouncement {
4060 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelAnnouncement {
4061 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4063 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelAnnouncement {
4064 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4066 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4067 pub(crate) fn take_inner(mut self) -> *mut nativeChannelAnnouncement {
4068 assert!(self.is_owned);
4069 let ret = ObjOps::untweak_ptr(self.inner);
4070 self.inner = core::ptr::null_mut();
4074 /// Authentication of the announcement by the first public node
4076 pub extern "C" fn ChannelAnnouncement_get_node_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
4077 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_1;
4078 crate::c_types::Signature::from_rust(&inner_val)
4080 /// Authentication of the announcement by the first public node
4082 pub extern "C" fn ChannelAnnouncement_set_node_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
4083 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_1 = val.into_rust();
4085 /// Authentication of the announcement by the second public node
4087 pub extern "C" fn ChannelAnnouncement_get_node_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
4088 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_2;
4089 crate::c_types::Signature::from_rust(&inner_val)
4091 /// Authentication of the announcement by the second public node
4093 pub extern "C" fn ChannelAnnouncement_set_node_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
4094 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_2 = val.into_rust();
4096 /// Proof of funding UTXO ownership by the first public node
4098 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
4099 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_1;
4100 crate::c_types::Signature::from_rust(&inner_val)
4102 /// Proof of funding UTXO ownership by the first public node
4104 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
4105 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_1 = val.into_rust();
4107 /// Proof of funding UTXO ownership by the second public node
4109 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
4110 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_2;
4111 crate::c_types::Signature::from_rust(&inner_val)
4113 /// Proof of funding UTXO ownership by the second public node
4115 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
4116 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_2 = val.into_rust();
4118 /// The actual announcement
4120 pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncement) -> crate::lightning::ln::msgs::UnsignedChannelAnnouncement {
4121 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
4122 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 }
4124 /// The actual announcement
4126 pub extern "C" fn ChannelAnnouncement_set_contents(this_ptr: &mut ChannelAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) {
4127 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
4129 /// Constructs a new ChannelAnnouncement given each field
4132 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 {
4133 ChannelAnnouncement { inner: ObjOps::heap_alloc(nativeChannelAnnouncement {
4134 node_signature_1: node_signature_1_arg.into_rust(),
4135 node_signature_2: node_signature_2_arg.into_rust(),
4136 bitcoin_signature_1: bitcoin_signature_1_arg.into_rust(),
4137 bitcoin_signature_2: bitcoin_signature_2_arg.into_rust(),
4138 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
4139 }), is_owned: true }
4141 impl Clone for ChannelAnnouncement {
4142 fn clone(&self) -> Self {
4144 inner: if <*mut nativeChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
4145 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4151 /// Used only if an object of this type is returned as a trait impl by a method
4152 pub(crate) extern "C" fn ChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
4153 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelAnnouncement)).clone() })) as *mut c_void
4156 /// Creates a copy of the ChannelAnnouncement
4157 pub extern "C" fn ChannelAnnouncement_clone(orig: &ChannelAnnouncement) -> ChannelAnnouncement {
4160 /// Checks if two ChannelAnnouncements contain equal inner contents.
4161 /// This ignores pointers and is_owned flags and looks at the values in fields.
4162 /// Two objects with NULL inner values will be considered "equal" here.
4164 pub extern "C" fn ChannelAnnouncement_eq(a: &ChannelAnnouncement, b: &ChannelAnnouncement) -> bool {
4165 if a.inner == b.inner { return true; }
4166 if a.inner.is_null() || b.inner.is_null() { return false; }
4167 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4170 use lightning::ln::msgs::UnsignedChannelUpdate as nativeUnsignedChannelUpdateImport;
4171 pub(crate) type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport;
4173 /// The unsigned part of a channel_update
4176 pub struct UnsignedChannelUpdate {
4177 /// A pointer to the opaque Rust object.
4179 /// Nearly everywhere, inner must be non-null, however in places where
4180 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4181 pub inner: *mut nativeUnsignedChannelUpdate,
4182 /// Indicates that this is the only struct which contains the same pointer.
4184 /// Rust functions which take ownership of an object provided via an argument require
4185 /// this to be true and invalidate the object pointed to by inner.
4189 impl Drop for UnsignedChannelUpdate {
4190 fn drop(&mut self) {
4191 if self.is_owned && !<*mut nativeUnsignedChannelUpdate>::is_null(self.inner) {
4192 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4196 /// Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL.
4198 pub extern "C" fn UnsignedChannelUpdate_free(this_obj: UnsignedChannelUpdate) { }
4200 /// Used only if an object of this type is returned as a trait impl by a method
4201 pub(crate) extern "C" fn UnsignedChannelUpdate_free_void(this_ptr: *mut c_void) {
4202 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelUpdate); }
4205 impl UnsignedChannelUpdate {
4206 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelUpdate {
4207 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4209 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelUpdate {
4210 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4212 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4213 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelUpdate {
4214 assert!(self.is_owned);
4215 let ret = ObjOps::untweak_ptr(self.inner);
4216 self.inner = core::ptr::null_mut();
4220 /// The genesis hash of the blockchain where the channel is to be opened
4222 pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChannelUpdate) -> *const [u8; 32] {
4223 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4224 inner_val.as_inner()
4226 /// The genesis hash of the blockchain where the channel is to be opened
4228 pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::ThirtyTwoBytes) {
4229 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4231 /// The short channel ID
4233 pub extern "C" fn UnsignedChannelUpdate_get_short_channel_id(this_ptr: &UnsignedChannelUpdate) -> u64 {
4234 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
4237 /// The short channel ID
4239 pub extern "C" fn UnsignedChannelUpdate_set_short_channel_id(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
4240 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
4242 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
4244 pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannelUpdate) -> u32 {
4245 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
4248 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
4250 pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
4251 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
4255 pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 {
4256 let mut inner_val = &mut this_ptr.get_native_mut_ref().flags;
4261 pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) {
4262 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.flags = val;
4264 /// The number of blocks such that if:
4265 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
4266 /// then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines
4267 /// the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a
4268 /// cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10,
4269 /// then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before
4270 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
4271 /// constructing the route.
4273 pub extern "C" fn UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr: &UnsignedChannelUpdate) -> u16 {
4274 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
4277 /// The number of blocks such that if:
4278 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
4279 /// then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines
4280 /// the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a
4281 /// cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10,
4282 /// then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before
4283 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
4284 /// constructing the route.
4286 pub extern "C" fn UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr: &mut UnsignedChannelUpdate, mut val: u16) {
4287 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
4289 /// The minimum HTLC size incoming to sender, in milli-satoshi
4291 pub extern "C" fn UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
4292 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
4295 /// The minimum HTLC size incoming to sender, in milli-satoshi
4297 pub extern "C" fn UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
4298 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
4300 /// The maximum HTLC value incoming to sender, in milli-satoshi. Used to be optional.
4302 pub extern "C" fn UnsignedChannelUpdate_get_htlc_maximum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
4303 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat;
4306 /// The maximum HTLC value incoming to sender, in milli-satoshi. Used to be optional.
4308 pub extern "C" fn UnsignedChannelUpdate_set_htlc_maximum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
4309 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = val;
4311 /// The base HTLC fee charged by sender, in milli-satoshi
4313 pub extern "C" fn UnsignedChannelUpdate_get_fee_base_msat(this_ptr: &UnsignedChannelUpdate) -> u32 {
4314 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat;
4317 /// The base HTLC fee charged by sender, in milli-satoshi
4319 pub extern "C" fn UnsignedChannelUpdate_set_fee_base_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
4320 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val;
4322 /// The amount to fee multiplier, in micro-satoshi
4324 pub extern "C" fn UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr: &UnsignedChannelUpdate) -> u32 {
4325 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths;
4328 /// The amount to fee multiplier, in micro-satoshi
4330 pub extern "C" fn UnsignedChannelUpdate_set_fee_proportional_millionths(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
4331 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val;
4333 /// Excess data which was signed as a part of the message which we do not (yet) understand how
4334 /// to decode. This is stored to ensure forward-compatibility as new fields are added to the
4335 /// lightning gossip
4337 /// Returns a copy of the field.
4339 pub extern "C" fn UnsignedChannelUpdate_get_excess_data(this_ptr: &UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
4340 let mut inner_val = this_ptr.get_native_mut_ref().excess_data.clone();
4341 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
4342 local_inner_val.into()
4344 /// Excess data which was signed as a part of the message which we do not (yet) understand how
4345 /// to decode. This is stored to ensure forward-compatibility as new fields are added to the
4346 /// lightning gossip
4348 pub extern "C" fn UnsignedChannelUpdate_set_excess_data(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::derived::CVec_u8Z) {
4349 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
4350 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_data = local_val;
4352 /// Constructs a new UnsignedChannelUpdate given each field
4355 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 {
4356 let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); };
4357 UnsignedChannelUpdate { inner: ObjOps::heap_alloc(nativeUnsignedChannelUpdate {
4358 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4359 short_channel_id: short_channel_id_arg,
4360 timestamp: timestamp_arg,
4362 cltv_expiry_delta: cltv_expiry_delta_arg,
4363 htlc_minimum_msat: htlc_minimum_msat_arg,
4364 htlc_maximum_msat: htlc_maximum_msat_arg,
4365 fee_base_msat: fee_base_msat_arg,
4366 fee_proportional_millionths: fee_proportional_millionths_arg,
4367 excess_data: local_excess_data_arg,
4368 }), is_owned: true }
4370 impl Clone for UnsignedChannelUpdate {
4371 fn clone(&self) -> Self {
4373 inner: if <*mut nativeUnsignedChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
4374 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4380 /// Used only if an object of this type is returned as a trait impl by a method
4381 pub(crate) extern "C" fn UnsignedChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
4382 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelUpdate)).clone() })) as *mut c_void
4385 /// Creates a copy of the UnsignedChannelUpdate
4386 pub extern "C" fn UnsignedChannelUpdate_clone(orig: &UnsignedChannelUpdate) -> UnsignedChannelUpdate {
4389 /// Checks if two UnsignedChannelUpdates contain equal inner contents.
4390 /// This ignores pointers and is_owned flags and looks at the values in fields.
4391 /// Two objects with NULL inner values will be considered "equal" here.
4393 pub extern "C" fn UnsignedChannelUpdate_eq(a: &UnsignedChannelUpdate, b: &UnsignedChannelUpdate) -> bool {
4394 if a.inner == b.inner { return true; }
4395 if a.inner.is_null() || b.inner.is_null() { return false; }
4396 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4399 use lightning::ln::msgs::ChannelUpdate as nativeChannelUpdateImport;
4400 pub(crate) type nativeChannelUpdate = nativeChannelUpdateImport;
4402 /// A channel_update message to be sent or received from a peer
4405 pub struct ChannelUpdate {
4406 /// A pointer to the opaque Rust object.
4408 /// Nearly everywhere, inner must be non-null, however in places where
4409 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4410 pub inner: *mut nativeChannelUpdate,
4411 /// Indicates that this is the only struct which contains the same pointer.
4413 /// Rust functions which take ownership of an object provided via an argument require
4414 /// this to be true and invalidate the object pointed to by inner.
4418 impl Drop for ChannelUpdate {
4419 fn drop(&mut self) {
4420 if self.is_owned && !<*mut nativeChannelUpdate>::is_null(self.inner) {
4421 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4425 /// Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL.
4427 pub extern "C" fn ChannelUpdate_free(this_obj: ChannelUpdate) { }
4429 /// Used only if an object of this type is returned as a trait impl by a method
4430 pub(crate) extern "C" fn ChannelUpdate_free_void(this_ptr: *mut c_void) {
4431 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelUpdate); }
4434 impl ChannelUpdate {
4435 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelUpdate {
4436 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4438 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelUpdate {
4439 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4441 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4442 pub(crate) fn take_inner(mut self) -> *mut nativeChannelUpdate {
4443 assert!(self.is_owned);
4444 let ret = ObjOps::untweak_ptr(self.inner);
4445 self.inner = core::ptr::null_mut();
4449 /// A signature of the channel update
4451 pub extern "C" fn ChannelUpdate_get_signature(this_ptr: &ChannelUpdate) -> crate::c_types::Signature {
4452 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
4453 crate::c_types::Signature::from_rust(&inner_val)
4455 /// A signature of the channel update
4457 pub extern "C" fn ChannelUpdate_set_signature(this_ptr: &mut ChannelUpdate, mut val: crate::c_types::Signature) {
4458 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
4460 /// The actual channel update
4462 pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate::lightning::ln::msgs::UnsignedChannelUpdate {
4463 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
4464 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 }
4466 /// The actual channel update
4468 pub extern "C" fn ChannelUpdate_set_contents(this_ptr: &mut ChannelUpdate, mut val: crate::lightning::ln::msgs::UnsignedChannelUpdate) {
4469 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
4471 /// Constructs a new ChannelUpdate given each field
4474 pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> ChannelUpdate {
4475 ChannelUpdate { inner: ObjOps::heap_alloc(nativeChannelUpdate {
4476 signature: signature_arg.into_rust(),
4477 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
4478 }), is_owned: true }
4480 impl Clone for ChannelUpdate {
4481 fn clone(&self) -> Self {
4483 inner: if <*mut nativeChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
4484 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4490 /// Used only if an object of this type is returned as a trait impl by a method
4491 pub(crate) extern "C" fn ChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
4492 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelUpdate)).clone() })) as *mut c_void
4495 /// Creates a copy of the ChannelUpdate
4496 pub extern "C" fn ChannelUpdate_clone(orig: &ChannelUpdate) -> ChannelUpdate {
4499 /// Checks if two ChannelUpdates contain equal inner contents.
4500 /// This ignores pointers and is_owned flags and looks at the values in fields.
4501 /// Two objects with NULL inner values will be considered "equal" here.
4503 pub extern "C" fn ChannelUpdate_eq(a: &ChannelUpdate, b: &ChannelUpdate) -> bool {
4504 if a.inner == b.inner { return true; }
4505 if a.inner.is_null() || b.inner.is_null() { return false; }
4506 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4509 use lightning::ln::msgs::QueryChannelRange as nativeQueryChannelRangeImport;
4510 pub(crate) type nativeQueryChannelRange = nativeQueryChannelRangeImport;
4512 /// A query_channel_range message is used to query a peer for channel
4513 /// UTXOs in a range of blocks. The recipient of a query makes a best
4514 /// effort to reply to the query using one or more reply_channel_range
4518 pub struct QueryChannelRange {
4519 /// A pointer to the opaque Rust object.
4521 /// Nearly everywhere, inner must be non-null, however in places where
4522 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4523 pub inner: *mut nativeQueryChannelRange,
4524 /// Indicates that this is the only struct which contains the same pointer.
4526 /// Rust functions which take ownership of an object provided via an argument require
4527 /// this to be true and invalidate the object pointed to by inner.
4531 impl Drop for QueryChannelRange {
4532 fn drop(&mut self) {
4533 if self.is_owned && !<*mut nativeQueryChannelRange>::is_null(self.inner) {
4534 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4538 /// Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL.
4540 pub extern "C" fn QueryChannelRange_free(this_obj: QueryChannelRange) { }
4542 /// Used only if an object of this type is returned as a trait impl by a method
4543 pub(crate) extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) {
4544 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryChannelRange); }
4547 impl QueryChannelRange {
4548 pub(crate) fn get_native_ref(&self) -> &'static nativeQueryChannelRange {
4549 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4551 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryChannelRange {
4552 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4554 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4555 pub(crate) fn take_inner(mut self) -> *mut nativeQueryChannelRange {
4556 assert!(self.is_owned);
4557 let ret = ObjOps::untweak_ptr(self.inner);
4558 self.inner = core::ptr::null_mut();
4562 /// The genesis hash of the blockchain being queried
4564 pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *const [u8; 32] {
4565 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4566 inner_val.as_inner()
4568 /// The genesis hash of the blockchain being queried
4570 pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
4571 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4573 /// The height of the first block for the channel UTXOs being queried
4575 pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 {
4576 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
4579 /// The height of the first block for the channel UTXOs being queried
4581 pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChannelRange, mut val: u32) {
4582 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
4584 /// The number of blocks to include in the query results
4586 pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 {
4587 let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
4590 /// The number of blocks to include in the query results
4592 pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryChannelRange, mut val: u32) {
4593 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
4595 /// Constructs a new QueryChannelRange given each field
4598 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 {
4599 QueryChannelRange { inner: ObjOps::heap_alloc(nativeQueryChannelRange {
4600 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4601 first_blocknum: first_blocknum_arg,
4602 number_of_blocks: number_of_blocks_arg,
4603 }), is_owned: true }
4605 impl Clone for QueryChannelRange {
4606 fn clone(&self) -> Self {
4608 inner: if <*mut nativeQueryChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
4609 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4615 /// Used only if an object of this type is returned as a trait impl by a method
4616 pub(crate) extern "C" fn QueryChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
4617 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryChannelRange)).clone() })) as *mut c_void
4620 /// Creates a copy of the QueryChannelRange
4621 pub extern "C" fn QueryChannelRange_clone(orig: &QueryChannelRange) -> QueryChannelRange {
4624 /// Checks if two QueryChannelRanges contain equal inner contents.
4625 /// This ignores pointers and is_owned flags and looks at the values in fields.
4626 /// Two objects with NULL inner values will be considered "equal" here.
4628 pub extern "C" fn QueryChannelRange_eq(a: &QueryChannelRange, b: &QueryChannelRange) -> bool {
4629 if a.inner == b.inner { return true; }
4630 if a.inner.is_null() || b.inner.is_null() { return false; }
4631 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4634 use lightning::ln::msgs::ReplyChannelRange as nativeReplyChannelRangeImport;
4635 pub(crate) type nativeReplyChannelRange = nativeReplyChannelRangeImport;
4637 /// A reply_channel_range message is a reply to a query_channel_range
4638 /// message. Multiple reply_channel_range messages can be sent in reply
4639 /// to a single query_channel_range message. The query recipient makes a
4640 /// best effort to respond based on their local network view which may
4641 /// not be a perfect view of the network. The short_channel_ids in the
4642 /// reply are encoded. We only support encoding_type=0 uncompressed
4643 /// serialization and do not support encoding_type=1 zlib serialization.
4646 pub struct ReplyChannelRange {
4647 /// A pointer to the opaque Rust object.
4649 /// Nearly everywhere, inner must be non-null, however in places where
4650 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4651 pub inner: *mut nativeReplyChannelRange,
4652 /// Indicates that this is the only struct which contains the same pointer.
4654 /// Rust functions which take ownership of an object provided via an argument require
4655 /// this to be true and invalidate the object pointed to by inner.
4659 impl Drop for ReplyChannelRange {
4660 fn drop(&mut self) {
4661 if self.is_owned && !<*mut nativeReplyChannelRange>::is_null(self.inner) {
4662 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4666 /// Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL.
4668 pub extern "C" fn ReplyChannelRange_free(this_obj: ReplyChannelRange) { }
4670 /// Used only if an object of this type is returned as a trait impl by a method
4671 pub(crate) extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) {
4672 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyChannelRange); }
4675 impl ReplyChannelRange {
4676 pub(crate) fn get_native_ref(&self) -> &'static nativeReplyChannelRange {
4677 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4679 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyChannelRange {
4680 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4682 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4683 pub(crate) fn take_inner(mut self) -> *mut nativeReplyChannelRange {
4684 assert!(self.is_owned);
4685 let ret = ObjOps::untweak_ptr(self.inner);
4686 self.inner = core::ptr::null_mut();
4690 /// The genesis hash of the blockchain being queried
4692 pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *const [u8; 32] {
4693 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4694 inner_val.as_inner()
4696 /// The genesis hash of the blockchain being queried
4698 pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
4699 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4701 /// The height of the first block in the range of the reply
4703 pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 {
4704 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
4707 /// The height of the first block in the range of the reply
4709 pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChannelRange, mut val: u32) {
4710 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
4712 /// The number of blocks included in the range of the reply
4714 pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 {
4715 let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
4718 /// The number of blocks included in the range of the reply
4720 pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyChannelRange, mut val: u32) {
4721 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
4723 /// True when this is the final reply for a query
4725 pub extern "C" fn ReplyChannelRange_get_sync_complete(this_ptr: &ReplyChannelRange) -> bool {
4726 let mut inner_val = &mut this_ptr.get_native_mut_ref().sync_complete;
4729 /// True when this is the final reply for a query
4731 pub extern "C" fn ReplyChannelRange_set_sync_complete(this_ptr: &mut ReplyChannelRange, mut val: bool) {
4732 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sync_complete = val;
4734 /// The short_channel_ids in the channel range
4736 /// Returns a copy of the field.
4738 pub extern "C" fn ReplyChannelRange_get_short_channel_ids(this_ptr: &ReplyChannelRange) -> crate::c_types::derived::CVec_u64Z {
4739 let mut inner_val = this_ptr.get_native_mut_ref().short_channel_ids.clone();
4740 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
4741 local_inner_val.into()
4743 /// The short_channel_ids in the channel range
4745 pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::derived::CVec_u64Z) {
4746 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
4747 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
4749 /// Constructs a new ReplyChannelRange given each field
4752 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 {
4753 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 }); };
4754 ReplyChannelRange { inner: ObjOps::heap_alloc(nativeReplyChannelRange {
4755 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4756 first_blocknum: first_blocknum_arg,
4757 number_of_blocks: number_of_blocks_arg,
4758 sync_complete: sync_complete_arg,
4759 short_channel_ids: local_short_channel_ids_arg,
4760 }), is_owned: true }
4762 impl Clone for ReplyChannelRange {
4763 fn clone(&self) -> Self {
4765 inner: if <*mut nativeReplyChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
4766 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4772 /// Used only if an object of this type is returned as a trait impl by a method
4773 pub(crate) extern "C" fn ReplyChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
4774 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyChannelRange)).clone() })) as *mut c_void
4777 /// Creates a copy of the ReplyChannelRange
4778 pub extern "C" fn ReplyChannelRange_clone(orig: &ReplyChannelRange) -> ReplyChannelRange {
4781 /// Checks if two ReplyChannelRanges contain equal inner contents.
4782 /// This ignores pointers and is_owned flags and looks at the values in fields.
4783 /// Two objects with NULL inner values will be considered "equal" here.
4785 pub extern "C" fn ReplyChannelRange_eq(a: &ReplyChannelRange, b: &ReplyChannelRange) -> bool {
4786 if a.inner == b.inner { return true; }
4787 if a.inner.is_null() || b.inner.is_null() { return false; }
4788 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4791 use lightning::ln::msgs::QueryShortChannelIds as nativeQueryShortChannelIdsImport;
4792 pub(crate) type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport;
4794 /// A query_short_channel_ids message is used to query a peer for
4795 /// routing gossip messages related to one or more short_channel_ids.
4796 /// The query recipient will reply with the latest, if available,
4797 /// channel_announcement, channel_update and node_announcement messages
4798 /// it maintains for the requested short_channel_ids followed by a
4799 /// reply_short_channel_ids_end message. The short_channel_ids sent in
4800 /// this query are encoded. We only support encoding_type=0 uncompressed
4801 /// serialization and do not support encoding_type=1 zlib serialization.
4804 pub struct QueryShortChannelIds {
4805 /// A pointer to the opaque Rust object.
4807 /// Nearly everywhere, inner must be non-null, however in places where
4808 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4809 pub inner: *mut nativeQueryShortChannelIds,
4810 /// Indicates that this is the only struct which contains the same pointer.
4812 /// Rust functions which take ownership of an object provided via an argument require
4813 /// this to be true and invalidate the object pointed to by inner.
4817 impl Drop for QueryShortChannelIds {
4818 fn drop(&mut self) {
4819 if self.is_owned && !<*mut nativeQueryShortChannelIds>::is_null(self.inner) {
4820 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4824 /// Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL.
4826 pub extern "C" fn QueryShortChannelIds_free(this_obj: QueryShortChannelIds) { }
4828 /// Used only if an object of this type is returned as a trait impl by a method
4829 pub(crate) extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) {
4830 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryShortChannelIds); }
4833 impl QueryShortChannelIds {
4834 pub(crate) fn get_native_ref(&self) -> &'static nativeQueryShortChannelIds {
4835 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4837 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryShortChannelIds {
4838 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4840 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4841 pub(crate) fn take_inner(mut self) -> *mut nativeQueryShortChannelIds {
4842 assert!(self.is_owned);
4843 let ret = ObjOps::untweak_ptr(self.inner);
4844 self.inner = core::ptr::null_mut();
4848 /// The genesis hash of the blockchain being queried
4850 pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *const [u8; 32] {
4851 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4852 inner_val.as_inner()
4854 /// The genesis hash of the blockchain being queried
4856 pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::ThirtyTwoBytes) {
4857 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4859 /// The short_channel_ids that are being queried
4861 /// Returns a copy of the field.
4863 pub extern "C" fn QueryShortChannelIds_get_short_channel_ids(this_ptr: &QueryShortChannelIds) -> crate::c_types::derived::CVec_u64Z {
4864 let mut inner_val = this_ptr.get_native_mut_ref().short_channel_ids.clone();
4865 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
4866 local_inner_val.into()
4868 /// The short_channel_ids that are being queried
4870 pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::derived::CVec_u64Z) {
4871 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
4872 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
4874 /// Constructs a new QueryShortChannelIds given each field
4877 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 {
4878 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 }); };
4879 QueryShortChannelIds { inner: ObjOps::heap_alloc(nativeQueryShortChannelIds {
4880 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4881 short_channel_ids: local_short_channel_ids_arg,
4882 }), is_owned: true }
4884 impl Clone for QueryShortChannelIds {
4885 fn clone(&self) -> Self {
4887 inner: if <*mut nativeQueryShortChannelIds>::is_null(self.inner) { core::ptr::null_mut() } else {
4888 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4894 /// Used only if an object of this type is returned as a trait impl by a method
4895 pub(crate) extern "C" fn QueryShortChannelIds_clone_void(this_ptr: *const c_void) -> *mut c_void {
4896 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryShortChannelIds)).clone() })) as *mut c_void
4899 /// Creates a copy of the QueryShortChannelIds
4900 pub extern "C" fn QueryShortChannelIds_clone(orig: &QueryShortChannelIds) -> QueryShortChannelIds {
4903 /// Checks if two QueryShortChannelIdss contain equal inner contents.
4904 /// This ignores pointers and is_owned flags and looks at the values in fields.
4905 /// Two objects with NULL inner values will be considered "equal" here.
4907 pub extern "C" fn QueryShortChannelIds_eq(a: &QueryShortChannelIds, b: &QueryShortChannelIds) -> bool {
4908 if a.inner == b.inner { return true; }
4909 if a.inner.is_null() || b.inner.is_null() { return false; }
4910 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4913 use lightning::ln::msgs::ReplyShortChannelIdsEnd as nativeReplyShortChannelIdsEndImport;
4914 pub(crate) type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport;
4916 /// A reply_short_channel_ids_end message is sent as a reply to a
4917 /// query_short_channel_ids message. The query recipient makes a best
4918 /// effort to respond based on their local network view which may not be
4919 /// a perfect view of the network.
4922 pub struct ReplyShortChannelIdsEnd {
4923 /// A pointer to the opaque Rust object.
4925 /// Nearly everywhere, inner must be non-null, however in places where
4926 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4927 pub inner: *mut nativeReplyShortChannelIdsEnd,
4928 /// Indicates that this is the only struct which contains the same pointer.
4930 /// Rust functions which take ownership of an object provided via an argument require
4931 /// this to be true and invalidate the object pointed to by inner.
4935 impl Drop for ReplyShortChannelIdsEnd {
4936 fn drop(&mut self) {
4937 if self.is_owned && !<*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) {
4938 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4942 /// Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL.
4944 pub extern "C" fn ReplyShortChannelIdsEnd_free(this_obj: ReplyShortChannelIdsEnd) { }
4946 /// Used only if an object of this type is returned as a trait impl by a method
4947 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) {
4948 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyShortChannelIdsEnd); }
4951 impl ReplyShortChannelIdsEnd {
4952 pub(crate) fn get_native_ref(&self) -> &'static nativeReplyShortChannelIdsEnd {
4953 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4955 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyShortChannelIdsEnd {
4956 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4958 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4959 pub(crate) fn take_inner(mut self) -> *mut nativeReplyShortChannelIdsEnd {
4960 assert!(self.is_owned);
4961 let ret = ObjOps::untweak_ptr(self.inner);
4962 self.inner = core::ptr::null_mut();
4966 /// The genesis hash of the blockchain that was queried
4968 pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *const [u8; 32] {
4969 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4970 inner_val.as_inner()
4972 /// The genesis hash of the blockchain that was queried
4974 pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) {
4975 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4977 /// Indicates if the query recipient maintains up-to-date channel
4978 /// information for the chain_hash
4980 pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool {
4981 let mut inner_val = &mut this_ptr.get_native_mut_ref().full_information;
4984 /// Indicates if the query recipient maintains up-to-date channel
4985 /// information for the chain_hash
4987 pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: bool) {
4988 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.full_information = val;
4990 /// Constructs a new ReplyShortChannelIdsEnd given each field
4993 pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd {
4994 ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(nativeReplyShortChannelIdsEnd {
4995 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4996 full_information: full_information_arg,
4997 }), is_owned: true }
4999 impl Clone for ReplyShortChannelIdsEnd {
5000 fn clone(&self) -> Self {
5002 inner: if <*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) { core::ptr::null_mut() } else {
5003 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5009 /// Used only if an object of this type is returned as a trait impl by a method
5010 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_void) -> *mut c_void {
5011 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyShortChannelIdsEnd)).clone() })) as *mut c_void
5014 /// Creates a copy of the ReplyShortChannelIdsEnd
5015 pub extern "C" fn ReplyShortChannelIdsEnd_clone(orig: &ReplyShortChannelIdsEnd) -> ReplyShortChannelIdsEnd {
5018 /// Checks if two ReplyShortChannelIdsEnds contain equal inner contents.
5019 /// This ignores pointers and is_owned flags and looks at the values in fields.
5020 /// Two objects with NULL inner values will be considered "equal" here.
5022 pub extern "C" fn ReplyShortChannelIdsEnd_eq(a: &ReplyShortChannelIdsEnd, b: &ReplyShortChannelIdsEnd) -> bool {
5023 if a.inner == b.inner { return true; }
5024 if a.inner.is_null() || b.inner.is_null() { return false; }
5025 if a.get_native_ref() == b.get_native_ref() { true } else { false }
5028 use lightning::ln::msgs::GossipTimestampFilter as nativeGossipTimestampFilterImport;
5029 pub(crate) type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport;
5031 /// A gossip_timestamp_filter message is used by a node to request
5032 /// gossip relay for messages in the requested time range when the
5033 /// gossip_queries feature has been negotiated.
5036 pub struct GossipTimestampFilter {
5037 /// A pointer to the opaque Rust object.
5039 /// Nearly everywhere, inner must be non-null, however in places where
5040 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5041 pub inner: *mut nativeGossipTimestampFilter,
5042 /// Indicates that this is the only struct which contains the same pointer.
5044 /// Rust functions which take ownership of an object provided via an argument require
5045 /// this to be true and invalidate the object pointed to by inner.
5049 impl Drop for GossipTimestampFilter {
5050 fn drop(&mut self) {
5051 if self.is_owned && !<*mut nativeGossipTimestampFilter>::is_null(self.inner) {
5052 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5056 /// Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL.
5058 pub extern "C" fn GossipTimestampFilter_free(this_obj: GossipTimestampFilter) { }
5060 /// Used only if an object of this type is returned as a trait impl by a method
5061 pub(crate) extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) {
5062 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeGossipTimestampFilter); }
5065 impl GossipTimestampFilter {
5066 pub(crate) fn get_native_ref(&self) -> &'static nativeGossipTimestampFilter {
5067 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5069 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeGossipTimestampFilter {
5070 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5072 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5073 pub(crate) fn take_inner(mut self) -> *mut nativeGossipTimestampFilter {
5074 assert!(self.is_owned);
5075 let ret = ObjOps::untweak_ptr(self.inner);
5076 self.inner = core::ptr::null_mut();
5080 /// The genesis hash of the blockchain for channel and node information
5082 pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *const [u8; 32] {
5083 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
5084 inner_val.as_inner()
5086 /// The genesis hash of the blockchain for channel and node information
5088 pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) {
5089 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
5091 /// The starting unix timestamp
5093 pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 {
5094 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_timestamp;
5097 /// The starting unix timestamp
5099 pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
5100 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_timestamp = val;
5102 /// The range of information in seconds
5104 pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 {
5105 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp_range;
5108 /// The range of information in seconds
5110 pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
5111 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp_range = val;
5113 /// Constructs a new GossipTimestampFilter given each field
5116 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 {
5117 GossipTimestampFilter { inner: ObjOps::heap_alloc(nativeGossipTimestampFilter {
5118 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
5119 first_timestamp: first_timestamp_arg,
5120 timestamp_range: timestamp_range_arg,
5121 }), is_owned: true }
5123 impl Clone for GossipTimestampFilter {
5124 fn clone(&self) -> Self {
5126 inner: if <*mut nativeGossipTimestampFilter>::is_null(self.inner) { core::ptr::null_mut() } else {
5127 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5133 /// Used only if an object of this type is returned as a trait impl by a method
5134 pub(crate) extern "C" fn GossipTimestampFilter_clone_void(this_ptr: *const c_void) -> *mut c_void {
5135 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeGossipTimestampFilter)).clone() })) as *mut c_void
5138 /// Creates a copy of the GossipTimestampFilter
5139 pub extern "C" fn GossipTimestampFilter_clone(orig: &GossipTimestampFilter) -> GossipTimestampFilter {
5142 /// Checks if two GossipTimestampFilters contain equal inner contents.
5143 /// This ignores pointers and is_owned flags and looks at the values in fields.
5144 /// Two objects with NULL inner values will be considered "equal" here.
5146 pub extern "C" fn GossipTimestampFilter_eq(a: &GossipTimestampFilter, b: &GossipTimestampFilter) -> bool {
5147 if a.inner == b.inner { return true; }
5148 if a.inner.is_null() || b.inner.is_null() { return false; }
5149 if a.get_native_ref() == b.get_native_ref() { true } else { false }
5151 /// Used to put an error message in a LightningError
5155 pub enum ErrorAction {
5156 /// The peer took some action which made us think they were useless. Disconnect them.
5158 /// An error message which we should make an effort to send before we disconnect.
5160 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
5161 msg: crate::lightning::ln::msgs::ErrorMessage,
5163 /// The peer did something harmless that we weren't able to process, just log and ignore
5165 /// The peer did something harmless that we weren't able to meaningfully process.
5166 /// If the error is logged, log it at the given level.
5168 crate::lightning::util::logger::Level),
5169 /// The peer provided us with a gossip message which we'd already seen. In most cases this
5170 /// should be ignored, but it may result in the message being forwarded if it is a duplicate of
5171 /// our own channel announcements.
5172 IgnoreDuplicateGossip,
5173 /// The peer did something incorrect. Tell them.
5175 /// The message to send.
5176 msg: crate::lightning::ln::msgs::ErrorMessage,
5178 /// The peer did something incorrect. Tell them without closing any channels.
5179 SendWarningMessage {
5180 /// The message to send.
5181 msg: crate::lightning::ln::msgs::WarningMessage,
5182 /// The peer may have done something harmless that we weren't able to meaningfully process,
5183 /// though we should still tell them about it.
5184 /// If this event is logged, log it at the given level.
5185 log_level: crate::lightning::util::logger::Level,
5188 use lightning::ln::msgs::ErrorAction as ErrorActionImport;
5189 pub(crate) type nativeErrorAction = ErrorActionImport;
5193 pub(crate) fn to_native(&self) -> nativeErrorAction {
5195 ErrorAction::DisconnectPeer {ref msg, } => {
5196 let mut msg_nonref = (*msg).clone();
5197 let mut local_msg_nonref = if msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg_nonref.take_inner()) } }) };
5198 nativeErrorAction::DisconnectPeer {
5199 msg: local_msg_nonref,
5202 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
5203 ErrorAction::IgnoreAndLog (ref a, ) => {
5204 let mut a_nonref = (*a).clone();
5205 nativeErrorAction::IgnoreAndLog (
5206 a_nonref.into_native(),
5209 ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
5210 ErrorAction::SendErrorMessage {ref msg, } => {
5211 let mut msg_nonref = (*msg).clone();
5212 nativeErrorAction::SendErrorMessage {
5213 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
5216 ErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
5217 let mut msg_nonref = (*msg).clone();
5218 let mut log_level_nonref = (*log_level).clone();
5219 nativeErrorAction::SendWarningMessage {
5220 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
5221 log_level: log_level_nonref.into_native(),
5227 pub(crate) fn into_native(self) -> nativeErrorAction {
5229 ErrorAction::DisconnectPeer {mut msg, } => {
5230 let mut local_msg = if msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg.take_inner()) } }) };
5231 nativeErrorAction::DisconnectPeer {
5235 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
5236 ErrorAction::IgnoreAndLog (mut a, ) => {
5237 nativeErrorAction::IgnoreAndLog (
5241 ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
5242 ErrorAction::SendErrorMessage {mut msg, } => {
5243 nativeErrorAction::SendErrorMessage {
5244 msg: *unsafe { Box::from_raw(msg.take_inner()) },
5247 ErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
5248 nativeErrorAction::SendWarningMessage {
5249 msg: *unsafe { Box::from_raw(msg.take_inner()) },
5250 log_level: log_level.into_native(),
5256 pub(crate) fn from_native(native: &nativeErrorAction) -> Self {
5258 nativeErrorAction::DisconnectPeer {ref msg, } => {
5259 let mut msg_nonref = (*msg).clone();
5260 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 };
5261 ErrorAction::DisconnectPeer {
5262 msg: local_msg_nonref,
5265 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
5266 nativeErrorAction::IgnoreAndLog (ref a, ) => {
5267 let mut a_nonref = (*a).clone();
5268 ErrorAction::IgnoreAndLog (
5269 crate::lightning::util::logger::Level::native_into(a_nonref),
5272 nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
5273 nativeErrorAction::SendErrorMessage {ref msg, } => {
5274 let mut msg_nonref = (*msg).clone();
5275 ErrorAction::SendErrorMessage {
5276 msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
5279 nativeErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
5280 let mut msg_nonref = (*msg).clone();
5281 let mut log_level_nonref = (*log_level).clone();
5282 ErrorAction::SendWarningMessage {
5283 msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
5284 log_level: crate::lightning::util::logger::Level::native_into(log_level_nonref),
5290 pub(crate) fn native_into(native: nativeErrorAction) -> Self {
5292 nativeErrorAction::DisconnectPeer {mut msg, } => {
5293 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 };
5294 ErrorAction::DisconnectPeer {
5298 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
5299 nativeErrorAction::IgnoreAndLog (mut a, ) => {
5300 ErrorAction::IgnoreAndLog (
5301 crate::lightning::util::logger::Level::native_into(a),
5304 nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
5305 nativeErrorAction::SendErrorMessage {mut msg, } => {
5306 ErrorAction::SendErrorMessage {
5307 msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
5310 nativeErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
5311 ErrorAction::SendWarningMessage {
5312 msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
5313 log_level: crate::lightning::util::logger::Level::native_into(log_level),
5319 /// Frees any resources used by the ErrorAction
5321 pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { }
5322 /// Creates a copy of the ErrorAction
5324 pub extern "C" fn ErrorAction_clone(orig: &ErrorAction) -> ErrorAction {
5328 /// Utility method to constructs a new DisconnectPeer-variant ErrorAction
5329 pub extern "C" fn ErrorAction_disconnect_peer(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
5330 ErrorAction::DisconnectPeer {
5335 /// Utility method to constructs a new IgnoreError-variant ErrorAction
5336 pub extern "C" fn ErrorAction_ignore_error() -> ErrorAction {
5337 ErrorAction::IgnoreError}
5339 /// Utility method to constructs a new IgnoreAndLog-variant ErrorAction
5340 pub extern "C" fn ErrorAction_ignore_and_log(a: crate::lightning::util::logger::Level) -> ErrorAction {
5341 ErrorAction::IgnoreAndLog(a, )
5344 /// Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction
5345 pub extern "C" fn ErrorAction_ignore_duplicate_gossip() -> ErrorAction {
5346 ErrorAction::IgnoreDuplicateGossip}
5348 /// Utility method to constructs a new SendErrorMessage-variant ErrorAction
5349 pub extern "C" fn ErrorAction_send_error_message(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
5350 ErrorAction::SendErrorMessage {
5355 /// Utility method to constructs a new SendWarningMessage-variant ErrorAction
5356 pub extern "C" fn ErrorAction_send_warning_message(msg: crate::lightning::ln::msgs::WarningMessage, log_level: crate::lightning::util::logger::Level) -> ErrorAction {
5357 ErrorAction::SendWarningMessage {
5363 use lightning::ln::msgs::LightningError as nativeLightningErrorImport;
5364 pub(crate) type nativeLightningError = nativeLightningErrorImport;
5366 /// An Err type for failure to process messages.
5369 pub struct LightningError {
5370 /// A pointer to the opaque Rust object.
5372 /// Nearly everywhere, inner must be non-null, however in places where
5373 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5374 pub inner: *mut nativeLightningError,
5375 /// Indicates that this is the only struct which contains the same pointer.
5377 /// Rust functions which take ownership of an object provided via an argument require
5378 /// this to be true and invalidate the object pointed to by inner.
5382 impl Drop for LightningError {
5383 fn drop(&mut self) {
5384 if self.is_owned && !<*mut nativeLightningError>::is_null(self.inner) {
5385 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5389 /// Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL.
5391 pub extern "C" fn LightningError_free(this_obj: LightningError) { }
5393 /// Used only if an object of this type is returned as a trait impl by a method
5394 pub(crate) extern "C" fn LightningError_free_void(this_ptr: *mut c_void) {
5395 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeLightningError); }
5398 impl LightningError {
5399 pub(crate) fn get_native_ref(&self) -> &'static nativeLightningError {
5400 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5402 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLightningError {
5403 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5405 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5406 pub(crate) fn take_inner(mut self) -> *mut nativeLightningError {
5407 assert!(self.is_owned);
5408 let ret = ObjOps::untweak_ptr(self.inner);
5409 self.inner = core::ptr::null_mut();
5413 /// A human-readable message describing the error
5415 pub extern "C" fn LightningError_get_err(this_ptr: &LightningError) -> crate::c_types::Str {
5416 let mut inner_val = &mut this_ptr.get_native_mut_ref().err;
5417 inner_val.as_str().into()
5419 /// A human-readable message describing the error
5421 pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: crate::c_types::Str) {
5422 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.err = val.into_string();
5424 /// The action which should be taken against the offending peer.
5426 pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate::lightning::ln::msgs::ErrorAction {
5427 let mut inner_val = &mut this_ptr.get_native_mut_ref().action;
5428 crate::lightning::ln::msgs::ErrorAction::from_native(inner_val)
5430 /// The action which should be taken against the offending peer.
5432 pub extern "C" fn LightningError_set_action(this_ptr: &mut LightningError, mut val: crate::lightning::ln::msgs::ErrorAction) {
5433 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.action = val.into_native();
5435 /// Constructs a new LightningError given each field
5438 pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::Str, mut action_arg: crate::lightning::ln::msgs::ErrorAction) -> LightningError {
5439 LightningError { inner: ObjOps::heap_alloc(nativeLightningError {
5440 err: err_arg.into_string(),
5441 action: action_arg.into_native(),
5442 }), is_owned: true }
5444 impl Clone for LightningError {
5445 fn clone(&self) -> Self {
5447 inner: if <*mut nativeLightningError>::is_null(self.inner) { core::ptr::null_mut() } else {
5448 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5454 /// Used only if an object of this type is returned as a trait impl by a method
5455 pub(crate) extern "C" fn LightningError_clone_void(this_ptr: *const c_void) -> *mut c_void {
5456 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeLightningError)).clone() })) as *mut c_void
5459 /// Creates a copy of the LightningError
5460 pub extern "C" fn LightningError_clone(orig: &LightningError) -> LightningError {
5464 use lightning::ln::msgs::CommitmentUpdate as nativeCommitmentUpdateImport;
5465 pub(crate) type nativeCommitmentUpdate = nativeCommitmentUpdateImport;
5467 /// Struct used to return values from revoke_and_ack messages, containing a bunch of commitment
5468 /// transaction updates if they were pending.
5471 pub struct CommitmentUpdate {
5472 /// A pointer to the opaque Rust object.
5474 /// Nearly everywhere, inner must be non-null, however in places where
5475 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5476 pub inner: *mut nativeCommitmentUpdate,
5477 /// Indicates that this is the only struct which contains the same pointer.
5479 /// Rust functions which take ownership of an object provided via an argument require
5480 /// this to be true and invalidate the object pointed to by inner.
5484 impl Drop for CommitmentUpdate {
5485 fn drop(&mut self) {
5486 if self.is_owned && !<*mut nativeCommitmentUpdate>::is_null(self.inner) {
5487 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5491 /// Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL.
5493 pub extern "C" fn CommitmentUpdate_free(this_obj: CommitmentUpdate) { }
5495 /// Used only if an object of this type is returned as a trait impl by a method
5496 pub(crate) extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) {
5497 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentUpdate); }
5500 impl CommitmentUpdate {
5501 pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentUpdate {
5502 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5504 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentUpdate {
5505 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5507 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5508 pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentUpdate {
5509 assert!(self.is_owned);
5510 let ret = ObjOps::untweak_ptr(self.inner);
5511 self.inner = core::ptr::null_mut();
5515 /// update_add_htlc messages which should be sent
5517 pub extern "C" fn CommitmentUpdate_get_update_add_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateAddHTLCZ {
5518 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_add_htlcs;
5519 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 } }); };
5520 local_inner_val.into()
5522 /// update_add_htlc messages which should be sent
5524 pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) {
5525 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
5526 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_add_htlcs = local_val;
5528 /// update_fulfill_htlc messages which should be sent
5530 pub extern "C" fn CommitmentUpdate_get_update_fulfill_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFulfillHTLCZ {
5531 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fulfill_htlcs;
5532 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 } }); };
5533 local_inner_val.into()
5535 /// update_fulfill_htlc messages which should be sent
5537 pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) {
5538 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
5539 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fulfill_htlcs = local_val;
5541 /// update_fail_htlc messages which should be sent
5543 pub extern "C" fn CommitmentUpdate_get_update_fail_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailHTLCZ {
5544 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_htlcs;
5545 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 } }); };
5546 local_inner_val.into()
5548 /// update_fail_htlc messages which should be sent
5550 pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) {
5551 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
5552 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_htlcs = local_val;
5554 /// update_fail_malformed_htlc messages which should be sent
5556 pub extern "C" fn CommitmentUpdate_get_update_fail_malformed_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ {
5557 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_malformed_htlcs;
5558 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 } }); };
5559 local_inner_val.into()
5561 /// update_fail_malformed_htlc messages which should be sent
5563 pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) {
5564 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
5565 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_malformed_htlcs = local_val;
5567 /// An update_fee message which should be sent
5569 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
5571 pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::UpdateFee {
5572 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fee;
5573 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 };
5576 /// An update_fee message which should be sent
5578 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
5580 pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::UpdateFee) {
5581 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
5582 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fee = local_val;
5584 /// Finally, the commitment_signed message which should be sent
5586 pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::CommitmentSigned {
5587 let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_signed;
5588 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 }
5590 /// Finally, the commitment_signed message which should be sent
5592 pub extern "C" fn CommitmentUpdate_set_commitment_signed(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::CommitmentSigned) {
5593 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_signed = *unsafe { Box::from_raw(val.take_inner()) };
5595 /// Constructs a new CommitmentUpdate given each field
5598 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 {
5599 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()) } }); };
5600 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()) } }); };
5601 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()) } }); };
5602 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()) } }); };
5603 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()) } }) };
5604 CommitmentUpdate { inner: ObjOps::heap_alloc(nativeCommitmentUpdate {
5605 update_add_htlcs: local_update_add_htlcs_arg,
5606 update_fulfill_htlcs: local_update_fulfill_htlcs_arg,
5607 update_fail_htlcs: local_update_fail_htlcs_arg,
5608 update_fail_malformed_htlcs: local_update_fail_malformed_htlcs_arg,
5609 update_fee: local_update_fee_arg,
5610 commitment_signed: *unsafe { Box::from_raw(commitment_signed_arg.take_inner()) },
5611 }), is_owned: true }
5613 impl Clone for CommitmentUpdate {
5614 fn clone(&self) -> Self {
5616 inner: if <*mut nativeCommitmentUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
5617 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5623 /// Used only if an object of this type is returned as a trait impl by a method
5624 pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
5625 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentUpdate)).clone() })) as *mut c_void
5628 /// Creates a copy of the CommitmentUpdate
5629 pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentUpdate {
5632 /// Checks if two CommitmentUpdates contain equal inner contents.
5633 /// This ignores pointers and is_owned flags and looks at the values in fields.
5634 /// Two objects with NULL inner values will be considered "equal" here.
5636 pub extern "C" fn CommitmentUpdate_eq(a: &CommitmentUpdate, b: &CommitmentUpdate) -> bool {
5637 if a.inner == b.inner { return true; }
5638 if a.inner.is_null() || b.inner.is_null() { return false; }
5639 if a.get_native_ref() == b.get_native_ref() { true } else { false }
5641 /// A trait to describe an object which can receive channel messages.
5643 /// Messages MAY be called in parallel when they originate from different their_node_ids, however
5644 /// they MUST NOT be called in parallel when the two calls have the same their_node_id.
5646 pub struct ChannelMessageHandler {
5647 /// An opaque pointer which is passed to your function implementations as an argument.
5648 /// This has no meaning in the LDK, and can be NULL or any other value.
5649 pub this_arg: *mut c_void,
5650 /// Handle an incoming open_channel message from the given peer.
5651 pub handle_open_channel: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, their_features: crate::lightning::ln::features::InitFeatures, msg: &crate::lightning::ln::msgs::OpenChannel),
5652 /// Handle an incoming accept_channel message from the given peer.
5653 pub handle_accept_channel: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, their_features: crate::lightning::ln::features::InitFeatures, msg: &crate::lightning::ln::msgs::AcceptChannel),
5654 /// Handle an incoming funding_created message from the given peer.
5655 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),
5656 /// Handle an incoming funding_signed message from the given peer.
5657 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),
5658 /// Handle an incoming channel_ready message from the given peer.
5659 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),
5660 /// Handle an incoming shutdown message from the given peer.
5661 pub handle_shutdown: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, their_features: &crate::lightning::ln::features::InitFeatures, msg: &crate::lightning::ln::msgs::Shutdown),
5662 /// Handle an incoming closing_signed message from the given peer.
5663 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),
5664 /// Handle an incoming update_add_htlc message from the given peer.
5665 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),
5666 /// Handle an incoming update_fulfill_htlc message from the given peer.
5667 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),
5668 /// Handle an incoming update_fail_htlc message from the given peer.
5669 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),
5670 /// Handle an incoming update_fail_malformed_htlc message from the given peer.
5671 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),
5672 /// Handle an incoming commitment_signed message from the given peer.
5673 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),
5674 /// Handle an incoming revoke_and_ack message from the given peer.
5675 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),
5676 /// Handle an incoming update_fee message from the given peer.
5677 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),
5678 /// Handle an incoming announcement_signatures message from the given peer.
5679 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),
5680 /// Indicates a connection to the peer failed/an existing connection was lost. If no connection
5681 /// is believed to be possible in the future (eg they're sending us messages we don't
5682 /// understand or indicate they require unknown feature bits), no_connection_possible is set
5683 /// and any outstanding channels should be failed.
5685 /// Note that in some rare cases this may be called without a corresponding
5686 /// [`Self::peer_connected`].
5687 pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, no_connection_possible: bool),
5688 /// Handle a peer reconnecting, possibly generating channel_reestablish message(s).
5690 /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
5691 /// with us. Implementors should be somewhat conservative about doing so, however, as other
5692 /// message handlers may still wish to communicate with this peer.
5694 pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Init) -> crate::c_types::derived::CResult_NoneNoneZ,
5695 /// Handle an incoming channel_reestablish message from the given peer.
5696 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),
5697 /// Handle an incoming channel update from the given peer.
5698 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),
5699 /// Handle an incoming error message from the given peer.
5700 pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ErrorMessage),
5701 /// Gets the node feature flags which this handler itself supports. All available handlers are
5702 /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
5703 /// which are broadcasted in our [`NodeAnnouncement`] message.
5705 pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
5706 /// Gets the init feature flags which should be sent to the given peer. All available handlers
5707 /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
5708 /// which are sent in our [`Init`] message.
5710 /// Note that this method is called before [`Self::peer_connected`].
5712 pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
5713 /// Implementation of MessageSendEventsProvider for this object.
5714 pub MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider,
5715 /// Frees any resources associated with this object given its this_arg pointer.
5716 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
5717 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
5719 unsafe impl Send for ChannelMessageHandler {}
5720 unsafe impl Sync for ChannelMessageHandler {}
5722 pub(crate) extern "C" fn ChannelMessageHandler_clone_fields(orig: &ChannelMessageHandler) -> ChannelMessageHandler {
5723 ChannelMessageHandler {
5724 this_arg: orig.this_arg,
5725 handle_open_channel: Clone::clone(&orig.handle_open_channel),
5726 handle_accept_channel: Clone::clone(&orig.handle_accept_channel),
5727 handle_funding_created: Clone::clone(&orig.handle_funding_created),
5728 handle_funding_signed: Clone::clone(&orig.handle_funding_signed),
5729 handle_channel_ready: Clone::clone(&orig.handle_channel_ready),
5730 handle_shutdown: Clone::clone(&orig.handle_shutdown),
5731 handle_closing_signed: Clone::clone(&orig.handle_closing_signed),
5732 handle_update_add_htlc: Clone::clone(&orig.handle_update_add_htlc),
5733 handle_update_fulfill_htlc: Clone::clone(&orig.handle_update_fulfill_htlc),
5734 handle_update_fail_htlc: Clone::clone(&orig.handle_update_fail_htlc),
5735 handle_update_fail_malformed_htlc: Clone::clone(&orig.handle_update_fail_malformed_htlc),
5736 handle_commitment_signed: Clone::clone(&orig.handle_commitment_signed),
5737 handle_revoke_and_ack: Clone::clone(&orig.handle_revoke_and_ack),
5738 handle_update_fee: Clone::clone(&orig.handle_update_fee),
5739 handle_announcement_signatures: Clone::clone(&orig.handle_announcement_signatures),
5740 peer_disconnected: Clone::clone(&orig.peer_disconnected),
5741 peer_connected: Clone::clone(&orig.peer_connected),
5742 handle_channel_reestablish: Clone::clone(&orig.handle_channel_reestablish),
5743 handle_channel_update: Clone::clone(&orig.handle_channel_update),
5744 handle_error: Clone::clone(&orig.handle_error),
5745 provided_node_features: Clone::clone(&orig.provided_node_features),
5746 provided_init_features: Clone::clone(&orig.provided_init_features),
5747 MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
5748 free: Clone::clone(&orig.free),
5751 impl lightning::util::events::MessageSendEventsProvider for ChannelMessageHandler {
5752 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
5753 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
5754 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
5759 use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler;
5760 impl rustChannelMessageHandler for ChannelMessageHandler {
5761 fn handle_open_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut their_features: lightning::ln::features::InitFeatures, mut msg: &lightning::ln::msgs::OpenChannel) {
5762 (self.handle_open_channel)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(their_features), is_owned: true }, &crate::lightning::ln::msgs::OpenChannel { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::OpenChannel<>) as *mut _) }, is_owned: false })
5764 fn handle_accept_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut their_features: lightning::ln::features::InitFeatures, mut msg: &lightning::ln::msgs::AcceptChannel) {
5765 (self.handle_accept_channel)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(their_features), is_owned: true }, &crate::lightning::ln::msgs::AcceptChannel { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::AcceptChannel<>) as *mut _) }, is_owned: false })
5767 fn handle_funding_created(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingCreated) {
5768 (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 })
5770 fn handle_funding_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingSigned) {
5771 (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 })
5773 fn handle_channel_ready(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReady) {
5774 (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 })
5776 fn handle_shutdown(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut their_features: &lightning::ln::features::InitFeatures, mut msg: &lightning::ln::msgs::Shutdown) {
5777 (self.handle_shutdown)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::features::InitFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((their_features as *const lightning::ln::features::InitFeatures<>) as *mut _) }, is_owned: false }, &crate::lightning::ln::msgs::Shutdown { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::Shutdown<>) as *mut _) }, is_owned: false })
5779 fn handle_closing_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ClosingSigned) {
5780 (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 })
5782 fn handle_update_add_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateAddHTLC) {
5783 (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 })
5785 fn handle_update_fulfill_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFulfillHTLC) {
5786 (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 })
5788 fn handle_update_fail_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailHTLC) {
5789 (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 })
5791 fn handle_update_fail_malformed_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) {
5792 (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 })
5794 fn handle_commitment_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::CommitmentSigned) {
5795 (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 })
5797 fn handle_revoke_and_ack(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::RevokeAndACK) {
5798 (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 })
5800 fn handle_update_fee(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFee) {
5801 (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 })
5803 fn handle_announcement_signatures(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AnnouncementSignatures) {
5804 (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 })
5806 fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut no_connection_possible: bool) {
5807 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), no_connection_possible)
5809 fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Init) -> Result<(), ()> {
5810 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 });
5811 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)) })*/ })};
5814 fn handle_channel_reestablish(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReestablish) {
5815 (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 })
5817 fn handle_channel_update(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelUpdate) {
5818 (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 })
5820 fn handle_error(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ErrorMessage) {
5821 (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 })
5823 fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
5824 let mut ret = (self.provided_node_features)(self.this_arg);
5825 *unsafe { Box::from_raw(ret.take_inner()) }
5827 fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
5828 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
5829 *unsafe { Box::from_raw(ret.take_inner()) }
5833 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
5834 // directly as a Deref trait in higher-level structs:
5835 impl core::ops::Deref for ChannelMessageHandler {
5837 fn deref(&self) -> &Self {
5841 /// Calls the free function if one is set
5843 pub extern "C" fn ChannelMessageHandler_free(this_ptr: ChannelMessageHandler) { }
5844 impl Drop for ChannelMessageHandler {
5845 fn drop(&mut self) {
5846 if let Some(f) = self.free {
5851 /// A trait to describe an object which can receive routing messages.
5853 /// # Implementor DoS Warnings
5855 /// For `gossip_queries` messages there are potential DoS vectors when handling
5856 /// inbound queries. Implementors using an on-disk network graph should be aware of
5857 /// repeated disk I/O for queries accessing different parts of the network graph.
5859 pub struct RoutingMessageHandler {
5860 /// An opaque pointer which is passed to your function implementations as an argument.
5861 /// This has no meaning in the LDK, and can be NULL or any other value.
5862 pub this_arg: *mut c_void,
5863 /// Handle an incoming node_announcement message, returning true if it should be forwarded on,
5864 /// false or returning an Err otherwise.
5866 pub handle_node_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
5867 /// Handle a channel_announcement message, returning true if it should be forwarded on, false
5868 /// or returning an Err otherwise.
5870 pub handle_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
5871 /// Handle an incoming channel_update message, returning true if it should be forwarded on,
5872 /// false or returning an Err otherwise.
5874 pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ,
5875 /// Gets channel announcements and updates required to dump our routing table to a remote node,
5876 /// starting at the short_channel_id indicated by starting_point and including announcements
5877 /// for a single channel.
5879 pub get_next_channel_announcement: extern "C" fn (this_arg: *const c_void, starting_point: u64) -> crate::c_types::derived::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ,
5880 /// Gets a node announcement required to dump our routing table to a remote node, starting at
5881 /// the node *after* the provided pubkey and including up to one announcement immediately
5882 /// higher (as defined by <PublicKey as Ord>::cmp) than starting_point.
5883 /// If None is provided for starting_point, we start at the first node.
5885 /// Note that starting_point (or a relevant inner pointer) may be NULL or all-0s to represent None
5886 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
5888 pub get_next_node_announcement: extern "C" fn (this_arg: *const c_void, starting_point: crate::c_types::PublicKey) -> crate::lightning::ln::msgs::NodeAnnouncement,
5889 /// Called when a connection is established with a peer. This can be used to
5890 /// perform routing table synchronization using a strategy defined by the
5893 /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
5894 /// with us. Implementors should be somewhat conservative about doing so, however, as other
5895 /// message handlers may still wish to communicate with this peer.
5897 pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, init: &crate::lightning::ln::msgs::Init) -> crate::c_types::derived::CResult_NoneNoneZ,
5898 /// Handles the reply of a query we initiated to learn about channels
5899 /// for a given range of blocks. We can expect to receive one or more
5900 /// replies to a single query.
5902 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,
5903 /// Handles the reply of a query we initiated asking for routing gossip
5904 /// messages for a list of channels. We should receive this message when
5905 /// a node has completed its best effort to send us the pertaining routing
5906 /// gossip messages.
5908 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,
5909 /// Handles when a peer asks us to send a list of short_channel_ids
5910 /// for the requested range of blocks.
5912 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,
5913 /// Handles when a peer asks us to send routing gossip messages for a
5914 /// list of short_channel_ids.
5916 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,
5917 /// Gets the node feature flags which this handler itself supports. All available handlers are
5918 /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
5919 /// which are broadcasted in our [`NodeAnnouncement`] message.
5921 pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
5922 /// Gets the init feature flags which should be sent to the given peer. All available handlers
5923 /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
5924 /// which are sent in our [`Init`] message.
5926 /// Note that this method is called before [`Self::peer_connected`].
5928 pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
5929 /// Implementation of MessageSendEventsProvider for this object.
5930 pub MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider,
5931 /// Frees any resources associated with this object given its this_arg pointer.
5932 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
5933 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
5935 unsafe impl Send for RoutingMessageHandler {}
5936 unsafe impl Sync for RoutingMessageHandler {}
5938 pub(crate) extern "C" fn RoutingMessageHandler_clone_fields(orig: &RoutingMessageHandler) -> RoutingMessageHandler {
5939 RoutingMessageHandler {
5940 this_arg: orig.this_arg,
5941 handle_node_announcement: Clone::clone(&orig.handle_node_announcement),
5942 handle_channel_announcement: Clone::clone(&orig.handle_channel_announcement),
5943 handle_channel_update: Clone::clone(&orig.handle_channel_update),
5944 get_next_channel_announcement: Clone::clone(&orig.get_next_channel_announcement),
5945 get_next_node_announcement: Clone::clone(&orig.get_next_node_announcement),
5946 peer_connected: Clone::clone(&orig.peer_connected),
5947 handle_reply_channel_range: Clone::clone(&orig.handle_reply_channel_range),
5948 handle_reply_short_channel_ids_end: Clone::clone(&orig.handle_reply_short_channel_ids_end),
5949 handle_query_channel_range: Clone::clone(&orig.handle_query_channel_range),
5950 handle_query_short_channel_ids: Clone::clone(&orig.handle_query_short_channel_ids),
5951 provided_node_features: Clone::clone(&orig.provided_node_features),
5952 provided_init_features: Clone::clone(&orig.provided_init_features),
5953 MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
5954 free: Clone::clone(&orig.free),
5957 impl lightning::util::events::MessageSendEventsProvider for RoutingMessageHandler {
5958 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
5959 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
5960 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
5965 use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler;
5966 impl rustRoutingMessageHandler for RoutingMessageHandler {
5967 fn handle_node_announcement(&self, mut msg: &lightning::ln::msgs::NodeAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
5968 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 });
5969 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()) } })};
5972 fn handle_channel_announcement(&self, mut msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
5973 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 });
5974 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()) } })};
5977 fn handle_channel_update(&self, mut msg: &lightning::ln::msgs::ChannelUpdate) -> Result<bool, lightning::ln::msgs::LightningError> {
5978 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 });
5979 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()) } })};
5982 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>)> {
5983 let mut ret = (self.get_next_channel_announcement)(self.this_arg, starting_point);
5984 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 };
5987 fn get_next_node_announcement(&self, mut starting_point: Option<&bitcoin::secp256k1::PublicKey>) -> Option<lightning::ln::msgs::NodeAnnouncement> {
5988 let mut local_starting_point = if starting_point.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(starting_point.unwrap())) } };
5989 let mut ret = (self.get_next_node_announcement)(self.this_arg, local_starting_point);
5990 let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) };
5993 fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init) -> Result<(), ()> {
5994 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 });
5995 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)) })*/ })};
5998 fn handle_reply_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::ReplyChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
5999 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 });
6000 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()) } })};
6003 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> {
6004 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 });
6005 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()) } })};
6008 fn handle_query_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::QueryChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
6009 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 });
6010 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()) } })};
6013 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> {
6014 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 });
6015 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()) } })};
6018 fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
6019 let mut ret = (self.provided_node_features)(self.this_arg);
6020 *unsafe { Box::from_raw(ret.take_inner()) }
6022 fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
6023 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
6024 *unsafe { Box::from_raw(ret.take_inner()) }
6028 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
6029 // directly as a Deref trait in higher-level structs:
6030 impl core::ops::Deref for RoutingMessageHandler {
6032 fn deref(&self) -> &Self {
6036 /// Calls the free function if one is set
6038 pub extern "C" fn RoutingMessageHandler_free(this_ptr: RoutingMessageHandler) { }
6039 impl Drop for RoutingMessageHandler {
6040 fn drop(&mut self) {
6041 if let Some(f) = self.free {
6046 /// A trait to describe an object that can receive onion messages.
6048 pub struct OnionMessageHandler {
6049 /// An opaque pointer which is passed to your function implementations as an argument.
6050 /// This has no meaning in the LDK, and can be NULL or any other value.
6051 pub this_arg: *mut c_void,
6052 /// Handle an incoming onion_message message from the given peer.
6053 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),
6054 /// Called when a connection is established with a peer. Can be used to track which peers
6055 /// advertise onion message support and are online.
6057 /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
6058 /// with us. Implementors should be somewhat conservative about doing so, however, as other
6059 /// message handlers may still wish to communicate with this peer.
6061 pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, init: &crate::lightning::ln::msgs::Init) -> crate::c_types::derived::CResult_NoneNoneZ,
6062 /// Indicates a connection to the peer failed/an existing connection was lost. Allows handlers to
6063 /// drop and refuse to forward onion messages to this peer.
6065 /// Note that in some rare cases this may be called without a corresponding
6066 /// [`Self::peer_connected`].
6067 pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, no_connection_possible: bool),
6068 /// Gets the node feature flags which this handler itself supports. All available handlers are
6069 /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
6070 /// which are broadcasted in our [`NodeAnnouncement`] message.
6072 pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
6073 /// Gets the init feature flags which should be sent to the given peer. All available handlers
6074 /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
6075 /// which are sent in our [`Init`] message.
6077 /// Note that this method is called before [`Self::peer_connected`].
6079 pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
6080 /// Implementation of OnionMessageProvider for this object.
6081 pub OnionMessageProvider: crate::lightning::util::events::OnionMessageProvider,
6082 /// Frees any resources associated with this object given its this_arg pointer.
6083 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
6084 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
6086 unsafe impl Send for OnionMessageHandler {}
6087 unsafe impl Sync for OnionMessageHandler {}
6089 pub(crate) extern "C" fn OnionMessageHandler_clone_fields(orig: &OnionMessageHandler) -> OnionMessageHandler {
6090 OnionMessageHandler {
6091 this_arg: orig.this_arg,
6092 handle_onion_message: Clone::clone(&orig.handle_onion_message),
6093 peer_connected: Clone::clone(&orig.peer_connected),
6094 peer_disconnected: Clone::clone(&orig.peer_disconnected),
6095 provided_node_features: Clone::clone(&orig.provided_node_features),
6096 provided_init_features: Clone::clone(&orig.provided_init_features),
6097 OnionMessageProvider: crate::lightning::util::events::OnionMessageProvider_clone_fields(&orig.OnionMessageProvider),
6098 free: Clone::clone(&orig.free),
6101 impl lightning::util::events::OnionMessageProvider for OnionMessageHandler {
6102 fn next_onion_message_for_peer(&self, mut peer_node_id: bitcoin::secp256k1::PublicKey) -> Option<lightning::ln::msgs::OnionMessage> {
6103 let mut ret = (self.OnionMessageProvider.next_onion_message_for_peer)(self.OnionMessageProvider.this_arg, crate::c_types::PublicKey::from_rust(&peer_node_id));
6104 let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) };
6109 use lightning::ln::msgs::OnionMessageHandler as rustOnionMessageHandler;
6110 impl rustOnionMessageHandler for OnionMessageHandler {
6111 fn handle_onion_message(&self, mut peer_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OnionMessage) {
6112 (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 })
6114 fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init) -> Result<(), ()> {
6115 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 });
6116 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)) })*/ })};
6119 fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut no_connection_possible: bool) {
6120 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), no_connection_possible)
6122 fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
6123 let mut ret = (self.provided_node_features)(self.this_arg);
6124 *unsafe { Box::from_raw(ret.take_inner()) }
6126 fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
6127 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
6128 *unsafe { Box::from_raw(ret.take_inner()) }
6132 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
6133 // directly as a Deref trait in higher-level structs:
6134 impl core::ops::Deref for OnionMessageHandler {
6136 fn deref(&self) -> &Self {
6140 /// Calls the free function if one is set
6142 pub extern "C" fn OnionMessageHandler_free(this_ptr: OnionMessageHandler) { }
6143 impl Drop for OnionMessageHandler {
6144 fn drop(&mut self) {
6145 if let Some(f) = self.free {
6150 mod fuzzy_internal_msgs {
6152 use alloc::str::FromStr;
6153 use core::ffi::c_void;
6154 use core::convert::Infallible;
6155 use bitcoin::hashes::Hash;
6156 use crate::c_types::*;
6157 #[cfg(feature="no-std")]
6158 use alloc::{vec::Vec, boxed::Box};
6162 /// Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read
6163 pub extern "C" fn AcceptChannel_write(obj: &crate::lightning::ln::msgs::AcceptChannel) -> crate::c_types::derived::CVec_u8Z {
6164 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6167 pub(crate) extern "C" fn AcceptChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6168 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannel) })
6171 /// Read a AcceptChannel from a byte array, created by AcceptChannel_write
6172 pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelDecodeErrorZ {
6173 let res: Result<lightning::ln::msgs::AcceptChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6174 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() };
6178 /// Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read
6179 pub extern "C" fn AnnouncementSignatures_write(obj: &crate::lightning::ln::msgs::AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z {
6180 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6183 pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6184 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAnnouncementSignatures) })
6187 /// Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write
6188 pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AnnouncementSignaturesDecodeErrorZ {
6189 let res: Result<lightning::ln::msgs::AnnouncementSignatures, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6190 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() };
6194 /// Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read
6195 pub extern "C" fn ChannelReestablish_write(obj: &crate::lightning::ln::msgs::ChannelReestablish) -> crate::c_types::derived::CVec_u8Z {
6196 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6199 pub(crate) extern "C" fn ChannelReestablish_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6200 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReestablish) })
6203 /// Read a ChannelReestablish from a byte array, created by ChannelReestablish_write
6204 pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReestablishDecodeErrorZ {
6205 let res: Result<lightning::ln::msgs::ChannelReestablish, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6206 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() };
6210 /// Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read
6211 pub extern "C" fn ClosingSigned_write(obj: &crate::lightning::ln::msgs::ClosingSigned) -> crate::c_types::derived::CVec_u8Z {
6212 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6215 pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6216 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSigned) })
6219 /// Read a ClosingSigned from a byte array, created by ClosingSigned_write
6220 pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedDecodeErrorZ {
6221 let res: Result<lightning::ln::msgs::ClosingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6222 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() };
6226 /// Serialize the ClosingSignedFeeRange object into a byte array which can be read by ClosingSignedFeeRange_read
6227 pub extern "C" fn ClosingSignedFeeRange_write(obj: &crate::lightning::ln::msgs::ClosingSignedFeeRange) -> crate::c_types::derived::CVec_u8Z {
6228 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6231 pub(crate) extern "C" fn ClosingSignedFeeRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6232 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSignedFeeRange) })
6235 /// Read a ClosingSignedFeeRange from a byte array, created by ClosingSignedFeeRange_write
6236 pub extern "C" fn ClosingSignedFeeRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedFeeRangeDecodeErrorZ {
6237 let res: Result<lightning::ln::msgs::ClosingSignedFeeRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6238 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() };
6242 /// Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read
6243 pub extern "C" fn CommitmentSigned_write(obj: &crate::lightning::ln::msgs::CommitmentSigned) -> crate::c_types::derived::CVec_u8Z {
6244 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6247 pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6248 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentSigned) })
6251 /// Read a CommitmentSigned from a byte array, created by CommitmentSigned_write
6252 pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CommitmentSignedDecodeErrorZ {
6253 let res: Result<lightning::ln::msgs::CommitmentSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6254 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() };
6258 /// Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read
6259 pub extern "C" fn FundingCreated_write(obj: &crate::lightning::ln::msgs::FundingCreated) -> crate::c_types::derived::CVec_u8Z {
6260 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6263 pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6264 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingCreated) })
6267 /// Read a FundingCreated from a byte array, created by FundingCreated_write
6268 pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingCreatedDecodeErrorZ {
6269 let res: Result<lightning::ln::msgs::FundingCreated, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6270 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() };
6274 /// Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read
6275 pub extern "C" fn FundingSigned_write(obj: &crate::lightning::ln::msgs::FundingSigned) -> crate::c_types::derived::CVec_u8Z {
6276 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6279 pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6280 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingSigned) })
6283 /// Read a FundingSigned from a byte array, created by FundingSigned_write
6284 pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingSignedDecodeErrorZ {
6285 let res: Result<lightning::ln::msgs::FundingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6286 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() };
6290 /// Serialize the ChannelReady object into a byte array which can be read by ChannelReady_read
6291 pub extern "C" fn ChannelReady_write(obj: &crate::lightning::ln::msgs::ChannelReady) -> crate::c_types::derived::CVec_u8Z {
6292 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6295 pub(crate) extern "C" fn ChannelReady_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6296 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReady) })
6299 /// Read a ChannelReady from a byte array, created by ChannelReady_write
6300 pub extern "C" fn ChannelReady_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReadyDecodeErrorZ {
6301 let res: Result<lightning::ln::msgs::ChannelReady, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6302 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() };
6306 /// Serialize the Init object into a byte array which can be read by Init_read
6307 pub extern "C" fn Init_write(obj: &crate::lightning::ln::msgs::Init) -> crate::c_types::derived::CVec_u8Z {
6308 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6311 pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6312 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInit) })
6315 /// Read a Init from a byte array, created by Init_write
6316 pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitDecodeErrorZ {
6317 let res: Result<lightning::ln::msgs::Init, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6318 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() };
6322 /// Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read
6323 pub extern "C" fn OpenChannel_write(obj: &crate::lightning::ln::msgs::OpenChannel) -> crate::c_types::derived::CVec_u8Z {
6324 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6327 pub(crate) extern "C" fn OpenChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6328 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannel) })
6331 /// Read a OpenChannel from a byte array, created by OpenChannel_write
6332 pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelDecodeErrorZ {
6333 let res: Result<lightning::ln::msgs::OpenChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6334 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() };
6338 /// Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read
6339 pub extern "C" fn RevokeAndACK_write(obj: &crate::lightning::ln::msgs::RevokeAndACK) -> crate::c_types::derived::CVec_u8Z {
6340 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6343 pub(crate) extern "C" fn RevokeAndACK_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6344 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevokeAndACK) })
6347 /// Read a RevokeAndACK from a byte array, created by RevokeAndACK_write
6348 pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RevokeAndACKDecodeErrorZ {
6349 let res: Result<lightning::ln::msgs::RevokeAndACK, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6350 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() };
6354 /// Serialize the Shutdown object into a byte array which can be read by Shutdown_read
6355 pub extern "C" fn Shutdown_write(obj: &crate::lightning::ln::msgs::Shutdown) -> crate::c_types::derived::CVec_u8Z {
6356 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6359 pub(crate) extern "C" fn Shutdown_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6360 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeShutdown) })
6363 /// Read a Shutdown from a byte array, created by Shutdown_write
6364 pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ShutdownDecodeErrorZ {
6365 let res: Result<lightning::ln::msgs::Shutdown, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6366 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() };
6370 /// Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read
6371 pub extern "C" fn UpdateFailHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFailHTLC) -> crate::c_types::derived::CVec_u8Z {
6372 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6375 pub(crate) extern "C" fn UpdateFailHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6376 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailHTLC) })
6379 /// Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write
6380 pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailHTLCDecodeErrorZ {
6381 let res: Result<lightning::ln::msgs::UpdateFailHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6382 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() };
6386 /// Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read
6387 pub extern "C" fn UpdateFailMalformedHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFailMalformedHTLC) -> crate::c_types::derived::CVec_u8Z {
6388 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6391 pub(crate) extern "C" fn UpdateFailMalformedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6392 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailMalformedHTLC) })
6395 /// Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write
6396 pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailMalformedHTLCDecodeErrorZ {
6397 let res: Result<lightning::ln::msgs::UpdateFailMalformedHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6398 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() };
6402 /// Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read
6403 pub extern "C" fn UpdateFee_write(obj: &crate::lightning::ln::msgs::UpdateFee) -> crate::c_types::derived::CVec_u8Z {
6404 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6407 pub(crate) extern "C" fn UpdateFee_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6408 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFee) })
6411 /// Read a UpdateFee from a byte array, created by UpdateFee_write
6412 pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFeeDecodeErrorZ {
6413 let res: Result<lightning::ln::msgs::UpdateFee, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6414 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() };
6418 /// Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read
6419 pub extern "C" fn UpdateFulfillHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFulfillHTLC) -> crate::c_types::derived::CVec_u8Z {
6420 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6423 pub(crate) extern "C" fn UpdateFulfillHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6424 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFulfillHTLC) })
6427 /// Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write
6428 pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFulfillHTLCDecodeErrorZ {
6429 let res: Result<lightning::ln::msgs::UpdateFulfillHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6430 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() };
6434 /// Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read
6435 pub extern "C" fn UpdateAddHTLC_write(obj: &crate::lightning::ln::msgs::UpdateAddHTLC) -> crate::c_types::derived::CVec_u8Z {
6436 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6439 pub(crate) extern "C" fn UpdateAddHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6440 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateAddHTLC) })
6443 /// Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write
6444 pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateAddHTLCDecodeErrorZ {
6445 let res: Result<lightning::ln::msgs::UpdateAddHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6446 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() };
6450 /// Read a OnionMessage from a byte array, created by OnionMessage_write
6451 pub extern "C" fn OnionMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OnionMessageDecodeErrorZ {
6452 let res: Result<lightning::ln::msgs::OnionMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6453 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() };
6457 /// Serialize the OnionMessage object into a byte array which can be read by OnionMessage_read
6458 pub extern "C" fn OnionMessage_write(obj: &crate::lightning::ln::msgs::OnionMessage) -> crate::c_types::derived::CVec_u8Z {
6459 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6462 pub(crate) extern "C" fn OnionMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6463 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOnionMessage) })
6466 /// Serialize the Ping object into a byte array which can be read by Ping_read
6467 pub extern "C" fn Ping_write(obj: &crate::lightning::ln::msgs::Ping) -> crate::c_types::derived::CVec_u8Z {
6468 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6471 pub(crate) extern "C" fn Ping_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6472 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePing) })
6475 /// Read a Ping from a byte array, created by Ping_write
6476 pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PingDecodeErrorZ {
6477 let res: Result<lightning::ln::msgs::Ping, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6478 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() };
6482 /// Serialize the Pong object into a byte array which can be read by Pong_read
6483 pub extern "C" fn Pong_write(obj: &crate::lightning::ln::msgs::Pong) -> crate::c_types::derived::CVec_u8Z {
6484 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6487 pub(crate) extern "C" fn Pong_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6488 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePong) })
6491 /// Read a Pong from a byte array, created by Pong_write
6492 pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PongDecodeErrorZ {
6493 let res: Result<lightning::ln::msgs::Pong, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6494 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() };
6498 /// Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read
6499 pub extern "C" fn UnsignedChannelAnnouncement_write(obj: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
6500 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6503 pub(crate) extern "C" fn UnsignedChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6504 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelAnnouncement) })
6507 /// Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write
6508 pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelAnnouncementDecodeErrorZ {
6509 let res: Result<lightning::ln::msgs::UnsignedChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6510 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() };
6514 /// Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read
6515 pub extern "C" fn ChannelAnnouncement_write(obj: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
6516 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6519 pub(crate) extern "C" fn ChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6520 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelAnnouncement) })
6523 /// Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write
6524 pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelAnnouncementDecodeErrorZ {
6525 let res: Result<lightning::ln::msgs::ChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6526 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() };
6530 /// Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read
6531 pub extern "C" fn UnsignedChannelUpdate_write(obj: &crate::lightning::ln::msgs::UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
6532 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6535 pub(crate) extern "C" fn UnsignedChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6536 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelUpdate) })
6539 /// Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write
6540 pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelUpdateDecodeErrorZ {
6541 let res: Result<lightning::ln::msgs::UnsignedChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6542 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() };
6546 /// Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read
6547 pub extern "C" fn ChannelUpdate_write(obj: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
6548 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6551 pub(crate) extern "C" fn ChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6552 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdate) })
6555 /// Read a ChannelUpdate from a byte array, created by ChannelUpdate_write
6556 pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelUpdateDecodeErrorZ {
6557 let res: Result<lightning::ln::msgs::ChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6558 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() };
6562 /// Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read
6563 pub extern "C" fn ErrorMessage_write(obj: &crate::lightning::ln::msgs::ErrorMessage) -> crate::c_types::derived::CVec_u8Z {
6564 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6567 pub(crate) extern "C" fn ErrorMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6568 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeErrorMessage) })
6571 /// Read a ErrorMessage from a byte array, created by ErrorMessage_write
6572 pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ErrorMessageDecodeErrorZ {
6573 let res: Result<lightning::ln::msgs::ErrorMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6574 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() };
6578 /// Serialize the WarningMessage object into a byte array which can be read by WarningMessage_read
6579 pub extern "C" fn WarningMessage_write(obj: &crate::lightning::ln::msgs::WarningMessage) -> crate::c_types::derived::CVec_u8Z {
6580 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6583 pub(crate) extern "C" fn WarningMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6584 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeWarningMessage) })
6587 /// Read a WarningMessage from a byte array, created by WarningMessage_write
6588 pub extern "C" fn WarningMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_WarningMessageDecodeErrorZ {
6589 let res: Result<lightning::ln::msgs::WarningMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6590 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() };
6594 /// Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read
6595 pub extern "C" fn UnsignedNodeAnnouncement_write(obj: &crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
6596 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6599 pub(crate) extern "C" fn UnsignedNodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6600 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedNodeAnnouncement) })
6603 /// Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write
6604 pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedNodeAnnouncementDecodeErrorZ {
6605 let res: Result<lightning::ln::msgs::UnsignedNodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6606 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() };
6610 /// Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read
6611 pub extern "C" fn NodeAnnouncement_write(obj: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
6612 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6615 pub(crate) extern "C" fn NodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6616 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncement) })
6619 /// Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write
6620 pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementDecodeErrorZ {
6621 let res: Result<lightning::ln::msgs::NodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6622 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() };
6626 /// Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write
6627 pub extern "C" fn QueryShortChannelIds_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryShortChannelIdsDecodeErrorZ {
6628 let res: Result<lightning::ln::msgs::QueryShortChannelIds, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6629 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() };
6633 /// Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read
6634 pub extern "C" fn QueryShortChannelIds_write(obj: &crate::lightning::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CVec_u8Z {
6635 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6638 pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6639 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) })
6642 /// Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read
6643 pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z {
6644 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6647 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6648 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) })
6651 /// Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write
6652 pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyShortChannelIdsEndDecodeErrorZ {
6653 let res: Result<lightning::ln::msgs::ReplyShortChannelIdsEnd, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6654 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() };
6657 ///\n\t * Calculates the overflow safe ending block height for the query.\n\t * Overflow returns `0xffffffff`, otherwise returns `first_blocknum + number_of_blocks`\n\t
6660 pub extern "C" fn QueryChannelRange_end_blocknum(this_arg: &crate::lightning::ln::msgs::QueryChannelRange) -> u32 {
6661 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.end_blocknum();
6666 /// Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read
6667 pub extern "C" fn QueryChannelRange_write(obj: &crate::lightning::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CVec_u8Z {
6668 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6671 pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6672 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) })
6675 /// Read a QueryChannelRange from a byte array, created by QueryChannelRange_write
6676 pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ {
6677 let res: Result<lightning::ln::msgs::QueryChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6678 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() };
6682 /// Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write
6683 pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyChannelRangeDecodeErrorZ {
6684 let res: Result<lightning::ln::msgs::ReplyChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6685 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() };
6689 /// Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read
6690 pub extern "C" fn ReplyChannelRange_write(obj: &crate::lightning::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CVec_u8Z {
6691 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6694 pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6695 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) })
6698 /// Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read
6699 pub extern "C" fn GossipTimestampFilter_write(obj: &crate::lightning::ln::msgs::GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z {
6700 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6703 pub(crate) extern "C" fn GossipTimestampFilter_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6704 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeGossipTimestampFilter) })
6707 /// Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write
6708 pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_GossipTimestampFilterDecodeErrorZ {
6709 let res: Result<lightning::ln::msgs::GossipTimestampFilter, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6710 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() };