1 // This file is Copyright its original authors, visible in version control
2 // history and in the source files from which this was generated.
4 // This file is licensed under the license available in the LICENSE or LICENSE.md
5 // file in the root of this repository or, if no such file exists, the same
6 // license as that which applies to the original source files from which this
7 // source was automatically generated.
9 //! Wire messages, traits representing wire message handlers, and a few error types live here.
11 //! For a normal node you probably don't need to use anything here, however, if you wish to split a
12 //! node into an internet-facing route/message socket handling daemon and a separate daemon (or
13 //! server entirely) which handles only channel-related messages you may wish to implement
14 //! [`ChannelMessageHandler`] yourself and use it to re-serialize messages and pass them across
17 //! Note that if you go with such an architecture (instead of passing raw socket events to a
18 //! non-internet-facing system) you trust the frontend internet-facing system to not lie about the
19 //! source `node_id` of the message, however this does allow you to significantly reduce bandwidth
20 //! between the systems as routing messages can represent a significant chunk of bandwidth usage
21 //! (especially for non-channel-publicly-announcing nodes). As an alternate design which avoids
22 //! this issue, if you have sufficient bidirectional bandwidth between your systems, you may send
23 //! raw socket events into your non-internet-facing system and then send routing events back to
24 //! track the network on the less-secure system.
26 use alloc::str::FromStr;
27 use alloc::string::String;
28 use core::ffi::c_void;
29 use core::convert::Infallible;
30 use bitcoin::hashes::Hash;
31 use crate::c_types::*;
32 #[cfg(feature="no-std")]
33 use alloc::{vec::Vec, boxed::Box};
35 /// An error in decoding a message or struct.
39 pub enum DecodeError {
40 /// A version byte specified something we don't know how to handle.
42 /// Includes unknown realm byte in an onion hop data packet.
44 /// Unknown feature mandating we fail to parse message (e.g., TLV with an even, unknown type)
45 UnknownRequiredFeature,
46 /// Value was invalid.
48 /// For example, a byte which was supposed to be a bool was something other than a 0
49 /// or 1, a public key/private key/signature was invalid, text wasn't UTF-8, TLV was
50 /// syntactically incorrect, etc.
52 /// The buffer to be read was too short.
54 /// A length descriptor in the packet didn't describe the later data correctly.
56 /// Error from [`std::io`].
58 crate::c_types::IOError),
59 /// The message included zlib-compressed values, which we don't support.
60 UnsupportedCompression,
62 use lightning::ln::msgs::DecodeError as DecodeErrorImport;
63 pub(crate) type nativeDecodeError = DecodeErrorImport;
67 pub(crate) fn to_native(&self) -> nativeDecodeError {
69 DecodeError::UnknownVersion => nativeDecodeError::UnknownVersion,
70 DecodeError::UnknownRequiredFeature => nativeDecodeError::UnknownRequiredFeature,
71 DecodeError::InvalidValue => nativeDecodeError::InvalidValue,
72 DecodeError::ShortRead => nativeDecodeError::ShortRead,
73 DecodeError::BadLengthDescriptor => nativeDecodeError::BadLengthDescriptor,
74 DecodeError::Io (ref a, ) => {
75 let mut a_nonref = Clone::clone(a);
76 nativeDecodeError::Io (
77 a_nonref.to_rust_kind(),
80 DecodeError::UnsupportedCompression => nativeDecodeError::UnsupportedCompression,
84 pub(crate) fn into_native(self) -> nativeDecodeError {
86 DecodeError::UnknownVersion => nativeDecodeError::UnknownVersion,
87 DecodeError::UnknownRequiredFeature => nativeDecodeError::UnknownRequiredFeature,
88 DecodeError::InvalidValue => nativeDecodeError::InvalidValue,
89 DecodeError::ShortRead => nativeDecodeError::ShortRead,
90 DecodeError::BadLengthDescriptor => nativeDecodeError::BadLengthDescriptor,
91 DecodeError::Io (mut a, ) => {
92 nativeDecodeError::Io (
96 DecodeError::UnsupportedCompression => nativeDecodeError::UnsupportedCompression,
100 pub(crate) fn from_native(native: &nativeDecodeError) -> Self {
102 nativeDecodeError::UnknownVersion => DecodeError::UnknownVersion,
103 nativeDecodeError::UnknownRequiredFeature => DecodeError::UnknownRequiredFeature,
104 nativeDecodeError::InvalidValue => DecodeError::InvalidValue,
105 nativeDecodeError::ShortRead => DecodeError::ShortRead,
106 nativeDecodeError::BadLengthDescriptor => DecodeError::BadLengthDescriptor,
107 nativeDecodeError::Io (ref a, ) => {
108 let mut a_nonref = Clone::clone(a);
110 crate::c_types::IOError::from_rust_kind(a_nonref),
113 nativeDecodeError::UnsupportedCompression => DecodeError::UnsupportedCompression,
117 pub(crate) fn native_into(native: nativeDecodeError) -> Self {
119 nativeDecodeError::UnknownVersion => DecodeError::UnknownVersion,
120 nativeDecodeError::UnknownRequiredFeature => DecodeError::UnknownRequiredFeature,
121 nativeDecodeError::InvalidValue => DecodeError::InvalidValue,
122 nativeDecodeError::ShortRead => DecodeError::ShortRead,
123 nativeDecodeError::BadLengthDescriptor => DecodeError::BadLengthDescriptor,
124 nativeDecodeError::Io (mut a, ) => {
126 crate::c_types::IOError::from_rust_kind(a),
129 nativeDecodeError::UnsupportedCompression => DecodeError::UnsupportedCompression,
133 /// Frees any resources used by the DecodeError
135 pub extern "C" fn DecodeError_free(this_ptr: DecodeError) { }
136 /// Creates a copy of the DecodeError
138 pub extern "C" fn DecodeError_clone(orig: &DecodeError) -> DecodeError {
142 /// Utility method to constructs a new UnknownVersion-variant DecodeError
143 pub extern "C" fn DecodeError_unknown_version() -> DecodeError {
144 DecodeError::UnknownVersion}
146 /// Utility method to constructs a new UnknownRequiredFeature-variant DecodeError
147 pub extern "C" fn DecodeError_unknown_required_feature() -> DecodeError {
148 DecodeError::UnknownRequiredFeature}
150 /// Utility method to constructs a new InvalidValue-variant DecodeError
151 pub extern "C" fn DecodeError_invalid_value() -> DecodeError {
152 DecodeError::InvalidValue}
154 /// Utility method to constructs a new ShortRead-variant DecodeError
155 pub extern "C" fn DecodeError_short_read() -> DecodeError {
156 DecodeError::ShortRead}
158 /// Utility method to constructs a new BadLengthDescriptor-variant DecodeError
159 pub extern "C" fn DecodeError_bad_length_descriptor() -> DecodeError {
160 DecodeError::BadLengthDescriptor}
162 /// Utility method to constructs a new Io-variant DecodeError
163 pub extern "C" fn DecodeError_io(a: crate::c_types::IOError) -> DecodeError {
167 /// Utility method to constructs a new UnsupportedCompression-variant DecodeError
168 pub extern "C" fn DecodeError_unsupported_compression() -> DecodeError {
169 DecodeError::UnsupportedCompression}
170 /// Checks if two DecodeErrors contain equal inner contents.
171 /// This ignores pointers and is_owned flags and looks at the values in fields.
173 pub extern "C" fn DecodeError_eq(a: &DecodeError, b: &DecodeError) -> bool {
174 if &a.to_native() == &b.to_native() { true } else { false }
177 use lightning::ln::msgs::Init as nativeInitImport;
178 pub(crate) type nativeInit = nativeInitImport;
180 /// An [`init`] message to be sent to or received from a peer.
182 /// [`init`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-init-message
186 /// A pointer to the opaque Rust object.
188 /// Nearly everywhere, inner must be non-null, however in places where
189 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
190 pub inner: *mut nativeInit,
191 /// Indicates that this is the only struct which contains the same pointer.
193 /// Rust functions which take ownership of an object provided via an argument require
194 /// this to be true and invalidate the object pointed to by inner.
200 if self.is_owned && !<*mut nativeInit>::is_null(self.inner) {
201 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
205 /// Frees any resources used by the Init, if is_owned is set and inner is non-NULL.
207 pub extern "C" fn Init_free(this_obj: Init) { }
209 /// Used only if an object of this type is returned as a trait impl by a method
210 pub(crate) extern "C" fn Init_free_void(this_ptr: *mut c_void) {
211 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInit) };
215 pub(crate) fn get_native_ref(&self) -> &'static nativeInit {
216 unsafe { &*ObjOps::untweak_ptr(self.inner) }
218 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInit {
219 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
221 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
222 pub(crate) fn take_inner(mut self) -> *mut nativeInit {
223 assert!(self.is_owned);
224 let ret = ObjOps::untweak_ptr(self.inner);
225 self.inner = core::ptr::null_mut();
229 /// The relevant features which the sender supports.
231 pub extern "C" fn Init_get_features(this_ptr: &Init) -> crate::lightning::ln::features::InitFeatures {
232 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
233 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 }
235 /// The relevant features which the sender supports.
237 pub extern "C" fn Init_set_features(this_ptr: &mut Init, mut val: crate::lightning::ln::features::InitFeatures) {
238 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
240 /// Indicates chains the sender is interested in.
242 /// If there are no common chains, the connection will be closed.
244 /// Returns a copy of the field.
246 pub extern "C" fn Init_get_networks(this_ptr: &Init) -> crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ {
247 let mut inner_val = this_ptr.get_native_mut_ref().networks.clone();
248 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ::None } else { crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ::Some( { let mut local_inner_val_0 = Vec::new(); for mut item in inner_val.unwrap().drain(..) { local_inner_val_0.push( { crate::c_types::ThirtyTwoBytes { data: item.to_bytes() } }); }; local_inner_val_0.into() }) };
251 /// Indicates chains the sender is interested in.
253 /// If there are no common chains, the connection will be closed.
255 pub extern "C" fn Init_set_networks(this_ptr: &mut Init, mut val: crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ) {
256 let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { let mut local_val_0 = Vec::new(); for mut item in { val_opt.take() }.into_rust().drain(..) { local_val_0.push( { ::bitcoin::blockdata::constants::ChainHash::from(&item.data[..]) }); }; local_val_0 }})} };
257 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.networks = local_val;
259 /// The receipient's network address.
261 /// This adds the option to report a remote IP address back to a connecting peer using the init
262 /// message. A node can decide to use that information to discover a potential update to its
263 /// public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing
266 pub extern "C" fn Init_get_remote_network_address(this_ptr: &Init) -> crate::c_types::derived::COption_SocketAddressZ {
267 let mut inner_val = &mut this_ptr.get_native_mut_ref().remote_network_address;
268 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_SocketAddressZ::None } else { crate::c_types::derived::COption_SocketAddressZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { crate::lightning::ln::msgs::SocketAddress::native_into((*inner_val.as_ref().unwrap()).clone()) }) };
271 /// The receipient's network address.
273 /// This adds the option to report a remote IP address back to a connecting peer using the init
274 /// message. A node can decide to use that information to discover a potential update to its
275 /// public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing
278 pub extern "C" fn Init_set_remote_network_address(this_ptr: &mut Init, mut val: crate::c_types::derived::COption_SocketAddressZ) {
279 let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_native() }})} };
280 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.remote_network_address = local_val;
282 /// Constructs a new Init given each field
285 pub extern "C" fn Init_new(mut features_arg: crate::lightning::ln::features::InitFeatures, mut networks_arg: crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ, mut remote_network_address_arg: crate::c_types::derived::COption_SocketAddressZ) -> Init {
286 let mut local_networks_arg = { /*networks_arg*/ let networks_arg_opt = networks_arg; if networks_arg_opt.is_none() { None } else { Some({ { let mut local_networks_arg_0 = Vec::new(); for mut item in { networks_arg_opt.take() }.into_rust().drain(..) { local_networks_arg_0.push( { ::bitcoin::blockdata::constants::ChainHash::from(&item.data[..]) }); }; local_networks_arg_0 }})} };
287 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() }})} };
288 Init { inner: ObjOps::heap_alloc(nativeInit {
289 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
290 networks: local_networks_arg,
291 remote_network_address: local_remote_network_address_arg,
294 impl Clone for Init {
295 fn clone(&self) -> Self {
297 inner: if <*mut nativeInit>::is_null(self.inner) { core::ptr::null_mut() } else {
298 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
304 /// Used only if an object of this type is returned as a trait impl by a method
305 pub(crate) extern "C" fn Init_clone_void(this_ptr: *const c_void) -> *mut c_void {
306 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInit)).clone() })) as *mut c_void
309 /// Creates a copy of the Init
310 pub extern "C" fn Init_clone(orig: &Init) -> Init {
313 /// Checks if two Inits contain equal inner contents.
314 /// This ignores pointers and is_owned flags and looks at the values in fields.
315 /// Two objects with NULL inner values will be considered "equal" here.
317 pub extern "C" fn Init_eq(a: &Init, b: &Init) -> bool {
318 if a.inner == b.inner { return true; }
319 if a.inner.is_null() || b.inner.is_null() { return false; }
320 if a.get_native_ref() == b.get_native_ref() { true } else { false }
323 use lightning::ln::msgs::ErrorMessage as nativeErrorMessageImport;
324 pub(crate) type nativeErrorMessage = nativeErrorMessageImport;
326 /// An [`error`] message to be sent to or received from a peer.
328 /// [`error`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages
331 pub struct ErrorMessage {
332 /// A pointer to the opaque Rust object.
334 /// Nearly everywhere, inner must be non-null, however in places where
335 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
336 pub inner: *mut nativeErrorMessage,
337 /// Indicates that this is the only struct which contains the same pointer.
339 /// Rust functions which take ownership of an object provided via an argument require
340 /// this to be true and invalidate the object pointed to by inner.
344 impl Drop for ErrorMessage {
346 if self.is_owned && !<*mut nativeErrorMessage>::is_null(self.inner) {
347 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
351 /// Frees any resources used by the ErrorMessage, if is_owned is set and inner is non-NULL.
353 pub extern "C" fn ErrorMessage_free(this_obj: ErrorMessage) { }
355 /// Used only if an object of this type is returned as a trait impl by a method
356 pub(crate) extern "C" fn ErrorMessage_free_void(this_ptr: *mut c_void) {
357 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeErrorMessage) };
361 pub(crate) fn get_native_ref(&self) -> &'static nativeErrorMessage {
362 unsafe { &*ObjOps::untweak_ptr(self.inner) }
364 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeErrorMessage {
365 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
367 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
368 pub(crate) fn take_inner(mut self) -> *mut nativeErrorMessage {
369 assert!(self.is_owned);
370 let ret = ObjOps::untweak_ptr(self.inner);
371 self.inner = core::ptr::null_mut();
375 /// The channel ID involved in the error.
377 /// All-0s indicates a general error unrelated to a specific channel, after which all channels
378 /// with the sending peer should be closed.
380 pub extern "C" fn ErrorMessage_get_channel_id(this_ptr: &ErrorMessage) -> *const [u8; 32] {
381 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
384 /// The channel ID involved in the error.
386 /// All-0s indicates a general error unrelated to a specific channel, after which all channels
387 /// with the sending peer should be closed.
389 pub extern "C" fn ErrorMessage_set_channel_id(this_ptr: &mut ErrorMessage, mut val: crate::c_types::ThirtyTwoBytes) {
390 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
392 /// A possibly human-readable error description.
394 /// The string should be sanitized before it is used (e.g., emitted to logs or printed to
395 /// `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in
396 /// the terminal emulator or the logging subsystem.
398 pub extern "C" fn ErrorMessage_get_data(this_ptr: &ErrorMessage) -> crate::c_types::Str {
399 let mut inner_val = &mut this_ptr.get_native_mut_ref().data;
400 inner_val.as_str().into()
402 /// A possibly human-readable error description.
404 /// The string should be sanitized before it is used (e.g., emitted to logs or printed to
405 /// `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in
406 /// the terminal emulator or the logging subsystem.
408 pub extern "C" fn ErrorMessage_set_data(this_ptr: &mut ErrorMessage, mut val: crate::c_types::Str) {
409 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string();
411 /// Constructs a new ErrorMessage given each field
414 pub extern "C" fn ErrorMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::Str) -> ErrorMessage {
415 ErrorMessage { inner: ObjOps::heap_alloc(nativeErrorMessage {
416 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
417 data: data_arg.into_string(),
420 impl Clone for ErrorMessage {
421 fn clone(&self) -> Self {
423 inner: if <*mut nativeErrorMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
424 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
430 /// Used only if an object of this type is returned as a trait impl by a method
431 pub(crate) extern "C" fn ErrorMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
432 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeErrorMessage)).clone() })) as *mut c_void
435 /// Creates a copy of the ErrorMessage
436 pub extern "C" fn ErrorMessage_clone(orig: &ErrorMessage) -> ErrorMessage {
439 /// Checks if two ErrorMessages contain equal inner contents.
440 /// This ignores pointers and is_owned flags and looks at the values in fields.
441 /// Two objects with NULL inner values will be considered "equal" here.
443 pub extern "C" fn ErrorMessage_eq(a: &ErrorMessage, b: &ErrorMessage) -> bool {
444 if a.inner == b.inner { return true; }
445 if a.inner.is_null() || b.inner.is_null() { return false; }
446 if a.get_native_ref() == b.get_native_ref() { true } else { false }
449 use lightning::ln::msgs::WarningMessage as nativeWarningMessageImport;
450 pub(crate) type nativeWarningMessage = nativeWarningMessageImport;
452 /// A [`warning`] message to be sent to or received from a peer.
454 /// [`warning`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages
457 pub struct WarningMessage {
458 /// A pointer to the opaque Rust object.
460 /// Nearly everywhere, inner must be non-null, however in places where
461 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
462 pub inner: *mut nativeWarningMessage,
463 /// Indicates that this is the only struct which contains the same pointer.
465 /// Rust functions which take ownership of an object provided via an argument require
466 /// this to be true and invalidate the object pointed to by inner.
470 impl Drop for WarningMessage {
472 if self.is_owned && !<*mut nativeWarningMessage>::is_null(self.inner) {
473 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
477 /// Frees any resources used by the WarningMessage, if is_owned is set and inner is non-NULL.
479 pub extern "C" fn WarningMessage_free(this_obj: WarningMessage) { }
481 /// Used only if an object of this type is returned as a trait impl by a method
482 pub(crate) extern "C" fn WarningMessage_free_void(this_ptr: *mut c_void) {
483 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeWarningMessage) };
486 impl WarningMessage {
487 pub(crate) fn get_native_ref(&self) -> &'static nativeWarningMessage {
488 unsafe { &*ObjOps::untweak_ptr(self.inner) }
490 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeWarningMessage {
491 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
493 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
494 pub(crate) fn take_inner(mut self) -> *mut nativeWarningMessage {
495 assert!(self.is_owned);
496 let ret = ObjOps::untweak_ptr(self.inner);
497 self.inner = core::ptr::null_mut();
501 /// The channel ID involved in the warning.
503 /// All-0s indicates a warning unrelated to a specific channel.
505 pub extern "C" fn WarningMessage_get_channel_id(this_ptr: &WarningMessage) -> *const [u8; 32] {
506 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
509 /// The channel ID involved in the warning.
511 /// All-0s indicates a warning unrelated to a specific channel.
513 pub extern "C" fn WarningMessage_set_channel_id(this_ptr: &mut WarningMessage, mut val: crate::c_types::ThirtyTwoBytes) {
514 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
516 /// A possibly human-readable warning description.
518 /// The string should be sanitized before it is used (e.g. emitted to logs or printed to
519 /// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
520 /// the terminal emulator or the logging subsystem.
522 pub extern "C" fn WarningMessage_get_data(this_ptr: &WarningMessage) -> crate::c_types::Str {
523 let mut inner_val = &mut this_ptr.get_native_mut_ref().data;
524 inner_val.as_str().into()
526 /// A possibly human-readable warning description.
528 /// The string should be sanitized before it is used (e.g. emitted to logs or printed to
529 /// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
530 /// the terminal emulator or the logging subsystem.
532 pub extern "C" fn WarningMessage_set_data(this_ptr: &mut WarningMessage, mut val: crate::c_types::Str) {
533 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string();
535 /// Constructs a new WarningMessage given each field
538 pub extern "C" fn WarningMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::Str) -> WarningMessage {
539 WarningMessage { inner: ObjOps::heap_alloc(nativeWarningMessage {
540 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
541 data: data_arg.into_string(),
544 impl Clone for WarningMessage {
545 fn clone(&self) -> Self {
547 inner: if <*mut nativeWarningMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
548 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
554 /// Used only if an object of this type is returned as a trait impl by a method
555 pub(crate) extern "C" fn WarningMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
556 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeWarningMessage)).clone() })) as *mut c_void
559 /// Creates a copy of the WarningMessage
560 pub extern "C" fn WarningMessage_clone(orig: &WarningMessage) -> WarningMessage {
563 /// Checks if two WarningMessages contain equal inner contents.
564 /// This ignores pointers and is_owned flags and looks at the values in fields.
565 /// Two objects with NULL inner values will be considered "equal" here.
567 pub extern "C" fn WarningMessage_eq(a: &WarningMessage, b: &WarningMessage) -> bool {
568 if a.inner == b.inner { return true; }
569 if a.inner.is_null() || b.inner.is_null() { return false; }
570 if a.get_native_ref() == b.get_native_ref() { true } else { false }
573 use lightning::ln::msgs::Ping as nativePingImport;
574 pub(crate) type nativePing = nativePingImport;
576 /// A [`ping`] message to be sent to or received from a peer.
578 /// [`ping`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-ping-and-pong-messages
582 /// A pointer to the opaque Rust object.
584 /// Nearly everywhere, inner must be non-null, however in places where
585 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
586 pub inner: *mut nativePing,
587 /// Indicates that this is the only struct which contains the same pointer.
589 /// Rust functions which take ownership of an object provided via an argument require
590 /// this to be true and invalidate the object pointed to by inner.
596 if self.is_owned && !<*mut nativePing>::is_null(self.inner) {
597 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
601 /// Frees any resources used by the Ping, if is_owned is set and inner is non-NULL.
603 pub extern "C" fn Ping_free(this_obj: Ping) { }
605 /// Used only if an object of this type is returned as a trait impl by a method
606 pub(crate) extern "C" fn Ping_free_void(this_ptr: *mut c_void) {
607 let _ = unsafe { Box::from_raw(this_ptr as *mut nativePing) };
611 pub(crate) fn get_native_ref(&self) -> &'static nativePing {
612 unsafe { &*ObjOps::untweak_ptr(self.inner) }
614 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePing {
615 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
617 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
618 pub(crate) fn take_inner(mut self) -> *mut nativePing {
619 assert!(self.is_owned);
620 let ret = ObjOps::untweak_ptr(self.inner);
621 self.inner = core::ptr::null_mut();
625 /// The desired response length.
627 pub extern "C" fn Ping_get_ponglen(this_ptr: &Ping) -> u16 {
628 let mut inner_val = &mut this_ptr.get_native_mut_ref().ponglen;
631 /// The desired response length.
633 pub extern "C" fn Ping_set_ponglen(this_ptr: &mut Ping, mut val: u16) {
634 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.ponglen = val;
636 /// The ping packet size.
638 /// This field is not sent on the wire. byteslen zeros are sent.
640 pub extern "C" fn Ping_get_byteslen(this_ptr: &Ping) -> u16 {
641 let mut inner_val = &mut this_ptr.get_native_mut_ref().byteslen;
644 /// The ping packet size.
646 /// This field is not sent on the wire. byteslen zeros are sent.
648 pub extern "C" fn Ping_set_byteslen(this_ptr: &mut Ping, mut val: u16) {
649 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.byteslen = val;
651 /// Constructs a new Ping given each field
654 pub extern "C" fn Ping_new(mut ponglen_arg: u16, mut byteslen_arg: u16) -> Ping {
655 Ping { inner: ObjOps::heap_alloc(nativePing {
656 ponglen: ponglen_arg,
657 byteslen: byteslen_arg,
660 impl Clone for Ping {
661 fn clone(&self) -> Self {
663 inner: if <*mut nativePing>::is_null(self.inner) { core::ptr::null_mut() } else {
664 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
670 /// Used only if an object of this type is returned as a trait impl by a method
671 pub(crate) extern "C" fn Ping_clone_void(this_ptr: *const c_void) -> *mut c_void {
672 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePing)).clone() })) as *mut c_void
675 /// Creates a copy of the Ping
676 pub extern "C" fn Ping_clone(orig: &Ping) -> Ping {
679 /// Checks if two Pings contain equal inner contents.
680 /// This ignores pointers and is_owned flags and looks at the values in fields.
681 /// Two objects with NULL inner values will be considered "equal" here.
683 pub extern "C" fn Ping_eq(a: &Ping, b: &Ping) -> bool {
684 if a.inner == b.inner { return true; }
685 if a.inner.is_null() || b.inner.is_null() { return false; }
686 if a.get_native_ref() == b.get_native_ref() { true } else { false }
689 use lightning::ln::msgs::Pong as nativePongImport;
690 pub(crate) type nativePong = nativePongImport;
692 /// A [`pong`] message to be sent to or received from a peer.
694 /// [`pong`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-ping-and-pong-messages
698 /// A pointer to the opaque Rust object.
700 /// Nearly everywhere, inner must be non-null, however in places where
701 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
702 pub inner: *mut nativePong,
703 /// Indicates that this is the only struct which contains the same pointer.
705 /// Rust functions which take ownership of an object provided via an argument require
706 /// this to be true and invalidate the object pointed to by inner.
712 if self.is_owned && !<*mut nativePong>::is_null(self.inner) {
713 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
717 /// Frees any resources used by the Pong, if is_owned is set and inner is non-NULL.
719 pub extern "C" fn Pong_free(this_obj: Pong) { }
721 /// Used only if an object of this type is returned as a trait impl by a method
722 pub(crate) extern "C" fn Pong_free_void(this_ptr: *mut c_void) {
723 let _ = unsafe { Box::from_raw(this_ptr as *mut nativePong) };
727 pub(crate) fn get_native_ref(&self) -> &'static nativePong {
728 unsafe { &*ObjOps::untweak_ptr(self.inner) }
730 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePong {
731 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
733 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
734 pub(crate) fn take_inner(mut self) -> *mut nativePong {
735 assert!(self.is_owned);
736 let ret = ObjOps::untweak_ptr(self.inner);
737 self.inner = core::ptr::null_mut();
741 /// The pong packet size.
743 /// This field is not sent on the wire. byteslen zeros are sent.
745 pub extern "C" fn Pong_get_byteslen(this_ptr: &Pong) -> u16 {
746 let mut inner_val = &mut this_ptr.get_native_mut_ref().byteslen;
749 /// The pong packet size.
751 /// This field is not sent on the wire. byteslen zeros are sent.
753 pub extern "C" fn Pong_set_byteslen(this_ptr: &mut Pong, mut val: u16) {
754 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.byteslen = val;
756 /// Constructs a new Pong given each field
759 pub extern "C" fn Pong_new(mut byteslen_arg: u16) -> Pong {
760 Pong { inner: ObjOps::heap_alloc(nativePong {
761 byteslen: byteslen_arg,
764 impl Clone for Pong {
765 fn clone(&self) -> Self {
767 inner: if <*mut nativePong>::is_null(self.inner) { core::ptr::null_mut() } else {
768 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
774 /// Used only if an object of this type is returned as a trait impl by a method
775 pub(crate) extern "C" fn Pong_clone_void(this_ptr: *const c_void) -> *mut c_void {
776 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePong)).clone() })) as *mut c_void
779 /// Creates a copy of the Pong
780 pub extern "C" fn Pong_clone(orig: &Pong) -> Pong {
783 /// Checks if two Pongs contain equal inner contents.
784 /// This ignores pointers and is_owned flags and looks at the values in fields.
785 /// Two objects with NULL inner values will be considered "equal" here.
787 pub extern "C" fn Pong_eq(a: &Pong, b: &Pong) -> bool {
788 if a.inner == b.inner { return true; }
789 if a.inner.is_null() || b.inner.is_null() { return false; }
790 if a.get_native_ref() == b.get_native_ref() { true } else { false }
793 use lightning::ln::msgs::OpenChannel as nativeOpenChannelImport;
794 pub(crate) type nativeOpenChannel = nativeOpenChannelImport;
796 /// An [`open_channel`] message to be sent to or received from a peer.
798 /// Used in V1 channel establishment
800 /// [`open_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message
803 pub struct OpenChannel {
804 /// A pointer to the opaque Rust object.
806 /// Nearly everywhere, inner must be non-null, however in places where
807 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
808 pub inner: *mut nativeOpenChannel,
809 /// Indicates that this is the only struct which contains the same pointer.
811 /// Rust functions which take ownership of an object provided via an argument require
812 /// this to be true and invalidate the object pointed to by inner.
816 impl Drop for OpenChannel {
818 if self.is_owned && !<*mut nativeOpenChannel>::is_null(self.inner) {
819 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
823 /// Frees any resources used by the OpenChannel, if is_owned is set and inner is non-NULL.
825 pub extern "C" fn OpenChannel_free(this_obj: OpenChannel) { }
827 /// Used only if an object of this type is returned as a trait impl by a method
828 pub(crate) extern "C" fn OpenChannel_free_void(this_ptr: *mut c_void) {
829 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOpenChannel) };
833 pub(crate) fn get_native_ref(&self) -> &'static nativeOpenChannel {
834 unsafe { &*ObjOps::untweak_ptr(self.inner) }
836 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOpenChannel {
837 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
839 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
840 pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannel {
841 assert!(self.is_owned);
842 let ret = ObjOps::untweak_ptr(self.inner);
843 self.inner = core::ptr::null_mut();
847 /// The genesis hash of the blockchain where the channel is to be opened
849 pub extern "C" fn OpenChannel_get_chain_hash(this_ptr: &OpenChannel) -> *const [u8; 32] {
850 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
853 /// The genesis hash of the blockchain where the channel is to be opened
855 pub extern "C" fn OpenChannel_set_chain_hash(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
856 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
858 /// A temporary channel ID, until the funding outpoint is announced
860 pub extern "C" fn OpenChannel_get_temporary_channel_id(this_ptr: &OpenChannel) -> *const [u8; 32] {
861 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
864 /// A temporary channel ID, until the funding outpoint is announced
866 pub extern "C" fn OpenChannel_set_temporary_channel_id(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
867 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = ::lightning::ln::ChannelId(val.data);
869 /// The channel value
871 pub extern "C" fn OpenChannel_get_funding_satoshis(this_ptr: &OpenChannel) -> u64 {
872 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
875 /// The channel value
877 pub extern "C" fn OpenChannel_set_funding_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
878 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
880 /// The amount to push to the counterparty as part of the open, in milli-satoshi
882 pub extern "C" fn OpenChannel_get_push_msat(this_ptr: &OpenChannel) -> u64 {
883 let mut inner_val = &mut this_ptr.get_native_mut_ref().push_msat;
886 /// The amount to push to the counterparty as part of the open, in milli-satoshi
888 pub extern "C" fn OpenChannel_set_push_msat(this_ptr: &mut OpenChannel, mut val: u64) {
889 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.push_msat = val;
891 /// The threshold below which outputs on transactions broadcast by sender will be omitted
893 pub extern "C" fn OpenChannel_get_dust_limit_satoshis(this_ptr: &OpenChannel) -> u64 {
894 let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
897 /// The threshold below which outputs on transactions broadcast by sender will be omitted
899 pub extern "C" fn OpenChannel_set_dust_limit_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
900 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
902 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
904 pub extern "C" fn OpenChannel_get_max_htlc_value_in_flight_msat(this_ptr: &OpenChannel) -> u64 {
905 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
908 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
910 pub extern "C" fn OpenChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut OpenChannel, mut val: u64) {
911 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
913 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
915 pub extern "C" fn OpenChannel_get_channel_reserve_satoshis(this_ptr: &OpenChannel) -> u64 {
916 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
919 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
921 pub extern "C" fn OpenChannel_set_channel_reserve_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
922 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
924 /// The minimum HTLC size incoming to sender, in milli-satoshi
926 pub extern "C" fn OpenChannel_get_htlc_minimum_msat(this_ptr: &OpenChannel) -> u64 {
927 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
930 /// The minimum HTLC size incoming to sender, in milli-satoshi
932 pub extern "C" fn OpenChannel_set_htlc_minimum_msat(this_ptr: &mut OpenChannel, mut val: u64) {
933 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
935 /// The feerate per 1000-weight of sender generated transactions, until updated by
938 pub extern "C" fn OpenChannel_get_feerate_per_kw(this_ptr: &OpenChannel) -> u32 {
939 let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
942 /// The feerate per 1000-weight of sender generated transactions, until updated by
945 pub extern "C" fn OpenChannel_set_feerate_per_kw(this_ptr: &mut OpenChannel, mut val: u32) {
946 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
948 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if
949 /// they broadcast a commitment transaction
951 pub extern "C" fn OpenChannel_get_to_self_delay(this_ptr: &OpenChannel) -> u16 {
952 let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
955 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if
956 /// they broadcast a commitment transaction
958 pub extern "C" fn OpenChannel_set_to_self_delay(this_ptr: &mut OpenChannel, mut val: u16) {
959 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
961 /// The maximum number of inbound HTLCs towards sender
963 pub extern "C" fn OpenChannel_get_max_accepted_htlcs(this_ptr: &OpenChannel) -> u16 {
964 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
967 /// The maximum number of inbound HTLCs towards sender
969 pub extern "C" fn OpenChannel_set_max_accepted_htlcs(this_ptr: &mut OpenChannel, mut val: u16) {
970 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
972 /// The sender's key controlling the funding transaction
974 pub extern "C" fn OpenChannel_get_funding_pubkey(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
975 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
976 crate::c_types::PublicKey::from_rust(&inner_val)
978 /// The sender's key controlling the funding transaction
980 pub extern "C" fn OpenChannel_set_funding_pubkey(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
981 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
983 /// Used to derive a revocation key for transactions broadcast by counterparty
985 pub extern "C" fn OpenChannel_get_revocation_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
986 let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
987 crate::c_types::PublicKey::from_rust(&inner_val)
989 /// Used to derive a revocation key for transactions broadcast by counterparty
991 pub extern "C" fn OpenChannel_set_revocation_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
992 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
994 /// A payment key to sender for transactions broadcast by counterparty
996 pub extern "C" fn OpenChannel_get_payment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
997 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_point;
998 crate::c_types::PublicKey::from_rust(&inner_val)
1000 /// A payment key to sender for transactions broadcast by counterparty
1002 pub extern "C" fn OpenChannel_set_payment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1003 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_point = val.into_rust();
1005 /// Used to derive a payment key to sender for transactions broadcast by sender
1007 pub extern "C" fn OpenChannel_get_delayed_payment_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
1008 let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
1009 crate::c_types::PublicKey::from_rust(&inner_val)
1011 /// Used to derive a payment key to sender for transactions broadcast by sender
1013 pub extern "C" fn OpenChannel_set_delayed_payment_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1014 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
1016 /// Used to derive an HTLC payment key to sender
1018 pub extern "C" fn OpenChannel_get_htlc_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
1019 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
1020 crate::c_types::PublicKey::from_rust(&inner_val)
1022 /// Used to derive an HTLC payment key to sender
1024 pub extern "C" fn OpenChannel_set_htlc_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1025 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
1027 /// The first to-be-broadcast-by-sender transaction's per commitment point
1029 pub extern "C" fn OpenChannel_get_first_per_commitment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
1030 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
1031 crate::c_types::PublicKey::from_rust(&inner_val)
1033 /// The first to-be-broadcast-by-sender transaction's per commitment point
1035 pub extern "C" fn OpenChannel_set_first_per_commitment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
1036 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
1038 /// The channel flags to be used
1040 pub extern "C" fn OpenChannel_get_channel_flags(this_ptr: &OpenChannel) -> u8 {
1041 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_flags;
1044 /// The channel flags to be used
1046 pub extern "C" fn OpenChannel_set_channel_flags(this_ptr: &mut OpenChannel, mut val: u8) {
1047 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_flags = val;
1049 /// A request to pre-set the to-sender output's `scriptPubkey` for when we collaboratively close
1051 pub extern "C" fn OpenChannel_get_shutdown_scriptpubkey(this_ptr: &OpenChannel) -> crate::c_types::derived::COption_CVec_u8ZZ {
1052 let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey;
1053 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().into_bytes().into() }) };
1056 /// A request to pre-set the to-sender output's `scriptPubkey` for when we collaboratively close
1058 pub extern "C" fn OpenChannel_set_shutdown_scriptpubkey(this_ptr: &mut OpenChannel, mut val: crate::c_types::derived::COption_CVec_u8ZZ) {
1059 let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ val_opt.take() }.into_rust()) }})} };
1060 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val;
1062 /// The channel type that this channel will represent
1064 /// If this is `None`, we derive the channel type from the intersection of our
1065 /// feature bits with our counterparty's feature bits from the [`Init`] message.
1067 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1069 pub extern "C" fn OpenChannel_get_channel_type(this_ptr: &OpenChannel) -> crate::lightning::ln::features::ChannelTypeFeatures {
1070 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1071 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 };
1074 /// The channel type that this channel will represent
1076 /// If this is `None`, we derive the channel type from the intersection of our
1077 /// feature bits with our counterparty's feature bits from the [`Init`] message.
1079 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1081 pub extern "C" fn OpenChannel_set_channel_type(this_ptr: &mut OpenChannel, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1082 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1083 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1085 /// Constructs a new OpenChannel given each field
1087 /// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
1090 pub extern "C" fn OpenChannel_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_satoshis_arg: u64, mut push_msat_arg: u64, mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut channel_reserve_satoshis_arg: u64, mut htlc_minimum_msat_arg: u64, mut feerate_per_kw_arg: u32, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16, mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_point_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey, mut first_per_commitment_point_arg: crate::c_types::PublicKey, mut channel_flags_arg: u8, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_CVec_u8ZZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures) -> OpenChannel {
1091 let mut local_shutdown_scriptpubkey_arg = { /*shutdown_scriptpubkey_arg*/ let shutdown_scriptpubkey_arg_opt = shutdown_scriptpubkey_arg; if shutdown_scriptpubkey_arg_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} };
1092 let mut local_channel_type_arg = if channel_type_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_type_arg.take_inner()) } }) };
1093 OpenChannel { inner: ObjOps::heap_alloc(nativeOpenChannel {
1094 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
1095 temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_arg.data),
1096 funding_satoshis: funding_satoshis_arg,
1097 push_msat: push_msat_arg,
1098 dust_limit_satoshis: dust_limit_satoshis_arg,
1099 max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg,
1100 channel_reserve_satoshis: channel_reserve_satoshis_arg,
1101 htlc_minimum_msat: htlc_minimum_msat_arg,
1102 feerate_per_kw: feerate_per_kw_arg,
1103 to_self_delay: to_self_delay_arg,
1104 max_accepted_htlcs: max_accepted_htlcs_arg,
1105 funding_pubkey: funding_pubkey_arg.into_rust(),
1106 revocation_basepoint: revocation_basepoint_arg.into_rust(),
1107 payment_point: payment_point_arg.into_rust(),
1108 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
1109 htlc_basepoint: htlc_basepoint_arg.into_rust(),
1110 first_per_commitment_point: first_per_commitment_point_arg.into_rust(),
1111 channel_flags: channel_flags_arg,
1112 shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg,
1113 channel_type: local_channel_type_arg,
1114 }), is_owned: true }
1116 impl Clone for OpenChannel {
1117 fn clone(&self) -> Self {
1119 inner: if <*mut nativeOpenChannel>::is_null(self.inner) { core::ptr::null_mut() } else {
1120 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1126 /// Used only if an object of this type is returned as a trait impl by a method
1127 pub(crate) extern "C" fn OpenChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
1128 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOpenChannel)).clone() })) as *mut c_void
1131 /// Creates a copy of the OpenChannel
1132 pub extern "C" fn OpenChannel_clone(orig: &OpenChannel) -> OpenChannel {
1135 /// Checks if two OpenChannels contain equal inner contents.
1136 /// This ignores pointers and is_owned flags and looks at the values in fields.
1137 /// Two objects with NULL inner values will be considered "equal" here.
1139 pub extern "C" fn OpenChannel_eq(a: &OpenChannel, b: &OpenChannel) -> bool {
1140 if a.inner == b.inner { return true; }
1141 if a.inner.is_null() || b.inner.is_null() { return false; }
1142 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1145 use lightning::ln::msgs::OpenChannelV2 as nativeOpenChannelV2Import;
1146 pub(crate) type nativeOpenChannelV2 = nativeOpenChannelV2Import;
1148 /// An open_channel2 message to be sent by or received from the channel initiator.
1150 /// Used in V2 channel establishment
1154 pub struct OpenChannelV2 {
1155 /// A pointer to the opaque Rust object.
1157 /// Nearly everywhere, inner must be non-null, however in places where
1158 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1159 pub inner: *mut nativeOpenChannelV2,
1160 /// Indicates that this is the only struct which contains the same pointer.
1162 /// Rust functions which take ownership of an object provided via an argument require
1163 /// this to be true and invalidate the object pointed to by inner.
1167 impl Drop for OpenChannelV2 {
1168 fn drop(&mut self) {
1169 if self.is_owned && !<*mut nativeOpenChannelV2>::is_null(self.inner) {
1170 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1174 /// Frees any resources used by the OpenChannelV2, if is_owned is set and inner is non-NULL.
1176 pub extern "C" fn OpenChannelV2_free(this_obj: OpenChannelV2) { }
1178 /// Used only if an object of this type is returned as a trait impl by a method
1179 pub(crate) extern "C" fn OpenChannelV2_free_void(this_ptr: *mut c_void) {
1180 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOpenChannelV2) };
1183 impl OpenChannelV2 {
1184 pub(crate) fn get_native_ref(&self) -> &'static nativeOpenChannelV2 {
1185 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1187 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOpenChannelV2 {
1188 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1190 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1191 pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannelV2 {
1192 assert!(self.is_owned);
1193 let ret = ObjOps::untweak_ptr(self.inner);
1194 self.inner = core::ptr::null_mut();
1198 /// The genesis hash of the blockchain where the channel is to be opened
1200 pub extern "C" fn OpenChannelV2_get_chain_hash(this_ptr: &OpenChannelV2) -> *const [u8; 32] {
1201 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
1202 inner_val.as_inner()
1204 /// The genesis hash of the blockchain where the channel is to be opened
1206 pub extern "C" fn OpenChannelV2_set_chain_hash(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::ThirtyTwoBytes) {
1207 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
1209 /// A temporary channel ID derived using a zeroed out value for the channel acceptor's revocation basepoint
1211 pub extern "C" fn OpenChannelV2_get_temporary_channel_id(this_ptr: &OpenChannelV2) -> *const [u8; 32] {
1212 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
1215 /// A temporary channel ID derived using a zeroed out value for the channel acceptor's revocation basepoint
1217 pub extern "C" fn OpenChannelV2_set_temporary_channel_id(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::ThirtyTwoBytes) {
1218 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = ::lightning::ln::ChannelId(val.data);
1220 /// The feerate for the funding transaction set by the channel initiator
1222 pub extern "C" fn OpenChannelV2_get_funding_feerate_sat_per_1000_weight(this_ptr: &OpenChannelV2) -> u32 {
1223 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_feerate_sat_per_1000_weight;
1226 /// The feerate for the funding transaction set by the channel initiator
1228 pub extern "C" fn OpenChannelV2_set_funding_feerate_sat_per_1000_weight(this_ptr: &mut OpenChannelV2, mut val: u32) {
1229 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_feerate_sat_per_1000_weight = val;
1231 /// The feerate for the commitment transaction set by the channel initiator
1233 pub extern "C" fn OpenChannelV2_get_commitment_feerate_sat_per_1000_weight(this_ptr: &OpenChannelV2) -> u32 {
1234 let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_feerate_sat_per_1000_weight;
1237 /// The feerate for the commitment transaction set by the channel initiator
1239 pub extern "C" fn OpenChannelV2_set_commitment_feerate_sat_per_1000_weight(this_ptr: &mut OpenChannelV2, mut val: u32) {
1240 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_feerate_sat_per_1000_weight = val;
1242 /// Part of the channel value contributed by the channel initiator
1244 pub extern "C" fn OpenChannelV2_get_funding_satoshis(this_ptr: &OpenChannelV2) -> u64 {
1245 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
1248 /// Part of the channel value contributed by the channel initiator
1250 pub extern "C" fn OpenChannelV2_set_funding_satoshis(this_ptr: &mut OpenChannelV2, mut val: u64) {
1251 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
1253 /// The threshold below which outputs on transactions broadcast by the channel initiator will be
1256 pub extern "C" fn OpenChannelV2_get_dust_limit_satoshis(this_ptr: &OpenChannelV2) -> u64 {
1257 let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
1260 /// The threshold below which outputs on transactions broadcast by the channel initiator will be
1263 pub extern "C" fn OpenChannelV2_set_dust_limit_satoshis(this_ptr: &mut OpenChannelV2, mut val: u64) {
1264 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
1266 /// The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi
1268 pub extern "C" fn OpenChannelV2_get_max_htlc_value_in_flight_msat(this_ptr: &OpenChannelV2) -> u64 {
1269 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
1272 /// The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi
1274 pub extern "C" fn OpenChannelV2_set_max_htlc_value_in_flight_msat(this_ptr: &mut OpenChannelV2, mut val: u64) {
1275 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
1277 /// The minimum HTLC size incoming to channel initiator, in milli-satoshi
1279 pub extern "C" fn OpenChannelV2_get_htlc_minimum_msat(this_ptr: &OpenChannelV2) -> u64 {
1280 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
1283 /// The minimum HTLC size incoming to channel initiator, in milli-satoshi
1285 pub extern "C" fn OpenChannelV2_set_htlc_minimum_msat(this_ptr: &mut OpenChannelV2, mut val: u64) {
1286 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
1288 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1289 /// broadcast a commitment transaction
1291 pub extern "C" fn OpenChannelV2_get_to_self_delay(this_ptr: &OpenChannelV2) -> u16 {
1292 let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
1295 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1296 /// broadcast a commitment transaction
1298 pub extern "C" fn OpenChannelV2_set_to_self_delay(this_ptr: &mut OpenChannelV2, mut val: u16) {
1299 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
1301 /// The maximum number of inbound HTLCs towards channel initiator
1303 pub extern "C" fn OpenChannelV2_get_max_accepted_htlcs(this_ptr: &OpenChannelV2) -> u16 {
1304 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
1307 /// The maximum number of inbound HTLCs towards channel initiator
1309 pub extern "C" fn OpenChannelV2_set_max_accepted_htlcs(this_ptr: &mut OpenChannelV2, mut val: u16) {
1310 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
1312 /// The locktime for the funding transaction
1314 pub extern "C" fn OpenChannelV2_get_locktime(this_ptr: &OpenChannelV2) -> u32 {
1315 let mut inner_val = &mut this_ptr.get_native_mut_ref().locktime;
1318 /// The locktime for the funding transaction
1320 pub extern "C" fn OpenChannelV2_set_locktime(this_ptr: &mut OpenChannelV2, mut val: u32) {
1321 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.locktime = val;
1323 /// The channel initiator's key controlling the funding transaction
1325 pub extern "C" fn OpenChannelV2_get_funding_pubkey(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1326 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
1327 crate::c_types::PublicKey::from_rust(&inner_val)
1329 /// The channel initiator's key controlling the funding transaction
1331 pub extern "C" fn OpenChannelV2_set_funding_pubkey(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1332 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
1334 /// Used to derive a revocation key for transactions broadcast by counterparty
1336 pub extern "C" fn OpenChannelV2_get_revocation_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1337 let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
1338 crate::c_types::PublicKey::from_rust(&inner_val)
1340 /// Used to derive a revocation key for transactions broadcast by counterparty
1342 pub extern "C" fn OpenChannelV2_set_revocation_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1343 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
1345 /// A payment key to channel initiator for transactions broadcast by counterparty
1347 pub extern "C" fn OpenChannelV2_get_payment_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1348 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_basepoint;
1349 crate::c_types::PublicKey::from_rust(&inner_val)
1351 /// A payment key to channel initiator for transactions broadcast by counterparty
1353 pub extern "C" fn OpenChannelV2_set_payment_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1354 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_basepoint = val.into_rust();
1356 /// Used to derive a payment key to channel initiator for transactions broadcast by channel
1359 pub extern "C" fn OpenChannelV2_get_delayed_payment_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1360 let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
1361 crate::c_types::PublicKey::from_rust(&inner_val)
1363 /// Used to derive a payment key to channel initiator for transactions broadcast by channel
1366 pub extern "C" fn OpenChannelV2_set_delayed_payment_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1367 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
1369 /// Used to derive an HTLC payment key to channel initiator
1371 pub extern "C" fn OpenChannelV2_get_htlc_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1372 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
1373 crate::c_types::PublicKey::from_rust(&inner_val)
1375 /// Used to derive an HTLC payment key to channel initiator
1377 pub extern "C" fn OpenChannelV2_set_htlc_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1378 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
1380 /// The first to-be-broadcast-by-channel-initiator transaction's per commitment point
1382 pub extern "C" fn OpenChannelV2_get_first_per_commitment_point(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1383 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
1384 crate::c_types::PublicKey::from_rust(&inner_val)
1386 /// The first to-be-broadcast-by-channel-initiator transaction's per commitment point
1388 pub extern "C" fn OpenChannelV2_set_first_per_commitment_point(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1389 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
1391 /// The second to-be-broadcast-by-channel-initiator transaction's per commitment point
1393 pub extern "C" fn OpenChannelV2_get_second_per_commitment_point(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey {
1394 let mut inner_val = &mut this_ptr.get_native_mut_ref().second_per_commitment_point;
1395 crate::c_types::PublicKey::from_rust(&inner_val)
1397 /// The second to-be-broadcast-by-channel-initiator transaction's per commitment point
1399 pub extern "C" fn OpenChannelV2_set_second_per_commitment_point(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) {
1400 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.second_per_commitment_point = val.into_rust();
1404 pub extern "C" fn OpenChannelV2_get_channel_flags(this_ptr: &OpenChannelV2) -> u8 {
1405 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_flags;
1410 pub extern "C" fn OpenChannelV2_set_channel_flags(this_ptr: &mut OpenChannelV2, mut val: u8) {
1411 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_flags = val;
1413 /// Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we
1414 /// collaboratively close
1416 pub extern "C" fn OpenChannelV2_get_shutdown_scriptpubkey(this_ptr: &OpenChannelV2) -> crate::c_types::derived::COption_CVec_u8ZZ {
1417 let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey;
1418 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().into_bytes().into() }) };
1421 /// Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we
1422 /// collaboratively close
1424 pub extern "C" fn OpenChannelV2_set_shutdown_scriptpubkey(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::derived::COption_CVec_u8ZZ) {
1425 let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ val_opt.take() }.into_rust()) }})} };
1426 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val;
1428 /// The channel type that this channel will represent. If none is set, we derive the channel
1429 /// type from the intersection of our feature bits with our counterparty's feature bits from
1430 /// the Init message.
1432 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1434 pub extern "C" fn OpenChannelV2_get_channel_type(this_ptr: &OpenChannelV2) -> crate::lightning::ln::features::ChannelTypeFeatures {
1435 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1436 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 };
1439 /// The channel type that this channel will represent. If none is set, we derive the channel
1440 /// type from the intersection of our feature bits with our counterparty's feature bits from
1441 /// the Init message.
1443 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1445 pub extern "C" fn OpenChannelV2_set_channel_type(this_ptr: &mut OpenChannelV2, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1446 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1447 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1449 /// Optionally, a requirement that only confirmed inputs can be added
1451 pub extern "C" fn OpenChannelV2_get_require_confirmed_inputs(this_ptr: &OpenChannelV2) -> crate::c_types::derived::COption_NoneZ {
1452 let mut inner_val = &mut this_ptr.get_native_mut_ref().require_confirmed_inputs;
1453 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_NoneZ::None } else { crate::c_types::derived::COption_NoneZ::Some /* { () /**/ } */ };
1456 /// Optionally, a requirement that only confirmed inputs can be added
1458 pub extern "C" fn OpenChannelV2_set_require_confirmed_inputs(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::derived::COption_NoneZ) {
1459 let mut local_val = if val.is_some() { Some( { () /*val.take()*/ }) } else { None };
1460 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.require_confirmed_inputs = local_val;
1462 /// Constructs a new OpenChannelV2 given each field
1464 /// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
1467 pub extern "C" fn OpenChannelV2_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_feerate_sat_per_1000_weight_arg: u32, mut commitment_feerate_sat_per_1000_weight_arg: u32, mut funding_satoshis_arg: u64, mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut htlc_minimum_msat_arg: u64, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16, mut locktime_arg: u32, mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_basepoint_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey, mut first_per_commitment_point_arg: crate::c_types::PublicKey, mut second_per_commitment_point_arg: crate::c_types::PublicKey, mut channel_flags_arg: u8, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_CVec_u8ZZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures, mut require_confirmed_inputs_arg: crate::c_types::derived::COption_NoneZ) -> OpenChannelV2 {
1468 let mut local_shutdown_scriptpubkey_arg = { /*shutdown_scriptpubkey_arg*/ let shutdown_scriptpubkey_arg_opt = shutdown_scriptpubkey_arg; if shutdown_scriptpubkey_arg_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} };
1469 let mut local_channel_type_arg = if channel_type_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_type_arg.take_inner()) } }) };
1470 let mut local_require_confirmed_inputs_arg = if require_confirmed_inputs_arg.is_some() { Some( { () /*require_confirmed_inputs_arg.take()*/ }) } else { None };
1471 OpenChannelV2 { inner: ObjOps::heap_alloc(nativeOpenChannelV2 {
1472 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
1473 temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_arg.data),
1474 funding_feerate_sat_per_1000_weight: funding_feerate_sat_per_1000_weight_arg,
1475 commitment_feerate_sat_per_1000_weight: commitment_feerate_sat_per_1000_weight_arg,
1476 funding_satoshis: funding_satoshis_arg,
1477 dust_limit_satoshis: dust_limit_satoshis_arg,
1478 max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg,
1479 htlc_minimum_msat: htlc_minimum_msat_arg,
1480 to_self_delay: to_self_delay_arg,
1481 max_accepted_htlcs: max_accepted_htlcs_arg,
1482 locktime: locktime_arg,
1483 funding_pubkey: funding_pubkey_arg.into_rust(),
1484 revocation_basepoint: revocation_basepoint_arg.into_rust(),
1485 payment_basepoint: payment_basepoint_arg.into_rust(),
1486 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
1487 htlc_basepoint: htlc_basepoint_arg.into_rust(),
1488 first_per_commitment_point: first_per_commitment_point_arg.into_rust(),
1489 second_per_commitment_point: second_per_commitment_point_arg.into_rust(),
1490 channel_flags: channel_flags_arg,
1491 shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg,
1492 channel_type: local_channel_type_arg,
1493 require_confirmed_inputs: local_require_confirmed_inputs_arg,
1494 }), is_owned: true }
1496 impl Clone for OpenChannelV2 {
1497 fn clone(&self) -> Self {
1499 inner: if <*mut nativeOpenChannelV2>::is_null(self.inner) { core::ptr::null_mut() } else {
1500 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1506 /// Used only if an object of this type is returned as a trait impl by a method
1507 pub(crate) extern "C" fn OpenChannelV2_clone_void(this_ptr: *const c_void) -> *mut c_void {
1508 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOpenChannelV2)).clone() })) as *mut c_void
1511 /// Creates a copy of the OpenChannelV2
1512 pub extern "C" fn OpenChannelV2_clone(orig: &OpenChannelV2) -> OpenChannelV2 {
1515 /// Checks if two OpenChannelV2s contain equal inner contents.
1516 /// This ignores pointers and is_owned flags and looks at the values in fields.
1517 /// Two objects with NULL inner values will be considered "equal" here.
1519 pub extern "C" fn OpenChannelV2_eq(a: &OpenChannelV2, b: &OpenChannelV2) -> bool {
1520 if a.inner == b.inner { return true; }
1521 if a.inner.is_null() || b.inner.is_null() { return false; }
1522 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1525 use lightning::ln::msgs::AcceptChannel as nativeAcceptChannelImport;
1526 pub(crate) type nativeAcceptChannel = nativeAcceptChannelImport;
1528 /// An [`accept_channel`] message to be sent to or received from a peer.
1530 /// Used in V1 channel establishment
1532 /// [`accept_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-accept_channel-message
1535 pub struct AcceptChannel {
1536 /// A pointer to the opaque Rust object.
1538 /// Nearly everywhere, inner must be non-null, however in places where
1539 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1540 pub inner: *mut nativeAcceptChannel,
1541 /// Indicates that this is the only struct which contains the same pointer.
1543 /// Rust functions which take ownership of an object provided via an argument require
1544 /// this to be true and invalidate the object pointed to by inner.
1548 impl Drop for AcceptChannel {
1549 fn drop(&mut self) {
1550 if self.is_owned && !<*mut nativeAcceptChannel>::is_null(self.inner) {
1551 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1555 /// Frees any resources used by the AcceptChannel, if is_owned is set and inner is non-NULL.
1557 pub extern "C" fn AcceptChannel_free(this_obj: AcceptChannel) { }
1559 /// Used only if an object of this type is returned as a trait impl by a method
1560 pub(crate) extern "C" fn AcceptChannel_free_void(this_ptr: *mut c_void) {
1561 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAcceptChannel) };
1564 impl AcceptChannel {
1565 pub(crate) fn get_native_ref(&self) -> &'static nativeAcceptChannel {
1566 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1568 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAcceptChannel {
1569 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1571 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1572 pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannel {
1573 assert!(self.is_owned);
1574 let ret = ObjOps::untweak_ptr(self.inner);
1575 self.inner = core::ptr::null_mut();
1579 /// A temporary channel ID, until the funding outpoint is announced
1581 pub extern "C" fn AcceptChannel_get_temporary_channel_id(this_ptr: &AcceptChannel) -> *const [u8; 32] {
1582 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
1585 /// A temporary channel ID, until the funding outpoint is announced
1587 pub extern "C" fn AcceptChannel_set_temporary_channel_id(this_ptr: &mut AcceptChannel, mut val: crate::c_types::ThirtyTwoBytes) {
1588 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = ::lightning::ln::ChannelId(val.data);
1590 /// The threshold below which outputs on transactions broadcast by sender will be omitted
1592 pub extern "C" fn AcceptChannel_get_dust_limit_satoshis(this_ptr: &AcceptChannel) -> u64 {
1593 let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
1596 /// The threshold below which outputs on transactions broadcast by sender will be omitted
1598 pub extern "C" fn AcceptChannel_set_dust_limit_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
1599 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
1601 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
1603 pub extern "C" fn AcceptChannel_get_max_htlc_value_in_flight_msat(this_ptr: &AcceptChannel) -> u64 {
1604 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
1607 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
1609 pub extern "C" fn AcceptChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
1610 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
1612 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1614 pub extern "C" fn AcceptChannel_get_channel_reserve_satoshis(this_ptr: &AcceptChannel) -> u64 {
1615 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
1618 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1620 pub extern "C" fn AcceptChannel_set_channel_reserve_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
1621 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
1623 /// The minimum HTLC size incoming to sender, in milli-satoshi
1625 pub extern "C" fn AcceptChannel_get_htlc_minimum_msat(this_ptr: &AcceptChannel) -> u64 {
1626 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
1629 /// The minimum HTLC size incoming to sender, in milli-satoshi
1631 pub extern "C" fn AcceptChannel_set_htlc_minimum_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
1632 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
1634 /// Minimum depth of the funding transaction before the channel is considered open
1636 pub extern "C" fn AcceptChannel_get_minimum_depth(this_ptr: &AcceptChannel) -> u32 {
1637 let mut inner_val = &mut this_ptr.get_native_mut_ref().minimum_depth;
1640 /// Minimum depth of the funding transaction before the channel is considered open
1642 pub extern "C" fn AcceptChannel_set_minimum_depth(this_ptr: &mut AcceptChannel, mut val: u32) {
1643 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.minimum_depth = val;
1645 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
1647 pub extern "C" fn AcceptChannel_get_to_self_delay(this_ptr: &AcceptChannel) -> u16 {
1648 let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
1651 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
1653 pub extern "C" fn AcceptChannel_set_to_self_delay(this_ptr: &mut AcceptChannel, mut val: u16) {
1654 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
1656 /// The maximum number of inbound HTLCs towards sender
1658 pub extern "C" fn AcceptChannel_get_max_accepted_htlcs(this_ptr: &AcceptChannel) -> u16 {
1659 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
1662 /// The maximum number of inbound HTLCs towards sender
1664 pub extern "C" fn AcceptChannel_set_max_accepted_htlcs(this_ptr: &mut AcceptChannel, mut val: u16) {
1665 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
1667 /// The sender's key controlling the funding transaction
1669 pub extern "C" fn AcceptChannel_get_funding_pubkey(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1670 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
1671 crate::c_types::PublicKey::from_rust(&inner_val)
1673 /// The sender's key controlling the funding transaction
1675 pub extern "C" fn AcceptChannel_set_funding_pubkey(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1676 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
1678 /// Used to derive a revocation key for transactions broadcast by counterparty
1680 pub extern "C" fn AcceptChannel_get_revocation_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1681 let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
1682 crate::c_types::PublicKey::from_rust(&inner_val)
1684 /// Used to derive a revocation key for transactions broadcast by counterparty
1686 pub extern "C" fn AcceptChannel_set_revocation_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1687 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
1689 /// A payment key to sender for transactions broadcast by counterparty
1691 pub extern "C" fn AcceptChannel_get_payment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1692 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_point;
1693 crate::c_types::PublicKey::from_rust(&inner_val)
1695 /// A payment key to sender for transactions broadcast by counterparty
1697 pub extern "C" fn AcceptChannel_set_payment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1698 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_point = val.into_rust();
1700 /// Used to derive a payment key to sender for transactions broadcast by sender
1702 pub extern "C" fn AcceptChannel_get_delayed_payment_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1703 let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
1704 crate::c_types::PublicKey::from_rust(&inner_val)
1706 /// Used to derive a payment key to sender for transactions broadcast by sender
1708 pub extern "C" fn AcceptChannel_set_delayed_payment_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1709 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
1711 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
1713 pub extern "C" fn AcceptChannel_get_htlc_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1714 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
1715 crate::c_types::PublicKey::from_rust(&inner_val)
1717 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
1719 pub extern "C" fn AcceptChannel_set_htlc_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1720 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
1722 /// The first to-be-broadcast-by-sender transaction's per commitment point
1724 pub extern "C" fn AcceptChannel_get_first_per_commitment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1725 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
1726 crate::c_types::PublicKey::from_rust(&inner_val)
1728 /// The first to-be-broadcast-by-sender transaction's per commitment point
1730 pub extern "C" fn AcceptChannel_set_first_per_commitment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1731 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
1733 /// A request to pre-set the to-sender output's scriptPubkey for when we collaboratively close
1735 pub extern "C" fn AcceptChannel_get_shutdown_scriptpubkey(this_ptr: &AcceptChannel) -> crate::c_types::derived::COption_CVec_u8ZZ {
1736 let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey;
1737 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().into_bytes().into() }) };
1740 /// A request to pre-set the to-sender output's scriptPubkey for when we collaboratively close
1742 pub extern "C" fn AcceptChannel_set_shutdown_scriptpubkey(this_ptr: &mut AcceptChannel, mut val: crate::c_types::derived::COption_CVec_u8ZZ) {
1743 let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ val_opt.take() }.into_rust()) }})} };
1744 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val;
1746 /// The channel type that this channel will represent.
1748 /// If this is `None`, we derive the channel type from the intersection of
1749 /// our feature bits with our counterparty's feature bits from the [`Init`] message.
1750 /// This is required to match the equivalent field in [`OpenChannel::channel_type`].
1752 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1754 pub extern "C" fn AcceptChannel_get_channel_type(this_ptr: &AcceptChannel) -> crate::lightning::ln::features::ChannelTypeFeatures {
1755 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1756 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 };
1759 /// The channel type that this channel will represent.
1761 /// If this is `None`, we derive the channel type from the intersection of
1762 /// our feature bits with our counterparty's feature bits from the [`Init`] message.
1763 /// This is required to match the equivalent field in [`OpenChannel::channel_type`].
1765 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1767 pub extern "C" fn AcceptChannel_set_channel_type(this_ptr: &mut AcceptChannel, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1768 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1769 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1771 /// Constructs a new AcceptChannel given each field
1773 /// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
1776 pub extern "C" fn AcceptChannel_new(mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut channel_reserve_satoshis_arg: u64, mut htlc_minimum_msat_arg: u64, mut minimum_depth_arg: u32, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16, mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_point_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey, mut first_per_commitment_point_arg: crate::c_types::PublicKey, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_CVec_u8ZZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures) -> AcceptChannel {
1777 let mut local_shutdown_scriptpubkey_arg = { /*shutdown_scriptpubkey_arg*/ let shutdown_scriptpubkey_arg_opt = shutdown_scriptpubkey_arg; if shutdown_scriptpubkey_arg_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} };
1778 let mut local_channel_type_arg = if channel_type_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_type_arg.take_inner()) } }) };
1779 AcceptChannel { inner: ObjOps::heap_alloc(nativeAcceptChannel {
1780 temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_arg.data),
1781 dust_limit_satoshis: dust_limit_satoshis_arg,
1782 max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg,
1783 channel_reserve_satoshis: channel_reserve_satoshis_arg,
1784 htlc_minimum_msat: htlc_minimum_msat_arg,
1785 minimum_depth: minimum_depth_arg,
1786 to_self_delay: to_self_delay_arg,
1787 max_accepted_htlcs: max_accepted_htlcs_arg,
1788 funding_pubkey: funding_pubkey_arg.into_rust(),
1789 revocation_basepoint: revocation_basepoint_arg.into_rust(),
1790 payment_point: payment_point_arg.into_rust(),
1791 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
1792 htlc_basepoint: htlc_basepoint_arg.into_rust(),
1793 first_per_commitment_point: first_per_commitment_point_arg.into_rust(),
1794 shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg,
1795 channel_type: local_channel_type_arg,
1796 }), is_owned: true }
1798 impl Clone for AcceptChannel {
1799 fn clone(&self) -> Self {
1801 inner: if <*mut nativeAcceptChannel>::is_null(self.inner) { core::ptr::null_mut() } else {
1802 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1808 /// Used only if an object of this type is returned as a trait impl by a method
1809 pub(crate) extern "C" fn AcceptChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
1810 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAcceptChannel)).clone() })) as *mut c_void
1813 /// Creates a copy of the AcceptChannel
1814 pub extern "C" fn AcceptChannel_clone(orig: &AcceptChannel) -> AcceptChannel {
1817 /// Checks if two AcceptChannels contain equal inner contents.
1818 /// This ignores pointers and is_owned flags and looks at the values in fields.
1819 /// Two objects with NULL inner values will be considered "equal" here.
1821 pub extern "C" fn AcceptChannel_eq(a: &AcceptChannel, b: &AcceptChannel) -> bool {
1822 if a.inner == b.inner { return true; }
1823 if a.inner.is_null() || b.inner.is_null() { return false; }
1824 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1827 use lightning::ln::msgs::AcceptChannelV2 as nativeAcceptChannelV2Import;
1828 pub(crate) type nativeAcceptChannelV2 = nativeAcceptChannelV2Import;
1830 /// An accept_channel2 message to be sent by or received from the channel accepter.
1832 /// Used in V2 channel establishment
1836 pub struct AcceptChannelV2 {
1837 /// A pointer to the opaque Rust object.
1839 /// Nearly everywhere, inner must be non-null, however in places where
1840 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1841 pub inner: *mut nativeAcceptChannelV2,
1842 /// Indicates that this is the only struct which contains the same pointer.
1844 /// Rust functions which take ownership of an object provided via an argument require
1845 /// this to be true and invalidate the object pointed to by inner.
1849 impl Drop for AcceptChannelV2 {
1850 fn drop(&mut self) {
1851 if self.is_owned && !<*mut nativeAcceptChannelV2>::is_null(self.inner) {
1852 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1856 /// Frees any resources used by the AcceptChannelV2, if is_owned is set and inner is non-NULL.
1858 pub extern "C" fn AcceptChannelV2_free(this_obj: AcceptChannelV2) { }
1860 /// Used only if an object of this type is returned as a trait impl by a method
1861 pub(crate) extern "C" fn AcceptChannelV2_free_void(this_ptr: *mut c_void) {
1862 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAcceptChannelV2) };
1865 impl AcceptChannelV2 {
1866 pub(crate) fn get_native_ref(&self) -> &'static nativeAcceptChannelV2 {
1867 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1869 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAcceptChannelV2 {
1870 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1872 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1873 pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannelV2 {
1874 assert!(self.is_owned);
1875 let ret = ObjOps::untweak_ptr(self.inner);
1876 self.inner = core::ptr::null_mut();
1880 /// The same `temporary_channel_id` received from the initiator's `open_channel2` message.
1882 pub extern "C" fn AcceptChannelV2_get_temporary_channel_id(this_ptr: &AcceptChannelV2) -> *const [u8; 32] {
1883 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
1886 /// The same `temporary_channel_id` received from the initiator's `open_channel2` message.
1888 pub extern "C" fn AcceptChannelV2_set_temporary_channel_id(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::ThirtyTwoBytes) {
1889 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = ::lightning::ln::ChannelId(val.data);
1891 /// Part of the channel value contributed by the channel acceptor
1893 pub extern "C" fn AcceptChannelV2_get_funding_satoshis(this_ptr: &AcceptChannelV2) -> u64 {
1894 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
1897 /// Part of the channel value contributed by the channel acceptor
1899 pub extern "C" fn AcceptChannelV2_set_funding_satoshis(this_ptr: &mut AcceptChannelV2, mut val: u64) {
1900 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
1902 /// The threshold below which outputs on transactions broadcast by the channel acceptor will be
1905 pub extern "C" fn AcceptChannelV2_get_dust_limit_satoshis(this_ptr: &AcceptChannelV2) -> u64 {
1906 let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
1909 /// The threshold below which outputs on transactions broadcast by the channel acceptor will be
1912 pub extern "C" fn AcceptChannelV2_set_dust_limit_satoshis(this_ptr: &mut AcceptChannelV2, mut val: u64) {
1913 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
1915 /// The maximum inbound HTLC value in flight towards channel acceptor, in milli-satoshi
1917 pub extern "C" fn AcceptChannelV2_get_max_htlc_value_in_flight_msat(this_ptr: &AcceptChannelV2) -> u64 {
1918 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
1921 /// The maximum inbound HTLC value in flight towards channel acceptor, in milli-satoshi
1923 pub extern "C" fn AcceptChannelV2_set_max_htlc_value_in_flight_msat(this_ptr: &mut AcceptChannelV2, mut val: u64) {
1924 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
1926 /// The minimum HTLC size incoming to channel acceptor, in milli-satoshi
1928 pub extern "C" fn AcceptChannelV2_get_htlc_minimum_msat(this_ptr: &AcceptChannelV2) -> u64 {
1929 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
1932 /// The minimum HTLC size incoming to channel acceptor, in milli-satoshi
1934 pub extern "C" fn AcceptChannelV2_set_htlc_minimum_msat(this_ptr: &mut AcceptChannelV2, mut val: u64) {
1935 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
1937 /// Minimum depth of the funding transaction before the channel is considered open
1939 pub extern "C" fn AcceptChannelV2_get_minimum_depth(this_ptr: &AcceptChannelV2) -> u32 {
1940 let mut inner_val = &mut this_ptr.get_native_mut_ref().minimum_depth;
1943 /// Minimum depth of the funding transaction before the channel is considered open
1945 pub extern "C" fn AcceptChannelV2_set_minimum_depth(this_ptr: &mut AcceptChannelV2, mut val: u32) {
1946 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.minimum_depth = val;
1948 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1949 /// broadcast a commitment transaction
1951 pub extern "C" fn AcceptChannelV2_get_to_self_delay(this_ptr: &AcceptChannelV2) -> u16 {
1952 let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
1955 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
1956 /// broadcast a commitment transaction
1958 pub extern "C" fn AcceptChannelV2_set_to_self_delay(this_ptr: &mut AcceptChannelV2, mut val: u16) {
1959 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
1961 /// The maximum number of inbound HTLCs towards channel acceptor
1963 pub extern "C" fn AcceptChannelV2_get_max_accepted_htlcs(this_ptr: &AcceptChannelV2) -> u16 {
1964 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
1967 /// The maximum number of inbound HTLCs towards channel acceptor
1969 pub extern "C" fn AcceptChannelV2_set_max_accepted_htlcs(this_ptr: &mut AcceptChannelV2, mut val: u16) {
1970 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
1972 /// The channel acceptor's key controlling the funding transaction
1974 pub extern "C" fn AcceptChannelV2_get_funding_pubkey(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
1975 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
1976 crate::c_types::PublicKey::from_rust(&inner_val)
1978 /// The channel acceptor's key controlling the funding transaction
1980 pub extern "C" fn AcceptChannelV2_set_funding_pubkey(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
1981 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
1983 /// Used to derive a revocation key for transactions broadcast by counterparty
1985 pub extern "C" fn AcceptChannelV2_get_revocation_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
1986 let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
1987 crate::c_types::PublicKey::from_rust(&inner_val)
1989 /// Used to derive a revocation key for transactions broadcast by counterparty
1991 pub extern "C" fn AcceptChannelV2_set_revocation_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
1992 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
1994 /// A payment key to channel acceptor for transactions broadcast by counterparty
1996 pub extern "C" fn AcceptChannelV2_get_payment_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
1997 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_basepoint;
1998 crate::c_types::PublicKey::from_rust(&inner_val)
2000 /// A payment key to channel acceptor for transactions broadcast by counterparty
2002 pub extern "C" fn AcceptChannelV2_set_payment_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2003 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_basepoint = val.into_rust();
2005 /// Used to derive a payment key to channel acceptor for transactions broadcast by channel
2008 pub extern "C" fn AcceptChannelV2_get_delayed_payment_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2009 let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
2010 crate::c_types::PublicKey::from_rust(&inner_val)
2012 /// Used to derive a payment key to channel acceptor for transactions broadcast by channel
2015 pub extern "C" fn AcceptChannelV2_set_delayed_payment_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2016 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
2018 /// Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty
2020 pub extern "C" fn AcceptChannelV2_get_htlc_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2021 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
2022 crate::c_types::PublicKey::from_rust(&inner_val)
2024 /// Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty
2026 pub extern "C" fn AcceptChannelV2_set_htlc_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2027 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
2029 /// The first to-be-broadcast-by-channel-acceptor transaction's per commitment point
2031 pub extern "C" fn AcceptChannelV2_get_first_per_commitment_point(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2032 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
2033 crate::c_types::PublicKey::from_rust(&inner_val)
2035 /// The first to-be-broadcast-by-channel-acceptor transaction's per commitment point
2037 pub extern "C" fn AcceptChannelV2_set_first_per_commitment_point(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2038 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
2040 /// The second to-be-broadcast-by-channel-acceptor transaction's per commitment point
2042 pub extern "C" fn AcceptChannelV2_get_second_per_commitment_point(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey {
2043 let mut inner_val = &mut this_ptr.get_native_mut_ref().second_per_commitment_point;
2044 crate::c_types::PublicKey::from_rust(&inner_val)
2046 /// The second to-be-broadcast-by-channel-acceptor transaction's per commitment point
2048 pub extern "C" fn AcceptChannelV2_set_second_per_commitment_point(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) {
2049 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.second_per_commitment_point = val.into_rust();
2051 /// Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we
2052 /// collaboratively close
2054 pub extern "C" fn AcceptChannelV2_get_shutdown_scriptpubkey(this_ptr: &AcceptChannelV2) -> crate::c_types::derived::COption_CVec_u8ZZ {
2055 let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey;
2056 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().into_bytes().into() }) };
2059 /// Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we
2060 /// collaboratively close
2062 pub extern "C" fn AcceptChannelV2_set_shutdown_scriptpubkey(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::derived::COption_CVec_u8ZZ) {
2063 let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ val_opt.take() }.into_rust()) }})} };
2064 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val;
2066 /// The channel type that this channel will represent. If none is set, we derive the channel
2067 /// type from the intersection of our feature bits with our counterparty's feature bits from
2068 /// the Init message.
2070 /// This is required to match the equivalent field in [`OpenChannelV2::channel_type`].
2072 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
2074 pub extern "C" fn AcceptChannelV2_get_channel_type(this_ptr: &AcceptChannelV2) -> crate::lightning::ln::features::ChannelTypeFeatures {
2075 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
2076 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 };
2079 /// The channel type that this channel will represent. If none is set, we derive the channel
2080 /// type from the intersection of our feature bits with our counterparty's feature bits from
2081 /// the Init message.
2083 /// This is required to match the equivalent field in [`OpenChannelV2::channel_type`].
2085 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
2087 pub extern "C" fn AcceptChannelV2_set_channel_type(this_ptr: &mut AcceptChannelV2, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
2088 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
2089 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
2091 /// Optionally, a requirement that only confirmed inputs can be added
2093 pub extern "C" fn AcceptChannelV2_get_require_confirmed_inputs(this_ptr: &AcceptChannelV2) -> crate::c_types::derived::COption_NoneZ {
2094 let mut inner_val = &mut this_ptr.get_native_mut_ref().require_confirmed_inputs;
2095 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_NoneZ::None } else { crate::c_types::derived::COption_NoneZ::Some /* { () /**/ } */ };
2098 /// Optionally, a requirement that only confirmed inputs can be added
2100 pub extern "C" fn AcceptChannelV2_set_require_confirmed_inputs(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::derived::COption_NoneZ) {
2101 let mut local_val = if val.is_some() { Some( { () /*val.take()*/ }) } else { None };
2102 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.require_confirmed_inputs = local_val;
2104 /// Constructs a new AcceptChannelV2 given each field
2106 /// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
2109 pub extern "C" fn AcceptChannelV2_new(mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_satoshis_arg: u64, mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut htlc_minimum_msat_arg: u64, mut minimum_depth_arg: u32, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16, mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_basepoint_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey, mut first_per_commitment_point_arg: crate::c_types::PublicKey, mut second_per_commitment_point_arg: crate::c_types::PublicKey, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_CVec_u8ZZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures, mut require_confirmed_inputs_arg: crate::c_types::derived::COption_NoneZ) -> AcceptChannelV2 {
2110 let mut local_shutdown_scriptpubkey_arg = { /*shutdown_scriptpubkey_arg*/ let shutdown_scriptpubkey_arg_opt = shutdown_scriptpubkey_arg; if shutdown_scriptpubkey_arg_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} };
2111 let mut local_channel_type_arg = if channel_type_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_type_arg.take_inner()) } }) };
2112 let mut local_require_confirmed_inputs_arg = if require_confirmed_inputs_arg.is_some() { Some( { () /*require_confirmed_inputs_arg.take()*/ }) } else { None };
2113 AcceptChannelV2 { inner: ObjOps::heap_alloc(nativeAcceptChannelV2 {
2114 temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_arg.data),
2115 funding_satoshis: funding_satoshis_arg,
2116 dust_limit_satoshis: dust_limit_satoshis_arg,
2117 max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg,
2118 htlc_minimum_msat: htlc_minimum_msat_arg,
2119 minimum_depth: minimum_depth_arg,
2120 to_self_delay: to_self_delay_arg,
2121 max_accepted_htlcs: max_accepted_htlcs_arg,
2122 funding_pubkey: funding_pubkey_arg.into_rust(),
2123 revocation_basepoint: revocation_basepoint_arg.into_rust(),
2124 payment_basepoint: payment_basepoint_arg.into_rust(),
2125 delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(),
2126 htlc_basepoint: htlc_basepoint_arg.into_rust(),
2127 first_per_commitment_point: first_per_commitment_point_arg.into_rust(),
2128 second_per_commitment_point: second_per_commitment_point_arg.into_rust(),
2129 shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg,
2130 channel_type: local_channel_type_arg,
2131 require_confirmed_inputs: local_require_confirmed_inputs_arg,
2132 }), is_owned: true }
2134 impl Clone for AcceptChannelV2 {
2135 fn clone(&self) -> Self {
2137 inner: if <*mut nativeAcceptChannelV2>::is_null(self.inner) { core::ptr::null_mut() } else {
2138 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2144 /// Used only if an object of this type is returned as a trait impl by a method
2145 pub(crate) extern "C" fn AcceptChannelV2_clone_void(this_ptr: *const c_void) -> *mut c_void {
2146 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAcceptChannelV2)).clone() })) as *mut c_void
2149 /// Creates a copy of the AcceptChannelV2
2150 pub extern "C" fn AcceptChannelV2_clone(orig: &AcceptChannelV2) -> AcceptChannelV2 {
2153 /// Checks if two AcceptChannelV2s contain equal inner contents.
2154 /// This ignores pointers and is_owned flags and looks at the values in fields.
2155 /// Two objects with NULL inner values will be considered "equal" here.
2157 pub extern "C" fn AcceptChannelV2_eq(a: &AcceptChannelV2, b: &AcceptChannelV2) -> bool {
2158 if a.inner == b.inner { return true; }
2159 if a.inner.is_null() || b.inner.is_null() { return false; }
2160 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2163 use lightning::ln::msgs::FundingCreated as nativeFundingCreatedImport;
2164 pub(crate) type nativeFundingCreated = nativeFundingCreatedImport;
2166 /// A [`funding_created`] message to be sent to or received from a peer.
2168 /// Used in V1 channel establishment
2170 /// [`funding_created`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_created-message
2173 pub struct FundingCreated {
2174 /// A pointer to the opaque Rust object.
2176 /// Nearly everywhere, inner must be non-null, however in places where
2177 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2178 pub inner: *mut nativeFundingCreated,
2179 /// Indicates that this is the only struct which contains the same pointer.
2181 /// Rust functions which take ownership of an object provided via an argument require
2182 /// this to be true and invalidate the object pointed to by inner.
2186 impl Drop for FundingCreated {
2187 fn drop(&mut self) {
2188 if self.is_owned && !<*mut nativeFundingCreated>::is_null(self.inner) {
2189 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2193 /// Frees any resources used by the FundingCreated, if is_owned is set and inner is non-NULL.
2195 pub extern "C" fn FundingCreated_free(this_obj: FundingCreated) { }
2197 /// Used only if an object of this type is returned as a trait impl by a method
2198 pub(crate) extern "C" fn FundingCreated_free_void(this_ptr: *mut c_void) {
2199 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeFundingCreated) };
2202 impl FundingCreated {
2203 pub(crate) fn get_native_ref(&self) -> &'static nativeFundingCreated {
2204 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2206 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingCreated {
2207 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2209 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2210 pub(crate) fn take_inner(mut self) -> *mut nativeFundingCreated {
2211 assert!(self.is_owned);
2212 let ret = ObjOps::untweak_ptr(self.inner);
2213 self.inner = core::ptr::null_mut();
2217 /// A temporary channel ID, until the funding is established
2219 pub extern "C" fn FundingCreated_get_temporary_channel_id(this_ptr: &FundingCreated) -> *const [u8; 32] {
2220 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
2223 /// A temporary channel ID, until the funding is established
2225 pub extern "C" fn FundingCreated_set_temporary_channel_id(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
2226 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = ::lightning::ln::ChannelId(val.data);
2228 /// The funding transaction ID
2230 pub extern "C" fn FundingCreated_get_funding_txid(this_ptr: &FundingCreated) -> *const [u8; 32] {
2231 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_txid;
2232 inner_val.as_inner()
2234 /// The funding transaction ID
2236 pub extern "C" fn FundingCreated_set_funding_txid(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
2237 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_txid = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
2239 /// The specific output index funding this channel
2241 pub extern "C" fn FundingCreated_get_funding_output_index(this_ptr: &FundingCreated) -> u16 {
2242 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_index;
2245 /// The specific output index funding this channel
2247 pub extern "C" fn FundingCreated_set_funding_output_index(this_ptr: &mut FundingCreated, mut val: u16) {
2248 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_index = val;
2250 /// The signature of the channel initiator (funder) on the initial commitment transaction
2252 pub extern "C" fn FundingCreated_get_signature(this_ptr: &FundingCreated) -> crate::c_types::ECDSASignature {
2253 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
2254 crate::c_types::ECDSASignature::from_rust(&inner_val)
2256 /// The signature of the channel initiator (funder) on the initial commitment transaction
2258 pub extern "C" fn FundingCreated_set_signature(this_ptr: &mut FundingCreated, mut val: crate::c_types::ECDSASignature) {
2259 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
2261 /// Constructs a new FundingCreated given each field
2264 pub extern "C" fn FundingCreated_new(mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_txid_arg: crate::c_types::ThirtyTwoBytes, mut funding_output_index_arg: u16, mut signature_arg: crate::c_types::ECDSASignature) -> FundingCreated {
2265 FundingCreated { inner: ObjOps::heap_alloc(nativeFundingCreated {
2266 temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_arg.data),
2267 funding_txid: ::bitcoin::hash_types::Txid::from_slice(&funding_txid_arg.data[..]).unwrap(),
2268 funding_output_index: funding_output_index_arg,
2269 signature: signature_arg.into_rust(),
2270 }), is_owned: true }
2272 impl Clone for FundingCreated {
2273 fn clone(&self) -> Self {
2275 inner: if <*mut nativeFundingCreated>::is_null(self.inner) { core::ptr::null_mut() } else {
2276 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2282 /// Used only if an object of this type is returned as a trait impl by a method
2283 pub(crate) extern "C" fn FundingCreated_clone_void(this_ptr: *const c_void) -> *mut c_void {
2284 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingCreated)).clone() })) as *mut c_void
2287 /// Creates a copy of the FundingCreated
2288 pub extern "C" fn FundingCreated_clone(orig: &FundingCreated) -> FundingCreated {
2291 /// Checks if two FundingCreateds contain equal inner contents.
2292 /// This ignores pointers and is_owned flags and looks at the values in fields.
2293 /// Two objects with NULL inner values will be considered "equal" here.
2295 pub extern "C" fn FundingCreated_eq(a: &FundingCreated, b: &FundingCreated) -> bool {
2296 if a.inner == b.inner { return true; }
2297 if a.inner.is_null() || b.inner.is_null() { return false; }
2298 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2301 use lightning::ln::msgs::FundingSigned as nativeFundingSignedImport;
2302 pub(crate) type nativeFundingSigned = nativeFundingSignedImport;
2304 /// A [`funding_signed`] message to be sent to or received from a peer.
2306 /// Used in V1 channel establishment
2308 /// [`funding_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_signed-message
2311 pub struct FundingSigned {
2312 /// A pointer to the opaque Rust object.
2314 /// Nearly everywhere, inner must be non-null, however in places where
2315 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2316 pub inner: *mut nativeFundingSigned,
2317 /// Indicates that this is the only struct which contains the same pointer.
2319 /// Rust functions which take ownership of an object provided via an argument require
2320 /// this to be true and invalidate the object pointed to by inner.
2324 impl Drop for FundingSigned {
2325 fn drop(&mut self) {
2326 if self.is_owned && !<*mut nativeFundingSigned>::is_null(self.inner) {
2327 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2331 /// Frees any resources used by the FundingSigned, if is_owned is set and inner is non-NULL.
2333 pub extern "C" fn FundingSigned_free(this_obj: FundingSigned) { }
2335 /// Used only if an object of this type is returned as a trait impl by a method
2336 pub(crate) extern "C" fn FundingSigned_free_void(this_ptr: *mut c_void) {
2337 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeFundingSigned) };
2340 impl FundingSigned {
2341 pub(crate) fn get_native_ref(&self) -> &'static nativeFundingSigned {
2342 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2344 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingSigned {
2345 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2347 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2348 pub(crate) fn take_inner(mut self) -> *mut nativeFundingSigned {
2349 assert!(self.is_owned);
2350 let ret = ObjOps::untweak_ptr(self.inner);
2351 self.inner = core::ptr::null_mut();
2357 pub extern "C" fn FundingSigned_get_channel_id(this_ptr: &FundingSigned) -> *const [u8; 32] {
2358 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2363 pub extern "C" fn FundingSigned_set_channel_id(this_ptr: &mut FundingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
2364 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
2366 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
2368 pub extern "C" fn FundingSigned_get_signature(this_ptr: &FundingSigned) -> crate::c_types::ECDSASignature {
2369 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
2370 crate::c_types::ECDSASignature::from_rust(&inner_val)
2372 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
2374 pub extern "C" fn FundingSigned_set_signature(this_ptr: &mut FundingSigned, mut val: crate::c_types::ECDSASignature) {
2375 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
2377 /// Constructs a new FundingSigned given each field
2380 pub extern "C" fn FundingSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut signature_arg: crate::c_types::ECDSASignature) -> FundingSigned {
2381 FundingSigned { inner: ObjOps::heap_alloc(nativeFundingSigned {
2382 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
2383 signature: signature_arg.into_rust(),
2384 }), is_owned: true }
2386 impl Clone for FundingSigned {
2387 fn clone(&self) -> Self {
2389 inner: if <*mut nativeFundingSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
2390 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2396 /// Used only if an object of this type is returned as a trait impl by a method
2397 pub(crate) extern "C" fn FundingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
2398 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingSigned)).clone() })) as *mut c_void
2401 /// Creates a copy of the FundingSigned
2402 pub extern "C" fn FundingSigned_clone(orig: &FundingSigned) -> FundingSigned {
2405 /// Checks if two FundingSigneds contain equal inner contents.
2406 /// This ignores pointers and is_owned flags and looks at the values in fields.
2407 /// Two objects with NULL inner values will be considered "equal" here.
2409 pub extern "C" fn FundingSigned_eq(a: &FundingSigned, b: &FundingSigned) -> bool {
2410 if a.inner == b.inner { return true; }
2411 if a.inner.is_null() || b.inner.is_null() { return false; }
2412 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2415 use lightning::ln::msgs::ChannelReady as nativeChannelReadyImport;
2416 pub(crate) type nativeChannelReady = nativeChannelReadyImport;
2418 /// A [`channel_ready`] message to be sent to or received from a peer.
2420 /// [`channel_ready`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-channel_ready-message
2423 pub struct ChannelReady {
2424 /// A pointer to the opaque Rust object.
2426 /// Nearly everywhere, inner must be non-null, however in places where
2427 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2428 pub inner: *mut nativeChannelReady,
2429 /// Indicates that this is the only struct which contains the same pointer.
2431 /// Rust functions which take ownership of an object provided via an argument require
2432 /// this to be true and invalidate the object pointed to by inner.
2436 impl Drop for ChannelReady {
2437 fn drop(&mut self) {
2438 if self.is_owned && !<*mut nativeChannelReady>::is_null(self.inner) {
2439 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2443 /// Frees any resources used by the ChannelReady, if is_owned is set and inner is non-NULL.
2445 pub extern "C" fn ChannelReady_free(this_obj: ChannelReady) { }
2447 /// Used only if an object of this type is returned as a trait impl by a method
2448 pub(crate) extern "C" fn ChannelReady_free_void(this_ptr: *mut c_void) {
2449 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelReady) };
2453 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelReady {
2454 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2456 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelReady {
2457 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2459 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2460 pub(crate) fn take_inner(mut self) -> *mut nativeChannelReady {
2461 assert!(self.is_owned);
2462 let ret = ObjOps::untweak_ptr(self.inner);
2463 self.inner = core::ptr::null_mut();
2469 pub extern "C" fn ChannelReady_get_channel_id(this_ptr: &ChannelReady) -> *const [u8; 32] {
2470 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2475 pub extern "C" fn ChannelReady_set_channel_id(this_ptr: &mut ChannelReady, mut val: crate::c_types::ThirtyTwoBytes) {
2476 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
2478 /// The per-commitment point of the second commitment transaction
2480 pub extern "C" fn ChannelReady_get_next_per_commitment_point(this_ptr: &ChannelReady) -> crate::c_types::PublicKey {
2481 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
2482 crate::c_types::PublicKey::from_rust(&inner_val)
2484 /// The per-commitment point of the second commitment transaction
2486 pub extern "C" fn ChannelReady_set_next_per_commitment_point(this_ptr: &mut ChannelReady, mut val: crate::c_types::PublicKey) {
2487 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
2489 /// If set, provides a `short_channel_id` alias for this channel.
2491 /// The sender will accept payments to be forwarded over this SCID and forward them to this
2492 /// messages' recipient.
2494 pub extern "C" fn ChannelReady_get_short_channel_id_alias(this_ptr: &ChannelReady) -> crate::c_types::derived::COption_u64Z {
2495 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id_alias;
2496 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() }) };
2499 /// If set, provides a `short_channel_id` alias for this channel.
2501 /// The sender will accept payments to be forwarded over this SCID and forward them to this
2502 /// messages' recipient.
2504 pub extern "C" fn ChannelReady_set_short_channel_id_alias(this_ptr: &mut ChannelReady, mut val: crate::c_types::derived::COption_u64Z) {
2505 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
2506 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id_alias = local_val;
2508 /// Constructs a new ChannelReady given each field
2511 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 {
2512 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 };
2513 ChannelReady { inner: ObjOps::heap_alloc(nativeChannelReady {
2514 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
2515 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
2516 short_channel_id_alias: local_short_channel_id_alias_arg,
2517 }), is_owned: true }
2519 impl Clone for ChannelReady {
2520 fn clone(&self) -> Self {
2522 inner: if <*mut nativeChannelReady>::is_null(self.inner) { core::ptr::null_mut() } else {
2523 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2529 /// Used only if an object of this type is returned as a trait impl by a method
2530 pub(crate) extern "C" fn ChannelReady_clone_void(this_ptr: *const c_void) -> *mut c_void {
2531 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelReady)).clone() })) as *mut c_void
2534 /// Creates a copy of the ChannelReady
2535 pub extern "C" fn ChannelReady_clone(orig: &ChannelReady) -> ChannelReady {
2538 /// Checks if two ChannelReadys contain equal inner contents.
2539 /// This ignores pointers and is_owned flags and looks at the values in fields.
2540 /// Two objects with NULL inner values will be considered "equal" here.
2542 pub extern "C" fn ChannelReady_eq(a: &ChannelReady, b: &ChannelReady) -> bool {
2543 if a.inner == b.inner { return true; }
2544 if a.inner.is_null() || b.inner.is_null() { return false; }
2545 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2548 use lightning::ln::msgs::TxAddInput as nativeTxAddInputImport;
2549 pub(crate) type nativeTxAddInput = nativeTxAddInputImport;
2551 /// A tx_add_input message for adding an input during interactive transaction construction
2555 pub struct TxAddInput {
2556 /// A pointer to the opaque Rust object.
2558 /// Nearly everywhere, inner must be non-null, however in places where
2559 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2560 pub inner: *mut nativeTxAddInput,
2561 /// Indicates that this is the only struct which contains the same pointer.
2563 /// Rust functions which take ownership of an object provided via an argument require
2564 /// this to be true and invalidate the object pointed to by inner.
2568 impl Drop for TxAddInput {
2569 fn drop(&mut self) {
2570 if self.is_owned && !<*mut nativeTxAddInput>::is_null(self.inner) {
2571 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2575 /// Frees any resources used by the TxAddInput, if is_owned is set and inner is non-NULL.
2577 pub extern "C" fn TxAddInput_free(this_obj: TxAddInput) { }
2579 /// Used only if an object of this type is returned as a trait impl by a method
2580 pub(crate) extern "C" fn TxAddInput_free_void(this_ptr: *mut c_void) {
2581 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAddInput) };
2585 pub(crate) fn get_native_ref(&self) -> &'static nativeTxAddInput {
2586 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2588 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAddInput {
2589 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2591 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2592 pub(crate) fn take_inner(mut self) -> *mut nativeTxAddInput {
2593 assert!(self.is_owned);
2594 let ret = ObjOps::untweak_ptr(self.inner);
2595 self.inner = core::ptr::null_mut();
2601 pub extern "C" fn TxAddInput_get_channel_id(this_ptr: &TxAddInput) -> *const [u8; 32] {
2602 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2607 pub extern "C" fn TxAddInput_set_channel_id(this_ptr: &mut TxAddInput, mut val: crate::c_types::ThirtyTwoBytes) {
2608 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
2610 /// A randomly chosen unique identifier for this input, which is even for initiators and odd for
2613 pub extern "C" fn TxAddInput_get_serial_id(this_ptr: &TxAddInput) -> u64 {
2614 let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
2617 /// A randomly chosen unique identifier for this input, which is even for initiators and odd for
2620 pub extern "C" fn TxAddInput_set_serial_id(this_ptr: &mut TxAddInput, mut val: u64) {
2621 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
2623 /// Serialized transaction that contains the output this input spends to verify that it is non
2626 pub extern "C" fn TxAddInput_get_prevtx(this_ptr: &TxAddInput) -> crate::lightning::util::ser::TransactionU16LenLimited {
2627 let mut inner_val = &mut this_ptr.get_native_mut_ref().prevtx;
2628 crate::lightning::util::ser::TransactionU16LenLimited { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::util::ser::TransactionU16LenLimited<>) as *mut _) }, is_owned: false }
2630 /// Serialized transaction that contains the output this input spends to verify that it is non
2633 pub extern "C" fn TxAddInput_set_prevtx(this_ptr: &mut TxAddInput, mut val: crate::lightning::util::ser::TransactionU16LenLimited) {
2634 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.prevtx = *unsafe { Box::from_raw(val.take_inner()) };
2636 /// The index of the output being spent
2638 pub extern "C" fn TxAddInput_get_prevtx_out(this_ptr: &TxAddInput) -> u32 {
2639 let mut inner_val = &mut this_ptr.get_native_mut_ref().prevtx_out;
2642 /// The index of the output being spent
2644 pub extern "C" fn TxAddInput_set_prevtx_out(this_ptr: &mut TxAddInput, mut val: u32) {
2645 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.prevtx_out = val;
2647 /// The sequence number of this input
2649 pub extern "C" fn TxAddInput_get_sequence(this_ptr: &TxAddInput) -> u32 {
2650 let mut inner_val = &mut this_ptr.get_native_mut_ref().sequence;
2653 /// The sequence number of this input
2655 pub extern "C" fn TxAddInput_set_sequence(this_ptr: &mut TxAddInput, mut val: u32) {
2656 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sequence = val;
2658 /// Constructs a new TxAddInput given each field
2661 pub extern "C" fn TxAddInput_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut serial_id_arg: u64, mut prevtx_arg: crate::lightning::util::ser::TransactionU16LenLimited, mut prevtx_out_arg: u32, mut sequence_arg: u32) -> TxAddInput {
2662 TxAddInput { inner: ObjOps::heap_alloc(nativeTxAddInput {
2663 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
2664 serial_id: serial_id_arg,
2665 prevtx: *unsafe { Box::from_raw(prevtx_arg.take_inner()) },
2666 prevtx_out: prevtx_out_arg,
2667 sequence: sequence_arg,
2668 }), is_owned: true }
2670 impl Clone for TxAddInput {
2671 fn clone(&self) -> Self {
2673 inner: if <*mut nativeTxAddInput>::is_null(self.inner) { core::ptr::null_mut() } else {
2674 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2680 /// Used only if an object of this type is returned as a trait impl by a method
2681 pub(crate) extern "C" fn TxAddInput_clone_void(this_ptr: *const c_void) -> *mut c_void {
2682 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxAddInput)).clone() })) as *mut c_void
2685 /// Creates a copy of the TxAddInput
2686 pub extern "C" fn TxAddInput_clone(orig: &TxAddInput) -> TxAddInput {
2689 /// Checks if two TxAddInputs contain equal inner contents.
2690 /// This ignores pointers and is_owned flags and looks at the values in fields.
2691 /// Two objects with NULL inner values will be considered "equal" here.
2693 pub extern "C" fn TxAddInput_eq(a: &TxAddInput, b: &TxAddInput) -> bool {
2694 if a.inner == b.inner { return true; }
2695 if a.inner.is_null() || b.inner.is_null() { return false; }
2696 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2699 use lightning::ln::msgs::TxAddOutput as nativeTxAddOutputImport;
2700 pub(crate) type nativeTxAddOutput = nativeTxAddOutputImport;
2702 /// A tx_add_output message for adding an output during interactive transaction construction.
2706 pub struct TxAddOutput {
2707 /// A pointer to the opaque Rust object.
2709 /// Nearly everywhere, inner must be non-null, however in places where
2710 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2711 pub inner: *mut nativeTxAddOutput,
2712 /// Indicates that this is the only struct which contains the same pointer.
2714 /// Rust functions which take ownership of an object provided via an argument require
2715 /// this to be true and invalidate the object pointed to by inner.
2719 impl Drop for TxAddOutput {
2720 fn drop(&mut self) {
2721 if self.is_owned && !<*mut nativeTxAddOutput>::is_null(self.inner) {
2722 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2726 /// Frees any resources used by the TxAddOutput, if is_owned is set and inner is non-NULL.
2728 pub extern "C" fn TxAddOutput_free(this_obj: TxAddOutput) { }
2730 /// Used only if an object of this type is returned as a trait impl by a method
2731 pub(crate) extern "C" fn TxAddOutput_free_void(this_ptr: *mut c_void) {
2732 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAddOutput) };
2736 pub(crate) fn get_native_ref(&self) -> &'static nativeTxAddOutput {
2737 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2739 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAddOutput {
2740 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2742 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2743 pub(crate) fn take_inner(mut self) -> *mut nativeTxAddOutput {
2744 assert!(self.is_owned);
2745 let ret = ObjOps::untweak_ptr(self.inner);
2746 self.inner = core::ptr::null_mut();
2752 pub extern "C" fn TxAddOutput_get_channel_id(this_ptr: &TxAddOutput) -> *const [u8; 32] {
2753 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2758 pub extern "C" fn TxAddOutput_set_channel_id(this_ptr: &mut TxAddOutput, mut val: crate::c_types::ThirtyTwoBytes) {
2759 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
2761 /// A randomly chosen unique identifier for this output, which is even for initiators and odd for
2764 pub extern "C" fn TxAddOutput_get_serial_id(this_ptr: &TxAddOutput) -> u64 {
2765 let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
2768 /// A randomly chosen unique identifier for this output, which is even for initiators and odd for
2771 pub extern "C" fn TxAddOutput_set_serial_id(this_ptr: &mut TxAddOutput, mut val: u64) {
2772 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
2774 /// The satoshi value of the output
2776 pub extern "C" fn TxAddOutput_get_sats(this_ptr: &TxAddOutput) -> u64 {
2777 let mut inner_val = &mut this_ptr.get_native_mut_ref().sats;
2780 /// The satoshi value of the output
2782 pub extern "C" fn TxAddOutput_set_sats(this_ptr: &mut TxAddOutput, mut val: u64) {
2783 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sats = val;
2785 /// The scriptPubKey for the output
2787 pub extern "C" fn TxAddOutput_get_script(this_ptr: &TxAddOutput) -> crate::c_types::u8slice {
2788 let mut inner_val = &mut this_ptr.get_native_mut_ref().script;
2789 crate::c_types::u8slice::from_slice(&inner_val[..])
2791 /// The scriptPubKey for the output
2793 pub extern "C" fn TxAddOutput_set_script(this_ptr: &mut TxAddOutput, mut val: crate::c_types::derived::CVec_u8Z) {
2794 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.script = ::bitcoin::blockdata::script::Script::from(val.into_rust());
2796 /// Constructs a new TxAddOutput given each field
2799 pub extern "C" fn TxAddOutput_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut serial_id_arg: u64, mut sats_arg: u64, mut script_arg: crate::c_types::derived::CVec_u8Z) -> TxAddOutput {
2800 TxAddOutput { inner: ObjOps::heap_alloc(nativeTxAddOutput {
2801 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
2802 serial_id: serial_id_arg,
2804 script: ::bitcoin::blockdata::script::Script::from(script_arg.into_rust()),
2805 }), is_owned: true }
2807 impl Clone for TxAddOutput {
2808 fn clone(&self) -> Self {
2810 inner: if <*mut nativeTxAddOutput>::is_null(self.inner) { core::ptr::null_mut() } else {
2811 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2817 /// Used only if an object of this type is returned as a trait impl by a method
2818 pub(crate) extern "C" fn TxAddOutput_clone_void(this_ptr: *const c_void) -> *mut c_void {
2819 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxAddOutput)).clone() })) as *mut c_void
2822 /// Creates a copy of the TxAddOutput
2823 pub extern "C" fn TxAddOutput_clone(orig: &TxAddOutput) -> TxAddOutput {
2826 /// Checks if two TxAddOutputs contain equal inner contents.
2827 /// This ignores pointers and is_owned flags and looks at the values in fields.
2828 /// Two objects with NULL inner values will be considered "equal" here.
2830 pub extern "C" fn TxAddOutput_eq(a: &TxAddOutput, b: &TxAddOutput) -> bool {
2831 if a.inner == b.inner { return true; }
2832 if a.inner.is_null() || b.inner.is_null() { return false; }
2833 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2836 use lightning::ln::msgs::TxRemoveInput as nativeTxRemoveInputImport;
2837 pub(crate) type nativeTxRemoveInput = nativeTxRemoveInputImport;
2839 /// A tx_remove_input message for removing an input during interactive transaction construction.
2843 pub struct TxRemoveInput {
2844 /// A pointer to the opaque Rust object.
2846 /// Nearly everywhere, inner must be non-null, however in places where
2847 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2848 pub inner: *mut nativeTxRemoveInput,
2849 /// Indicates that this is the only struct which contains the same pointer.
2851 /// Rust functions which take ownership of an object provided via an argument require
2852 /// this to be true and invalidate the object pointed to by inner.
2856 impl Drop for TxRemoveInput {
2857 fn drop(&mut self) {
2858 if self.is_owned && !<*mut nativeTxRemoveInput>::is_null(self.inner) {
2859 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2863 /// Frees any resources used by the TxRemoveInput, if is_owned is set and inner is non-NULL.
2865 pub extern "C" fn TxRemoveInput_free(this_obj: TxRemoveInput) { }
2867 /// Used only if an object of this type is returned as a trait impl by a method
2868 pub(crate) extern "C" fn TxRemoveInput_free_void(this_ptr: *mut c_void) {
2869 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxRemoveInput) };
2872 impl TxRemoveInput {
2873 pub(crate) fn get_native_ref(&self) -> &'static nativeTxRemoveInput {
2874 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2876 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxRemoveInput {
2877 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2879 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2880 pub(crate) fn take_inner(mut self) -> *mut nativeTxRemoveInput {
2881 assert!(self.is_owned);
2882 let ret = ObjOps::untweak_ptr(self.inner);
2883 self.inner = core::ptr::null_mut();
2889 pub extern "C" fn TxRemoveInput_get_channel_id(this_ptr: &TxRemoveInput) -> *const [u8; 32] {
2890 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2895 pub extern "C" fn TxRemoveInput_set_channel_id(this_ptr: &mut TxRemoveInput, mut val: crate::c_types::ThirtyTwoBytes) {
2896 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
2898 /// The serial ID of the input to be removed
2900 pub extern "C" fn TxRemoveInput_get_serial_id(this_ptr: &TxRemoveInput) -> u64 {
2901 let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
2904 /// The serial ID of the input to be removed
2906 pub extern "C" fn TxRemoveInput_set_serial_id(this_ptr: &mut TxRemoveInput, mut val: u64) {
2907 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
2909 /// Constructs a new TxRemoveInput given each field
2912 pub extern "C" fn TxRemoveInput_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut serial_id_arg: u64) -> TxRemoveInput {
2913 TxRemoveInput { inner: ObjOps::heap_alloc(nativeTxRemoveInput {
2914 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
2915 serial_id: serial_id_arg,
2916 }), is_owned: true }
2918 impl Clone for TxRemoveInput {
2919 fn clone(&self) -> Self {
2921 inner: if <*mut nativeTxRemoveInput>::is_null(self.inner) { core::ptr::null_mut() } else {
2922 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2928 /// Used only if an object of this type is returned as a trait impl by a method
2929 pub(crate) extern "C" fn TxRemoveInput_clone_void(this_ptr: *const c_void) -> *mut c_void {
2930 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxRemoveInput)).clone() })) as *mut c_void
2933 /// Creates a copy of the TxRemoveInput
2934 pub extern "C" fn TxRemoveInput_clone(orig: &TxRemoveInput) -> TxRemoveInput {
2937 /// Checks if two TxRemoveInputs contain equal inner contents.
2938 /// This ignores pointers and is_owned flags and looks at the values in fields.
2939 /// Two objects with NULL inner values will be considered "equal" here.
2941 pub extern "C" fn TxRemoveInput_eq(a: &TxRemoveInput, b: &TxRemoveInput) -> bool {
2942 if a.inner == b.inner { return true; }
2943 if a.inner.is_null() || b.inner.is_null() { return false; }
2944 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2947 use lightning::ln::msgs::TxRemoveOutput as nativeTxRemoveOutputImport;
2948 pub(crate) type nativeTxRemoveOutput = nativeTxRemoveOutputImport;
2950 /// A tx_remove_output message for removing an output during interactive transaction construction.
2954 pub struct TxRemoveOutput {
2955 /// A pointer to the opaque Rust object.
2957 /// Nearly everywhere, inner must be non-null, however in places where
2958 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2959 pub inner: *mut nativeTxRemoveOutput,
2960 /// Indicates that this is the only struct which contains the same pointer.
2962 /// Rust functions which take ownership of an object provided via an argument require
2963 /// this to be true and invalidate the object pointed to by inner.
2967 impl Drop for TxRemoveOutput {
2968 fn drop(&mut self) {
2969 if self.is_owned && !<*mut nativeTxRemoveOutput>::is_null(self.inner) {
2970 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2974 /// Frees any resources used by the TxRemoveOutput, if is_owned is set and inner is non-NULL.
2976 pub extern "C" fn TxRemoveOutput_free(this_obj: TxRemoveOutput) { }
2978 /// Used only if an object of this type is returned as a trait impl by a method
2979 pub(crate) extern "C" fn TxRemoveOutput_free_void(this_ptr: *mut c_void) {
2980 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxRemoveOutput) };
2983 impl TxRemoveOutput {
2984 pub(crate) fn get_native_ref(&self) -> &'static nativeTxRemoveOutput {
2985 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2987 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxRemoveOutput {
2988 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2990 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2991 pub(crate) fn take_inner(mut self) -> *mut nativeTxRemoveOutput {
2992 assert!(self.is_owned);
2993 let ret = ObjOps::untweak_ptr(self.inner);
2994 self.inner = core::ptr::null_mut();
3000 pub extern "C" fn TxRemoveOutput_get_channel_id(this_ptr: &TxRemoveOutput) -> *const [u8; 32] {
3001 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3006 pub extern "C" fn TxRemoveOutput_set_channel_id(this_ptr: &mut TxRemoveOutput, mut val: crate::c_types::ThirtyTwoBytes) {
3007 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3009 /// The serial ID of the output to be removed
3011 pub extern "C" fn TxRemoveOutput_get_serial_id(this_ptr: &TxRemoveOutput) -> u64 {
3012 let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id;
3015 /// The serial ID of the output to be removed
3017 pub extern "C" fn TxRemoveOutput_set_serial_id(this_ptr: &mut TxRemoveOutput, mut val: u64) {
3018 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val;
3020 /// Constructs a new TxRemoveOutput given each field
3023 pub extern "C" fn TxRemoveOutput_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut serial_id_arg: u64) -> TxRemoveOutput {
3024 TxRemoveOutput { inner: ObjOps::heap_alloc(nativeTxRemoveOutput {
3025 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3026 serial_id: serial_id_arg,
3027 }), is_owned: true }
3029 impl Clone for TxRemoveOutput {
3030 fn clone(&self) -> Self {
3032 inner: if <*mut nativeTxRemoveOutput>::is_null(self.inner) { core::ptr::null_mut() } else {
3033 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3039 /// Used only if an object of this type is returned as a trait impl by a method
3040 pub(crate) extern "C" fn TxRemoveOutput_clone_void(this_ptr: *const c_void) -> *mut c_void {
3041 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxRemoveOutput)).clone() })) as *mut c_void
3044 /// Creates a copy of the TxRemoveOutput
3045 pub extern "C" fn TxRemoveOutput_clone(orig: &TxRemoveOutput) -> TxRemoveOutput {
3048 /// Checks if two TxRemoveOutputs contain equal inner contents.
3049 /// This ignores pointers and is_owned flags and looks at the values in fields.
3050 /// Two objects with NULL inner values will be considered "equal" here.
3052 pub extern "C" fn TxRemoveOutput_eq(a: &TxRemoveOutput, b: &TxRemoveOutput) -> bool {
3053 if a.inner == b.inner { return true; }
3054 if a.inner.is_null() || b.inner.is_null() { return false; }
3055 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3058 use lightning::ln::msgs::TxComplete as nativeTxCompleteImport;
3059 pub(crate) type nativeTxComplete = nativeTxCompleteImport;
3061 /// A tx_complete message signalling the conclusion of a peer's transaction contributions during
3062 /// interactive transaction construction.
3066 pub struct TxComplete {
3067 /// A pointer to the opaque Rust object.
3069 /// Nearly everywhere, inner must be non-null, however in places where
3070 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3071 pub inner: *mut nativeTxComplete,
3072 /// Indicates that this is the only struct which contains the same pointer.
3074 /// Rust functions which take ownership of an object provided via an argument require
3075 /// this to be true and invalidate the object pointed to by inner.
3079 impl Drop for TxComplete {
3080 fn drop(&mut self) {
3081 if self.is_owned && !<*mut nativeTxComplete>::is_null(self.inner) {
3082 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3086 /// Frees any resources used by the TxComplete, if is_owned is set and inner is non-NULL.
3088 pub extern "C" fn TxComplete_free(this_obj: TxComplete) { }
3090 /// Used only if an object of this type is returned as a trait impl by a method
3091 pub(crate) extern "C" fn TxComplete_free_void(this_ptr: *mut c_void) {
3092 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxComplete) };
3096 pub(crate) fn get_native_ref(&self) -> &'static nativeTxComplete {
3097 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3099 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxComplete {
3100 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3102 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3103 pub(crate) fn take_inner(mut self) -> *mut nativeTxComplete {
3104 assert!(self.is_owned);
3105 let ret = ObjOps::untweak_ptr(self.inner);
3106 self.inner = core::ptr::null_mut();
3112 pub extern "C" fn TxComplete_get_channel_id(this_ptr: &TxComplete) -> *const [u8; 32] {
3113 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3118 pub extern "C" fn TxComplete_set_channel_id(this_ptr: &mut TxComplete, mut val: crate::c_types::ThirtyTwoBytes) {
3119 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3121 /// Constructs a new TxComplete given each field
3124 pub extern "C" fn TxComplete_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes) -> TxComplete {
3125 TxComplete { inner: ObjOps::heap_alloc(nativeTxComplete {
3126 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3127 }), is_owned: true }
3129 impl Clone for TxComplete {
3130 fn clone(&self) -> Self {
3132 inner: if <*mut nativeTxComplete>::is_null(self.inner) { core::ptr::null_mut() } else {
3133 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3139 /// Used only if an object of this type is returned as a trait impl by a method
3140 pub(crate) extern "C" fn TxComplete_clone_void(this_ptr: *const c_void) -> *mut c_void {
3141 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxComplete)).clone() })) as *mut c_void
3144 /// Creates a copy of the TxComplete
3145 pub extern "C" fn TxComplete_clone(orig: &TxComplete) -> TxComplete {
3148 /// Checks if two TxCompletes contain equal inner contents.
3149 /// This ignores pointers and is_owned flags and looks at the values in fields.
3150 /// Two objects with NULL inner values will be considered "equal" here.
3152 pub extern "C" fn TxComplete_eq(a: &TxComplete, b: &TxComplete) -> bool {
3153 if a.inner == b.inner { return true; }
3154 if a.inner.is_null() || b.inner.is_null() { return false; }
3155 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3158 use lightning::ln::msgs::TxSignatures as nativeTxSignaturesImport;
3159 pub(crate) type nativeTxSignatures = nativeTxSignaturesImport;
3161 /// A tx_signatures message containing the sender's signatures for a transaction constructed with
3162 /// interactive transaction construction.
3166 pub struct TxSignatures {
3167 /// A pointer to the opaque Rust object.
3169 /// Nearly everywhere, inner must be non-null, however in places where
3170 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3171 pub inner: *mut nativeTxSignatures,
3172 /// Indicates that this is the only struct which contains the same pointer.
3174 /// Rust functions which take ownership of an object provided via an argument require
3175 /// this to be true and invalidate the object pointed to by inner.
3179 impl Drop for TxSignatures {
3180 fn drop(&mut self) {
3181 if self.is_owned && !<*mut nativeTxSignatures>::is_null(self.inner) {
3182 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3186 /// Frees any resources used by the TxSignatures, if is_owned is set and inner is non-NULL.
3188 pub extern "C" fn TxSignatures_free(this_obj: TxSignatures) { }
3190 /// Used only if an object of this type is returned as a trait impl by a method
3191 pub(crate) extern "C" fn TxSignatures_free_void(this_ptr: *mut c_void) {
3192 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxSignatures) };
3196 pub(crate) fn get_native_ref(&self) -> &'static nativeTxSignatures {
3197 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3199 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxSignatures {
3200 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3202 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3203 pub(crate) fn take_inner(mut self) -> *mut nativeTxSignatures {
3204 assert!(self.is_owned);
3205 let ret = ObjOps::untweak_ptr(self.inner);
3206 self.inner = core::ptr::null_mut();
3212 pub extern "C" fn TxSignatures_get_channel_id(this_ptr: &TxSignatures) -> *const [u8; 32] {
3213 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3218 pub extern "C" fn TxSignatures_set_channel_id(this_ptr: &mut TxSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
3219 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3223 pub extern "C" fn TxSignatures_get_tx_hash(this_ptr: &TxSignatures) -> *const [u8; 32] {
3224 let mut inner_val = &mut this_ptr.get_native_mut_ref().tx_hash;
3225 inner_val.as_inner()
3229 pub extern "C" fn TxSignatures_set_tx_hash(this_ptr: &mut TxSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
3230 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.tx_hash = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
3232 /// The list of witnesses
3234 /// Returns a copy of the field.
3236 pub extern "C" fn TxSignatures_get_witnesses(this_ptr: &TxSignatures) -> crate::c_types::derived::CVec_WitnessZ {
3237 let mut inner_val = this_ptr.get_native_mut_ref().witnesses.clone();
3238 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { crate::c_types::Witness::from_bitcoin(&item) }); };
3239 local_inner_val.into()
3241 /// The list of witnesses
3243 pub extern "C" fn TxSignatures_set_witnesses(this_ptr: &mut TxSignatures, mut val: crate::c_types::derived::CVec_WitnessZ) {
3244 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_bitcoin() }); };
3245 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.witnesses = local_val;
3247 /// Constructs a new TxSignatures given each field
3250 pub extern "C" fn TxSignatures_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut tx_hash_arg: crate::c_types::ThirtyTwoBytes, mut witnesses_arg: crate::c_types::derived::CVec_WitnessZ) -> TxSignatures {
3251 let mut local_witnesses_arg = Vec::new(); for mut item in witnesses_arg.into_rust().drain(..) { local_witnesses_arg.push( { item.into_bitcoin() }); };
3252 TxSignatures { inner: ObjOps::heap_alloc(nativeTxSignatures {
3253 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3254 tx_hash: ::bitcoin::hash_types::Txid::from_slice(&tx_hash_arg.data[..]).unwrap(),
3255 witnesses: local_witnesses_arg,
3256 }), is_owned: true }
3258 impl Clone for TxSignatures {
3259 fn clone(&self) -> Self {
3261 inner: if <*mut nativeTxSignatures>::is_null(self.inner) { core::ptr::null_mut() } else {
3262 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3268 /// Used only if an object of this type is returned as a trait impl by a method
3269 pub(crate) extern "C" fn TxSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
3270 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxSignatures)).clone() })) as *mut c_void
3273 /// Creates a copy of the TxSignatures
3274 pub extern "C" fn TxSignatures_clone(orig: &TxSignatures) -> TxSignatures {
3277 /// Checks if two TxSignaturess contain equal inner contents.
3278 /// This ignores pointers and is_owned flags and looks at the values in fields.
3279 /// Two objects with NULL inner values will be considered "equal" here.
3281 pub extern "C" fn TxSignatures_eq(a: &TxSignatures, b: &TxSignatures) -> bool {
3282 if a.inner == b.inner { return true; }
3283 if a.inner.is_null() || b.inner.is_null() { return false; }
3284 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3287 use lightning::ln::msgs::TxInitRbf as nativeTxInitRbfImport;
3288 pub(crate) type nativeTxInitRbf = nativeTxInitRbfImport;
3290 /// A tx_init_rbf message which initiates a replacement of the transaction after it's been
3295 pub struct TxInitRbf {
3296 /// A pointer to the opaque Rust object.
3298 /// Nearly everywhere, inner must be non-null, however in places where
3299 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3300 pub inner: *mut nativeTxInitRbf,
3301 /// Indicates that this is the only struct which contains the same pointer.
3303 /// Rust functions which take ownership of an object provided via an argument require
3304 /// this to be true and invalidate the object pointed to by inner.
3308 impl Drop for TxInitRbf {
3309 fn drop(&mut self) {
3310 if self.is_owned && !<*mut nativeTxInitRbf>::is_null(self.inner) {
3311 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3315 /// Frees any resources used by the TxInitRbf, if is_owned is set and inner is non-NULL.
3317 pub extern "C" fn TxInitRbf_free(this_obj: TxInitRbf) { }
3319 /// Used only if an object of this type is returned as a trait impl by a method
3320 pub(crate) extern "C" fn TxInitRbf_free_void(this_ptr: *mut c_void) {
3321 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxInitRbf) };
3325 pub(crate) fn get_native_ref(&self) -> &'static nativeTxInitRbf {
3326 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3328 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxInitRbf {
3329 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3331 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3332 pub(crate) fn take_inner(mut self) -> *mut nativeTxInitRbf {
3333 assert!(self.is_owned);
3334 let ret = ObjOps::untweak_ptr(self.inner);
3335 self.inner = core::ptr::null_mut();
3341 pub extern "C" fn TxInitRbf_get_channel_id(this_ptr: &TxInitRbf) -> *const [u8; 32] {
3342 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3347 pub extern "C" fn TxInitRbf_set_channel_id(this_ptr: &mut TxInitRbf, mut val: crate::c_types::ThirtyTwoBytes) {
3348 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3350 /// The locktime of the transaction
3352 pub extern "C" fn TxInitRbf_get_locktime(this_ptr: &TxInitRbf) -> u32 {
3353 let mut inner_val = &mut this_ptr.get_native_mut_ref().locktime;
3356 /// The locktime of the transaction
3358 pub extern "C" fn TxInitRbf_set_locktime(this_ptr: &mut TxInitRbf, mut val: u32) {
3359 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.locktime = val;
3361 /// The feerate of the transaction
3363 pub extern "C" fn TxInitRbf_get_feerate_sat_per_1000_weight(this_ptr: &TxInitRbf) -> u32 {
3364 let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_sat_per_1000_weight;
3367 /// The feerate of the transaction
3369 pub extern "C" fn TxInitRbf_set_feerate_sat_per_1000_weight(this_ptr: &mut TxInitRbf, mut val: u32) {
3370 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_sat_per_1000_weight = val;
3372 /// The number of satoshis the sender will contribute to or, if negative, remove from
3373 /// (e.g. splice-out) the funding output of the transaction
3375 pub extern "C" fn TxInitRbf_get_funding_output_contribution(this_ptr: &TxInitRbf) -> crate::c_types::derived::COption_i64Z {
3376 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_contribution;
3377 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_i64Z::None } else { crate::c_types::derived::COption_i64Z::Some( { inner_val.unwrap() }) };
3380 /// The number of satoshis the sender will contribute to or, if negative, remove from
3381 /// (e.g. splice-out) the funding output of the transaction
3383 pub extern "C" fn TxInitRbf_set_funding_output_contribution(this_ptr: &mut TxInitRbf, mut val: crate::c_types::derived::COption_i64Z) {
3384 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
3385 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_contribution = local_val;
3387 /// Constructs a new TxInitRbf given each field
3390 pub extern "C" fn TxInitRbf_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut locktime_arg: u32, mut feerate_sat_per_1000_weight_arg: u32, mut funding_output_contribution_arg: crate::c_types::derived::COption_i64Z) -> TxInitRbf {
3391 let mut local_funding_output_contribution_arg = if funding_output_contribution_arg.is_some() { Some( { funding_output_contribution_arg.take() }) } else { None };
3392 TxInitRbf { inner: ObjOps::heap_alloc(nativeTxInitRbf {
3393 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3394 locktime: locktime_arg,
3395 feerate_sat_per_1000_weight: feerate_sat_per_1000_weight_arg,
3396 funding_output_contribution: local_funding_output_contribution_arg,
3397 }), is_owned: true }
3399 impl Clone for TxInitRbf {
3400 fn clone(&self) -> Self {
3402 inner: if <*mut nativeTxInitRbf>::is_null(self.inner) { core::ptr::null_mut() } else {
3403 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3409 /// Used only if an object of this type is returned as a trait impl by a method
3410 pub(crate) extern "C" fn TxInitRbf_clone_void(this_ptr: *const c_void) -> *mut c_void {
3411 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxInitRbf)).clone() })) as *mut c_void
3414 /// Creates a copy of the TxInitRbf
3415 pub extern "C" fn TxInitRbf_clone(orig: &TxInitRbf) -> TxInitRbf {
3418 /// Checks if two TxInitRbfs contain equal inner contents.
3419 /// This ignores pointers and is_owned flags and looks at the values in fields.
3420 /// Two objects with NULL inner values will be considered "equal" here.
3422 pub extern "C" fn TxInitRbf_eq(a: &TxInitRbf, b: &TxInitRbf) -> bool {
3423 if a.inner == b.inner { return true; }
3424 if a.inner.is_null() || b.inner.is_null() { return false; }
3425 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3428 use lightning::ln::msgs::TxAckRbf as nativeTxAckRbfImport;
3429 pub(crate) type nativeTxAckRbf = nativeTxAckRbfImport;
3431 /// A tx_ack_rbf message which acknowledges replacement of the transaction after it's been
3436 pub struct TxAckRbf {
3437 /// A pointer to the opaque Rust object.
3439 /// Nearly everywhere, inner must be non-null, however in places where
3440 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3441 pub inner: *mut nativeTxAckRbf,
3442 /// Indicates that this is the only struct which contains the same pointer.
3444 /// Rust functions which take ownership of an object provided via an argument require
3445 /// this to be true and invalidate the object pointed to by inner.
3449 impl Drop for TxAckRbf {
3450 fn drop(&mut self) {
3451 if self.is_owned && !<*mut nativeTxAckRbf>::is_null(self.inner) {
3452 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3456 /// Frees any resources used by the TxAckRbf, if is_owned is set and inner is non-NULL.
3458 pub extern "C" fn TxAckRbf_free(this_obj: TxAckRbf) { }
3460 /// Used only if an object of this type is returned as a trait impl by a method
3461 pub(crate) extern "C" fn TxAckRbf_free_void(this_ptr: *mut c_void) {
3462 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAckRbf) };
3466 pub(crate) fn get_native_ref(&self) -> &'static nativeTxAckRbf {
3467 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3469 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAckRbf {
3470 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3472 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3473 pub(crate) fn take_inner(mut self) -> *mut nativeTxAckRbf {
3474 assert!(self.is_owned);
3475 let ret = ObjOps::untweak_ptr(self.inner);
3476 self.inner = core::ptr::null_mut();
3482 pub extern "C" fn TxAckRbf_get_channel_id(this_ptr: &TxAckRbf) -> *const [u8; 32] {
3483 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3488 pub extern "C" fn TxAckRbf_set_channel_id(this_ptr: &mut TxAckRbf, mut val: crate::c_types::ThirtyTwoBytes) {
3489 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3491 /// The number of satoshis the sender will contribute to or, if negative, remove from
3492 /// (e.g. splice-out) the funding output of the transaction
3494 pub extern "C" fn TxAckRbf_get_funding_output_contribution(this_ptr: &TxAckRbf) -> crate::c_types::derived::COption_i64Z {
3495 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_contribution;
3496 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_i64Z::None } else { crate::c_types::derived::COption_i64Z::Some( { inner_val.unwrap() }) };
3499 /// The number of satoshis the sender will contribute to or, if negative, remove from
3500 /// (e.g. splice-out) the funding output of the transaction
3502 pub extern "C" fn TxAckRbf_set_funding_output_contribution(this_ptr: &mut TxAckRbf, mut val: crate::c_types::derived::COption_i64Z) {
3503 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
3504 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_contribution = local_val;
3506 /// Constructs a new TxAckRbf given each field
3509 pub extern "C" fn TxAckRbf_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_output_contribution_arg: crate::c_types::derived::COption_i64Z) -> TxAckRbf {
3510 let mut local_funding_output_contribution_arg = if funding_output_contribution_arg.is_some() { Some( { funding_output_contribution_arg.take() }) } else { None };
3511 TxAckRbf { inner: ObjOps::heap_alloc(nativeTxAckRbf {
3512 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3513 funding_output_contribution: local_funding_output_contribution_arg,
3514 }), is_owned: true }
3516 impl Clone for TxAckRbf {
3517 fn clone(&self) -> Self {
3519 inner: if <*mut nativeTxAckRbf>::is_null(self.inner) { core::ptr::null_mut() } else {
3520 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3526 /// Used only if an object of this type is returned as a trait impl by a method
3527 pub(crate) extern "C" fn TxAckRbf_clone_void(this_ptr: *const c_void) -> *mut c_void {
3528 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxAckRbf)).clone() })) as *mut c_void
3531 /// Creates a copy of the TxAckRbf
3532 pub extern "C" fn TxAckRbf_clone(orig: &TxAckRbf) -> TxAckRbf {
3535 /// Checks if two TxAckRbfs contain equal inner contents.
3536 /// This ignores pointers and is_owned flags and looks at the values in fields.
3537 /// Two objects with NULL inner values will be considered "equal" here.
3539 pub extern "C" fn TxAckRbf_eq(a: &TxAckRbf, b: &TxAckRbf) -> bool {
3540 if a.inner == b.inner { return true; }
3541 if a.inner.is_null() || b.inner.is_null() { return false; }
3542 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3545 use lightning::ln::msgs::TxAbort as nativeTxAbortImport;
3546 pub(crate) type nativeTxAbort = nativeTxAbortImport;
3548 /// A tx_abort message which signals the cancellation of an in-progress transaction negotiation.
3552 pub struct TxAbort {
3553 /// A pointer to the opaque Rust object.
3555 /// Nearly everywhere, inner must be non-null, however in places where
3556 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3557 pub inner: *mut nativeTxAbort,
3558 /// Indicates that this is the only struct which contains the same pointer.
3560 /// Rust functions which take ownership of an object provided via an argument require
3561 /// this to be true and invalidate the object pointed to by inner.
3565 impl Drop for TxAbort {
3566 fn drop(&mut self) {
3567 if self.is_owned && !<*mut nativeTxAbort>::is_null(self.inner) {
3568 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3572 /// Frees any resources used by the TxAbort, if is_owned is set and inner is non-NULL.
3574 pub extern "C" fn TxAbort_free(this_obj: TxAbort) { }
3576 /// Used only if an object of this type is returned as a trait impl by a method
3577 pub(crate) extern "C" fn TxAbort_free_void(this_ptr: *mut c_void) {
3578 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAbort) };
3582 pub(crate) fn get_native_ref(&self) -> &'static nativeTxAbort {
3583 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3585 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAbort {
3586 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3588 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3589 pub(crate) fn take_inner(mut self) -> *mut nativeTxAbort {
3590 assert!(self.is_owned);
3591 let ret = ObjOps::untweak_ptr(self.inner);
3592 self.inner = core::ptr::null_mut();
3598 pub extern "C" fn TxAbort_get_channel_id(this_ptr: &TxAbort) -> *const [u8; 32] {
3599 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3604 pub extern "C" fn TxAbort_set_channel_id(this_ptr: &mut TxAbort, mut val: crate::c_types::ThirtyTwoBytes) {
3605 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3609 /// Returns a copy of the field.
3611 pub extern "C" fn TxAbort_get_data(this_ptr: &TxAbort) -> crate::c_types::derived::CVec_u8Z {
3612 let mut inner_val = this_ptr.get_native_mut_ref().data.clone();
3613 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
3614 local_inner_val.into()
3618 pub extern "C" fn TxAbort_set_data(this_ptr: &mut TxAbort, mut val: crate::c_types::derived::CVec_u8Z) {
3619 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
3620 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = local_val;
3622 /// Constructs a new TxAbort given each field
3625 pub extern "C" fn TxAbort_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::derived::CVec_u8Z) -> TxAbort {
3626 let mut local_data_arg = Vec::new(); for mut item in data_arg.into_rust().drain(..) { local_data_arg.push( { item }); };
3627 TxAbort { inner: ObjOps::heap_alloc(nativeTxAbort {
3628 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3629 data: local_data_arg,
3630 }), is_owned: true }
3632 impl Clone for TxAbort {
3633 fn clone(&self) -> Self {
3635 inner: if <*mut nativeTxAbort>::is_null(self.inner) { core::ptr::null_mut() } else {
3636 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3642 /// Used only if an object of this type is returned as a trait impl by a method
3643 pub(crate) extern "C" fn TxAbort_clone_void(this_ptr: *const c_void) -> *mut c_void {
3644 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxAbort)).clone() })) as *mut c_void
3647 /// Creates a copy of the TxAbort
3648 pub extern "C" fn TxAbort_clone(orig: &TxAbort) -> TxAbort {
3651 /// Checks if two TxAborts contain equal inner contents.
3652 /// This ignores pointers and is_owned flags and looks at the values in fields.
3653 /// Two objects with NULL inner values will be considered "equal" here.
3655 pub extern "C" fn TxAbort_eq(a: &TxAbort, b: &TxAbort) -> bool {
3656 if a.inner == b.inner { return true; }
3657 if a.inner.is_null() || b.inner.is_null() { return false; }
3658 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3661 use lightning::ln::msgs::Shutdown as nativeShutdownImport;
3662 pub(crate) type nativeShutdown = nativeShutdownImport;
3664 /// A [`shutdown`] message to be sent to or received from a peer.
3666 /// [`shutdown`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-initiation-shutdown
3669 pub struct Shutdown {
3670 /// A pointer to the opaque Rust object.
3672 /// Nearly everywhere, inner must be non-null, however in places where
3673 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3674 pub inner: *mut nativeShutdown,
3675 /// Indicates that this is the only struct which contains the same pointer.
3677 /// Rust functions which take ownership of an object provided via an argument require
3678 /// this to be true and invalidate the object pointed to by inner.
3682 impl Drop for Shutdown {
3683 fn drop(&mut self) {
3684 if self.is_owned && !<*mut nativeShutdown>::is_null(self.inner) {
3685 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3689 /// Frees any resources used by the Shutdown, if is_owned is set and inner is non-NULL.
3691 pub extern "C" fn Shutdown_free(this_obj: Shutdown) { }
3693 /// Used only if an object of this type is returned as a trait impl by a method
3694 pub(crate) extern "C" fn Shutdown_free_void(this_ptr: *mut c_void) {
3695 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeShutdown) };
3699 pub(crate) fn get_native_ref(&self) -> &'static nativeShutdown {
3700 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3702 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeShutdown {
3703 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3705 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3706 pub(crate) fn take_inner(mut self) -> *mut nativeShutdown {
3707 assert!(self.is_owned);
3708 let ret = ObjOps::untweak_ptr(self.inner);
3709 self.inner = core::ptr::null_mut();
3715 pub extern "C" fn Shutdown_get_channel_id(this_ptr: &Shutdown) -> *const [u8; 32] {
3716 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3721 pub extern "C" fn Shutdown_set_channel_id(this_ptr: &mut Shutdown, mut val: crate::c_types::ThirtyTwoBytes) {
3722 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3724 /// The destination of this peer's funds on closing.
3726 /// Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.
3728 pub extern "C" fn Shutdown_get_scriptpubkey(this_ptr: &Shutdown) -> crate::c_types::u8slice {
3729 let mut inner_val = &mut this_ptr.get_native_mut_ref().scriptpubkey;
3730 crate::c_types::u8slice::from_slice(&inner_val[..])
3732 /// The destination of this peer's funds on closing.
3734 /// Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR.
3736 pub extern "C" fn Shutdown_set_scriptpubkey(this_ptr: &mut Shutdown, mut val: crate::c_types::derived::CVec_u8Z) {
3737 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.scriptpubkey = ::bitcoin::blockdata::script::Script::from(val.into_rust());
3739 /// Constructs a new Shutdown given each field
3742 pub extern "C" fn Shutdown_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut scriptpubkey_arg: crate::c_types::derived::CVec_u8Z) -> Shutdown {
3743 Shutdown { inner: ObjOps::heap_alloc(nativeShutdown {
3744 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
3745 scriptpubkey: ::bitcoin::blockdata::script::Script::from(scriptpubkey_arg.into_rust()),
3746 }), is_owned: true }
3748 impl Clone for Shutdown {
3749 fn clone(&self) -> Self {
3751 inner: if <*mut nativeShutdown>::is_null(self.inner) { core::ptr::null_mut() } else {
3752 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3758 /// Used only if an object of this type is returned as a trait impl by a method
3759 pub(crate) extern "C" fn Shutdown_clone_void(this_ptr: *const c_void) -> *mut c_void {
3760 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeShutdown)).clone() })) as *mut c_void
3763 /// Creates a copy of the Shutdown
3764 pub extern "C" fn Shutdown_clone(orig: &Shutdown) -> Shutdown {
3767 /// Checks if two Shutdowns contain equal inner contents.
3768 /// This ignores pointers and is_owned flags and looks at the values in fields.
3769 /// Two objects with NULL inner values will be considered "equal" here.
3771 pub extern "C" fn Shutdown_eq(a: &Shutdown, b: &Shutdown) -> bool {
3772 if a.inner == b.inner { return true; }
3773 if a.inner.is_null() || b.inner.is_null() { return false; }
3774 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3777 use lightning::ln::msgs::ClosingSignedFeeRange as nativeClosingSignedFeeRangeImport;
3778 pub(crate) type nativeClosingSignedFeeRange = nativeClosingSignedFeeRangeImport;
3780 /// The minimum and maximum fees which the sender is willing to place on the closing transaction.
3782 /// This is provided in [`ClosingSigned`] by both sides to indicate the fee range they are willing
3786 pub struct ClosingSignedFeeRange {
3787 /// A pointer to the opaque Rust object.
3789 /// Nearly everywhere, inner must be non-null, however in places where
3790 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3791 pub inner: *mut nativeClosingSignedFeeRange,
3792 /// Indicates that this is the only struct which contains the same pointer.
3794 /// Rust functions which take ownership of an object provided via an argument require
3795 /// this to be true and invalidate the object pointed to by inner.
3799 impl Drop for ClosingSignedFeeRange {
3800 fn drop(&mut self) {
3801 if self.is_owned && !<*mut nativeClosingSignedFeeRange>::is_null(self.inner) {
3802 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3806 /// Frees any resources used by the ClosingSignedFeeRange, if is_owned is set and inner is non-NULL.
3808 pub extern "C" fn ClosingSignedFeeRange_free(this_obj: ClosingSignedFeeRange) { }
3810 /// Used only if an object of this type is returned as a trait impl by a method
3811 pub(crate) extern "C" fn ClosingSignedFeeRange_free_void(this_ptr: *mut c_void) {
3812 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeClosingSignedFeeRange) };
3815 impl ClosingSignedFeeRange {
3816 pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSignedFeeRange {
3817 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3819 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSignedFeeRange {
3820 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3822 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3823 pub(crate) fn take_inner(mut self) -> *mut nativeClosingSignedFeeRange {
3824 assert!(self.is_owned);
3825 let ret = ObjOps::untweak_ptr(self.inner);
3826 self.inner = core::ptr::null_mut();
3830 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
3833 pub extern "C" fn ClosingSignedFeeRange_get_min_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
3834 let mut inner_val = &mut this_ptr.get_native_mut_ref().min_fee_satoshis;
3837 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
3840 pub extern "C" fn ClosingSignedFeeRange_set_min_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
3841 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_fee_satoshis = val;
3843 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
3846 pub extern "C" fn ClosingSignedFeeRange_get_max_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
3847 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_fee_satoshis;
3850 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
3853 pub extern "C" fn ClosingSignedFeeRange_set_max_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
3854 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_fee_satoshis = val;
3856 /// Constructs a new ClosingSignedFeeRange given each field
3859 pub extern "C" fn ClosingSignedFeeRange_new(mut min_fee_satoshis_arg: u64, mut max_fee_satoshis_arg: u64) -> ClosingSignedFeeRange {
3860 ClosingSignedFeeRange { inner: ObjOps::heap_alloc(nativeClosingSignedFeeRange {
3861 min_fee_satoshis: min_fee_satoshis_arg,
3862 max_fee_satoshis: max_fee_satoshis_arg,
3863 }), is_owned: true }
3865 impl Clone for ClosingSignedFeeRange {
3866 fn clone(&self) -> Self {
3868 inner: if <*mut nativeClosingSignedFeeRange>::is_null(self.inner) { core::ptr::null_mut() } else {
3869 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3875 /// Used only if an object of this type is returned as a trait impl by a method
3876 pub(crate) extern "C" fn ClosingSignedFeeRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
3877 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClosingSignedFeeRange)).clone() })) as *mut c_void
3880 /// Creates a copy of the ClosingSignedFeeRange
3881 pub extern "C" fn ClosingSignedFeeRange_clone(orig: &ClosingSignedFeeRange) -> ClosingSignedFeeRange {
3884 /// Checks if two ClosingSignedFeeRanges contain equal inner contents.
3885 /// This ignores pointers and is_owned flags and looks at the values in fields.
3886 /// Two objects with NULL inner values will be considered "equal" here.
3888 pub extern "C" fn ClosingSignedFeeRange_eq(a: &ClosingSignedFeeRange, b: &ClosingSignedFeeRange) -> bool {
3889 if a.inner == b.inner { return true; }
3890 if a.inner.is_null() || b.inner.is_null() { return false; }
3891 if a.get_native_ref() == b.get_native_ref() { true } else { false }
3894 use lightning::ln::msgs::ClosingSigned as nativeClosingSignedImport;
3895 pub(crate) type nativeClosingSigned = nativeClosingSignedImport;
3897 /// A [`closing_signed`] message to be sent to or received from a peer.
3899 /// [`closing_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-negotiation-closing_signed
3902 pub struct ClosingSigned {
3903 /// A pointer to the opaque Rust object.
3905 /// Nearly everywhere, inner must be non-null, however in places where
3906 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3907 pub inner: *mut nativeClosingSigned,
3908 /// Indicates that this is the only struct which contains the same pointer.
3910 /// Rust functions which take ownership of an object provided via an argument require
3911 /// this to be true and invalidate the object pointed to by inner.
3915 impl Drop for ClosingSigned {
3916 fn drop(&mut self) {
3917 if self.is_owned && !<*mut nativeClosingSigned>::is_null(self.inner) {
3918 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3922 /// Frees any resources used by the ClosingSigned, if is_owned is set and inner is non-NULL.
3924 pub extern "C" fn ClosingSigned_free(this_obj: ClosingSigned) { }
3926 /// Used only if an object of this type is returned as a trait impl by a method
3927 pub(crate) extern "C" fn ClosingSigned_free_void(this_ptr: *mut c_void) {
3928 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeClosingSigned) };
3931 impl ClosingSigned {
3932 pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSigned {
3933 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3935 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSigned {
3936 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3938 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3939 pub(crate) fn take_inner(mut self) -> *mut nativeClosingSigned {
3940 assert!(self.is_owned);
3941 let ret = ObjOps::untweak_ptr(self.inner);
3942 self.inner = core::ptr::null_mut();
3948 pub extern "C" fn ClosingSigned_get_channel_id(this_ptr: &ClosingSigned) -> *const [u8; 32] {
3949 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
3954 pub extern "C" fn ClosingSigned_set_channel_id(this_ptr: &mut ClosingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
3955 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
3957 /// The proposed total fee for the closing transaction
3959 pub extern "C" fn ClosingSigned_get_fee_satoshis(this_ptr: &ClosingSigned) -> u64 {
3960 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_satoshis;
3963 /// The proposed total fee for the closing transaction
3965 pub extern "C" fn ClosingSigned_set_fee_satoshis(this_ptr: &mut ClosingSigned, mut val: u64) {
3966 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_satoshis = val;
3968 /// A signature on the closing transaction
3970 pub extern "C" fn ClosingSigned_get_signature(this_ptr: &ClosingSigned) -> crate::c_types::ECDSASignature {
3971 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
3972 crate::c_types::ECDSASignature::from_rust(&inner_val)
3974 /// A signature on the closing transaction
3976 pub extern "C" fn ClosingSigned_set_signature(this_ptr: &mut ClosingSigned, mut val: crate::c_types::ECDSASignature) {
3977 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
3979 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
3982 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
3984 pub extern "C" fn ClosingSigned_get_fee_range(this_ptr: &ClosingSigned) -> crate::lightning::ln::msgs::ClosingSignedFeeRange {
3985 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_range;
3986 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 };
3989 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
3992 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
3994 pub extern "C" fn ClosingSigned_set_fee_range(this_ptr: &mut ClosingSigned, mut val: crate::lightning::ln::msgs::ClosingSignedFeeRange) {
3995 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
3996 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_range = local_val;
3998 /// Constructs a new ClosingSigned given each field
4000 /// Note that fee_range_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
4003 pub extern "C" fn ClosingSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut fee_satoshis_arg: u64, mut signature_arg: crate::c_types::ECDSASignature, mut fee_range_arg: crate::lightning::ln::msgs::ClosingSignedFeeRange) -> ClosingSigned {
4004 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()) } }) };
4005 ClosingSigned { inner: ObjOps::heap_alloc(nativeClosingSigned {
4006 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
4007 fee_satoshis: fee_satoshis_arg,
4008 signature: signature_arg.into_rust(),
4009 fee_range: local_fee_range_arg,
4010 }), is_owned: true }
4012 impl Clone for ClosingSigned {
4013 fn clone(&self) -> Self {
4015 inner: if <*mut nativeClosingSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
4016 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4022 /// Used only if an object of this type is returned as a trait impl by a method
4023 pub(crate) extern "C" fn ClosingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
4024 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClosingSigned)).clone() })) as *mut c_void
4027 /// Creates a copy of the ClosingSigned
4028 pub extern "C" fn ClosingSigned_clone(orig: &ClosingSigned) -> ClosingSigned {
4031 /// Checks if two ClosingSigneds contain equal inner contents.
4032 /// This ignores pointers and is_owned flags and looks at the values in fields.
4033 /// Two objects with NULL inner values will be considered "equal" here.
4035 pub extern "C" fn ClosingSigned_eq(a: &ClosingSigned, b: &ClosingSigned) -> bool {
4036 if a.inner == b.inner { return true; }
4037 if a.inner.is_null() || b.inner.is_null() { return false; }
4038 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4041 use lightning::ln::msgs::UpdateAddHTLC as nativeUpdateAddHTLCImport;
4042 pub(crate) type nativeUpdateAddHTLC = nativeUpdateAddHTLCImport;
4044 /// An [`update_add_htlc`] message to be sent to or received from a peer.
4046 /// [`update_add_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#adding-an-htlc-update_add_htlc
4049 pub struct UpdateAddHTLC {
4050 /// A pointer to the opaque Rust object.
4052 /// Nearly everywhere, inner must be non-null, however in places where
4053 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4054 pub inner: *mut nativeUpdateAddHTLC,
4055 /// Indicates that this is the only struct which contains the same pointer.
4057 /// Rust functions which take ownership of an object provided via an argument require
4058 /// this to be true and invalidate the object pointed to by inner.
4062 impl Drop for UpdateAddHTLC {
4063 fn drop(&mut self) {
4064 if self.is_owned && !<*mut nativeUpdateAddHTLC>::is_null(self.inner) {
4065 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4069 /// Frees any resources used by the UpdateAddHTLC, if is_owned is set and inner is non-NULL.
4071 pub extern "C" fn UpdateAddHTLC_free(this_obj: UpdateAddHTLC) { }
4073 /// Used only if an object of this type is returned as a trait impl by a method
4074 pub(crate) extern "C" fn UpdateAddHTLC_free_void(this_ptr: *mut c_void) {
4075 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateAddHTLC) };
4078 impl UpdateAddHTLC {
4079 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateAddHTLC {
4080 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4082 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateAddHTLC {
4083 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4085 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4086 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateAddHTLC {
4087 assert!(self.is_owned);
4088 let ret = ObjOps::untweak_ptr(self.inner);
4089 self.inner = core::ptr::null_mut();
4095 pub extern "C" fn UpdateAddHTLC_get_channel_id(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
4096 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4101 pub extern "C" fn UpdateAddHTLC_set_channel_id(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4102 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4106 pub extern "C" fn UpdateAddHTLC_get_htlc_id(this_ptr: &UpdateAddHTLC) -> u64 {
4107 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
4112 pub extern "C" fn UpdateAddHTLC_set_htlc_id(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
4113 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
4115 /// The HTLC value in milli-satoshi
4117 pub extern "C" fn UpdateAddHTLC_get_amount_msat(this_ptr: &UpdateAddHTLC) -> u64 {
4118 let mut inner_val = &mut this_ptr.get_native_mut_ref().amount_msat;
4121 /// The HTLC value in milli-satoshi
4123 pub extern "C" fn UpdateAddHTLC_set_amount_msat(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
4124 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.amount_msat = val;
4126 /// The payment hash, the pre-image of which controls HTLC redemption
4128 pub extern "C" fn UpdateAddHTLC_get_payment_hash(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
4129 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_hash;
4132 /// The payment hash, the pre-image of which controls HTLC redemption
4134 pub extern "C" fn UpdateAddHTLC_set_payment_hash(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4135 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_hash = ::lightning::ln::PaymentHash(val.data);
4137 /// The expiry height of the HTLC
4139 pub extern "C" fn UpdateAddHTLC_get_cltv_expiry(this_ptr: &UpdateAddHTLC) -> u32 {
4140 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry;
4143 /// The expiry height of the HTLC
4145 pub extern "C" fn UpdateAddHTLC_set_cltv_expiry(this_ptr: &mut UpdateAddHTLC, mut val: u32) {
4146 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry = val;
4148 /// The extra fee skimmed by the sender of this message. See
4149 /// [`ChannelConfig::accept_underpaying_htlcs`].
4151 /// [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
4153 pub extern "C" fn UpdateAddHTLC_get_skimmed_fee_msat(this_ptr: &UpdateAddHTLC) -> crate::c_types::derived::COption_u64Z {
4154 let mut inner_val = &mut this_ptr.get_native_mut_ref().skimmed_fee_msat;
4155 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() }) };
4158 /// The extra fee skimmed by the sender of this message. See
4159 /// [`ChannelConfig::accept_underpaying_htlcs`].
4161 /// [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
4163 pub extern "C" fn UpdateAddHTLC_set_skimmed_fee_msat(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::derived::COption_u64Z) {
4164 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
4165 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.skimmed_fee_msat = local_val;
4167 impl Clone for UpdateAddHTLC {
4168 fn clone(&self) -> Self {
4170 inner: if <*mut nativeUpdateAddHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
4171 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4177 /// Used only if an object of this type is returned as a trait impl by a method
4178 pub(crate) extern "C" fn UpdateAddHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
4179 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateAddHTLC)).clone() })) as *mut c_void
4182 /// Creates a copy of the UpdateAddHTLC
4183 pub extern "C" fn UpdateAddHTLC_clone(orig: &UpdateAddHTLC) -> UpdateAddHTLC {
4186 /// Checks if two UpdateAddHTLCs contain equal inner contents.
4187 /// This ignores pointers and is_owned flags and looks at the values in fields.
4188 /// Two objects with NULL inner values will be considered "equal" here.
4190 pub extern "C" fn UpdateAddHTLC_eq(a: &UpdateAddHTLC, b: &UpdateAddHTLC) -> bool {
4191 if a.inner == b.inner { return true; }
4192 if a.inner.is_null() || b.inner.is_null() { return false; }
4193 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4196 use lightning::ln::msgs::OnionMessage as nativeOnionMessageImport;
4197 pub(crate) type nativeOnionMessage = nativeOnionMessageImport;
4199 /// An onion message to be sent to or received from a peer.
4203 pub struct OnionMessage {
4204 /// A pointer to the opaque Rust object.
4206 /// Nearly everywhere, inner must be non-null, however in places where
4207 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4208 pub inner: *mut nativeOnionMessage,
4209 /// Indicates that this is the only struct which contains the same pointer.
4211 /// Rust functions which take ownership of an object provided via an argument require
4212 /// this to be true and invalidate the object pointed to by inner.
4216 impl Drop for OnionMessage {
4217 fn drop(&mut self) {
4218 if self.is_owned && !<*mut nativeOnionMessage>::is_null(self.inner) {
4219 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4223 /// Frees any resources used by the OnionMessage, if is_owned is set and inner is non-NULL.
4225 pub extern "C" fn OnionMessage_free(this_obj: OnionMessage) { }
4227 /// Used only if an object of this type is returned as a trait impl by a method
4228 pub(crate) extern "C" fn OnionMessage_free_void(this_ptr: *mut c_void) {
4229 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOnionMessage) };
4233 pub(crate) fn get_native_ref(&self) -> &'static nativeOnionMessage {
4234 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4236 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOnionMessage {
4237 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4239 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4240 pub(crate) fn take_inner(mut self) -> *mut nativeOnionMessage {
4241 assert!(self.is_owned);
4242 let ret = ObjOps::untweak_ptr(self.inner);
4243 self.inner = core::ptr::null_mut();
4247 /// Used in decrypting the onion packet's payload.
4249 pub extern "C" fn OnionMessage_get_blinding_point(this_ptr: &OnionMessage) -> crate::c_types::PublicKey {
4250 let mut inner_val = &mut this_ptr.get_native_mut_ref().blinding_point;
4251 crate::c_types::PublicKey::from_rust(&inner_val)
4253 /// Used in decrypting the onion packet's payload.
4255 pub extern "C" fn OnionMessage_set_blinding_point(this_ptr: &mut OnionMessage, mut val: crate::c_types::PublicKey) {
4256 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.blinding_point = val.into_rust();
4258 /// The full onion packet including hop data, pubkey, and hmac
4260 pub extern "C" fn OnionMessage_get_onion_routing_packet(this_ptr: &OnionMessage) -> crate::lightning::onion_message::packet::Packet {
4261 let mut inner_val = &mut this_ptr.get_native_mut_ref().onion_routing_packet;
4262 crate::lightning::onion_message::packet::Packet { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::onion_message::packet::Packet<>) as *mut _) }, is_owned: false }
4264 /// The full onion packet including hop data, pubkey, and hmac
4266 pub extern "C" fn OnionMessage_set_onion_routing_packet(this_ptr: &mut OnionMessage, mut val: crate::lightning::onion_message::packet::Packet) {
4267 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.onion_routing_packet = *unsafe { Box::from_raw(val.take_inner()) };
4269 /// Constructs a new OnionMessage given each field
4272 pub extern "C" fn OnionMessage_new(mut blinding_point_arg: crate::c_types::PublicKey, mut onion_routing_packet_arg: crate::lightning::onion_message::packet::Packet) -> OnionMessage {
4273 OnionMessage { inner: ObjOps::heap_alloc(nativeOnionMessage {
4274 blinding_point: blinding_point_arg.into_rust(),
4275 onion_routing_packet: *unsafe { Box::from_raw(onion_routing_packet_arg.take_inner()) },
4276 }), is_owned: true }
4278 impl Clone for OnionMessage {
4279 fn clone(&self) -> Self {
4281 inner: if <*mut nativeOnionMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
4282 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4288 /// Used only if an object of this type is returned as a trait impl by a method
4289 pub(crate) extern "C" fn OnionMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
4290 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOnionMessage)).clone() })) as *mut c_void
4293 /// Creates a copy of the OnionMessage
4294 pub extern "C" fn OnionMessage_clone(orig: &OnionMessage) -> OnionMessage {
4297 /// Checks if two OnionMessages contain equal inner contents.
4298 /// This ignores pointers and is_owned flags and looks at the values in fields.
4299 /// Two objects with NULL inner values will be considered "equal" here.
4301 pub extern "C" fn OnionMessage_eq(a: &OnionMessage, b: &OnionMessage) -> bool {
4302 if a.inner == b.inner { return true; }
4303 if a.inner.is_null() || b.inner.is_null() { return false; }
4304 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4307 use lightning::ln::msgs::UpdateFulfillHTLC as nativeUpdateFulfillHTLCImport;
4308 pub(crate) type nativeUpdateFulfillHTLC = nativeUpdateFulfillHTLCImport;
4310 /// An [`update_fulfill_htlc`] message to be sent to or received from a peer.
4312 /// [`update_fulfill_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#removing-an-htlc-update_fulfill_htlc-update_fail_htlc-and-update_fail_malformed_htlc
4315 pub struct UpdateFulfillHTLC {
4316 /// A pointer to the opaque Rust object.
4318 /// Nearly everywhere, inner must be non-null, however in places where
4319 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4320 pub inner: *mut nativeUpdateFulfillHTLC,
4321 /// Indicates that this is the only struct which contains the same pointer.
4323 /// Rust functions which take ownership of an object provided via an argument require
4324 /// this to be true and invalidate the object pointed to by inner.
4328 impl Drop for UpdateFulfillHTLC {
4329 fn drop(&mut self) {
4330 if self.is_owned && !<*mut nativeUpdateFulfillHTLC>::is_null(self.inner) {
4331 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4335 /// Frees any resources used by the UpdateFulfillHTLC, if is_owned is set and inner is non-NULL.
4337 pub extern "C" fn UpdateFulfillHTLC_free(this_obj: UpdateFulfillHTLC) { }
4339 /// Used only if an object of this type is returned as a trait impl by a method
4340 pub(crate) extern "C" fn UpdateFulfillHTLC_free_void(this_ptr: *mut c_void) {
4341 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFulfillHTLC) };
4344 impl UpdateFulfillHTLC {
4345 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFulfillHTLC {
4346 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4348 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFulfillHTLC {
4349 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4351 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4352 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFulfillHTLC {
4353 assert!(self.is_owned);
4354 let ret = ObjOps::untweak_ptr(self.inner);
4355 self.inner = core::ptr::null_mut();
4361 pub extern "C" fn UpdateFulfillHTLC_get_channel_id(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
4362 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4367 pub extern "C" fn UpdateFulfillHTLC_set_channel_id(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4368 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4372 pub extern "C" fn UpdateFulfillHTLC_get_htlc_id(this_ptr: &UpdateFulfillHTLC) -> u64 {
4373 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
4378 pub extern "C" fn UpdateFulfillHTLC_set_htlc_id(this_ptr: &mut UpdateFulfillHTLC, mut val: u64) {
4379 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
4381 /// The pre-image of the payment hash, allowing HTLC redemption
4383 pub extern "C" fn UpdateFulfillHTLC_get_payment_preimage(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
4384 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_preimage;
4387 /// The pre-image of the payment hash, allowing HTLC redemption
4389 pub extern "C" fn UpdateFulfillHTLC_set_payment_preimage(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4390 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_preimage = ::lightning::ln::PaymentPreimage(val.data);
4392 /// Constructs a new UpdateFulfillHTLC given each field
4395 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 {
4396 UpdateFulfillHTLC { inner: ObjOps::heap_alloc(nativeUpdateFulfillHTLC {
4397 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
4398 htlc_id: htlc_id_arg,
4399 payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_arg.data),
4400 }), is_owned: true }
4402 impl Clone for UpdateFulfillHTLC {
4403 fn clone(&self) -> Self {
4405 inner: if <*mut nativeUpdateFulfillHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
4406 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4412 /// Used only if an object of this type is returned as a trait impl by a method
4413 pub(crate) extern "C" fn UpdateFulfillHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
4414 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFulfillHTLC)).clone() })) as *mut c_void
4417 /// Creates a copy of the UpdateFulfillHTLC
4418 pub extern "C" fn UpdateFulfillHTLC_clone(orig: &UpdateFulfillHTLC) -> UpdateFulfillHTLC {
4421 /// Checks if two UpdateFulfillHTLCs contain equal inner contents.
4422 /// This ignores pointers and is_owned flags and looks at the values in fields.
4423 /// Two objects with NULL inner values will be considered "equal" here.
4425 pub extern "C" fn UpdateFulfillHTLC_eq(a: &UpdateFulfillHTLC, b: &UpdateFulfillHTLC) -> bool {
4426 if a.inner == b.inner { return true; }
4427 if a.inner.is_null() || b.inner.is_null() { return false; }
4428 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4431 use lightning::ln::msgs::UpdateFailHTLC as nativeUpdateFailHTLCImport;
4432 pub(crate) type nativeUpdateFailHTLC = nativeUpdateFailHTLCImport;
4434 /// An [`update_fail_htlc`] message to be sent to or received from a peer.
4436 /// [`update_fail_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#removing-an-htlc-update_fulfill_htlc-update_fail_htlc-and-update_fail_malformed_htlc
4439 pub struct UpdateFailHTLC {
4440 /// A pointer to the opaque Rust object.
4442 /// Nearly everywhere, inner must be non-null, however in places where
4443 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4444 pub inner: *mut nativeUpdateFailHTLC,
4445 /// Indicates that this is the only struct which contains the same pointer.
4447 /// Rust functions which take ownership of an object provided via an argument require
4448 /// this to be true and invalidate the object pointed to by inner.
4452 impl Drop for UpdateFailHTLC {
4453 fn drop(&mut self) {
4454 if self.is_owned && !<*mut nativeUpdateFailHTLC>::is_null(self.inner) {
4455 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4459 /// Frees any resources used by the UpdateFailHTLC, if is_owned is set and inner is non-NULL.
4461 pub extern "C" fn UpdateFailHTLC_free(this_obj: UpdateFailHTLC) { }
4463 /// Used only if an object of this type is returned as a trait impl by a method
4464 pub(crate) extern "C" fn UpdateFailHTLC_free_void(this_ptr: *mut c_void) {
4465 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFailHTLC) };
4468 impl UpdateFailHTLC {
4469 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailHTLC {
4470 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4472 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailHTLC {
4473 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4475 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4476 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailHTLC {
4477 assert!(self.is_owned);
4478 let ret = ObjOps::untweak_ptr(self.inner);
4479 self.inner = core::ptr::null_mut();
4485 pub extern "C" fn UpdateFailHTLC_get_channel_id(this_ptr: &UpdateFailHTLC) -> *const [u8; 32] {
4486 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4491 pub extern "C" fn UpdateFailHTLC_set_channel_id(this_ptr: &mut UpdateFailHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4492 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4496 pub extern "C" fn UpdateFailHTLC_get_htlc_id(this_ptr: &UpdateFailHTLC) -> u64 {
4497 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
4502 pub extern "C" fn UpdateFailHTLC_set_htlc_id(this_ptr: &mut UpdateFailHTLC, mut val: u64) {
4503 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
4505 impl Clone for UpdateFailHTLC {
4506 fn clone(&self) -> Self {
4508 inner: if <*mut nativeUpdateFailHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
4509 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4515 /// Used only if an object of this type is returned as a trait impl by a method
4516 pub(crate) extern "C" fn UpdateFailHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
4517 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailHTLC)).clone() })) as *mut c_void
4520 /// Creates a copy of the UpdateFailHTLC
4521 pub extern "C" fn UpdateFailHTLC_clone(orig: &UpdateFailHTLC) -> UpdateFailHTLC {
4524 /// Checks if two UpdateFailHTLCs contain equal inner contents.
4525 /// This ignores pointers and is_owned flags and looks at the values in fields.
4526 /// Two objects with NULL inner values will be considered "equal" here.
4528 pub extern "C" fn UpdateFailHTLC_eq(a: &UpdateFailHTLC, b: &UpdateFailHTLC) -> bool {
4529 if a.inner == b.inner { return true; }
4530 if a.inner.is_null() || b.inner.is_null() { return false; }
4531 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4534 use lightning::ln::msgs::UpdateFailMalformedHTLC as nativeUpdateFailMalformedHTLCImport;
4535 pub(crate) type nativeUpdateFailMalformedHTLC = nativeUpdateFailMalformedHTLCImport;
4537 /// An [`update_fail_malformed_htlc`] message to be sent to or received from a peer.
4539 /// [`update_fail_malformed_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#removing-an-htlc-update_fulfill_htlc-update_fail_htlc-and-update_fail_malformed_htlc
4542 pub struct UpdateFailMalformedHTLC {
4543 /// A pointer to the opaque Rust object.
4545 /// Nearly everywhere, inner must be non-null, however in places where
4546 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4547 pub inner: *mut nativeUpdateFailMalformedHTLC,
4548 /// Indicates that this is the only struct which contains the same pointer.
4550 /// Rust functions which take ownership of an object provided via an argument require
4551 /// this to be true and invalidate the object pointed to by inner.
4555 impl Drop for UpdateFailMalformedHTLC {
4556 fn drop(&mut self) {
4557 if self.is_owned && !<*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) {
4558 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4562 /// Frees any resources used by the UpdateFailMalformedHTLC, if is_owned is set and inner is non-NULL.
4564 pub extern "C" fn UpdateFailMalformedHTLC_free(this_obj: UpdateFailMalformedHTLC) { }
4566 /// Used only if an object of this type is returned as a trait impl by a method
4567 pub(crate) extern "C" fn UpdateFailMalformedHTLC_free_void(this_ptr: *mut c_void) {
4568 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFailMalformedHTLC) };
4571 impl UpdateFailMalformedHTLC {
4572 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailMalformedHTLC {
4573 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4575 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailMalformedHTLC {
4576 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4578 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4579 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailMalformedHTLC {
4580 assert!(self.is_owned);
4581 let ret = ObjOps::untweak_ptr(self.inner);
4582 self.inner = core::ptr::null_mut();
4588 pub extern "C" fn UpdateFailMalformedHTLC_get_channel_id(this_ptr: &UpdateFailMalformedHTLC) -> *const [u8; 32] {
4589 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4594 pub extern "C" fn UpdateFailMalformedHTLC_set_channel_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
4595 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4599 pub extern "C" fn UpdateFailMalformedHTLC_get_htlc_id(this_ptr: &UpdateFailMalformedHTLC) -> u64 {
4600 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
4605 pub extern "C" fn UpdateFailMalformedHTLC_set_htlc_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u64) {
4606 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
4608 /// The failure code
4610 pub extern "C" fn UpdateFailMalformedHTLC_get_failure_code(this_ptr: &UpdateFailMalformedHTLC) -> u16 {
4611 let mut inner_val = &mut this_ptr.get_native_mut_ref().failure_code;
4614 /// The failure code
4616 pub extern "C" fn UpdateFailMalformedHTLC_set_failure_code(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u16) {
4617 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.failure_code = val;
4619 impl Clone for UpdateFailMalformedHTLC {
4620 fn clone(&self) -> Self {
4622 inner: if <*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
4623 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4629 /// Used only if an object of this type is returned as a trait impl by a method
4630 pub(crate) extern "C" fn UpdateFailMalformedHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
4631 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailMalformedHTLC)).clone() })) as *mut c_void
4634 /// Creates a copy of the UpdateFailMalformedHTLC
4635 pub extern "C" fn UpdateFailMalformedHTLC_clone(orig: &UpdateFailMalformedHTLC) -> UpdateFailMalformedHTLC {
4638 /// Checks if two UpdateFailMalformedHTLCs contain equal inner contents.
4639 /// This ignores pointers and is_owned flags and looks at the values in fields.
4640 /// Two objects with NULL inner values will be considered "equal" here.
4642 pub extern "C" fn UpdateFailMalformedHTLC_eq(a: &UpdateFailMalformedHTLC, b: &UpdateFailMalformedHTLC) -> bool {
4643 if a.inner == b.inner { return true; }
4644 if a.inner.is_null() || b.inner.is_null() { return false; }
4645 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4648 use lightning::ln::msgs::CommitmentSigned as nativeCommitmentSignedImport;
4649 pub(crate) type nativeCommitmentSigned = nativeCommitmentSignedImport;
4651 /// A [`commitment_signed`] message to be sent to or received from a peer.
4653 /// [`commitment_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#committing-updates-so-far-commitment_signed
4656 pub struct CommitmentSigned {
4657 /// A pointer to the opaque Rust object.
4659 /// Nearly everywhere, inner must be non-null, however in places where
4660 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4661 pub inner: *mut nativeCommitmentSigned,
4662 /// Indicates that this is the only struct which contains the same pointer.
4664 /// Rust functions which take ownership of an object provided via an argument require
4665 /// this to be true and invalidate the object pointed to by inner.
4669 impl Drop for CommitmentSigned {
4670 fn drop(&mut self) {
4671 if self.is_owned && !<*mut nativeCommitmentSigned>::is_null(self.inner) {
4672 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4676 /// Frees any resources used by the CommitmentSigned, if is_owned is set and inner is non-NULL.
4678 pub extern "C" fn CommitmentSigned_free(this_obj: CommitmentSigned) { }
4680 /// Used only if an object of this type is returned as a trait impl by a method
4681 pub(crate) extern "C" fn CommitmentSigned_free_void(this_ptr: *mut c_void) {
4682 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCommitmentSigned) };
4685 impl CommitmentSigned {
4686 pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentSigned {
4687 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4689 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentSigned {
4690 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4692 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4693 pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentSigned {
4694 assert!(self.is_owned);
4695 let ret = ObjOps::untweak_ptr(self.inner);
4696 self.inner = core::ptr::null_mut();
4702 pub extern "C" fn CommitmentSigned_get_channel_id(this_ptr: &CommitmentSigned) -> *const [u8; 32] {
4703 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4708 pub extern "C" fn CommitmentSigned_set_channel_id(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::ThirtyTwoBytes) {
4709 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4711 /// A signature on the commitment transaction
4713 pub extern "C" fn CommitmentSigned_get_signature(this_ptr: &CommitmentSigned) -> crate::c_types::ECDSASignature {
4714 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
4715 crate::c_types::ECDSASignature::from_rust(&inner_val)
4717 /// A signature on the commitment transaction
4719 pub extern "C" fn CommitmentSigned_set_signature(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::ECDSASignature) {
4720 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
4722 /// Signatures on the HTLC transactions
4724 /// Returns a copy of the field.
4726 pub extern "C" fn CommitmentSigned_get_htlc_signatures(this_ptr: &CommitmentSigned) -> crate::c_types::derived::CVec_ECDSASignatureZ {
4727 let mut inner_val = this_ptr.get_native_mut_ref().htlc_signatures.clone();
4728 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { crate::c_types::ECDSASignature::from_rust(&item) }); };
4729 local_inner_val.into()
4731 /// Signatures on the HTLC transactions
4733 pub extern "C" fn CommitmentSigned_set_htlc_signatures(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::derived::CVec_ECDSASignatureZ) {
4734 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_rust() }); };
4735 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_signatures = local_val;
4737 /// Constructs a new CommitmentSigned given each field
4740 pub extern "C" fn CommitmentSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut signature_arg: crate::c_types::ECDSASignature, mut htlc_signatures_arg: crate::c_types::derived::CVec_ECDSASignatureZ) -> CommitmentSigned {
4741 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() }); };
4742 CommitmentSigned { inner: ObjOps::heap_alloc(nativeCommitmentSigned {
4743 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
4744 signature: signature_arg.into_rust(),
4745 htlc_signatures: local_htlc_signatures_arg,
4746 }), is_owned: true }
4748 impl Clone for CommitmentSigned {
4749 fn clone(&self) -> Self {
4751 inner: if <*mut nativeCommitmentSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
4752 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4758 /// Used only if an object of this type is returned as a trait impl by a method
4759 pub(crate) extern "C" fn CommitmentSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
4760 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentSigned)).clone() })) as *mut c_void
4763 /// Creates a copy of the CommitmentSigned
4764 pub extern "C" fn CommitmentSigned_clone(orig: &CommitmentSigned) -> CommitmentSigned {
4767 /// Checks if two CommitmentSigneds contain equal inner contents.
4768 /// This ignores pointers and is_owned flags and looks at the values in fields.
4769 /// Two objects with NULL inner values will be considered "equal" here.
4771 pub extern "C" fn CommitmentSigned_eq(a: &CommitmentSigned, b: &CommitmentSigned) -> bool {
4772 if a.inner == b.inner { return true; }
4773 if a.inner.is_null() || b.inner.is_null() { return false; }
4774 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4777 use lightning::ln::msgs::RevokeAndACK as nativeRevokeAndACKImport;
4778 pub(crate) type nativeRevokeAndACK = nativeRevokeAndACKImport;
4780 /// A [`revoke_and_ack`] message to be sent to or received from a peer.
4782 /// [`revoke_and_ack`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#completing-the-transition-to-the-updated-state-revoke_and_ack
4785 pub struct RevokeAndACK {
4786 /// A pointer to the opaque Rust object.
4788 /// Nearly everywhere, inner must be non-null, however in places where
4789 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4790 pub inner: *mut nativeRevokeAndACK,
4791 /// Indicates that this is the only struct which contains the same pointer.
4793 /// Rust functions which take ownership of an object provided via an argument require
4794 /// this to be true and invalidate the object pointed to by inner.
4798 impl Drop for RevokeAndACK {
4799 fn drop(&mut self) {
4800 if self.is_owned && !<*mut nativeRevokeAndACK>::is_null(self.inner) {
4801 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4805 /// Frees any resources used by the RevokeAndACK, if is_owned is set and inner is non-NULL.
4807 pub extern "C" fn RevokeAndACK_free(this_obj: RevokeAndACK) { }
4809 /// Used only if an object of this type is returned as a trait impl by a method
4810 pub(crate) extern "C" fn RevokeAndACK_free_void(this_ptr: *mut c_void) {
4811 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRevokeAndACK) };
4815 pub(crate) fn get_native_ref(&self) -> &'static nativeRevokeAndACK {
4816 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4818 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRevokeAndACK {
4819 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4821 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4822 pub(crate) fn take_inner(mut self) -> *mut nativeRevokeAndACK {
4823 assert!(self.is_owned);
4824 let ret = ObjOps::untweak_ptr(self.inner);
4825 self.inner = core::ptr::null_mut();
4831 pub extern "C" fn RevokeAndACK_get_channel_id(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
4832 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4837 pub extern "C" fn RevokeAndACK_set_channel_id(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
4838 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4840 /// The secret corresponding to the per-commitment point
4842 pub extern "C" fn RevokeAndACK_get_per_commitment_secret(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
4843 let mut inner_val = &mut this_ptr.get_native_mut_ref().per_commitment_secret;
4846 /// The secret corresponding to the per-commitment point
4848 pub extern "C" fn RevokeAndACK_set_per_commitment_secret(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
4849 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.per_commitment_secret = val.data;
4851 /// The next sender-broadcast commitment transaction's per-commitment point
4853 pub extern "C" fn RevokeAndACK_get_next_per_commitment_point(this_ptr: &RevokeAndACK) -> crate::c_types::PublicKey {
4854 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
4855 crate::c_types::PublicKey::from_rust(&inner_val)
4857 /// The next sender-broadcast commitment transaction's per-commitment point
4859 pub extern "C" fn RevokeAndACK_set_next_per_commitment_point(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::PublicKey) {
4860 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
4862 /// Constructs a new RevokeAndACK given each field
4865 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 {
4866 RevokeAndACK { inner: ObjOps::heap_alloc(nativeRevokeAndACK {
4867 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
4868 per_commitment_secret: per_commitment_secret_arg.data,
4869 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
4870 }), is_owned: true }
4872 impl Clone for RevokeAndACK {
4873 fn clone(&self) -> Self {
4875 inner: if <*mut nativeRevokeAndACK>::is_null(self.inner) { core::ptr::null_mut() } else {
4876 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4882 /// Used only if an object of this type is returned as a trait impl by a method
4883 pub(crate) extern "C" fn RevokeAndACK_clone_void(this_ptr: *const c_void) -> *mut c_void {
4884 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRevokeAndACK)).clone() })) as *mut c_void
4887 /// Creates a copy of the RevokeAndACK
4888 pub extern "C" fn RevokeAndACK_clone(orig: &RevokeAndACK) -> RevokeAndACK {
4891 /// Checks if two RevokeAndACKs contain equal inner contents.
4892 /// This ignores pointers and is_owned flags and looks at the values in fields.
4893 /// Two objects with NULL inner values will be considered "equal" here.
4895 pub extern "C" fn RevokeAndACK_eq(a: &RevokeAndACK, b: &RevokeAndACK) -> bool {
4896 if a.inner == b.inner { return true; }
4897 if a.inner.is_null() || b.inner.is_null() { return false; }
4898 if a.get_native_ref() == b.get_native_ref() { true } else { false }
4901 use lightning::ln::msgs::UpdateFee as nativeUpdateFeeImport;
4902 pub(crate) type nativeUpdateFee = nativeUpdateFeeImport;
4904 /// An [`update_fee`] message to be sent to or received from a peer
4906 /// [`update_fee`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#updating-fees-update_fee
4909 pub struct UpdateFee {
4910 /// A pointer to the opaque Rust object.
4912 /// Nearly everywhere, inner must be non-null, however in places where
4913 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4914 pub inner: *mut nativeUpdateFee,
4915 /// Indicates that this is the only struct which contains the same pointer.
4917 /// Rust functions which take ownership of an object provided via an argument require
4918 /// this to be true and invalidate the object pointed to by inner.
4922 impl Drop for UpdateFee {
4923 fn drop(&mut self) {
4924 if self.is_owned && !<*mut nativeUpdateFee>::is_null(self.inner) {
4925 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4929 /// Frees any resources used by the UpdateFee, if is_owned is set and inner is non-NULL.
4931 pub extern "C" fn UpdateFee_free(this_obj: UpdateFee) { }
4933 /// Used only if an object of this type is returned as a trait impl by a method
4934 pub(crate) extern "C" fn UpdateFee_free_void(this_ptr: *mut c_void) {
4935 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFee) };
4939 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFee {
4940 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4942 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFee {
4943 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4945 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4946 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFee {
4947 assert!(self.is_owned);
4948 let ret = ObjOps::untweak_ptr(self.inner);
4949 self.inner = core::ptr::null_mut();
4955 pub extern "C" fn UpdateFee_get_channel_id(this_ptr: &UpdateFee) -> *const [u8; 32] {
4956 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
4961 pub extern "C" fn UpdateFee_set_channel_id(this_ptr: &mut UpdateFee, mut val: crate::c_types::ThirtyTwoBytes) {
4962 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
4964 /// Fee rate per 1000-weight of the transaction
4966 pub extern "C" fn UpdateFee_get_feerate_per_kw(this_ptr: &UpdateFee) -> u32 {
4967 let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
4970 /// Fee rate per 1000-weight of the transaction
4972 pub extern "C" fn UpdateFee_set_feerate_per_kw(this_ptr: &mut UpdateFee, mut val: u32) {
4973 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
4975 /// Constructs a new UpdateFee given each field
4978 pub extern "C" fn UpdateFee_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut feerate_per_kw_arg: u32) -> UpdateFee {
4979 UpdateFee { inner: ObjOps::heap_alloc(nativeUpdateFee {
4980 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
4981 feerate_per_kw: feerate_per_kw_arg,
4982 }), is_owned: true }
4984 impl Clone for UpdateFee {
4985 fn clone(&self) -> Self {
4987 inner: if <*mut nativeUpdateFee>::is_null(self.inner) { core::ptr::null_mut() } else {
4988 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4994 /// Used only if an object of this type is returned as a trait impl by a method
4995 pub(crate) extern "C" fn UpdateFee_clone_void(this_ptr: *const c_void) -> *mut c_void {
4996 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFee)).clone() })) as *mut c_void
4999 /// Creates a copy of the UpdateFee
5000 pub extern "C" fn UpdateFee_clone(orig: &UpdateFee) -> UpdateFee {
5003 /// Checks if two UpdateFees contain equal inner contents.
5004 /// This ignores pointers and is_owned flags and looks at the values in fields.
5005 /// Two objects with NULL inner values will be considered "equal" here.
5007 pub extern "C" fn UpdateFee_eq(a: &UpdateFee, b: &UpdateFee) -> bool {
5008 if a.inner == b.inner { return true; }
5009 if a.inner.is_null() || b.inner.is_null() { return false; }
5010 if a.get_native_ref() == b.get_native_ref() { true } else { false }
5013 use lightning::ln::msgs::ChannelReestablish as nativeChannelReestablishImport;
5014 pub(crate) type nativeChannelReestablish = nativeChannelReestablishImport;
5016 /// A [`channel_reestablish`] message to be sent to or received from a peer.
5018 /// [`channel_reestablish`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#message-retransmission
5021 pub struct ChannelReestablish {
5022 /// A pointer to the opaque Rust object.
5024 /// Nearly everywhere, inner must be non-null, however in places where
5025 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5026 pub inner: *mut nativeChannelReestablish,
5027 /// Indicates that this is the only struct which contains the same pointer.
5029 /// Rust functions which take ownership of an object provided via an argument require
5030 /// this to be true and invalidate the object pointed to by inner.
5034 impl Drop for ChannelReestablish {
5035 fn drop(&mut self) {
5036 if self.is_owned && !<*mut nativeChannelReestablish>::is_null(self.inner) {
5037 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5041 /// Frees any resources used by the ChannelReestablish, if is_owned is set and inner is non-NULL.
5043 pub extern "C" fn ChannelReestablish_free(this_obj: ChannelReestablish) { }
5045 /// Used only if an object of this type is returned as a trait impl by a method
5046 pub(crate) extern "C" fn ChannelReestablish_free_void(this_ptr: *mut c_void) {
5047 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelReestablish) };
5050 impl ChannelReestablish {
5051 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelReestablish {
5052 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5054 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelReestablish {
5055 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5057 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5058 pub(crate) fn take_inner(mut self) -> *mut nativeChannelReestablish {
5059 assert!(self.is_owned);
5060 let ret = ObjOps::untweak_ptr(self.inner);
5061 self.inner = core::ptr::null_mut();
5067 pub extern "C" fn ChannelReestablish_get_channel_id(this_ptr: &ChannelReestablish) -> *const [u8; 32] {
5068 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5073 pub extern "C" fn ChannelReestablish_set_channel_id(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) {
5074 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
5076 /// The next commitment number for the sender
5078 pub extern "C" fn ChannelReestablish_get_next_local_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
5079 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_local_commitment_number;
5082 /// The next commitment number for the sender
5084 pub extern "C" fn ChannelReestablish_set_next_local_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
5085 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_local_commitment_number = val;
5087 /// The next commitment number for the recipient
5089 pub extern "C" fn ChannelReestablish_get_next_remote_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
5090 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_remote_commitment_number;
5093 /// The next commitment number for the recipient
5095 pub extern "C" fn ChannelReestablish_set_next_remote_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
5096 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_remote_commitment_number = val;
5098 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
5099 /// belonging to the recipient
5101 pub extern "C" fn ChannelReestablish_get_your_last_per_commitment_secret(this_ptr: &ChannelReestablish) -> *const [u8; 32] {
5102 let mut inner_val = &mut this_ptr.get_native_mut_ref().your_last_per_commitment_secret;
5105 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
5106 /// belonging to the recipient
5108 pub extern "C" fn ChannelReestablish_set_your_last_per_commitment_secret(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) {
5109 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.your_last_per_commitment_secret = val.data;
5111 /// The sender's per-commitment point for their current commitment transaction
5113 pub extern "C" fn ChannelReestablish_get_my_current_per_commitment_point(this_ptr: &ChannelReestablish) -> crate::c_types::PublicKey {
5114 let mut inner_val = &mut this_ptr.get_native_mut_ref().my_current_per_commitment_point;
5115 crate::c_types::PublicKey::from_rust(&inner_val)
5117 /// The sender's per-commitment point for their current commitment transaction
5119 pub extern "C" fn ChannelReestablish_set_my_current_per_commitment_point(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::PublicKey) {
5120 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.my_current_per_commitment_point = val.into_rust();
5122 /// The next funding transaction ID
5124 pub extern "C" fn ChannelReestablish_get_next_funding_txid(this_ptr: &ChannelReestablish) -> crate::c_types::derived::COption_ThirtyTwoBytesZ {
5125 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_funding_txid;
5126 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { crate::c_types::ThirtyTwoBytes { data: (*inner_val.as_ref().unwrap()).clone().into_inner() } }) };
5129 /// The next funding transaction ID
5131 pub extern "C" fn ChannelReestablish_set_next_funding_txid(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::derived::COption_ThirtyTwoBytesZ) {
5132 let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::hash_types::Txid::from_slice(&{ val_opt.take() }.data[..]).unwrap() }})} };
5133 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_funding_txid = local_val;
5135 /// Constructs a new ChannelReestablish given each field
5138 pub extern "C" fn ChannelReestablish_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut next_local_commitment_number_arg: u64, mut next_remote_commitment_number_arg: u64, mut your_last_per_commitment_secret_arg: crate::c_types::ThirtyTwoBytes, mut my_current_per_commitment_point_arg: crate::c_types::PublicKey, mut next_funding_txid_arg: crate::c_types::derived::COption_ThirtyTwoBytesZ) -> ChannelReestablish {
5139 let mut local_next_funding_txid_arg = { /*next_funding_txid_arg*/ let next_funding_txid_arg_opt = next_funding_txid_arg; if next_funding_txid_arg_opt.is_none() { None } else { Some({ { ::bitcoin::hash_types::Txid::from_slice(&{ next_funding_txid_arg_opt.take() }.data[..]).unwrap() }})} };
5140 ChannelReestablish { inner: ObjOps::heap_alloc(nativeChannelReestablish {
5141 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
5142 next_local_commitment_number: next_local_commitment_number_arg,
5143 next_remote_commitment_number: next_remote_commitment_number_arg,
5144 your_last_per_commitment_secret: your_last_per_commitment_secret_arg.data,
5145 my_current_per_commitment_point: my_current_per_commitment_point_arg.into_rust(),
5146 next_funding_txid: local_next_funding_txid_arg,
5147 }), is_owned: true }
5149 impl Clone for ChannelReestablish {
5150 fn clone(&self) -> Self {
5152 inner: if <*mut nativeChannelReestablish>::is_null(self.inner) { core::ptr::null_mut() } else {
5153 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5159 /// Used only if an object of this type is returned as a trait impl by a method
5160 pub(crate) extern "C" fn ChannelReestablish_clone_void(this_ptr: *const c_void) -> *mut c_void {
5161 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelReestablish)).clone() })) as *mut c_void
5164 /// Creates a copy of the ChannelReestablish
5165 pub extern "C" fn ChannelReestablish_clone(orig: &ChannelReestablish) -> ChannelReestablish {
5168 /// Checks if two ChannelReestablishs contain equal inner contents.
5169 /// This ignores pointers and is_owned flags and looks at the values in fields.
5170 /// Two objects with NULL inner values will be considered "equal" here.
5172 pub extern "C" fn ChannelReestablish_eq(a: &ChannelReestablish, b: &ChannelReestablish) -> bool {
5173 if a.inner == b.inner { return true; }
5174 if a.inner.is_null() || b.inner.is_null() { return false; }
5175 if a.get_native_ref() == b.get_native_ref() { true } else { false }
5178 use lightning::ln::msgs::AnnouncementSignatures as nativeAnnouncementSignaturesImport;
5179 pub(crate) type nativeAnnouncementSignatures = nativeAnnouncementSignaturesImport;
5181 /// An [`announcement_signatures`] message to be sent to or received from a peer.
5183 /// [`announcement_signatures`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-announcement_signatures-message
5186 pub struct AnnouncementSignatures {
5187 /// A pointer to the opaque Rust object.
5189 /// Nearly everywhere, inner must be non-null, however in places where
5190 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5191 pub inner: *mut nativeAnnouncementSignatures,
5192 /// Indicates that this is the only struct which contains the same pointer.
5194 /// Rust functions which take ownership of an object provided via an argument require
5195 /// this to be true and invalidate the object pointed to by inner.
5199 impl Drop for AnnouncementSignatures {
5200 fn drop(&mut self) {
5201 if self.is_owned && !<*mut nativeAnnouncementSignatures>::is_null(self.inner) {
5202 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5206 /// Frees any resources used by the AnnouncementSignatures, if is_owned is set and inner is non-NULL.
5208 pub extern "C" fn AnnouncementSignatures_free(this_obj: AnnouncementSignatures) { }
5210 /// Used only if an object of this type is returned as a trait impl by a method
5211 pub(crate) extern "C" fn AnnouncementSignatures_free_void(this_ptr: *mut c_void) {
5212 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAnnouncementSignatures) };
5215 impl AnnouncementSignatures {
5216 pub(crate) fn get_native_ref(&self) -> &'static nativeAnnouncementSignatures {
5217 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5219 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAnnouncementSignatures {
5220 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5222 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5223 pub(crate) fn take_inner(mut self) -> *mut nativeAnnouncementSignatures {
5224 assert!(self.is_owned);
5225 let ret = ObjOps::untweak_ptr(self.inner);
5226 self.inner = core::ptr::null_mut();
5232 pub extern "C" fn AnnouncementSignatures_get_channel_id(this_ptr: &AnnouncementSignatures) -> *const [u8; 32] {
5233 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
5238 pub extern "C" fn AnnouncementSignatures_set_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
5239 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
5241 /// The short channel ID
5243 pub extern "C" fn AnnouncementSignatures_get_short_channel_id(this_ptr: &AnnouncementSignatures) -> u64 {
5244 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
5247 /// The short channel ID
5249 pub extern "C" fn AnnouncementSignatures_set_short_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: u64) {
5250 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
5252 /// A signature by the node key
5254 pub extern "C" fn AnnouncementSignatures_get_node_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::ECDSASignature {
5255 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature;
5256 crate::c_types::ECDSASignature::from_rust(&inner_val)
5258 /// A signature by the node key
5260 pub extern "C" fn AnnouncementSignatures_set_node_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ECDSASignature) {
5261 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature = val.into_rust();
5263 /// A signature by the funding key
5265 pub extern "C" fn AnnouncementSignatures_get_bitcoin_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::ECDSASignature {
5266 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature;
5267 crate::c_types::ECDSASignature::from_rust(&inner_val)
5269 /// A signature by the funding key
5271 pub extern "C" fn AnnouncementSignatures_set_bitcoin_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ECDSASignature) {
5272 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature = val.into_rust();
5274 /// Constructs a new AnnouncementSignatures given each field
5277 pub extern "C" fn AnnouncementSignatures_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_id_arg: u64, mut node_signature_arg: crate::c_types::ECDSASignature, mut bitcoin_signature_arg: crate::c_types::ECDSASignature) -> AnnouncementSignatures {
5278 AnnouncementSignatures { inner: ObjOps::heap_alloc(nativeAnnouncementSignatures {
5279 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
5280 short_channel_id: short_channel_id_arg,
5281 node_signature: node_signature_arg.into_rust(),
5282 bitcoin_signature: bitcoin_signature_arg.into_rust(),
5283 }), is_owned: true }
5285 impl Clone for AnnouncementSignatures {
5286 fn clone(&self) -> Self {
5288 inner: if <*mut nativeAnnouncementSignatures>::is_null(self.inner) { core::ptr::null_mut() } else {
5289 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5295 /// Used only if an object of this type is returned as a trait impl by a method
5296 pub(crate) extern "C" fn AnnouncementSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
5297 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAnnouncementSignatures)).clone() })) as *mut c_void
5300 /// Creates a copy of the AnnouncementSignatures
5301 pub extern "C" fn AnnouncementSignatures_clone(orig: &AnnouncementSignatures) -> AnnouncementSignatures {
5304 /// Checks if two AnnouncementSignaturess contain equal inner contents.
5305 /// This ignores pointers and is_owned flags and looks at the values in fields.
5306 /// Two objects with NULL inner values will be considered "equal" here.
5308 pub extern "C" fn AnnouncementSignatures_eq(a: &AnnouncementSignatures, b: &AnnouncementSignatures) -> bool {
5309 if a.inner == b.inner { return true; }
5310 if a.inner.is_null() || b.inner.is_null() { return false; }
5311 if a.get_native_ref() == b.get_native_ref() { true } else { false }
5313 /// An address which can be used to connect to a remote peer.
5317 pub enum SocketAddress {
5318 /// An IPv4 address and port on which the peer is listening.
5320 /// The 4-byte IPv4 address
5321 addr: crate::c_types::FourBytes,
5322 /// The port on which the node is listening
5325 /// An IPv6 address and port on which the peer is listening.
5327 /// The 16-byte IPv6 address
5328 addr: crate::c_types::SixteenBytes,
5329 /// The port on which the node is listening
5332 /// An old-style Tor onion address/port on which the peer is listening.
5334 /// This field is deprecated and the Tor network generally no longer supports V2 Onion
5335 /// addresses. Thus, the details are not parsed here.
5337 crate::c_types::TwelveBytes),
5338 /// A new-style Tor onion address/port on which the peer is listening.
5340 /// To create the human-readable \"hostname\", concatenate the ED25519 pubkey, checksum, and version,
5341 /// wrap as base32 and append \".onion\".
5343 /// The ed25519 long-term public key of the peer
5344 ed25519_pubkey: crate::c_types::ThirtyTwoBytes,
5345 /// The checksum of the pubkey and version, as included in the onion address
5347 /// The version byte, as defined by the Tor Onion v3 spec.
5349 /// The port on which the node is listening
5352 /// A hostname/port on which the peer is listening.
5354 /// The hostname on which the node is listening.
5355 hostname: crate::lightning::util::ser::Hostname,
5356 /// The port on which the node is listening.
5360 use lightning::ln::msgs::SocketAddress as SocketAddressImport;
5361 pub(crate) type nativeSocketAddress = SocketAddressImport;
5363 impl SocketAddress {
5365 pub(crate) fn to_native(&self) -> nativeSocketAddress {
5367 SocketAddress::TcpIpV4 {ref addr, ref port, } => {
5368 let mut addr_nonref = Clone::clone(addr);
5369 let mut port_nonref = Clone::clone(port);
5370 nativeSocketAddress::TcpIpV4 {
5371 addr: addr_nonref.data,
5375 SocketAddress::TcpIpV6 {ref addr, ref port, } => {
5376 let mut addr_nonref = Clone::clone(addr);
5377 let mut port_nonref = Clone::clone(port);
5378 nativeSocketAddress::TcpIpV6 {
5379 addr: addr_nonref.data,
5383 SocketAddress::OnionV2 (ref a, ) => {
5384 let mut a_nonref = Clone::clone(a);
5385 nativeSocketAddress::OnionV2 (
5389 SocketAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
5390 let mut ed25519_pubkey_nonref = Clone::clone(ed25519_pubkey);
5391 let mut checksum_nonref = Clone::clone(checksum);
5392 let mut version_nonref = Clone::clone(version);
5393 let mut port_nonref = Clone::clone(port);
5394 nativeSocketAddress::OnionV3 {
5395 ed25519_pubkey: ed25519_pubkey_nonref.data,
5396 checksum: checksum_nonref,
5397 version: version_nonref,
5401 SocketAddress::Hostname {ref hostname, ref port, } => {
5402 let mut hostname_nonref = Clone::clone(hostname);
5403 let mut port_nonref = Clone::clone(port);
5404 nativeSocketAddress::Hostname {
5405 hostname: *unsafe { Box::from_raw(hostname_nonref.take_inner()) },
5412 pub(crate) fn into_native(self) -> nativeSocketAddress {
5414 SocketAddress::TcpIpV4 {mut addr, mut port, } => {
5415 nativeSocketAddress::TcpIpV4 {
5420 SocketAddress::TcpIpV6 {mut addr, mut port, } => {
5421 nativeSocketAddress::TcpIpV6 {
5426 SocketAddress::OnionV2 (mut a, ) => {
5427 nativeSocketAddress::OnionV2 (
5431 SocketAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
5432 nativeSocketAddress::OnionV3 {
5433 ed25519_pubkey: ed25519_pubkey.data,
5439 SocketAddress::Hostname {mut hostname, mut port, } => {
5440 nativeSocketAddress::Hostname {
5441 hostname: *unsafe { Box::from_raw(hostname.take_inner()) },
5448 pub(crate) fn from_native(native: &nativeSocketAddress) -> Self {
5450 nativeSocketAddress::TcpIpV4 {ref addr, ref port, } => {
5451 let mut addr_nonref = Clone::clone(addr);
5452 let mut port_nonref = Clone::clone(port);
5453 SocketAddress::TcpIpV4 {
5454 addr: crate::c_types::FourBytes { data: addr_nonref },
5458 nativeSocketAddress::TcpIpV6 {ref addr, ref port, } => {
5459 let mut addr_nonref = Clone::clone(addr);
5460 let mut port_nonref = Clone::clone(port);
5461 SocketAddress::TcpIpV6 {
5462 addr: crate::c_types::SixteenBytes { data: addr_nonref },
5466 nativeSocketAddress::OnionV2 (ref a, ) => {
5467 let mut a_nonref = Clone::clone(a);
5468 SocketAddress::OnionV2 (
5469 crate::c_types::TwelveBytes { data: a_nonref },
5472 nativeSocketAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
5473 let mut ed25519_pubkey_nonref = Clone::clone(ed25519_pubkey);
5474 let mut checksum_nonref = Clone::clone(checksum);
5475 let mut version_nonref = Clone::clone(version);
5476 let mut port_nonref = Clone::clone(port);
5477 SocketAddress::OnionV3 {
5478 ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey_nonref },
5479 checksum: checksum_nonref,
5480 version: version_nonref,
5484 nativeSocketAddress::Hostname {ref hostname, ref port, } => {
5485 let mut hostname_nonref = Clone::clone(hostname);
5486 let mut port_nonref = Clone::clone(port);
5487 SocketAddress::Hostname {
5488 hostname: crate::lightning::util::ser::Hostname { inner: ObjOps::heap_alloc(hostname_nonref), is_owned: true },
5495 pub(crate) fn native_into(native: nativeSocketAddress) -> Self {
5497 nativeSocketAddress::TcpIpV4 {mut addr, mut port, } => {
5498 SocketAddress::TcpIpV4 {
5499 addr: crate::c_types::FourBytes { data: addr },
5503 nativeSocketAddress::TcpIpV6 {mut addr, mut port, } => {
5504 SocketAddress::TcpIpV6 {
5505 addr: crate::c_types::SixteenBytes { data: addr },
5509 nativeSocketAddress::OnionV2 (mut a, ) => {
5510 SocketAddress::OnionV2 (
5511 crate::c_types::TwelveBytes { data: a },
5514 nativeSocketAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
5515 SocketAddress::OnionV3 {
5516 ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey },
5522 nativeSocketAddress::Hostname {mut hostname, mut port, } => {
5523 SocketAddress::Hostname {
5524 hostname: crate::lightning::util::ser::Hostname { inner: ObjOps::heap_alloc(hostname), is_owned: true },
5531 /// Frees any resources used by the SocketAddress
5533 pub extern "C" fn SocketAddress_free(this_ptr: SocketAddress) { }
5534 /// Creates a copy of the SocketAddress
5536 pub extern "C" fn SocketAddress_clone(orig: &SocketAddress) -> SocketAddress {
5540 /// Utility method to constructs a new TcpIpV4-variant SocketAddress
5541 pub extern "C" fn SocketAddress_tcp_ip_v4(addr: crate::c_types::FourBytes, port: u16) -> SocketAddress {
5542 SocketAddress::TcpIpV4 {
5548 /// Utility method to constructs a new TcpIpV6-variant SocketAddress
5549 pub extern "C" fn SocketAddress_tcp_ip_v6(addr: crate::c_types::SixteenBytes, port: u16) -> SocketAddress {
5550 SocketAddress::TcpIpV6 {
5556 /// Utility method to constructs a new OnionV2-variant SocketAddress
5557 pub extern "C" fn SocketAddress_onion_v2(a: crate::c_types::TwelveBytes) -> SocketAddress {
5558 SocketAddress::OnionV2(a, )
5561 /// Utility method to constructs a new OnionV3-variant SocketAddress
5562 pub extern "C" fn SocketAddress_onion_v3(ed25519_pubkey: crate::c_types::ThirtyTwoBytes, checksum: u16, version: u8, port: u16) -> SocketAddress {
5563 SocketAddress::OnionV3 {
5571 /// Utility method to constructs a new Hostname-variant SocketAddress
5572 pub extern "C" fn SocketAddress_hostname(hostname: crate::lightning::util::ser::Hostname, port: u16) -> SocketAddress {
5573 SocketAddress::Hostname {
5578 /// Checks if two SocketAddresss contain equal inner contents.
5579 /// This ignores pointers and is_owned flags and looks at the values in fields.
5581 pub extern "C" fn SocketAddress_eq(a: &SocketAddress, b: &SocketAddress) -> bool {
5582 if &a.to_native() == &b.to_native() { true } else { false }
5585 /// Serialize the SocketAddress object into a byte array which can be read by SocketAddress_read
5586 pub extern "C" fn SocketAddress_write(obj: &crate::lightning::ln::msgs::SocketAddress) -> crate::c_types::derived::CVec_u8Z {
5587 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
5590 /// Read a SocketAddress from a byte array, created by SocketAddress_write
5591 pub extern "C" fn SocketAddress_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SocketAddressDecodeErrorZ {
5592 let res: Result<lightning::ln::msgs::SocketAddress, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5593 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::SocketAddress::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
5596 /// [`SocketAddress`] error variants
5600 pub enum SocketAddressParseError {
5601 /// Socket address (IPv4/IPv6) parsing error
5603 /// Invalid input format
5607 /// Invalid onion v3 address
5610 use lightning::ln::msgs::SocketAddressParseError as SocketAddressParseErrorImport;
5611 pub(crate) type nativeSocketAddressParseError = SocketAddressParseErrorImport;
5613 impl SocketAddressParseError {
5615 pub(crate) fn to_native(&self) -> nativeSocketAddressParseError {
5617 SocketAddressParseError::SocketAddrParse => nativeSocketAddressParseError::SocketAddrParse,
5618 SocketAddressParseError::InvalidInput => nativeSocketAddressParseError::InvalidInput,
5619 SocketAddressParseError::InvalidPort => nativeSocketAddressParseError::InvalidPort,
5620 SocketAddressParseError::InvalidOnionV3 => nativeSocketAddressParseError::InvalidOnionV3,
5624 pub(crate) fn into_native(self) -> nativeSocketAddressParseError {
5626 SocketAddressParseError::SocketAddrParse => nativeSocketAddressParseError::SocketAddrParse,
5627 SocketAddressParseError::InvalidInput => nativeSocketAddressParseError::InvalidInput,
5628 SocketAddressParseError::InvalidPort => nativeSocketAddressParseError::InvalidPort,
5629 SocketAddressParseError::InvalidOnionV3 => nativeSocketAddressParseError::InvalidOnionV3,
5633 pub(crate) fn from_native(native: &nativeSocketAddressParseError) -> Self {
5635 nativeSocketAddressParseError::SocketAddrParse => SocketAddressParseError::SocketAddrParse,
5636 nativeSocketAddressParseError::InvalidInput => SocketAddressParseError::InvalidInput,
5637 nativeSocketAddressParseError::InvalidPort => SocketAddressParseError::InvalidPort,
5638 nativeSocketAddressParseError::InvalidOnionV3 => SocketAddressParseError::InvalidOnionV3,
5642 pub(crate) fn native_into(native: nativeSocketAddressParseError) -> Self {
5644 nativeSocketAddressParseError::SocketAddrParse => SocketAddressParseError::SocketAddrParse,
5645 nativeSocketAddressParseError::InvalidInput => SocketAddressParseError::InvalidInput,
5646 nativeSocketAddressParseError::InvalidPort => SocketAddressParseError::InvalidPort,
5647 nativeSocketAddressParseError::InvalidOnionV3 => SocketAddressParseError::InvalidOnionV3,
5651 /// Creates a copy of the SocketAddressParseError
5653 pub extern "C" fn SocketAddressParseError_clone(orig: &SocketAddressParseError) -> SocketAddressParseError {
5657 /// Utility method to constructs a new SocketAddrParse-variant SocketAddressParseError
5658 pub extern "C" fn SocketAddressParseError_socket_addr_parse() -> SocketAddressParseError {
5659 SocketAddressParseError::SocketAddrParse}
5661 /// Utility method to constructs a new InvalidInput-variant SocketAddressParseError
5662 pub extern "C" fn SocketAddressParseError_invalid_input() -> SocketAddressParseError {
5663 SocketAddressParseError::InvalidInput}
5665 /// Utility method to constructs a new InvalidPort-variant SocketAddressParseError
5666 pub extern "C" fn SocketAddressParseError_invalid_port() -> SocketAddressParseError {
5667 SocketAddressParseError::InvalidPort}
5669 /// Utility method to constructs a new InvalidOnionV3-variant SocketAddressParseError
5670 pub extern "C" fn SocketAddressParseError_invalid_onion_v3() -> SocketAddressParseError {
5671 SocketAddressParseError::InvalidOnionV3}
5672 /// Checks if two SocketAddressParseErrors contain equal inner contents.
5673 /// This ignores pointers and is_owned flags and looks at the values in fields.
5675 pub extern "C" fn SocketAddressParseError_eq(a: &SocketAddressParseError, b: &SocketAddressParseError) -> bool {
5676 if &a.to_native() == &b.to_native() { true } else { false }
5678 /// Parses an OnionV3 host and port into a [`SocketAddress::OnionV3`].
5680 /// The host part must end with \".onion\".
5682 pub extern "C" fn parse_onion_address(mut host: crate::c_types::Str, mut port: u16) -> crate::c_types::derived::CResult_SocketAddressSocketAddressParseErrorZ {
5683 let mut ret = lightning::ln::msgs::parse_onion_address(host.into_str(), port);
5684 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::SocketAddress::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::SocketAddressParseError::native_into(e) }).into() };
5689 /// Read a SocketAddress object from a string
5690 pub extern "C" fn SocketAddress_from_str(s: crate::c_types::Str) -> crate::c_types::derived::CResult_SocketAddressSocketAddressParseErrorZ {
5691 match lightning::ln::msgs::SocketAddress::from_str(s.into_str()) {
5693 crate::c_types::CResultTempl::ok(
5694 crate::lightning::ln::msgs::SocketAddress::native_into(r)
5698 crate::c_types::CResultTempl::err(
5699 crate::lightning::ln::msgs::SocketAddressParseError::native_into(e)
5704 /// Represents the set of gossip messages that require a signature from a node's identity key.
5708 pub enum UnsignedGossipMessage {
5709 /// An unsigned channel announcement.
5710 ChannelAnnouncement(
5711 crate::lightning::ln::msgs::UnsignedChannelAnnouncement),
5712 /// An unsigned channel update.
5714 crate::lightning::ln::msgs::UnsignedChannelUpdate),
5715 /// An unsigned node announcement.
5717 crate::lightning::ln::msgs::UnsignedNodeAnnouncement),
5719 use lightning::ln::msgs::UnsignedGossipMessage as UnsignedGossipMessageImport;
5720 pub(crate) type nativeUnsignedGossipMessage = UnsignedGossipMessageImport;
5722 impl UnsignedGossipMessage {
5724 pub(crate) fn to_native(&self) -> nativeUnsignedGossipMessage {
5726 UnsignedGossipMessage::ChannelAnnouncement (ref a, ) => {
5727 let mut a_nonref = Clone::clone(a);
5728 nativeUnsignedGossipMessage::ChannelAnnouncement (
5729 *unsafe { Box::from_raw(a_nonref.take_inner()) },
5732 UnsignedGossipMessage::ChannelUpdate (ref a, ) => {
5733 let mut a_nonref = Clone::clone(a);
5734 nativeUnsignedGossipMessage::ChannelUpdate (
5735 *unsafe { Box::from_raw(a_nonref.take_inner()) },
5738 UnsignedGossipMessage::NodeAnnouncement (ref a, ) => {
5739 let mut a_nonref = Clone::clone(a);
5740 nativeUnsignedGossipMessage::NodeAnnouncement (
5741 *unsafe { Box::from_raw(a_nonref.take_inner()) },
5747 pub(crate) fn into_native(self) -> nativeUnsignedGossipMessage {
5749 UnsignedGossipMessage::ChannelAnnouncement (mut a, ) => {
5750 nativeUnsignedGossipMessage::ChannelAnnouncement (
5751 *unsafe { Box::from_raw(a.take_inner()) },
5754 UnsignedGossipMessage::ChannelUpdate (mut a, ) => {
5755 nativeUnsignedGossipMessage::ChannelUpdate (
5756 *unsafe { Box::from_raw(a.take_inner()) },
5759 UnsignedGossipMessage::NodeAnnouncement (mut a, ) => {
5760 nativeUnsignedGossipMessage::NodeAnnouncement (
5761 *unsafe { Box::from_raw(a.take_inner()) },
5767 pub(crate) fn from_native(native: &nativeUnsignedGossipMessage) -> Self {
5769 nativeUnsignedGossipMessage::ChannelAnnouncement (ref a, ) => {
5770 let mut a_nonref = Clone::clone(a);
5771 UnsignedGossipMessage::ChannelAnnouncement (
5772 crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
5775 nativeUnsignedGossipMessage::ChannelUpdate (ref a, ) => {
5776 let mut a_nonref = Clone::clone(a);
5777 UnsignedGossipMessage::ChannelUpdate (
5778 crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
5781 nativeUnsignedGossipMessage::NodeAnnouncement (ref a, ) => {
5782 let mut a_nonref = Clone::clone(a);
5783 UnsignedGossipMessage::NodeAnnouncement (
5784 crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
5790 pub(crate) fn native_into(native: nativeUnsignedGossipMessage) -> Self {
5792 nativeUnsignedGossipMessage::ChannelAnnouncement (mut a, ) => {
5793 UnsignedGossipMessage::ChannelAnnouncement (
5794 crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(a), is_owned: true },
5797 nativeUnsignedGossipMessage::ChannelUpdate (mut a, ) => {
5798 UnsignedGossipMessage::ChannelUpdate (
5799 crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: ObjOps::heap_alloc(a), is_owned: true },
5802 nativeUnsignedGossipMessage::NodeAnnouncement (mut a, ) => {
5803 UnsignedGossipMessage::NodeAnnouncement (
5804 crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: ObjOps::heap_alloc(a), is_owned: true },
5810 /// Frees any resources used by the UnsignedGossipMessage
5812 pub extern "C" fn UnsignedGossipMessage_free(this_ptr: UnsignedGossipMessage) { }
5813 /// Creates a copy of the UnsignedGossipMessage
5815 pub extern "C" fn UnsignedGossipMessage_clone(orig: &UnsignedGossipMessage) -> UnsignedGossipMessage {
5819 /// Utility method to constructs a new ChannelAnnouncement-variant UnsignedGossipMessage
5820 pub extern "C" fn UnsignedGossipMessage_channel_announcement(a: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> UnsignedGossipMessage {
5821 UnsignedGossipMessage::ChannelAnnouncement(a, )
5824 /// Utility method to constructs a new ChannelUpdate-variant UnsignedGossipMessage
5825 pub extern "C" fn UnsignedGossipMessage_channel_update(a: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> UnsignedGossipMessage {
5826 UnsignedGossipMessage::ChannelUpdate(a, )
5829 /// Utility method to constructs a new NodeAnnouncement-variant UnsignedGossipMessage
5830 pub extern "C" fn UnsignedGossipMessage_node_announcement(a: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> UnsignedGossipMessage {
5831 UnsignedGossipMessage::NodeAnnouncement(a, )
5834 /// Serialize the UnsignedGossipMessage object into a byte array which can be read by UnsignedGossipMessage_read
5835 pub extern "C" fn UnsignedGossipMessage_write(obj: &crate::lightning::ln::msgs::UnsignedGossipMessage) -> crate::c_types::derived::CVec_u8Z {
5836 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
5839 use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport;
5840 pub(crate) type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport;
5842 /// The unsigned part of a [`node_announcement`] message.
5844 /// [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message
5847 pub struct UnsignedNodeAnnouncement {
5848 /// A pointer to the opaque Rust object.
5850 /// Nearly everywhere, inner must be non-null, however in places where
5851 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5852 pub inner: *mut nativeUnsignedNodeAnnouncement,
5853 /// Indicates that this is the only struct which contains the same pointer.
5855 /// Rust functions which take ownership of an object provided via an argument require
5856 /// this to be true and invalidate the object pointed to by inner.
5860 impl Drop for UnsignedNodeAnnouncement {
5861 fn drop(&mut self) {
5862 if self.is_owned && !<*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) {
5863 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5867 /// Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL.
5869 pub extern "C" fn UnsignedNodeAnnouncement_free(this_obj: UnsignedNodeAnnouncement) { }
5871 /// Used only if an object of this type is returned as a trait impl by a method
5872 pub(crate) extern "C" fn UnsignedNodeAnnouncement_free_void(this_ptr: *mut c_void) {
5873 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedNodeAnnouncement) };
5876 impl UnsignedNodeAnnouncement {
5877 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedNodeAnnouncement {
5878 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5880 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedNodeAnnouncement {
5881 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5883 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5884 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedNodeAnnouncement {
5885 assert!(self.is_owned);
5886 let ret = ObjOps::untweak_ptr(self.inner);
5887 self.inner = core::ptr::null_mut();
5891 /// The advertised features
5893 pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::ln::features::NodeFeatures {
5894 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
5895 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 }
5897 /// The advertised features
5899 pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::ln::features::NodeFeatures) {
5900 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
5902 /// A strictly monotonic announcement counter, with gaps allowed
5904 pub extern "C" fn UnsignedNodeAnnouncement_get_timestamp(this_ptr: &UnsignedNodeAnnouncement) -> u32 {
5905 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
5908 /// A strictly monotonic announcement counter, with gaps allowed
5910 pub extern "C" fn UnsignedNodeAnnouncement_set_timestamp(this_ptr: &mut UnsignedNodeAnnouncement, mut val: u32) {
5911 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
5913 /// The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back
5916 pub extern "C" fn UnsignedNodeAnnouncement_get_node_id(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::routing::gossip::NodeId {
5917 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id;
5918 crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false }
5920 /// The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back
5923 pub extern "C" fn UnsignedNodeAnnouncement_set_node_id(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
5924 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id = *unsafe { Box::from_raw(val.take_inner()) };
5926 /// An RGB color for UI purposes
5928 pub extern "C" fn UnsignedNodeAnnouncement_get_rgb(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 3] {
5929 let mut inner_val = &mut this_ptr.get_native_mut_ref().rgb;
5932 /// An RGB color for UI purposes
5934 pub extern "C" fn UnsignedNodeAnnouncement_set_rgb(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThreeBytes) {
5935 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.rgb = val.data;
5937 /// An alias, for UI purposes.
5939 /// This should be sanitized before use. There is no guarantee of uniqueness.
5941 pub extern "C" fn UnsignedNodeAnnouncement_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::routing::gossip::NodeAlias {
5942 let mut inner_val = &mut this_ptr.get_native_mut_ref().alias;
5943 crate::lightning::routing::gossip::NodeAlias { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeAlias<>) as *mut _) }, is_owned: false }
5945 /// An alias, for UI purposes.
5947 /// This should be sanitized before use. There is no guarantee of uniqueness.
5949 pub extern "C" fn UnsignedNodeAnnouncement_set_alias(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::routing::gossip::NodeAlias) {
5950 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.alias = *unsafe { Box::from_raw(val.take_inner()) };
5952 /// List of addresses on which this node is reachable
5954 /// Returns a copy of the field.
5956 pub extern "C" fn UnsignedNodeAnnouncement_get_addresses(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_SocketAddressZ {
5957 let mut inner_val = this_ptr.get_native_mut_ref().addresses.clone();
5958 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { crate::lightning::ln::msgs::SocketAddress::native_into(item) }); };
5959 local_inner_val.into()
5961 /// List of addresses on which this node is reachable
5963 pub extern "C" fn UnsignedNodeAnnouncement_set_addresses(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_SocketAddressZ) {
5964 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
5965 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.addresses = local_val;
5967 impl Clone for UnsignedNodeAnnouncement {
5968 fn clone(&self) -> Self {
5970 inner: if <*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
5971 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5977 /// Used only if an object of this type is returned as a trait impl by a method
5978 pub(crate) extern "C" fn UnsignedNodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
5979 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedNodeAnnouncement)).clone() })) as *mut c_void
5982 /// Creates a copy of the UnsignedNodeAnnouncement
5983 pub extern "C" fn UnsignedNodeAnnouncement_clone(orig: &UnsignedNodeAnnouncement) -> UnsignedNodeAnnouncement {
5986 /// Checks if two UnsignedNodeAnnouncements contain equal inner contents.
5987 /// This ignores pointers and is_owned flags and looks at the values in fields.
5988 /// Two objects with NULL inner values will be considered "equal" here.
5990 pub extern "C" fn UnsignedNodeAnnouncement_eq(a: &UnsignedNodeAnnouncement, b: &UnsignedNodeAnnouncement) -> bool {
5991 if a.inner == b.inner { return true; }
5992 if a.inner.is_null() || b.inner.is_null() { return false; }
5993 if a.get_native_ref() == b.get_native_ref() { true } else { false }
5996 use lightning::ln::msgs::NodeAnnouncement as nativeNodeAnnouncementImport;
5997 pub(crate) type nativeNodeAnnouncement = nativeNodeAnnouncementImport;
5999 /// A [`node_announcement`] message to be sent to or received from a peer.
6001 /// [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message
6004 pub struct NodeAnnouncement {
6005 /// A pointer to the opaque Rust object.
6007 /// Nearly everywhere, inner must be non-null, however in places where
6008 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6009 pub inner: *mut nativeNodeAnnouncement,
6010 /// Indicates that this is the only struct which contains the same pointer.
6012 /// Rust functions which take ownership of an object provided via an argument require
6013 /// this to be true and invalidate the object pointed to by inner.
6017 impl Drop for NodeAnnouncement {
6018 fn drop(&mut self) {
6019 if self.is_owned && !<*mut nativeNodeAnnouncement>::is_null(self.inner) {
6020 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6024 /// Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL.
6026 pub extern "C" fn NodeAnnouncement_free(this_obj: NodeAnnouncement) { }
6028 /// Used only if an object of this type is returned as a trait impl by a method
6029 pub(crate) extern "C" fn NodeAnnouncement_free_void(this_ptr: *mut c_void) {
6030 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeNodeAnnouncement) };
6033 impl NodeAnnouncement {
6034 pub(crate) fn get_native_ref(&self) -> &'static nativeNodeAnnouncement {
6035 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6037 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeAnnouncement {
6038 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6040 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6041 pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncement {
6042 assert!(self.is_owned);
6043 let ret = ObjOps::untweak_ptr(self.inner);
6044 self.inner = core::ptr::null_mut();
6048 /// The signature by the node key
6050 pub extern "C" fn NodeAnnouncement_get_signature(this_ptr: &NodeAnnouncement) -> crate::c_types::ECDSASignature {
6051 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
6052 crate::c_types::ECDSASignature::from_rust(&inner_val)
6054 /// The signature by the node key
6056 pub extern "C" fn NodeAnnouncement_set_signature(this_ptr: &mut NodeAnnouncement, mut val: crate::c_types::ECDSASignature) {
6057 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
6059 /// The actual content of the announcement
6061 pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> crate::lightning::ln::msgs::UnsignedNodeAnnouncement {
6062 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
6063 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 }
6065 /// The actual content of the announcement
6067 pub extern "C" fn NodeAnnouncement_set_contents(this_ptr: &mut NodeAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) {
6068 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
6070 /// Constructs a new NodeAnnouncement given each field
6073 pub extern "C" fn NodeAnnouncement_new(mut signature_arg: crate::c_types::ECDSASignature, mut contents_arg: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> NodeAnnouncement {
6074 NodeAnnouncement { inner: ObjOps::heap_alloc(nativeNodeAnnouncement {
6075 signature: signature_arg.into_rust(),
6076 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
6077 }), is_owned: true }
6079 impl Clone for NodeAnnouncement {
6080 fn clone(&self) -> Self {
6082 inner: if <*mut nativeNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
6083 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6089 /// Used only if an object of this type is returned as a trait impl by a method
6090 pub(crate) extern "C" fn NodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
6091 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeAnnouncement)).clone() })) as *mut c_void
6094 /// Creates a copy of the NodeAnnouncement
6095 pub extern "C" fn NodeAnnouncement_clone(orig: &NodeAnnouncement) -> NodeAnnouncement {
6098 /// Checks if two NodeAnnouncements contain equal inner contents.
6099 /// This ignores pointers and is_owned flags and looks at the values in fields.
6100 /// Two objects with NULL inner values will be considered "equal" here.
6102 pub extern "C" fn NodeAnnouncement_eq(a: &NodeAnnouncement, b: &NodeAnnouncement) -> bool {
6103 if a.inner == b.inner { return true; }
6104 if a.inner.is_null() || b.inner.is_null() { return false; }
6105 if a.get_native_ref() == b.get_native_ref() { true } else { false }
6108 use lightning::ln::msgs::UnsignedChannelAnnouncement as nativeUnsignedChannelAnnouncementImport;
6109 pub(crate) type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport;
6111 /// The unsigned part of a [`channel_announcement`] message.
6113 /// [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message
6116 pub struct UnsignedChannelAnnouncement {
6117 /// A pointer to the opaque Rust object.
6119 /// Nearly everywhere, inner must be non-null, however in places where
6120 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6121 pub inner: *mut nativeUnsignedChannelAnnouncement,
6122 /// Indicates that this is the only struct which contains the same pointer.
6124 /// Rust functions which take ownership of an object provided via an argument require
6125 /// this to be true and invalidate the object pointed to by inner.
6129 impl Drop for UnsignedChannelAnnouncement {
6130 fn drop(&mut self) {
6131 if self.is_owned && !<*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) {
6132 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6136 /// Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL.
6138 pub extern "C" fn UnsignedChannelAnnouncement_free(this_obj: UnsignedChannelAnnouncement) { }
6140 /// Used only if an object of this type is returned as a trait impl by a method
6141 pub(crate) extern "C" fn UnsignedChannelAnnouncement_free_void(this_ptr: *mut c_void) {
6142 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedChannelAnnouncement) };
6145 impl UnsignedChannelAnnouncement {
6146 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelAnnouncement {
6147 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6149 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelAnnouncement {
6150 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6152 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6153 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelAnnouncement {
6154 assert!(self.is_owned);
6155 let ret = ObjOps::untweak_ptr(self.inner);
6156 self.inner = core::ptr::null_mut();
6160 /// The advertised channel features
6162 pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::ln::features::ChannelFeatures {
6163 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
6164 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 }
6166 /// The advertised channel features
6168 pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::ln::features::ChannelFeatures) {
6169 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
6171 /// The genesis hash of the blockchain where the channel is to be opened
6173 pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &UnsignedChannelAnnouncement) -> *const [u8; 32] {
6174 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
6175 inner_val.as_inner()
6177 /// The genesis hash of the blockchain where the channel is to be opened
6179 pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
6180 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
6182 /// The short channel ID
6184 pub extern "C" fn UnsignedChannelAnnouncement_get_short_channel_id(this_ptr: &UnsignedChannelAnnouncement) -> u64 {
6185 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
6188 /// The short channel ID
6190 pub extern "C" fn UnsignedChannelAnnouncement_set_short_channel_id(this_ptr: &mut UnsignedChannelAnnouncement, mut val: u64) {
6191 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
6193 /// One of the two `node_id`s which are endpoints of this channel
6195 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
6196 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_1;
6197 crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false }
6199 /// One of the two `node_id`s which are endpoints of this channel
6201 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
6202 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_1 = *unsafe { Box::from_raw(val.take_inner()) };
6204 /// The other of the two `node_id`s which are endpoints of this channel
6206 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
6207 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_2;
6208 crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false }
6210 /// The other of the two `node_id`s which are endpoints of this channel
6212 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
6213 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_2 = *unsafe { Box::from_raw(val.take_inner()) };
6215 /// The funding key for the first node
6217 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
6218 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_1;
6219 crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false }
6221 /// The funding key for the first node
6223 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
6224 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_1 = *unsafe { Box::from_raw(val.take_inner()) };
6226 /// The funding key for the second node
6228 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::routing::gossip::NodeId {
6229 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_2;
6230 crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false }
6232 /// The funding key for the second node
6234 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::routing::gossip::NodeId) {
6235 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_2 = *unsafe { Box::from_raw(val.take_inner()) };
6237 /// Excess data which was signed as a part of the message which we do not (yet) understand how
6240 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
6242 /// Returns a copy of the field.
6244 pub extern "C" fn UnsignedChannelAnnouncement_get_excess_data(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
6245 let mut inner_val = this_ptr.get_native_mut_ref().excess_data.clone();
6246 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
6247 local_inner_val.into()
6249 /// Excess data which was signed as a part of the message which we do not (yet) understand how
6252 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
6254 pub extern "C" fn UnsignedChannelAnnouncement_set_excess_data(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::derived::CVec_u8Z) {
6255 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
6256 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_data = local_val;
6258 /// Constructs a new UnsignedChannelAnnouncement given each field
6261 pub extern "C" fn UnsignedChannelAnnouncement_new(mut features_arg: crate::lightning::ln::features::ChannelFeatures, mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_id_arg: u64, mut node_id_1_arg: crate::lightning::routing::gossip::NodeId, mut node_id_2_arg: crate::lightning::routing::gossip::NodeId, mut bitcoin_key_1_arg: crate::lightning::routing::gossip::NodeId, mut bitcoin_key_2_arg: crate::lightning::routing::gossip::NodeId, mut excess_data_arg: crate::c_types::derived::CVec_u8Z) -> UnsignedChannelAnnouncement {
6262 let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); };
6263 UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(nativeUnsignedChannelAnnouncement {
6264 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
6265 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
6266 short_channel_id: short_channel_id_arg,
6267 node_id_1: *unsafe { Box::from_raw(node_id_1_arg.take_inner()) },
6268 node_id_2: *unsafe { Box::from_raw(node_id_2_arg.take_inner()) },
6269 bitcoin_key_1: *unsafe { Box::from_raw(bitcoin_key_1_arg.take_inner()) },
6270 bitcoin_key_2: *unsafe { Box::from_raw(bitcoin_key_2_arg.take_inner()) },
6271 excess_data: local_excess_data_arg,
6272 }), is_owned: true }
6274 impl Clone for UnsignedChannelAnnouncement {
6275 fn clone(&self) -> Self {
6277 inner: if <*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
6278 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6284 /// Used only if an object of this type is returned as a trait impl by a method
6285 pub(crate) extern "C" fn UnsignedChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
6286 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelAnnouncement)).clone() })) as *mut c_void
6289 /// Creates a copy of the UnsignedChannelAnnouncement
6290 pub extern "C" fn UnsignedChannelAnnouncement_clone(orig: &UnsignedChannelAnnouncement) -> UnsignedChannelAnnouncement {
6293 /// Checks if two UnsignedChannelAnnouncements contain equal inner contents.
6294 /// This ignores pointers and is_owned flags and looks at the values in fields.
6295 /// Two objects with NULL inner values will be considered "equal" here.
6297 pub extern "C" fn UnsignedChannelAnnouncement_eq(a: &UnsignedChannelAnnouncement, b: &UnsignedChannelAnnouncement) -> bool {
6298 if a.inner == b.inner { return true; }
6299 if a.inner.is_null() || b.inner.is_null() { return false; }
6300 if a.get_native_ref() == b.get_native_ref() { true } else { false }
6303 use lightning::ln::msgs::ChannelAnnouncement as nativeChannelAnnouncementImport;
6304 pub(crate) type nativeChannelAnnouncement = nativeChannelAnnouncementImport;
6306 /// A [`channel_announcement`] message to be sent to or received from a peer.
6308 /// [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message
6311 pub struct ChannelAnnouncement {
6312 /// A pointer to the opaque Rust object.
6314 /// Nearly everywhere, inner must be non-null, however in places where
6315 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6316 pub inner: *mut nativeChannelAnnouncement,
6317 /// Indicates that this is the only struct which contains the same pointer.
6319 /// Rust functions which take ownership of an object provided via an argument require
6320 /// this to be true and invalidate the object pointed to by inner.
6324 impl Drop for ChannelAnnouncement {
6325 fn drop(&mut self) {
6326 if self.is_owned && !<*mut nativeChannelAnnouncement>::is_null(self.inner) {
6327 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6331 /// Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL.
6333 pub extern "C" fn ChannelAnnouncement_free(this_obj: ChannelAnnouncement) { }
6335 /// Used only if an object of this type is returned as a trait impl by a method
6336 pub(crate) extern "C" fn ChannelAnnouncement_free_void(this_ptr: *mut c_void) {
6337 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelAnnouncement) };
6340 impl ChannelAnnouncement {
6341 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelAnnouncement {
6342 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6344 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelAnnouncement {
6345 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6347 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6348 pub(crate) fn take_inner(mut self) -> *mut nativeChannelAnnouncement {
6349 assert!(self.is_owned);
6350 let ret = ObjOps::untweak_ptr(self.inner);
6351 self.inner = core::ptr::null_mut();
6355 /// Authentication of the announcement by the first public node
6357 pub extern "C" fn ChannelAnnouncement_get_node_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
6358 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_1;
6359 crate::c_types::ECDSASignature::from_rust(&inner_val)
6361 /// Authentication of the announcement by the first public node
6363 pub extern "C" fn ChannelAnnouncement_set_node_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
6364 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_1 = val.into_rust();
6366 /// Authentication of the announcement by the second public node
6368 pub extern "C" fn ChannelAnnouncement_get_node_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
6369 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_2;
6370 crate::c_types::ECDSASignature::from_rust(&inner_val)
6372 /// Authentication of the announcement by the second public node
6374 pub extern "C" fn ChannelAnnouncement_set_node_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
6375 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_2 = val.into_rust();
6377 /// Proof of funding UTXO ownership by the first public node
6379 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
6380 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_1;
6381 crate::c_types::ECDSASignature::from_rust(&inner_val)
6383 /// Proof of funding UTXO ownership by the first public node
6385 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
6386 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_1 = val.into_rust();
6388 /// Proof of funding UTXO ownership by the second public node
6390 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::ECDSASignature {
6391 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_2;
6392 crate::c_types::ECDSASignature::from_rust(&inner_val)
6394 /// Proof of funding UTXO ownership by the second public node
6396 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::ECDSASignature) {
6397 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_2 = val.into_rust();
6399 /// The actual announcement
6401 pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncement) -> crate::lightning::ln::msgs::UnsignedChannelAnnouncement {
6402 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
6403 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 }
6405 /// The actual announcement
6407 pub extern "C" fn ChannelAnnouncement_set_contents(this_ptr: &mut ChannelAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) {
6408 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
6410 /// Constructs a new ChannelAnnouncement given each field
6413 pub extern "C" fn ChannelAnnouncement_new(mut node_signature_1_arg: crate::c_types::ECDSASignature, mut node_signature_2_arg: crate::c_types::ECDSASignature, mut bitcoin_signature_1_arg: crate::c_types::ECDSASignature, mut bitcoin_signature_2_arg: crate::c_types::ECDSASignature, mut contents_arg: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> ChannelAnnouncement {
6414 ChannelAnnouncement { inner: ObjOps::heap_alloc(nativeChannelAnnouncement {
6415 node_signature_1: node_signature_1_arg.into_rust(),
6416 node_signature_2: node_signature_2_arg.into_rust(),
6417 bitcoin_signature_1: bitcoin_signature_1_arg.into_rust(),
6418 bitcoin_signature_2: bitcoin_signature_2_arg.into_rust(),
6419 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
6420 }), is_owned: true }
6422 impl Clone for ChannelAnnouncement {
6423 fn clone(&self) -> Self {
6425 inner: if <*mut nativeChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
6426 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6432 /// Used only if an object of this type is returned as a trait impl by a method
6433 pub(crate) extern "C" fn ChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
6434 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelAnnouncement)).clone() })) as *mut c_void
6437 /// Creates a copy of the ChannelAnnouncement
6438 pub extern "C" fn ChannelAnnouncement_clone(orig: &ChannelAnnouncement) -> ChannelAnnouncement {
6441 /// Checks if two ChannelAnnouncements contain equal inner contents.
6442 /// This ignores pointers and is_owned flags and looks at the values in fields.
6443 /// Two objects with NULL inner values will be considered "equal" here.
6445 pub extern "C" fn ChannelAnnouncement_eq(a: &ChannelAnnouncement, b: &ChannelAnnouncement) -> bool {
6446 if a.inner == b.inner { return true; }
6447 if a.inner.is_null() || b.inner.is_null() { return false; }
6448 if a.get_native_ref() == b.get_native_ref() { true } else { false }
6451 use lightning::ln::msgs::UnsignedChannelUpdate as nativeUnsignedChannelUpdateImport;
6452 pub(crate) type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport;
6454 /// The unsigned part of a [`channel_update`] message.
6456 /// [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
6459 pub struct UnsignedChannelUpdate {
6460 /// A pointer to the opaque Rust object.
6462 /// Nearly everywhere, inner must be non-null, however in places where
6463 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6464 pub inner: *mut nativeUnsignedChannelUpdate,
6465 /// Indicates that this is the only struct which contains the same pointer.
6467 /// Rust functions which take ownership of an object provided via an argument require
6468 /// this to be true and invalidate the object pointed to by inner.
6472 impl Drop for UnsignedChannelUpdate {
6473 fn drop(&mut self) {
6474 if self.is_owned && !<*mut nativeUnsignedChannelUpdate>::is_null(self.inner) {
6475 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6479 /// Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL.
6481 pub extern "C" fn UnsignedChannelUpdate_free(this_obj: UnsignedChannelUpdate) { }
6483 /// Used only if an object of this type is returned as a trait impl by a method
6484 pub(crate) extern "C" fn UnsignedChannelUpdate_free_void(this_ptr: *mut c_void) {
6485 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedChannelUpdate) };
6488 impl UnsignedChannelUpdate {
6489 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelUpdate {
6490 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6492 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelUpdate {
6493 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6495 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6496 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelUpdate {
6497 assert!(self.is_owned);
6498 let ret = ObjOps::untweak_ptr(self.inner);
6499 self.inner = core::ptr::null_mut();
6503 /// The genesis hash of the blockchain where the channel is to be opened
6505 pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChannelUpdate) -> *const [u8; 32] {
6506 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
6507 inner_val.as_inner()
6509 /// The genesis hash of the blockchain where the channel is to be opened
6511 pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::ThirtyTwoBytes) {
6512 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
6514 /// The short channel ID
6516 pub extern "C" fn UnsignedChannelUpdate_get_short_channel_id(this_ptr: &UnsignedChannelUpdate) -> u64 {
6517 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
6520 /// The short channel ID
6522 pub extern "C" fn UnsignedChannelUpdate_set_short_channel_id(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
6523 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
6525 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
6527 pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannelUpdate) -> u32 {
6528 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
6531 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
6533 pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
6534 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
6538 pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 {
6539 let mut inner_val = &mut this_ptr.get_native_mut_ref().flags;
6544 pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) {
6545 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.flags = val;
6547 /// The number of blocks such that if:
6548 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
6549 /// then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines
6550 /// the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a
6551 /// `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10,
6552 /// then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before
6553 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
6554 /// constructing the route.
6556 pub extern "C" fn UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr: &UnsignedChannelUpdate) -> u16 {
6557 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
6560 /// The number of blocks such that if:
6561 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
6562 /// then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines
6563 /// the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a
6564 /// `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10,
6565 /// then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before
6566 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
6567 /// constructing the route.
6569 pub extern "C" fn UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr: &mut UnsignedChannelUpdate, mut val: u16) {
6570 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
6572 /// The minimum HTLC size incoming to sender, in milli-satoshi
6574 pub extern "C" fn UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
6575 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
6578 /// The minimum HTLC size incoming to sender, in milli-satoshi
6580 pub extern "C" fn UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
6581 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
6583 /// The maximum HTLC value incoming to sender, in milli-satoshi.
6585 /// This used to be optional.
6587 pub extern "C" fn UnsignedChannelUpdate_get_htlc_maximum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
6588 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat;
6591 /// The maximum HTLC value incoming to sender, in milli-satoshi.
6593 /// This used to be optional.
6595 pub extern "C" fn UnsignedChannelUpdate_set_htlc_maximum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
6596 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = val;
6598 /// The base HTLC fee charged by sender, in milli-satoshi
6600 pub extern "C" fn UnsignedChannelUpdate_get_fee_base_msat(this_ptr: &UnsignedChannelUpdate) -> u32 {
6601 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat;
6604 /// The base HTLC fee charged by sender, in milli-satoshi
6606 pub extern "C" fn UnsignedChannelUpdate_set_fee_base_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
6607 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val;
6609 /// The amount to fee multiplier, in micro-satoshi
6611 pub extern "C" fn UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr: &UnsignedChannelUpdate) -> u32 {
6612 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths;
6615 /// The amount to fee multiplier, in micro-satoshi
6617 pub extern "C" fn UnsignedChannelUpdate_set_fee_proportional_millionths(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
6618 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val;
6620 /// Excess data which was signed as a part of the message which we do not (yet) understand how
6623 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
6625 /// Returns a copy of the field.
6627 pub extern "C" fn UnsignedChannelUpdate_get_excess_data(this_ptr: &UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
6628 let mut inner_val = this_ptr.get_native_mut_ref().excess_data.clone();
6629 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
6630 local_inner_val.into()
6632 /// Excess data which was signed as a part of the message which we do not (yet) understand how
6635 /// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
6637 pub extern "C" fn UnsignedChannelUpdate_set_excess_data(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::derived::CVec_u8Z) {
6638 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
6639 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_data = local_val;
6641 /// Constructs a new UnsignedChannelUpdate given each field
6644 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 {
6645 let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); };
6646 UnsignedChannelUpdate { inner: ObjOps::heap_alloc(nativeUnsignedChannelUpdate {
6647 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
6648 short_channel_id: short_channel_id_arg,
6649 timestamp: timestamp_arg,
6651 cltv_expiry_delta: cltv_expiry_delta_arg,
6652 htlc_minimum_msat: htlc_minimum_msat_arg,
6653 htlc_maximum_msat: htlc_maximum_msat_arg,
6654 fee_base_msat: fee_base_msat_arg,
6655 fee_proportional_millionths: fee_proportional_millionths_arg,
6656 excess_data: local_excess_data_arg,
6657 }), is_owned: true }
6659 impl Clone for UnsignedChannelUpdate {
6660 fn clone(&self) -> Self {
6662 inner: if <*mut nativeUnsignedChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
6663 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6669 /// Used only if an object of this type is returned as a trait impl by a method
6670 pub(crate) extern "C" fn UnsignedChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
6671 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelUpdate)).clone() })) as *mut c_void
6674 /// Creates a copy of the UnsignedChannelUpdate
6675 pub extern "C" fn UnsignedChannelUpdate_clone(orig: &UnsignedChannelUpdate) -> UnsignedChannelUpdate {
6678 /// Checks if two UnsignedChannelUpdates contain equal inner contents.
6679 /// This ignores pointers and is_owned flags and looks at the values in fields.
6680 /// Two objects with NULL inner values will be considered "equal" here.
6682 pub extern "C" fn UnsignedChannelUpdate_eq(a: &UnsignedChannelUpdate, b: &UnsignedChannelUpdate) -> bool {
6683 if a.inner == b.inner { return true; }
6684 if a.inner.is_null() || b.inner.is_null() { return false; }
6685 if a.get_native_ref() == b.get_native_ref() { true } else { false }
6688 use lightning::ln::msgs::ChannelUpdate as nativeChannelUpdateImport;
6689 pub(crate) type nativeChannelUpdate = nativeChannelUpdateImport;
6691 /// A [`channel_update`] message to be sent to or received from a peer.
6693 /// [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
6696 pub struct ChannelUpdate {
6697 /// A pointer to the opaque Rust object.
6699 /// Nearly everywhere, inner must be non-null, however in places where
6700 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6701 pub inner: *mut nativeChannelUpdate,
6702 /// Indicates that this is the only struct which contains the same pointer.
6704 /// Rust functions which take ownership of an object provided via an argument require
6705 /// this to be true and invalidate the object pointed to by inner.
6709 impl Drop for ChannelUpdate {
6710 fn drop(&mut self) {
6711 if self.is_owned && !<*mut nativeChannelUpdate>::is_null(self.inner) {
6712 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6716 /// Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL.
6718 pub extern "C" fn ChannelUpdate_free(this_obj: ChannelUpdate) { }
6720 /// Used only if an object of this type is returned as a trait impl by a method
6721 pub(crate) extern "C" fn ChannelUpdate_free_void(this_ptr: *mut c_void) {
6722 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelUpdate) };
6725 impl ChannelUpdate {
6726 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelUpdate {
6727 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6729 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelUpdate {
6730 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6732 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6733 pub(crate) fn take_inner(mut self) -> *mut nativeChannelUpdate {
6734 assert!(self.is_owned);
6735 let ret = ObjOps::untweak_ptr(self.inner);
6736 self.inner = core::ptr::null_mut();
6740 /// A signature of the channel update
6742 pub extern "C" fn ChannelUpdate_get_signature(this_ptr: &ChannelUpdate) -> crate::c_types::ECDSASignature {
6743 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
6744 crate::c_types::ECDSASignature::from_rust(&inner_val)
6746 /// A signature of the channel update
6748 pub extern "C" fn ChannelUpdate_set_signature(this_ptr: &mut ChannelUpdate, mut val: crate::c_types::ECDSASignature) {
6749 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
6751 /// The actual channel update
6753 pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate::lightning::ln::msgs::UnsignedChannelUpdate {
6754 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
6755 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 }
6757 /// The actual channel update
6759 pub extern "C" fn ChannelUpdate_set_contents(this_ptr: &mut ChannelUpdate, mut val: crate::lightning::ln::msgs::UnsignedChannelUpdate) {
6760 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
6762 /// Constructs a new ChannelUpdate given each field
6765 pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::ECDSASignature, mut contents_arg: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> ChannelUpdate {
6766 ChannelUpdate { inner: ObjOps::heap_alloc(nativeChannelUpdate {
6767 signature: signature_arg.into_rust(),
6768 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
6769 }), is_owned: true }
6771 impl Clone for ChannelUpdate {
6772 fn clone(&self) -> Self {
6774 inner: if <*mut nativeChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
6775 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6781 /// Used only if an object of this type is returned as a trait impl by a method
6782 pub(crate) extern "C" fn ChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
6783 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelUpdate)).clone() })) as *mut c_void
6786 /// Creates a copy of the ChannelUpdate
6787 pub extern "C" fn ChannelUpdate_clone(orig: &ChannelUpdate) -> ChannelUpdate {
6790 /// Checks if two ChannelUpdates contain equal inner contents.
6791 /// This ignores pointers and is_owned flags and looks at the values in fields.
6792 /// Two objects with NULL inner values will be considered "equal" here.
6794 pub extern "C" fn ChannelUpdate_eq(a: &ChannelUpdate, b: &ChannelUpdate) -> bool {
6795 if a.inner == b.inner { return true; }
6796 if a.inner.is_null() || b.inner.is_null() { return false; }
6797 if a.get_native_ref() == b.get_native_ref() { true } else { false }
6800 use lightning::ln::msgs::QueryChannelRange as nativeQueryChannelRangeImport;
6801 pub(crate) type nativeQueryChannelRange = nativeQueryChannelRangeImport;
6803 /// A [`query_channel_range`] message is used to query a peer for channel
6804 /// UTXOs in a range of blocks. The recipient of a query makes a best
6805 /// effort to reply to the query using one or more [`ReplyChannelRange`]
6808 /// [`query_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages
6811 pub struct QueryChannelRange {
6812 /// A pointer to the opaque Rust object.
6814 /// Nearly everywhere, inner must be non-null, however in places where
6815 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6816 pub inner: *mut nativeQueryChannelRange,
6817 /// Indicates that this is the only struct which contains the same pointer.
6819 /// Rust functions which take ownership of an object provided via an argument require
6820 /// this to be true and invalidate the object pointed to by inner.
6824 impl Drop for QueryChannelRange {
6825 fn drop(&mut self) {
6826 if self.is_owned && !<*mut nativeQueryChannelRange>::is_null(self.inner) {
6827 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6831 /// Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL.
6833 pub extern "C" fn QueryChannelRange_free(this_obj: QueryChannelRange) { }
6835 /// Used only if an object of this type is returned as a trait impl by a method
6836 pub(crate) extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) {
6837 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeQueryChannelRange) };
6840 impl QueryChannelRange {
6841 pub(crate) fn get_native_ref(&self) -> &'static nativeQueryChannelRange {
6842 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6844 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryChannelRange {
6845 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6847 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6848 pub(crate) fn take_inner(mut self) -> *mut nativeQueryChannelRange {
6849 assert!(self.is_owned);
6850 let ret = ObjOps::untweak_ptr(self.inner);
6851 self.inner = core::ptr::null_mut();
6855 /// The genesis hash of the blockchain being queried
6857 pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *const [u8; 32] {
6858 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
6859 inner_val.as_inner()
6861 /// The genesis hash of the blockchain being queried
6863 pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
6864 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
6866 /// The height of the first block for the channel UTXOs being queried
6868 pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 {
6869 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
6872 /// The height of the first block for the channel UTXOs being queried
6874 pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChannelRange, mut val: u32) {
6875 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
6877 /// The number of blocks to include in the query results
6879 pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 {
6880 let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
6883 /// The number of blocks to include in the query results
6885 pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryChannelRange, mut val: u32) {
6886 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
6888 /// Constructs a new QueryChannelRange given each field
6891 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 {
6892 QueryChannelRange { inner: ObjOps::heap_alloc(nativeQueryChannelRange {
6893 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
6894 first_blocknum: first_blocknum_arg,
6895 number_of_blocks: number_of_blocks_arg,
6896 }), is_owned: true }
6898 impl Clone for QueryChannelRange {
6899 fn clone(&self) -> Self {
6901 inner: if <*mut nativeQueryChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
6902 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
6908 /// Used only if an object of this type is returned as a trait impl by a method
6909 pub(crate) extern "C" fn QueryChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
6910 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryChannelRange)).clone() })) as *mut c_void
6913 /// Creates a copy of the QueryChannelRange
6914 pub extern "C" fn QueryChannelRange_clone(orig: &QueryChannelRange) -> QueryChannelRange {
6917 /// Checks if two QueryChannelRanges contain equal inner contents.
6918 /// This ignores pointers and is_owned flags and looks at the values in fields.
6919 /// Two objects with NULL inner values will be considered "equal" here.
6921 pub extern "C" fn QueryChannelRange_eq(a: &QueryChannelRange, b: &QueryChannelRange) -> bool {
6922 if a.inner == b.inner { return true; }
6923 if a.inner.is_null() || b.inner.is_null() { return false; }
6924 if a.get_native_ref() == b.get_native_ref() { true } else { false }
6927 use lightning::ln::msgs::ReplyChannelRange as nativeReplyChannelRangeImport;
6928 pub(crate) type nativeReplyChannelRange = nativeReplyChannelRangeImport;
6930 /// A [`reply_channel_range`] message is a reply to a [`QueryChannelRange`]
6933 /// Multiple `reply_channel_range` messages can be sent in reply
6934 /// to a single [`QueryChannelRange`] message. The query recipient makes a
6935 /// best effort to respond based on their local network view which may
6936 /// not be a perfect view of the network. The `short_channel_id`s in the
6937 /// reply are encoded. We only support `encoding_type=0` uncompressed
6938 /// serialization and do not support `encoding_type=1` zlib serialization.
6940 /// [`reply_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages
6943 pub struct ReplyChannelRange {
6944 /// A pointer to the opaque Rust object.
6946 /// Nearly everywhere, inner must be non-null, however in places where
6947 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
6948 pub inner: *mut nativeReplyChannelRange,
6949 /// Indicates that this is the only struct which contains the same pointer.
6951 /// Rust functions which take ownership of an object provided via an argument require
6952 /// this to be true and invalidate the object pointed to by inner.
6956 impl Drop for ReplyChannelRange {
6957 fn drop(&mut self) {
6958 if self.is_owned && !<*mut nativeReplyChannelRange>::is_null(self.inner) {
6959 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
6963 /// Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL.
6965 pub extern "C" fn ReplyChannelRange_free(this_obj: ReplyChannelRange) { }
6967 /// Used only if an object of this type is returned as a trait impl by a method
6968 pub(crate) extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) {
6969 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeReplyChannelRange) };
6972 impl ReplyChannelRange {
6973 pub(crate) fn get_native_ref(&self) -> &'static nativeReplyChannelRange {
6974 unsafe { &*ObjOps::untweak_ptr(self.inner) }
6976 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyChannelRange {
6977 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
6979 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
6980 pub(crate) fn take_inner(mut self) -> *mut nativeReplyChannelRange {
6981 assert!(self.is_owned);
6982 let ret = ObjOps::untweak_ptr(self.inner);
6983 self.inner = core::ptr::null_mut();
6987 /// The genesis hash of the blockchain being queried
6989 pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *const [u8; 32] {
6990 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
6991 inner_val.as_inner()
6993 /// The genesis hash of the blockchain being queried
6995 pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
6996 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
6998 /// The height of the first block in the range of the reply
7000 pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 {
7001 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
7004 /// The height of the first block in the range of the reply
7006 pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChannelRange, mut val: u32) {
7007 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
7009 /// The number of blocks included in the range of the reply
7011 pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 {
7012 let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
7015 /// The number of blocks included in the range of the reply
7017 pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyChannelRange, mut val: u32) {
7018 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
7020 /// True when this is the final reply for a query
7022 pub extern "C" fn ReplyChannelRange_get_sync_complete(this_ptr: &ReplyChannelRange) -> bool {
7023 let mut inner_val = &mut this_ptr.get_native_mut_ref().sync_complete;
7026 /// True when this is the final reply for a query
7028 pub extern "C" fn ReplyChannelRange_set_sync_complete(this_ptr: &mut ReplyChannelRange, mut val: bool) {
7029 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sync_complete = val;
7031 /// The `short_channel_id`s in the channel range
7033 /// Returns a copy of the field.
7035 pub extern "C" fn ReplyChannelRange_get_short_channel_ids(this_ptr: &ReplyChannelRange) -> crate::c_types::derived::CVec_u64Z {
7036 let mut inner_val = this_ptr.get_native_mut_ref().short_channel_ids.clone();
7037 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
7038 local_inner_val.into()
7040 /// The `short_channel_id`s in the channel range
7042 pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::derived::CVec_u64Z) {
7043 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
7044 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
7046 /// Constructs a new ReplyChannelRange given each field
7049 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 {
7050 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 }); };
7051 ReplyChannelRange { inner: ObjOps::heap_alloc(nativeReplyChannelRange {
7052 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
7053 first_blocknum: first_blocknum_arg,
7054 number_of_blocks: number_of_blocks_arg,
7055 sync_complete: sync_complete_arg,
7056 short_channel_ids: local_short_channel_ids_arg,
7057 }), is_owned: true }
7059 impl Clone for ReplyChannelRange {
7060 fn clone(&self) -> Self {
7062 inner: if <*mut nativeReplyChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
7063 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7069 /// Used only if an object of this type is returned as a trait impl by a method
7070 pub(crate) extern "C" fn ReplyChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
7071 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyChannelRange)).clone() })) as *mut c_void
7074 /// Creates a copy of the ReplyChannelRange
7075 pub extern "C" fn ReplyChannelRange_clone(orig: &ReplyChannelRange) -> ReplyChannelRange {
7078 /// Checks if two ReplyChannelRanges contain equal inner contents.
7079 /// This ignores pointers and is_owned flags and looks at the values in fields.
7080 /// Two objects with NULL inner values will be considered "equal" here.
7082 pub extern "C" fn ReplyChannelRange_eq(a: &ReplyChannelRange, b: &ReplyChannelRange) -> bool {
7083 if a.inner == b.inner { return true; }
7084 if a.inner.is_null() || b.inner.is_null() { return false; }
7085 if a.get_native_ref() == b.get_native_ref() { true } else { false }
7088 use lightning::ln::msgs::QueryShortChannelIds as nativeQueryShortChannelIdsImport;
7089 pub(crate) type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport;
7091 /// A [`query_short_channel_ids`] message is used to query a peer for
7092 /// routing gossip messages related to one or more `short_channel_id`s.
7094 /// The query recipient will reply with the latest, if available,
7095 /// [`ChannelAnnouncement`], [`ChannelUpdate`] and [`NodeAnnouncement`] messages
7096 /// it maintains for the requested `short_channel_id`s followed by a
7097 /// [`ReplyShortChannelIdsEnd`] message. The `short_channel_id`s sent in
7098 /// this query are encoded. We only support `encoding_type=0` uncompressed
7099 /// serialization and do not support `encoding_type=1` zlib serialization.
7101 /// [`query_short_channel_ids`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_short_channel_idsreply_short_channel_ids_end-messages
7104 pub struct QueryShortChannelIds {
7105 /// A pointer to the opaque Rust object.
7107 /// Nearly everywhere, inner must be non-null, however in places where
7108 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7109 pub inner: *mut nativeQueryShortChannelIds,
7110 /// Indicates that this is the only struct which contains the same pointer.
7112 /// Rust functions which take ownership of an object provided via an argument require
7113 /// this to be true and invalidate the object pointed to by inner.
7117 impl Drop for QueryShortChannelIds {
7118 fn drop(&mut self) {
7119 if self.is_owned && !<*mut nativeQueryShortChannelIds>::is_null(self.inner) {
7120 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7124 /// Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL.
7126 pub extern "C" fn QueryShortChannelIds_free(this_obj: QueryShortChannelIds) { }
7128 /// Used only if an object of this type is returned as a trait impl by a method
7129 pub(crate) extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) {
7130 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeQueryShortChannelIds) };
7133 impl QueryShortChannelIds {
7134 pub(crate) fn get_native_ref(&self) -> &'static nativeQueryShortChannelIds {
7135 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7137 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryShortChannelIds {
7138 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7140 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7141 pub(crate) fn take_inner(mut self) -> *mut nativeQueryShortChannelIds {
7142 assert!(self.is_owned);
7143 let ret = ObjOps::untweak_ptr(self.inner);
7144 self.inner = core::ptr::null_mut();
7148 /// The genesis hash of the blockchain being queried
7150 pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *const [u8; 32] {
7151 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
7152 inner_val.as_inner()
7154 /// The genesis hash of the blockchain being queried
7156 pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::ThirtyTwoBytes) {
7157 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
7159 /// The short_channel_ids that are being queried
7161 /// Returns a copy of the field.
7163 pub extern "C" fn QueryShortChannelIds_get_short_channel_ids(this_ptr: &QueryShortChannelIds) -> crate::c_types::derived::CVec_u64Z {
7164 let mut inner_val = this_ptr.get_native_mut_ref().short_channel_ids.clone();
7165 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
7166 local_inner_val.into()
7168 /// The short_channel_ids that are being queried
7170 pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::derived::CVec_u64Z) {
7171 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
7172 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
7174 /// Constructs a new QueryShortChannelIds given each field
7177 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 {
7178 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 }); };
7179 QueryShortChannelIds { inner: ObjOps::heap_alloc(nativeQueryShortChannelIds {
7180 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
7181 short_channel_ids: local_short_channel_ids_arg,
7182 }), is_owned: true }
7184 impl Clone for QueryShortChannelIds {
7185 fn clone(&self) -> Self {
7187 inner: if <*mut nativeQueryShortChannelIds>::is_null(self.inner) { core::ptr::null_mut() } else {
7188 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7194 /// Used only if an object of this type is returned as a trait impl by a method
7195 pub(crate) extern "C" fn QueryShortChannelIds_clone_void(this_ptr: *const c_void) -> *mut c_void {
7196 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryShortChannelIds)).clone() })) as *mut c_void
7199 /// Creates a copy of the QueryShortChannelIds
7200 pub extern "C" fn QueryShortChannelIds_clone(orig: &QueryShortChannelIds) -> QueryShortChannelIds {
7203 /// Checks if two QueryShortChannelIdss contain equal inner contents.
7204 /// This ignores pointers and is_owned flags and looks at the values in fields.
7205 /// Two objects with NULL inner values will be considered "equal" here.
7207 pub extern "C" fn QueryShortChannelIds_eq(a: &QueryShortChannelIds, b: &QueryShortChannelIds) -> bool {
7208 if a.inner == b.inner { return true; }
7209 if a.inner.is_null() || b.inner.is_null() { return false; }
7210 if a.get_native_ref() == b.get_native_ref() { true } else { false }
7213 use lightning::ln::msgs::ReplyShortChannelIdsEnd as nativeReplyShortChannelIdsEndImport;
7214 pub(crate) type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport;
7216 /// A [`reply_short_channel_ids_end`] message is sent as a reply to a
7217 /// message. The query recipient makes a best
7218 /// effort to respond based on their local network view which may not be
7219 /// a perfect view of the network.
7221 /// [`reply_short_channel_ids_end`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_short_channel_idsreply_short_channel_ids_end-messages
7224 pub struct ReplyShortChannelIdsEnd {
7225 /// A pointer to the opaque Rust object.
7227 /// Nearly everywhere, inner must be non-null, however in places where
7228 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7229 pub inner: *mut nativeReplyShortChannelIdsEnd,
7230 /// Indicates that this is the only struct which contains the same pointer.
7232 /// Rust functions which take ownership of an object provided via an argument require
7233 /// this to be true and invalidate the object pointed to by inner.
7237 impl Drop for ReplyShortChannelIdsEnd {
7238 fn drop(&mut self) {
7239 if self.is_owned && !<*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) {
7240 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7244 /// Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL.
7246 pub extern "C" fn ReplyShortChannelIdsEnd_free(this_obj: ReplyShortChannelIdsEnd) { }
7248 /// Used only if an object of this type is returned as a trait impl by a method
7249 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) {
7250 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeReplyShortChannelIdsEnd) };
7253 impl ReplyShortChannelIdsEnd {
7254 pub(crate) fn get_native_ref(&self) -> &'static nativeReplyShortChannelIdsEnd {
7255 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7257 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyShortChannelIdsEnd {
7258 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7260 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7261 pub(crate) fn take_inner(mut self) -> *mut nativeReplyShortChannelIdsEnd {
7262 assert!(self.is_owned);
7263 let ret = ObjOps::untweak_ptr(self.inner);
7264 self.inner = core::ptr::null_mut();
7268 /// The genesis hash of the blockchain that was queried
7270 pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *const [u8; 32] {
7271 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
7272 inner_val.as_inner()
7274 /// The genesis hash of the blockchain that was queried
7276 pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) {
7277 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
7279 /// Indicates if the query recipient maintains up-to-date channel
7280 /// information for the `chain_hash`
7282 pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool {
7283 let mut inner_val = &mut this_ptr.get_native_mut_ref().full_information;
7286 /// Indicates if the query recipient maintains up-to-date channel
7287 /// information for the `chain_hash`
7289 pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: bool) {
7290 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.full_information = val;
7292 /// Constructs a new ReplyShortChannelIdsEnd given each field
7295 pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd {
7296 ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(nativeReplyShortChannelIdsEnd {
7297 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
7298 full_information: full_information_arg,
7299 }), is_owned: true }
7301 impl Clone for ReplyShortChannelIdsEnd {
7302 fn clone(&self) -> Self {
7304 inner: if <*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) { core::ptr::null_mut() } else {
7305 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7311 /// Used only if an object of this type is returned as a trait impl by a method
7312 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_void) -> *mut c_void {
7313 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyShortChannelIdsEnd)).clone() })) as *mut c_void
7316 /// Creates a copy of the ReplyShortChannelIdsEnd
7317 pub extern "C" fn ReplyShortChannelIdsEnd_clone(orig: &ReplyShortChannelIdsEnd) -> ReplyShortChannelIdsEnd {
7320 /// Checks if two ReplyShortChannelIdsEnds contain equal inner contents.
7321 /// This ignores pointers and is_owned flags and looks at the values in fields.
7322 /// Two objects with NULL inner values will be considered "equal" here.
7324 pub extern "C" fn ReplyShortChannelIdsEnd_eq(a: &ReplyShortChannelIdsEnd, b: &ReplyShortChannelIdsEnd) -> bool {
7325 if a.inner == b.inner { return true; }
7326 if a.inner.is_null() || b.inner.is_null() { return false; }
7327 if a.get_native_ref() == b.get_native_ref() { true } else { false }
7330 use lightning::ln::msgs::GossipTimestampFilter as nativeGossipTimestampFilterImport;
7331 pub(crate) type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport;
7333 /// A [`gossip_timestamp_filter`] message is used by a node to request
7334 /// gossip relay for messages in the requested time range when the
7335 /// `gossip_queries` feature has been negotiated.
7337 /// [`gossip_timestamp_filter`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-gossip_timestamp_filter-message
7340 pub struct GossipTimestampFilter {
7341 /// A pointer to the opaque Rust object.
7343 /// Nearly everywhere, inner must be non-null, however in places where
7344 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7345 pub inner: *mut nativeGossipTimestampFilter,
7346 /// Indicates that this is the only struct which contains the same pointer.
7348 /// Rust functions which take ownership of an object provided via an argument require
7349 /// this to be true and invalidate the object pointed to by inner.
7353 impl Drop for GossipTimestampFilter {
7354 fn drop(&mut self) {
7355 if self.is_owned && !<*mut nativeGossipTimestampFilter>::is_null(self.inner) {
7356 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7360 /// Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL.
7362 pub extern "C" fn GossipTimestampFilter_free(this_obj: GossipTimestampFilter) { }
7364 /// Used only if an object of this type is returned as a trait impl by a method
7365 pub(crate) extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) {
7366 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeGossipTimestampFilter) };
7369 impl GossipTimestampFilter {
7370 pub(crate) fn get_native_ref(&self) -> &'static nativeGossipTimestampFilter {
7371 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7373 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeGossipTimestampFilter {
7374 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7376 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7377 pub(crate) fn take_inner(mut self) -> *mut nativeGossipTimestampFilter {
7378 assert!(self.is_owned);
7379 let ret = ObjOps::untweak_ptr(self.inner);
7380 self.inner = core::ptr::null_mut();
7384 /// The genesis hash of the blockchain for channel and node information
7386 pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *const [u8; 32] {
7387 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
7388 inner_val.as_inner()
7390 /// The genesis hash of the blockchain for channel and node information
7392 pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) {
7393 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
7395 /// The starting unix timestamp
7397 pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 {
7398 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_timestamp;
7401 /// The starting unix timestamp
7403 pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
7404 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_timestamp = val;
7406 /// The range of information in seconds
7408 pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 {
7409 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp_range;
7412 /// The range of information in seconds
7414 pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
7415 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp_range = val;
7417 /// Constructs a new GossipTimestampFilter given each field
7420 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 {
7421 GossipTimestampFilter { inner: ObjOps::heap_alloc(nativeGossipTimestampFilter {
7422 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
7423 first_timestamp: first_timestamp_arg,
7424 timestamp_range: timestamp_range_arg,
7425 }), is_owned: true }
7427 impl Clone for GossipTimestampFilter {
7428 fn clone(&self) -> Self {
7430 inner: if <*mut nativeGossipTimestampFilter>::is_null(self.inner) { core::ptr::null_mut() } else {
7431 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7437 /// Used only if an object of this type is returned as a trait impl by a method
7438 pub(crate) extern "C" fn GossipTimestampFilter_clone_void(this_ptr: *const c_void) -> *mut c_void {
7439 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeGossipTimestampFilter)).clone() })) as *mut c_void
7442 /// Creates a copy of the GossipTimestampFilter
7443 pub extern "C" fn GossipTimestampFilter_clone(orig: &GossipTimestampFilter) -> GossipTimestampFilter {
7446 /// Checks if two GossipTimestampFilters contain equal inner contents.
7447 /// This ignores pointers and is_owned flags and looks at the values in fields.
7448 /// Two objects with NULL inner values will be considered "equal" here.
7450 pub extern "C" fn GossipTimestampFilter_eq(a: &GossipTimestampFilter, b: &GossipTimestampFilter) -> bool {
7451 if a.inner == b.inner { return true; }
7452 if a.inner.is_null() || b.inner.is_null() { return false; }
7453 if a.get_native_ref() == b.get_native_ref() { true } else { false }
7455 /// Used to put an error message in a [`LightningError`].
7459 pub enum ErrorAction {
7460 /// The peer took some action which made us think they were useless. Disconnect them.
7462 /// An error message which we should make an effort to send before we disconnect.
7464 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
7465 msg: crate::lightning::ln::msgs::ErrorMessage,
7467 /// The peer did something incorrect. Tell them without closing any channels and disconnect them.
7468 DisconnectPeerWithWarning {
7469 /// A warning message which we should make an effort to send before we disconnect.
7470 msg: crate::lightning::ln::msgs::WarningMessage,
7472 /// The peer did something harmless that we weren't able to process, just log and ignore
7474 /// The peer did something harmless that we weren't able to meaningfully process.
7475 /// If the error is logged, log it at the given level.
7477 crate::lightning::util::logger::Level),
7478 /// The peer provided us with a gossip message which we'd already seen. In most cases this
7479 /// should be ignored, but it may result in the message being forwarded if it is a duplicate of
7480 /// our own channel announcements.
7481 IgnoreDuplicateGossip,
7482 /// The peer did something incorrect. Tell them.
7484 /// The message to send.
7485 msg: crate::lightning::ln::msgs::ErrorMessage,
7487 /// The peer did something incorrect. Tell them without closing any channels.
7488 SendWarningMessage {
7489 /// The message to send.
7490 msg: crate::lightning::ln::msgs::WarningMessage,
7491 /// The peer may have done something harmless that we weren't able to meaningfully process,
7492 /// though we should still tell them about it.
7493 /// If this event is logged, log it at the given level.
7494 log_level: crate::lightning::util::logger::Level,
7497 use lightning::ln::msgs::ErrorAction as ErrorActionImport;
7498 pub(crate) type nativeErrorAction = ErrorActionImport;
7502 pub(crate) fn to_native(&self) -> nativeErrorAction {
7504 ErrorAction::DisconnectPeer {ref msg, } => {
7505 let mut msg_nonref = Clone::clone(msg);
7506 let mut local_msg_nonref = if msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg_nonref.take_inner()) } }) };
7507 nativeErrorAction::DisconnectPeer {
7508 msg: local_msg_nonref,
7511 ErrorAction::DisconnectPeerWithWarning {ref msg, } => {
7512 let mut msg_nonref = Clone::clone(msg);
7513 nativeErrorAction::DisconnectPeerWithWarning {
7514 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
7517 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
7518 ErrorAction::IgnoreAndLog (ref a, ) => {
7519 let mut a_nonref = Clone::clone(a);
7520 nativeErrorAction::IgnoreAndLog (
7521 a_nonref.into_native(),
7524 ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
7525 ErrorAction::SendErrorMessage {ref msg, } => {
7526 let mut msg_nonref = Clone::clone(msg);
7527 nativeErrorAction::SendErrorMessage {
7528 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
7531 ErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
7532 let mut msg_nonref = Clone::clone(msg);
7533 let mut log_level_nonref = Clone::clone(log_level);
7534 nativeErrorAction::SendWarningMessage {
7535 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
7536 log_level: log_level_nonref.into_native(),
7542 pub(crate) fn into_native(self) -> nativeErrorAction {
7544 ErrorAction::DisconnectPeer {mut msg, } => {
7545 let mut local_msg = if msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg.take_inner()) } }) };
7546 nativeErrorAction::DisconnectPeer {
7550 ErrorAction::DisconnectPeerWithWarning {mut msg, } => {
7551 nativeErrorAction::DisconnectPeerWithWarning {
7552 msg: *unsafe { Box::from_raw(msg.take_inner()) },
7555 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
7556 ErrorAction::IgnoreAndLog (mut a, ) => {
7557 nativeErrorAction::IgnoreAndLog (
7561 ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
7562 ErrorAction::SendErrorMessage {mut msg, } => {
7563 nativeErrorAction::SendErrorMessage {
7564 msg: *unsafe { Box::from_raw(msg.take_inner()) },
7567 ErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
7568 nativeErrorAction::SendWarningMessage {
7569 msg: *unsafe { Box::from_raw(msg.take_inner()) },
7570 log_level: log_level.into_native(),
7576 pub(crate) fn from_native(native: &nativeErrorAction) -> Self {
7578 nativeErrorAction::DisconnectPeer {ref msg, } => {
7579 let mut msg_nonref = Clone::clone(msg);
7580 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 };
7581 ErrorAction::DisconnectPeer {
7582 msg: local_msg_nonref,
7585 nativeErrorAction::DisconnectPeerWithWarning {ref msg, } => {
7586 let mut msg_nonref = Clone::clone(msg);
7587 ErrorAction::DisconnectPeerWithWarning {
7588 msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
7591 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
7592 nativeErrorAction::IgnoreAndLog (ref a, ) => {
7593 let mut a_nonref = Clone::clone(a);
7594 ErrorAction::IgnoreAndLog (
7595 crate::lightning::util::logger::Level::native_into(a_nonref),
7598 nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
7599 nativeErrorAction::SendErrorMessage {ref msg, } => {
7600 let mut msg_nonref = Clone::clone(msg);
7601 ErrorAction::SendErrorMessage {
7602 msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
7605 nativeErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
7606 let mut msg_nonref = Clone::clone(msg);
7607 let mut log_level_nonref = Clone::clone(log_level);
7608 ErrorAction::SendWarningMessage {
7609 msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
7610 log_level: crate::lightning::util::logger::Level::native_into(log_level_nonref),
7616 pub(crate) fn native_into(native: nativeErrorAction) -> Self {
7618 nativeErrorAction::DisconnectPeer {mut msg, } => {
7619 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 };
7620 ErrorAction::DisconnectPeer {
7624 nativeErrorAction::DisconnectPeerWithWarning {mut msg, } => {
7625 ErrorAction::DisconnectPeerWithWarning {
7626 msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
7629 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
7630 nativeErrorAction::IgnoreAndLog (mut a, ) => {
7631 ErrorAction::IgnoreAndLog (
7632 crate::lightning::util::logger::Level::native_into(a),
7635 nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
7636 nativeErrorAction::SendErrorMessage {mut msg, } => {
7637 ErrorAction::SendErrorMessage {
7638 msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
7641 nativeErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
7642 ErrorAction::SendWarningMessage {
7643 msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
7644 log_level: crate::lightning::util::logger::Level::native_into(log_level),
7650 /// Frees any resources used by the ErrorAction
7652 pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { }
7653 /// Creates a copy of the ErrorAction
7655 pub extern "C" fn ErrorAction_clone(orig: &ErrorAction) -> ErrorAction {
7659 /// Utility method to constructs a new DisconnectPeer-variant ErrorAction
7660 pub extern "C" fn ErrorAction_disconnect_peer(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
7661 ErrorAction::DisconnectPeer {
7666 /// Utility method to constructs a new DisconnectPeerWithWarning-variant ErrorAction
7667 pub extern "C" fn ErrorAction_disconnect_peer_with_warning(msg: crate::lightning::ln::msgs::WarningMessage) -> ErrorAction {
7668 ErrorAction::DisconnectPeerWithWarning {
7673 /// Utility method to constructs a new IgnoreError-variant ErrorAction
7674 pub extern "C" fn ErrorAction_ignore_error() -> ErrorAction {
7675 ErrorAction::IgnoreError}
7677 /// Utility method to constructs a new IgnoreAndLog-variant ErrorAction
7678 pub extern "C" fn ErrorAction_ignore_and_log(a: crate::lightning::util::logger::Level) -> ErrorAction {
7679 ErrorAction::IgnoreAndLog(a, )
7682 /// Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction
7683 pub extern "C" fn ErrorAction_ignore_duplicate_gossip() -> ErrorAction {
7684 ErrorAction::IgnoreDuplicateGossip}
7686 /// Utility method to constructs a new SendErrorMessage-variant ErrorAction
7687 pub extern "C" fn ErrorAction_send_error_message(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
7688 ErrorAction::SendErrorMessage {
7693 /// Utility method to constructs a new SendWarningMessage-variant ErrorAction
7694 pub extern "C" fn ErrorAction_send_warning_message(msg: crate::lightning::ln::msgs::WarningMessage, log_level: crate::lightning::util::logger::Level) -> ErrorAction {
7695 ErrorAction::SendWarningMessage {
7701 use lightning::ln::msgs::LightningError as nativeLightningErrorImport;
7702 pub(crate) type nativeLightningError = nativeLightningErrorImport;
7704 /// An Err type for failure to process messages.
7707 pub struct LightningError {
7708 /// A pointer to the opaque Rust object.
7710 /// Nearly everywhere, inner must be non-null, however in places where
7711 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7712 pub inner: *mut nativeLightningError,
7713 /// Indicates that this is the only struct which contains the same pointer.
7715 /// Rust functions which take ownership of an object provided via an argument require
7716 /// this to be true and invalidate the object pointed to by inner.
7720 impl Drop for LightningError {
7721 fn drop(&mut self) {
7722 if self.is_owned && !<*mut nativeLightningError>::is_null(self.inner) {
7723 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7727 /// Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL.
7729 pub extern "C" fn LightningError_free(this_obj: LightningError) { }
7731 /// Used only if an object of this type is returned as a trait impl by a method
7732 pub(crate) extern "C" fn LightningError_free_void(this_ptr: *mut c_void) {
7733 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeLightningError) };
7736 impl LightningError {
7737 pub(crate) fn get_native_ref(&self) -> &'static nativeLightningError {
7738 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7740 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLightningError {
7741 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7743 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7744 pub(crate) fn take_inner(mut self) -> *mut nativeLightningError {
7745 assert!(self.is_owned);
7746 let ret = ObjOps::untweak_ptr(self.inner);
7747 self.inner = core::ptr::null_mut();
7751 /// A human-readable message describing the error
7753 pub extern "C" fn LightningError_get_err(this_ptr: &LightningError) -> crate::c_types::Str {
7754 let mut inner_val = &mut this_ptr.get_native_mut_ref().err;
7755 inner_val.as_str().into()
7757 /// A human-readable message describing the error
7759 pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: crate::c_types::Str) {
7760 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.err = val.into_string();
7762 /// The action which should be taken against the offending peer.
7764 pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate::lightning::ln::msgs::ErrorAction {
7765 let mut inner_val = &mut this_ptr.get_native_mut_ref().action;
7766 crate::lightning::ln::msgs::ErrorAction::from_native(inner_val)
7768 /// The action which should be taken against the offending peer.
7770 pub extern "C" fn LightningError_set_action(this_ptr: &mut LightningError, mut val: crate::lightning::ln::msgs::ErrorAction) {
7771 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.action = val.into_native();
7773 /// Constructs a new LightningError given each field
7776 pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::Str, mut action_arg: crate::lightning::ln::msgs::ErrorAction) -> LightningError {
7777 LightningError { inner: ObjOps::heap_alloc(nativeLightningError {
7778 err: err_arg.into_string(),
7779 action: action_arg.into_native(),
7780 }), is_owned: true }
7782 impl Clone for LightningError {
7783 fn clone(&self) -> Self {
7785 inner: if <*mut nativeLightningError>::is_null(self.inner) { core::ptr::null_mut() } else {
7786 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7792 /// Used only if an object of this type is returned as a trait impl by a method
7793 pub(crate) extern "C" fn LightningError_clone_void(this_ptr: *const c_void) -> *mut c_void {
7794 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeLightningError)).clone() })) as *mut c_void
7797 /// Creates a copy of the LightningError
7798 pub extern "C" fn LightningError_clone(orig: &LightningError) -> LightningError {
7802 use lightning::ln::msgs::CommitmentUpdate as nativeCommitmentUpdateImport;
7803 pub(crate) type nativeCommitmentUpdate = nativeCommitmentUpdateImport;
7805 /// Struct used to return values from [`RevokeAndACK`] messages, containing a bunch of commitment
7806 /// transaction updates if they were pending.
7809 pub struct CommitmentUpdate {
7810 /// A pointer to the opaque Rust object.
7812 /// Nearly everywhere, inner must be non-null, however in places where
7813 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
7814 pub inner: *mut nativeCommitmentUpdate,
7815 /// Indicates that this is the only struct which contains the same pointer.
7817 /// Rust functions which take ownership of an object provided via an argument require
7818 /// this to be true and invalidate the object pointed to by inner.
7822 impl Drop for CommitmentUpdate {
7823 fn drop(&mut self) {
7824 if self.is_owned && !<*mut nativeCommitmentUpdate>::is_null(self.inner) {
7825 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
7829 /// Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL.
7831 pub extern "C" fn CommitmentUpdate_free(this_obj: CommitmentUpdate) { }
7833 /// Used only if an object of this type is returned as a trait impl by a method
7834 pub(crate) extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) {
7835 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCommitmentUpdate) };
7838 impl CommitmentUpdate {
7839 pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentUpdate {
7840 unsafe { &*ObjOps::untweak_ptr(self.inner) }
7842 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentUpdate {
7843 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
7845 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
7846 pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentUpdate {
7847 assert!(self.is_owned);
7848 let ret = ObjOps::untweak_ptr(self.inner);
7849 self.inner = core::ptr::null_mut();
7853 /// `update_add_htlc` messages which should be sent
7855 pub extern "C" fn CommitmentUpdate_get_update_add_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateAddHTLCZ {
7856 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_add_htlcs;
7857 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 } }); };
7858 local_inner_val.into()
7860 /// `update_add_htlc` messages which should be sent
7862 pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) {
7863 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
7864 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_add_htlcs = local_val;
7866 /// `update_fulfill_htlc` messages which should be sent
7868 pub extern "C" fn CommitmentUpdate_get_update_fulfill_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFulfillHTLCZ {
7869 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fulfill_htlcs;
7870 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 } }); };
7871 local_inner_val.into()
7873 /// `update_fulfill_htlc` messages which should be sent
7875 pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) {
7876 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
7877 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fulfill_htlcs = local_val;
7879 /// `update_fail_htlc` messages which should be sent
7881 pub extern "C" fn CommitmentUpdate_get_update_fail_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailHTLCZ {
7882 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_htlcs;
7883 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 } }); };
7884 local_inner_val.into()
7886 /// `update_fail_htlc` messages which should be sent
7888 pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) {
7889 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
7890 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_htlcs = local_val;
7892 /// `update_fail_malformed_htlc` messages which should be sent
7894 pub extern "C" fn CommitmentUpdate_get_update_fail_malformed_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ {
7895 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_malformed_htlcs;
7896 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 } }); };
7897 local_inner_val.into()
7899 /// `update_fail_malformed_htlc` messages which should be sent
7901 pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) {
7902 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
7903 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_malformed_htlcs = local_val;
7905 /// An `update_fee` message which should be sent
7907 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
7909 pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::UpdateFee {
7910 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fee;
7911 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 };
7914 /// An `update_fee` message which should be sent
7916 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
7918 pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::UpdateFee) {
7919 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
7920 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fee = local_val;
7922 /// A `commitment_signed` message which should be sent
7924 pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::CommitmentSigned {
7925 let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_signed;
7926 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 }
7928 /// A `commitment_signed` message which should be sent
7930 pub extern "C" fn CommitmentUpdate_set_commitment_signed(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::CommitmentSigned) {
7931 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_signed = *unsafe { Box::from_raw(val.take_inner()) };
7933 /// Constructs a new CommitmentUpdate given each field
7935 /// Note that update_fee_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
7938 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 {
7939 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()) } }); };
7940 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()) } }); };
7941 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()) } }); };
7942 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()) } }); };
7943 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()) } }) };
7944 CommitmentUpdate { inner: ObjOps::heap_alloc(nativeCommitmentUpdate {
7945 update_add_htlcs: local_update_add_htlcs_arg,
7946 update_fulfill_htlcs: local_update_fulfill_htlcs_arg,
7947 update_fail_htlcs: local_update_fail_htlcs_arg,
7948 update_fail_malformed_htlcs: local_update_fail_malformed_htlcs_arg,
7949 update_fee: local_update_fee_arg,
7950 commitment_signed: *unsafe { Box::from_raw(commitment_signed_arg.take_inner()) },
7951 }), is_owned: true }
7953 impl Clone for CommitmentUpdate {
7954 fn clone(&self) -> Self {
7956 inner: if <*mut nativeCommitmentUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
7957 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
7963 /// Used only if an object of this type is returned as a trait impl by a method
7964 pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
7965 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentUpdate)).clone() })) as *mut c_void
7968 /// Creates a copy of the CommitmentUpdate
7969 pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentUpdate {
7972 /// Checks if two CommitmentUpdates contain equal inner contents.
7973 /// This ignores pointers and is_owned flags and looks at the values in fields.
7974 /// Two objects with NULL inner values will be considered "equal" here.
7976 pub extern "C" fn CommitmentUpdate_eq(a: &CommitmentUpdate, b: &CommitmentUpdate) -> bool {
7977 if a.inner == b.inner { return true; }
7978 if a.inner.is_null() || b.inner.is_null() { return false; }
7979 if a.get_native_ref() == b.get_native_ref() { true } else { false }
7981 /// A trait to describe an object which can receive channel messages.
7983 /// Messages MAY be called in parallel when they originate from different `their_node_ids`, however
7984 /// they MUST NOT be called in parallel when the two calls have the same `their_node_id`.
7986 pub struct ChannelMessageHandler {
7987 /// An opaque pointer which is passed to your function implementations as an argument.
7988 /// This has no meaning in the LDK, and can be NULL or any other value.
7989 pub this_arg: *mut c_void,
7990 /// Handle an incoming `open_channel` message from the given peer.
7991 pub handle_open_channel: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OpenChannel),
7992 /// Handle an incoming `open_channel2` message from the given peer.
7993 pub handle_open_channel_v2: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OpenChannelV2),
7994 /// Handle an incoming `accept_channel` message from the given peer.
7995 pub handle_accept_channel: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AcceptChannel),
7996 /// Handle an incoming `accept_channel2` message from the given peer.
7997 pub handle_accept_channel_v2: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AcceptChannelV2),
7998 /// Handle an incoming `funding_created` message from the given peer.
7999 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),
8000 /// Handle an incoming `funding_signed` message from the given peer.
8001 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),
8002 /// Handle an incoming `channel_ready` message from the given peer.
8003 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),
8004 /// Handle an incoming `shutdown` message from the given peer.
8005 pub handle_shutdown: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Shutdown),
8006 /// Handle an incoming `closing_signed` message from the given peer.
8007 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),
8008 /// Handle an incoming `tx_add_input message` from the given peer.
8009 pub handle_tx_add_input: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAddInput),
8010 /// Handle an incoming `tx_add_output` message from the given peer.
8011 pub handle_tx_add_output: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAddOutput),
8012 /// Handle an incoming `tx_remove_input` message from the given peer.
8013 pub handle_tx_remove_input: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxRemoveInput),
8014 /// Handle an incoming `tx_remove_output` message from the given peer.
8015 pub handle_tx_remove_output: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxRemoveOutput),
8016 /// Handle an incoming `tx_complete message` from the given peer.
8017 pub handle_tx_complete: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxComplete),
8018 /// Handle an incoming `tx_signatures` message from the given peer.
8019 pub handle_tx_signatures: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxSignatures),
8020 /// Handle an incoming `tx_init_rbf` message from the given peer.
8021 pub handle_tx_init_rbf: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxInitRbf),
8022 /// Handle an incoming `tx_ack_rbf` message from the given peer.
8023 pub handle_tx_ack_rbf: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAckRbf),
8024 /// Handle an incoming `tx_abort message` from the given peer.
8025 pub handle_tx_abort: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAbort),
8026 /// Handle an incoming `update_add_htlc` message from the given peer.
8027 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),
8028 /// Handle an incoming `update_fulfill_htlc` message from the given peer.
8029 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),
8030 /// Handle an incoming `update_fail_htlc` message from the given peer.
8031 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),
8032 /// Handle an incoming `update_fail_malformed_htlc` message from the given peer.
8033 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),
8034 /// Handle an incoming `commitment_signed` message from the given peer.
8035 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),
8036 /// Handle an incoming `revoke_and_ack` message from the given peer.
8037 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),
8038 /// Handle an incoming `update_fee` message from the given peer.
8039 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),
8040 /// Handle an incoming `announcement_signatures` message from the given peer.
8041 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),
8042 /// Indicates a connection to the peer failed/an existing connection was lost.
8043 pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey),
8044 /// Handle a peer reconnecting, possibly generating `channel_reestablish` message(s).
8046 /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
8047 /// with us. Implementors should be somewhat conservative about doing so, however, as other
8048 /// message handlers may still wish to communicate with this peer.
8049 pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Init, inbound: bool) -> crate::c_types::derived::CResult_NoneNoneZ,
8050 /// Handle an incoming `channel_reestablish` message from the given peer.
8051 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),
8052 /// Handle an incoming `channel_update` message from the given peer.
8053 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),
8054 /// Handle an incoming `error` message from the given peer.
8055 pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ErrorMessage),
8056 /// Gets the node feature flags which this handler itself supports. All available handlers are
8057 /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
8058 /// which are broadcasted in our [`NodeAnnouncement`] message.
8059 pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
8060 /// Gets the init feature flags which should be sent to the given peer. All available handlers
8061 /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
8062 /// which are sent in our [`Init`] message.
8064 /// Note that this method is called before [`Self::peer_connected`].
8065 pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
8066 /// Gets the genesis hashes for this `ChannelMessageHandler` indicating which chains it supports.
8068 /// If it's `None`, then no particular network chain hash compatibility will be enforced when
8069 /// connecting to peers.
8070 pub get_genesis_hashes: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ,
8071 /// Implementation of MessageSendEventsProvider for this object.
8072 pub MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider,
8073 /// Frees any resources associated with this object given its this_arg pointer.
8074 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
8075 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
8077 unsafe impl Send for ChannelMessageHandler {}
8078 unsafe impl Sync for ChannelMessageHandler {}
8079 pub(crate) fn ChannelMessageHandler_clone_fields(orig: &ChannelMessageHandler) -> ChannelMessageHandler {
8080 ChannelMessageHandler {
8081 this_arg: orig.this_arg,
8082 handle_open_channel: Clone::clone(&orig.handle_open_channel),
8083 handle_open_channel_v2: Clone::clone(&orig.handle_open_channel_v2),
8084 handle_accept_channel: Clone::clone(&orig.handle_accept_channel),
8085 handle_accept_channel_v2: Clone::clone(&orig.handle_accept_channel_v2),
8086 handle_funding_created: Clone::clone(&orig.handle_funding_created),
8087 handle_funding_signed: Clone::clone(&orig.handle_funding_signed),
8088 handle_channel_ready: Clone::clone(&orig.handle_channel_ready),
8089 handle_shutdown: Clone::clone(&orig.handle_shutdown),
8090 handle_closing_signed: Clone::clone(&orig.handle_closing_signed),
8091 handle_tx_add_input: Clone::clone(&orig.handle_tx_add_input),
8092 handle_tx_add_output: Clone::clone(&orig.handle_tx_add_output),
8093 handle_tx_remove_input: Clone::clone(&orig.handle_tx_remove_input),
8094 handle_tx_remove_output: Clone::clone(&orig.handle_tx_remove_output),
8095 handle_tx_complete: Clone::clone(&orig.handle_tx_complete),
8096 handle_tx_signatures: Clone::clone(&orig.handle_tx_signatures),
8097 handle_tx_init_rbf: Clone::clone(&orig.handle_tx_init_rbf),
8098 handle_tx_ack_rbf: Clone::clone(&orig.handle_tx_ack_rbf),
8099 handle_tx_abort: Clone::clone(&orig.handle_tx_abort),
8100 handle_update_add_htlc: Clone::clone(&orig.handle_update_add_htlc),
8101 handle_update_fulfill_htlc: Clone::clone(&orig.handle_update_fulfill_htlc),
8102 handle_update_fail_htlc: Clone::clone(&orig.handle_update_fail_htlc),
8103 handle_update_fail_malformed_htlc: Clone::clone(&orig.handle_update_fail_malformed_htlc),
8104 handle_commitment_signed: Clone::clone(&orig.handle_commitment_signed),
8105 handle_revoke_and_ack: Clone::clone(&orig.handle_revoke_and_ack),
8106 handle_update_fee: Clone::clone(&orig.handle_update_fee),
8107 handle_announcement_signatures: Clone::clone(&orig.handle_announcement_signatures),
8108 peer_disconnected: Clone::clone(&orig.peer_disconnected),
8109 peer_connected: Clone::clone(&orig.peer_connected),
8110 handle_channel_reestablish: Clone::clone(&orig.handle_channel_reestablish),
8111 handle_channel_update: Clone::clone(&orig.handle_channel_update),
8112 handle_error: Clone::clone(&orig.handle_error),
8113 provided_node_features: Clone::clone(&orig.provided_node_features),
8114 provided_init_features: Clone::clone(&orig.provided_init_features),
8115 get_genesis_hashes: Clone::clone(&orig.get_genesis_hashes),
8116 MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
8117 free: Clone::clone(&orig.free),
8120 impl lightning::events::MessageSendEventsProvider for ChannelMessageHandler {
8121 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::events::MessageSendEvent> {
8122 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
8123 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
8128 use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler;
8129 impl rustChannelMessageHandler for ChannelMessageHandler {
8130 fn handle_open_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OpenChannel) {
8131 (self.handle_open_channel)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::OpenChannel { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::OpenChannel<>) as *mut _) }, is_owned: false })
8133 fn handle_open_channel_v2(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OpenChannelV2) {
8134 (self.handle_open_channel_v2)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::OpenChannelV2 { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::OpenChannelV2<>) as *mut _) }, is_owned: false })
8136 fn handle_accept_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AcceptChannel) {
8137 (self.handle_accept_channel)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::AcceptChannel { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::AcceptChannel<>) as *mut _) }, is_owned: false })
8139 fn handle_accept_channel_v2(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AcceptChannelV2) {
8140 (self.handle_accept_channel_v2)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::AcceptChannelV2 { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::AcceptChannelV2<>) as *mut _) }, is_owned: false })
8142 fn handle_funding_created(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingCreated) {
8143 (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 })
8145 fn handle_funding_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingSigned) {
8146 (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 })
8148 fn handle_channel_ready(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReady) {
8149 (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 })
8151 fn handle_shutdown(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Shutdown) {
8152 (self.handle_shutdown)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Shutdown { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::Shutdown<>) as *mut _) }, is_owned: false })
8154 fn handle_closing_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ClosingSigned) {
8155 (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 })
8157 fn handle_tx_add_input(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAddInput) {
8158 (self.handle_tx_add_input)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAddInput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAddInput<>) as *mut _) }, is_owned: false })
8160 fn handle_tx_add_output(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAddOutput) {
8161 (self.handle_tx_add_output)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAddOutput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAddOutput<>) as *mut _) }, is_owned: false })
8163 fn handle_tx_remove_input(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxRemoveInput) {
8164 (self.handle_tx_remove_input)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxRemoveInput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxRemoveInput<>) as *mut _) }, is_owned: false })
8166 fn handle_tx_remove_output(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxRemoveOutput) {
8167 (self.handle_tx_remove_output)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxRemoveOutput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxRemoveOutput<>) as *mut _) }, is_owned: false })
8169 fn handle_tx_complete(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxComplete) {
8170 (self.handle_tx_complete)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxComplete { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxComplete<>) as *mut _) }, is_owned: false })
8172 fn handle_tx_signatures(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxSignatures) {
8173 (self.handle_tx_signatures)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxSignatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxSignatures<>) as *mut _) }, is_owned: false })
8175 fn handle_tx_init_rbf(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxInitRbf) {
8176 (self.handle_tx_init_rbf)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxInitRbf { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxInitRbf<>) as *mut _) }, is_owned: false })
8178 fn handle_tx_ack_rbf(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAckRbf) {
8179 (self.handle_tx_ack_rbf)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAckRbf { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAckRbf<>) as *mut _) }, is_owned: false })
8181 fn handle_tx_abort(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAbort) {
8182 (self.handle_tx_abort)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAbort { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAbort<>) as *mut _) }, is_owned: false })
8184 fn handle_update_add_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateAddHTLC) {
8185 (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 })
8187 fn handle_update_fulfill_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFulfillHTLC) {
8188 (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 })
8190 fn handle_update_fail_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailHTLC) {
8191 (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 })
8193 fn handle_update_fail_malformed_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) {
8194 (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 })
8196 fn handle_commitment_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::CommitmentSigned) {
8197 (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 })
8199 fn handle_revoke_and_ack(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::RevokeAndACK) {
8200 (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 })
8202 fn handle_update_fee(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFee) {
8203 (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 })
8205 fn handle_announcement_signatures(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AnnouncementSignatures) {
8206 (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 })
8208 fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) {
8209 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id))
8211 fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
8212 let mut ret = (self.peer_connected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::Init<>) as *mut _) }, is_owned: false }, inbound);
8213 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)) })*/ })};
8216 fn handle_channel_reestablish(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReestablish) {
8217 (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 })
8219 fn handle_channel_update(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelUpdate) {
8220 (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 })
8222 fn handle_error(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ErrorMessage) {
8223 (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 })
8225 fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
8226 let mut ret = (self.provided_node_features)(self.this_arg);
8227 *unsafe { Box::from_raw(ret.take_inner()) }
8229 fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
8230 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
8231 *unsafe { Box::from_raw(ret.take_inner()) }
8233 fn get_genesis_hashes(&self) -> Option<Vec<bitcoin::blockdata::constants::ChainHash>> {
8234 let mut ret = (self.get_genesis_hashes)(self.this_arg);
8235 let mut local_ret = { /*ret*/ let ret_opt = ret; if ret_opt.is_none() { None } else { Some({ { let mut local_ret_0 = Vec::new(); for mut item in { ret_opt.take() }.into_rust().drain(..) { local_ret_0.push( { ::bitcoin::blockdata::constants::ChainHash::from(&item.data[..]) }); }; local_ret_0 }})} };
8240 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
8241 // directly as a Deref trait in higher-level structs:
8242 impl core::ops::Deref for ChannelMessageHandler {
8244 fn deref(&self) -> &Self {
8248 impl core::ops::DerefMut for ChannelMessageHandler {
8249 fn deref_mut(&mut self) -> &mut Self {
8253 /// Calls the free function if one is set
8255 pub extern "C" fn ChannelMessageHandler_free(this_ptr: ChannelMessageHandler) { }
8256 impl Drop for ChannelMessageHandler {
8257 fn drop(&mut self) {
8258 if let Some(f) = self.free {
8263 /// A trait to describe an object which can receive routing messages.
8265 /// # Implementor DoS Warnings
8267 /// For messages enabled with the `gossip_queries` feature there are potential DoS vectors when
8268 /// handling inbound queries. Implementors using an on-disk network graph should be aware of
8269 /// repeated disk I/O for queries accessing different parts of the network graph.
8271 pub struct RoutingMessageHandler {
8272 /// An opaque pointer which is passed to your function implementations as an argument.
8273 /// This has no meaning in the LDK, and can be NULL or any other value.
8274 pub this_arg: *mut c_void,
8275 /// Handle an incoming `node_announcement` message, returning `true` if it should be forwarded on,
8276 /// `false` or returning an `Err` otherwise.
8277 pub handle_node_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
8278 /// Handle a `channel_announcement` message, returning `true` if it should be forwarded on, `false`
8279 /// or returning an `Err` otherwise.
8280 pub handle_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
8281 /// Handle an incoming `channel_update` message, returning true if it should be forwarded on,
8282 /// `false` or returning an `Err` otherwise.
8283 pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ,
8284 /// Gets channel announcements and updates required to dump our routing table to a remote node,
8285 /// starting at the `short_channel_id` indicated by `starting_point` and including announcements
8286 /// for a single channel.
8287 pub get_next_channel_announcement: extern "C" fn (this_arg: *const c_void, starting_point: u64) -> crate::c_types::derived::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ,
8288 /// Gets a node announcement required to dump our routing table to a remote node, starting at
8289 /// the node *after* the provided pubkey and including up to one announcement immediately
8290 /// higher (as defined by `<PublicKey as Ord>::cmp`) than `starting_point`.
8291 /// If `None` is provided for `starting_point`, we start at the first node.
8293 /// Note that starting_point (or a relevant inner pointer) may be NULL or all-0s to represent None
8294 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
8295 pub get_next_node_announcement: extern "C" fn (this_arg: *const c_void, starting_point: crate::lightning::routing::gossip::NodeId) -> crate::lightning::ln::msgs::NodeAnnouncement,
8296 /// Called when a connection is established with a peer. This can be used to
8297 /// perform routing table synchronization using a strategy defined by the
8300 /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
8301 /// with us. Implementors should be somewhat conservative about doing so, however, as other
8302 /// message handlers may still wish to communicate with this peer.
8303 pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, init: &crate::lightning::ln::msgs::Init, inbound: bool) -> crate::c_types::derived::CResult_NoneNoneZ,
8304 /// Handles the reply of a query we initiated to learn about channels
8305 /// for a given range of blocks. We can expect to receive one or more
8306 /// replies to a single query.
8307 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,
8308 /// Handles the reply of a query we initiated asking for routing gossip
8309 /// messages for a list of channels. We should receive this message when
8310 /// a node has completed its best effort to send us the pertaining routing
8311 /// gossip messages.
8312 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,
8313 /// Handles when a peer asks us to send a list of `short_channel_id`s
8314 /// for the requested range of blocks.
8315 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,
8316 /// Handles when a peer asks us to send routing gossip messages for a
8317 /// list of `short_channel_id`s.
8318 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,
8319 /// Indicates that there are a large number of [`ChannelAnnouncement`] (or other) messages
8320 /// pending some async action. While there is no guarantee of the rate of future messages, the
8321 /// caller should seek to reduce the rate of new gossip messages handled, especially
8322 /// [`ChannelAnnouncement`]s.
8323 pub processing_queue_high: extern "C" fn (this_arg: *const c_void) -> bool,
8324 /// Gets the node feature flags which this handler itself supports. All available handlers are
8325 /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
8326 /// which are broadcasted in our [`NodeAnnouncement`] message.
8327 pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
8328 /// Gets the init feature flags which should be sent to the given peer. All available handlers
8329 /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
8330 /// which are sent in our [`Init`] message.
8332 /// Note that this method is called before [`Self::peer_connected`].
8333 pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
8334 /// Implementation of MessageSendEventsProvider for this object.
8335 pub MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider,
8336 /// Frees any resources associated with this object given its this_arg pointer.
8337 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
8338 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
8340 unsafe impl Send for RoutingMessageHandler {}
8341 unsafe impl Sync for RoutingMessageHandler {}
8342 pub(crate) fn RoutingMessageHandler_clone_fields(orig: &RoutingMessageHandler) -> RoutingMessageHandler {
8343 RoutingMessageHandler {
8344 this_arg: orig.this_arg,
8345 handle_node_announcement: Clone::clone(&orig.handle_node_announcement),
8346 handle_channel_announcement: Clone::clone(&orig.handle_channel_announcement),
8347 handle_channel_update: Clone::clone(&orig.handle_channel_update),
8348 get_next_channel_announcement: Clone::clone(&orig.get_next_channel_announcement),
8349 get_next_node_announcement: Clone::clone(&orig.get_next_node_announcement),
8350 peer_connected: Clone::clone(&orig.peer_connected),
8351 handle_reply_channel_range: Clone::clone(&orig.handle_reply_channel_range),
8352 handle_reply_short_channel_ids_end: Clone::clone(&orig.handle_reply_short_channel_ids_end),
8353 handle_query_channel_range: Clone::clone(&orig.handle_query_channel_range),
8354 handle_query_short_channel_ids: Clone::clone(&orig.handle_query_short_channel_ids),
8355 processing_queue_high: Clone::clone(&orig.processing_queue_high),
8356 provided_node_features: Clone::clone(&orig.provided_node_features),
8357 provided_init_features: Clone::clone(&orig.provided_init_features),
8358 MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
8359 free: Clone::clone(&orig.free),
8362 impl lightning::events::MessageSendEventsProvider for RoutingMessageHandler {
8363 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::events::MessageSendEvent> {
8364 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
8365 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
8370 use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler;
8371 impl rustRoutingMessageHandler for RoutingMessageHandler {
8372 fn handle_node_announcement(&self, mut msg: &lightning::ln::msgs::NodeAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
8373 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 });
8374 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()) } })};
8377 fn handle_channel_announcement(&self, mut msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
8378 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 });
8379 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()) } })};
8382 fn handle_channel_update(&self, mut msg: &lightning::ln::msgs::ChannelUpdate) -> Result<bool, lightning::ln::msgs::LightningError> {
8383 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 });
8384 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()) } })};
8387 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>)> {
8388 let mut ret = (self.get_next_channel_announcement)(self.this_arg, starting_point);
8389 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 };
8392 fn get_next_node_announcement(&self, mut starting_point: Option<&lightning::routing::gossip::NodeId>) -> Option<lightning::ln::msgs::NodeAnnouncement> {
8393 let mut local_starting_point = crate::lightning::routing::gossip::NodeId { inner: unsafe { (if starting_point.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (starting_point.unwrap()) }) } as *const lightning::routing::gossip::NodeId<>) as *mut _ }, is_owned: false };
8394 let mut ret = (self.get_next_node_announcement)(self.this_arg, local_starting_point);
8395 let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) };
8398 fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
8399 let mut ret = (self.peer_connected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { ObjOps::nonnull_ptr_to_inner((init as *const lightning::ln::msgs::Init<>) as *mut _) }, is_owned: false }, inbound);
8400 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)) })*/ })};
8403 fn handle_reply_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::ReplyChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
8404 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 });
8405 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()) } })};
8408 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> {
8409 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 });
8410 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()) } })};
8413 fn handle_query_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::QueryChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
8414 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 });
8415 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()) } })};
8418 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> {
8419 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 });
8420 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()) } })};
8423 fn processing_queue_high(&self) -> bool {
8424 let mut ret = (self.processing_queue_high)(self.this_arg);
8427 fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
8428 let mut ret = (self.provided_node_features)(self.this_arg);
8429 *unsafe { Box::from_raw(ret.take_inner()) }
8431 fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
8432 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
8433 *unsafe { Box::from_raw(ret.take_inner()) }
8437 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
8438 // directly as a Deref trait in higher-level structs:
8439 impl core::ops::Deref for RoutingMessageHandler {
8441 fn deref(&self) -> &Self {
8445 impl core::ops::DerefMut for RoutingMessageHandler {
8446 fn deref_mut(&mut self) -> &mut Self {
8450 /// Calls the free function if one is set
8452 pub extern "C" fn RoutingMessageHandler_free(this_ptr: RoutingMessageHandler) { }
8453 impl Drop for RoutingMessageHandler {
8454 fn drop(&mut self) {
8455 if let Some(f) = self.free {
8460 /// A trait to describe an object that can receive onion messages.
8462 pub struct OnionMessageHandler {
8463 /// An opaque pointer which is passed to your function implementations as an argument.
8464 /// This has no meaning in the LDK, and can be NULL or any other value.
8465 pub this_arg: *mut c_void,
8466 /// Handle an incoming `onion_message` message from the given peer.
8467 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),
8468 /// Called when a connection is established with a peer. Can be used to track which peers
8469 /// advertise onion message support and are online.
8471 /// May return an `Err(())` if the features the peer supports are not sufficient to communicate
8472 /// with us. Implementors should be somewhat conservative about doing so, however, as other
8473 /// message handlers may still wish to communicate with this peer.
8474 pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, init: &crate::lightning::ln::msgs::Init, inbound: bool) -> crate::c_types::derived::CResult_NoneNoneZ,
8475 /// Indicates a connection to the peer failed/an existing connection was lost. Allows handlers to
8476 /// drop and refuse to forward onion messages to this peer.
8477 pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey),
8478 /// Gets the node feature flags which this handler itself supports. All available handlers are
8479 /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`]
8480 /// which are broadcasted in our [`NodeAnnouncement`] message.
8481 pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures,
8482 /// Gets the init feature flags which should be sent to the given peer. All available handlers
8483 /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`]
8484 /// which are sent in our [`Init`] message.
8486 /// Note that this method is called before [`Self::peer_connected`].
8487 pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures,
8488 /// Implementation of OnionMessageProvider for this object.
8489 pub OnionMessageProvider: crate::lightning::events::OnionMessageProvider,
8490 /// Frees any resources associated with this object given its this_arg pointer.
8491 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
8492 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
8494 unsafe impl Send for OnionMessageHandler {}
8495 unsafe impl Sync for OnionMessageHandler {}
8496 pub(crate) fn OnionMessageHandler_clone_fields(orig: &OnionMessageHandler) -> OnionMessageHandler {
8497 OnionMessageHandler {
8498 this_arg: orig.this_arg,
8499 handle_onion_message: Clone::clone(&orig.handle_onion_message),
8500 peer_connected: Clone::clone(&orig.peer_connected),
8501 peer_disconnected: Clone::clone(&orig.peer_disconnected),
8502 provided_node_features: Clone::clone(&orig.provided_node_features),
8503 provided_init_features: Clone::clone(&orig.provided_init_features),
8504 OnionMessageProvider: crate::lightning::events::OnionMessageProvider_clone_fields(&orig.OnionMessageProvider),
8505 free: Clone::clone(&orig.free),
8508 impl lightning::events::OnionMessageProvider for OnionMessageHandler {
8509 fn next_onion_message_for_peer(&self, mut peer_node_id: bitcoin::secp256k1::PublicKey) -> Option<lightning::ln::msgs::OnionMessage> {
8510 let mut ret = (self.OnionMessageProvider.next_onion_message_for_peer)(self.OnionMessageProvider.this_arg, crate::c_types::PublicKey::from_rust(&peer_node_id));
8511 let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) };
8516 use lightning::ln::msgs::OnionMessageHandler as rustOnionMessageHandler;
8517 impl rustOnionMessageHandler for OnionMessageHandler {
8518 fn handle_onion_message(&self, mut peer_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OnionMessage) {
8519 (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 })
8521 fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> {
8522 let mut ret = (self.peer_connected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { ObjOps::nonnull_ptr_to_inner((init as *const lightning::ln::msgs::Init<>) as *mut _) }, is_owned: false }, inbound);
8523 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)) })*/ })};
8526 fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) {
8527 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id))
8529 fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures {
8530 let mut ret = (self.provided_node_features)(self.this_arg);
8531 *unsafe { Box::from_raw(ret.take_inner()) }
8533 fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures {
8534 let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id));
8535 *unsafe { Box::from_raw(ret.take_inner()) }
8539 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
8540 // directly as a Deref trait in higher-level structs:
8541 impl core::ops::Deref for OnionMessageHandler {
8543 fn deref(&self) -> &Self {
8547 impl core::ops::DerefMut for OnionMessageHandler {
8548 fn deref_mut(&mut self) -> &mut Self {
8552 /// Calls the free function if one is set
8554 pub extern "C" fn OnionMessageHandler_free(this_ptr: OnionMessageHandler) { }
8555 impl Drop for OnionMessageHandler {
8556 fn drop(&mut self) {
8557 if let Some(f) = self.free {
8562 mod fuzzy_internal_msgs {
8564 use alloc::str::FromStr;
8565 use alloc::string::String;
8566 use core::ffi::c_void;
8567 use core::convert::Infallible;
8568 use bitcoin::hashes::Hash;
8569 use crate::c_types::*;
8570 #[cfg(feature="no-std")]
8571 use alloc::{vec::Vec, boxed::Box};
8575 /// Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read
8576 pub extern "C" fn AcceptChannel_write(obj: &crate::lightning::ln::msgs::AcceptChannel) -> crate::c_types::derived::CVec_u8Z {
8577 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8580 pub(crate) extern "C" fn AcceptChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8581 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannel) })
8584 /// Read a AcceptChannel from a byte array, created by AcceptChannel_write
8585 pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelDecodeErrorZ {
8586 let res: Result<lightning::ln::msgs::AcceptChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8587 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() };
8591 /// Serialize the AcceptChannelV2 object into a byte array which can be read by AcceptChannelV2_read
8592 pub extern "C" fn AcceptChannelV2_write(obj: &crate::lightning::ln::msgs::AcceptChannelV2) -> crate::c_types::derived::CVec_u8Z {
8593 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8596 pub(crate) extern "C" fn AcceptChannelV2_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8597 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannelV2) })
8600 /// Read a AcceptChannelV2 from a byte array, created by AcceptChannelV2_write
8601 pub extern "C" fn AcceptChannelV2_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelV2DecodeErrorZ {
8602 let res: Result<lightning::ln::msgs::AcceptChannelV2, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8603 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::AcceptChannelV2 { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8607 /// Serialize the TxAddInput object into a byte array which can be read by TxAddInput_read
8608 pub extern "C" fn TxAddInput_write(obj: &crate::lightning::ln::msgs::TxAddInput) -> crate::c_types::derived::CVec_u8Z {
8609 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8612 pub(crate) extern "C" fn TxAddInput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8613 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAddInput) })
8616 /// Read a TxAddInput from a byte array, created by TxAddInput_write
8617 pub extern "C" fn TxAddInput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAddInputDecodeErrorZ {
8618 let res: Result<lightning::ln::msgs::TxAddInput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8619 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxAddInput { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8623 /// Serialize the TxAddOutput object into a byte array which can be read by TxAddOutput_read
8624 pub extern "C" fn TxAddOutput_write(obj: &crate::lightning::ln::msgs::TxAddOutput) -> crate::c_types::derived::CVec_u8Z {
8625 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8628 pub(crate) extern "C" fn TxAddOutput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8629 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAddOutput) })
8632 /// Read a TxAddOutput from a byte array, created by TxAddOutput_write
8633 pub extern "C" fn TxAddOutput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAddOutputDecodeErrorZ {
8634 let res: Result<lightning::ln::msgs::TxAddOutput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8635 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxAddOutput { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8639 /// Serialize the TxRemoveInput object into a byte array which can be read by TxRemoveInput_read
8640 pub extern "C" fn TxRemoveInput_write(obj: &crate::lightning::ln::msgs::TxRemoveInput) -> crate::c_types::derived::CVec_u8Z {
8641 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8644 pub(crate) extern "C" fn TxRemoveInput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8645 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxRemoveInput) })
8648 /// Read a TxRemoveInput from a byte array, created by TxRemoveInput_write
8649 pub extern "C" fn TxRemoveInput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxRemoveInputDecodeErrorZ {
8650 let res: Result<lightning::ln::msgs::TxRemoveInput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8651 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxRemoveInput { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8655 /// Serialize the TxRemoveOutput object into a byte array which can be read by TxRemoveOutput_read
8656 pub extern "C" fn TxRemoveOutput_write(obj: &crate::lightning::ln::msgs::TxRemoveOutput) -> crate::c_types::derived::CVec_u8Z {
8657 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8660 pub(crate) extern "C" fn TxRemoveOutput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8661 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxRemoveOutput) })
8664 /// Read a TxRemoveOutput from a byte array, created by TxRemoveOutput_write
8665 pub extern "C" fn TxRemoveOutput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxRemoveOutputDecodeErrorZ {
8666 let res: Result<lightning::ln::msgs::TxRemoveOutput, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8667 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxRemoveOutput { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8671 /// Serialize the TxComplete object into a byte array which can be read by TxComplete_read
8672 pub extern "C" fn TxComplete_write(obj: &crate::lightning::ln::msgs::TxComplete) -> crate::c_types::derived::CVec_u8Z {
8673 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8676 pub(crate) extern "C" fn TxComplete_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8677 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxComplete) })
8680 /// Read a TxComplete from a byte array, created by TxComplete_write
8681 pub extern "C" fn TxComplete_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxCompleteDecodeErrorZ {
8682 let res: Result<lightning::ln::msgs::TxComplete, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8683 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxComplete { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8687 /// Serialize the TxSignatures object into a byte array which can be read by TxSignatures_read
8688 pub extern "C" fn TxSignatures_write(obj: &crate::lightning::ln::msgs::TxSignatures) -> crate::c_types::derived::CVec_u8Z {
8689 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8692 pub(crate) extern "C" fn TxSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8693 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxSignatures) })
8696 /// Read a TxSignatures from a byte array, created by TxSignatures_write
8697 pub extern "C" fn TxSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxSignaturesDecodeErrorZ {
8698 let res: Result<lightning::ln::msgs::TxSignatures, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8699 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxSignatures { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8703 /// Serialize the TxInitRbf object into a byte array which can be read by TxInitRbf_read
8704 pub extern "C" fn TxInitRbf_write(obj: &crate::lightning::ln::msgs::TxInitRbf) -> crate::c_types::derived::CVec_u8Z {
8705 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8708 pub(crate) extern "C" fn TxInitRbf_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8709 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxInitRbf) })
8712 /// Read a TxInitRbf from a byte array, created by TxInitRbf_write
8713 pub extern "C" fn TxInitRbf_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxInitRbfDecodeErrorZ {
8714 let res: Result<lightning::ln::msgs::TxInitRbf, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8715 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxInitRbf { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8719 /// Serialize the TxAckRbf object into a byte array which can be read by TxAckRbf_read
8720 pub extern "C" fn TxAckRbf_write(obj: &crate::lightning::ln::msgs::TxAckRbf) -> crate::c_types::derived::CVec_u8Z {
8721 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8724 pub(crate) extern "C" fn TxAckRbf_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8725 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAckRbf) })
8728 /// Read a TxAckRbf from a byte array, created by TxAckRbf_write
8729 pub extern "C" fn TxAckRbf_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAckRbfDecodeErrorZ {
8730 let res: Result<lightning::ln::msgs::TxAckRbf, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8731 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxAckRbf { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8735 /// Serialize the TxAbort object into a byte array which can be read by TxAbort_read
8736 pub extern "C" fn TxAbort_write(obj: &crate::lightning::ln::msgs::TxAbort) -> crate::c_types::derived::CVec_u8Z {
8737 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8740 pub(crate) extern "C" fn TxAbort_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8741 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAbort) })
8744 /// Read a TxAbort from a byte array, created by TxAbort_write
8745 pub extern "C" fn TxAbort_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAbortDecodeErrorZ {
8746 let res: Result<lightning::ln::msgs::TxAbort, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8747 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxAbort { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8751 /// Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read
8752 pub extern "C" fn AnnouncementSignatures_write(obj: &crate::lightning::ln::msgs::AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z {
8753 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8756 pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8757 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAnnouncementSignatures) })
8760 /// Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write
8761 pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AnnouncementSignaturesDecodeErrorZ {
8762 let res: Result<lightning::ln::msgs::AnnouncementSignatures, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8763 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() };
8767 /// Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read
8768 pub extern "C" fn ChannelReestablish_write(obj: &crate::lightning::ln::msgs::ChannelReestablish) -> crate::c_types::derived::CVec_u8Z {
8769 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8772 pub(crate) extern "C" fn ChannelReestablish_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8773 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReestablish) })
8776 /// Read a ChannelReestablish from a byte array, created by ChannelReestablish_write
8777 pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReestablishDecodeErrorZ {
8778 let res: Result<lightning::ln::msgs::ChannelReestablish, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8779 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() };
8783 /// Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read
8784 pub extern "C" fn ClosingSigned_write(obj: &crate::lightning::ln::msgs::ClosingSigned) -> crate::c_types::derived::CVec_u8Z {
8785 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8788 pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8789 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSigned) })
8792 /// Read a ClosingSigned from a byte array, created by ClosingSigned_write
8793 pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedDecodeErrorZ {
8794 let res: Result<lightning::ln::msgs::ClosingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8795 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() };
8799 /// Serialize the ClosingSignedFeeRange object into a byte array which can be read by ClosingSignedFeeRange_read
8800 pub extern "C" fn ClosingSignedFeeRange_write(obj: &crate::lightning::ln::msgs::ClosingSignedFeeRange) -> crate::c_types::derived::CVec_u8Z {
8801 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8804 pub(crate) extern "C" fn ClosingSignedFeeRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8805 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSignedFeeRange) })
8808 /// Read a ClosingSignedFeeRange from a byte array, created by ClosingSignedFeeRange_write
8809 pub extern "C" fn ClosingSignedFeeRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedFeeRangeDecodeErrorZ {
8810 let res: Result<lightning::ln::msgs::ClosingSignedFeeRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8811 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() };
8815 /// Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read
8816 pub extern "C" fn CommitmentSigned_write(obj: &crate::lightning::ln::msgs::CommitmentSigned) -> crate::c_types::derived::CVec_u8Z {
8817 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8820 pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8821 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentSigned) })
8824 /// Read a CommitmentSigned from a byte array, created by CommitmentSigned_write
8825 pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CommitmentSignedDecodeErrorZ {
8826 let res: Result<lightning::ln::msgs::CommitmentSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8827 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() };
8831 /// Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read
8832 pub extern "C" fn FundingCreated_write(obj: &crate::lightning::ln::msgs::FundingCreated) -> crate::c_types::derived::CVec_u8Z {
8833 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8836 pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8837 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingCreated) })
8840 /// Read a FundingCreated from a byte array, created by FundingCreated_write
8841 pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingCreatedDecodeErrorZ {
8842 let res: Result<lightning::ln::msgs::FundingCreated, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8843 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() };
8847 /// Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read
8848 pub extern "C" fn FundingSigned_write(obj: &crate::lightning::ln::msgs::FundingSigned) -> crate::c_types::derived::CVec_u8Z {
8849 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8852 pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8853 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingSigned) })
8856 /// Read a FundingSigned from a byte array, created by FundingSigned_write
8857 pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingSignedDecodeErrorZ {
8858 let res: Result<lightning::ln::msgs::FundingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8859 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() };
8863 /// Serialize the ChannelReady object into a byte array which can be read by ChannelReady_read
8864 pub extern "C" fn ChannelReady_write(obj: &crate::lightning::ln::msgs::ChannelReady) -> crate::c_types::derived::CVec_u8Z {
8865 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8868 pub(crate) extern "C" fn ChannelReady_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8869 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReady) })
8872 /// Read a ChannelReady from a byte array, created by ChannelReady_write
8873 pub extern "C" fn ChannelReady_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReadyDecodeErrorZ {
8874 let res: Result<lightning::ln::msgs::ChannelReady, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8875 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() };
8879 /// Serialize the Init object into a byte array which can be read by Init_read
8880 pub extern "C" fn Init_write(obj: &crate::lightning::ln::msgs::Init) -> crate::c_types::derived::CVec_u8Z {
8881 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8884 pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8885 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInit) })
8888 /// Read a Init from a byte array, created by Init_write
8889 pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitDecodeErrorZ {
8890 let res: Result<lightning::ln::msgs::Init, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8891 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() };
8895 /// Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read
8896 pub extern "C" fn OpenChannel_write(obj: &crate::lightning::ln::msgs::OpenChannel) -> crate::c_types::derived::CVec_u8Z {
8897 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8900 pub(crate) extern "C" fn OpenChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8901 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannel) })
8904 /// Read a OpenChannel from a byte array, created by OpenChannel_write
8905 pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelDecodeErrorZ {
8906 let res: Result<lightning::ln::msgs::OpenChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8907 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() };
8911 /// Serialize the OpenChannelV2 object into a byte array which can be read by OpenChannelV2_read
8912 pub extern "C" fn OpenChannelV2_write(obj: &crate::lightning::ln::msgs::OpenChannelV2) -> crate::c_types::derived::CVec_u8Z {
8913 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8916 pub(crate) extern "C" fn OpenChannelV2_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8917 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannelV2) })
8920 /// Read a OpenChannelV2 from a byte array, created by OpenChannelV2_write
8921 pub extern "C" fn OpenChannelV2_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelV2DecodeErrorZ {
8922 let res: Result<lightning::ln::msgs::OpenChannelV2, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8923 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::OpenChannelV2 { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
8927 /// Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read
8928 pub extern "C" fn RevokeAndACK_write(obj: &crate::lightning::ln::msgs::RevokeAndACK) -> crate::c_types::derived::CVec_u8Z {
8929 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8932 pub(crate) extern "C" fn RevokeAndACK_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8933 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevokeAndACK) })
8936 /// Read a RevokeAndACK from a byte array, created by RevokeAndACK_write
8937 pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RevokeAndACKDecodeErrorZ {
8938 let res: Result<lightning::ln::msgs::RevokeAndACK, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8939 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() };
8943 /// Serialize the Shutdown object into a byte array which can be read by Shutdown_read
8944 pub extern "C" fn Shutdown_write(obj: &crate::lightning::ln::msgs::Shutdown) -> crate::c_types::derived::CVec_u8Z {
8945 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8948 pub(crate) extern "C" fn Shutdown_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8949 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeShutdown) })
8952 /// Read a Shutdown from a byte array, created by Shutdown_write
8953 pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ShutdownDecodeErrorZ {
8954 let res: Result<lightning::ln::msgs::Shutdown, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8955 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() };
8959 /// Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read
8960 pub extern "C" fn UpdateFailHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFailHTLC) -> crate::c_types::derived::CVec_u8Z {
8961 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8964 pub(crate) extern "C" fn UpdateFailHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8965 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailHTLC) })
8968 /// Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write
8969 pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailHTLCDecodeErrorZ {
8970 let res: Result<lightning::ln::msgs::UpdateFailHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8971 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() };
8975 /// Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read
8976 pub extern "C" fn UpdateFailMalformedHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFailMalformedHTLC) -> crate::c_types::derived::CVec_u8Z {
8977 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8980 pub(crate) extern "C" fn UpdateFailMalformedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8981 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailMalformedHTLC) })
8984 /// Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write
8985 pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailMalformedHTLCDecodeErrorZ {
8986 let res: Result<lightning::ln::msgs::UpdateFailMalformedHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
8987 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() };
8991 /// Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read
8992 pub extern "C" fn UpdateFee_write(obj: &crate::lightning::ln::msgs::UpdateFee) -> crate::c_types::derived::CVec_u8Z {
8993 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
8996 pub(crate) extern "C" fn UpdateFee_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
8997 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFee) })
9000 /// Read a UpdateFee from a byte array, created by UpdateFee_write
9001 pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFeeDecodeErrorZ {
9002 let res: Result<lightning::ln::msgs::UpdateFee, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9003 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() };
9007 /// Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read
9008 pub extern "C" fn UpdateFulfillHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFulfillHTLC) -> crate::c_types::derived::CVec_u8Z {
9009 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9012 pub(crate) extern "C" fn UpdateFulfillHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9013 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFulfillHTLC) })
9016 /// Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write
9017 pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFulfillHTLCDecodeErrorZ {
9018 let res: Result<lightning::ln::msgs::UpdateFulfillHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9019 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() };
9023 /// Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read
9024 pub extern "C" fn UpdateAddHTLC_write(obj: &crate::lightning::ln::msgs::UpdateAddHTLC) -> crate::c_types::derived::CVec_u8Z {
9025 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9028 pub(crate) extern "C" fn UpdateAddHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9029 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateAddHTLC) })
9032 /// Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write
9033 pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateAddHTLCDecodeErrorZ {
9034 let res: Result<lightning::ln::msgs::UpdateAddHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9035 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() };
9039 /// Read a OnionMessage from a byte array, created by OnionMessage_write
9040 pub extern "C" fn OnionMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OnionMessageDecodeErrorZ {
9041 let res: Result<lightning::ln::msgs::OnionMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9042 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() };
9046 /// Serialize the OnionMessage object into a byte array which can be read by OnionMessage_read
9047 pub extern "C" fn OnionMessage_write(obj: &crate::lightning::ln::msgs::OnionMessage) -> crate::c_types::derived::CVec_u8Z {
9048 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9051 pub(crate) extern "C" fn OnionMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9052 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOnionMessage) })
9055 /// Serialize the Ping object into a byte array which can be read by Ping_read
9056 pub extern "C" fn Ping_write(obj: &crate::lightning::ln::msgs::Ping) -> crate::c_types::derived::CVec_u8Z {
9057 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9060 pub(crate) extern "C" fn Ping_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9061 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePing) })
9064 /// Read a Ping from a byte array, created by Ping_write
9065 pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PingDecodeErrorZ {
9066 let res: Result<lightning::ln::msgs::Ping, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9067 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() };
9071 /// Serialize the Pong object into a byte array which can be read by Pong_read
9072 pub extern "C" fn Pong_write(obj: &crate::lightning::ln::msgs::Pong) -> crate::c_types::derived::CVec_u8Z {
9073 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9076 pub(crate) extern "C" fn Pong_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9077 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePong) })
9080 /// Read a Pong from a byte array, created by Pong_write
9081 pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PongDecodeErrorZ {
9082 let res: Result<lightning::ln::msgs::Pong, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9083 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() };
9087 /// Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read
9088 pub extern "C" fn UnsignedChannelAnnouncement_write(obj: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
9089 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9092 pub(crate) extern "C" fn UnsignedChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9093 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelAnnouncement) })
9096 /// Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write
9097 pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelAnnouncementDecodeErrorZ {
9098 let res: Result<lightning::ln::msgs::UnsignedChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9099 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() };
9103 /// Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read
9104 pub extern "C" fn ChannelAnnouncement_write(obj: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
9105 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9108 pub(crate) extern "C" fn ChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9109 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelAnnouncement) })
9112 /// Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write
9113 pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelAnnouncementDecodeErrorZ {
9114 let res: Result<lightning::ln::msgs::ChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9115 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() };
9119 /// Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read
9120 pub extern "C" fn UnsignedChannelUpdate_write(obj: &crate::lightning::ln::msgs::UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
9121 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9124 pub(crate) extern "C" fn UnsignedChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9125 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelUpdate) })
9128 /// Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write
9129 pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelUpdateDecodeErrorZ {
9130 let res: Result<lightning::ln::msgs::UnsignedChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9131 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() };
9135 /// Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read
9136 pub extern "C" fn ChannelUpdate_write(obj: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
9137 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9140 pub(crate) extern "C" fn ChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9141 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdate) })
9144 /// Read a ChannelUpdate from a byte array, created by ChannelUpdate_write
9145 pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelUpdateDecodeErrorZ {
9146 let res: Result<lightning::ln::msgs::ChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9147 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() };
9151 /// Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read
9152 pub extern "C" fn ErrorMessage_write(obj: &crate::lightning::ln::msgs::ErrorMessage) -> crate::c_types::derived::CVec_u8Z {
9153 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9156 pub(crate) extern "C" fn ErrorMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9157 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeErrorMessage) })
9160 /// Read a ErrorMessage from a byte array, created by ErrorMessage_write
9161 pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ErrorMessageDecodeErrorZ {
9162 let res: Result<lightning::ln::msgs::ErrorMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9163 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() };
9167 /// Serialize the WarningMessage object into a byte array which can be read by WarningMessage_read
9168 pub extern "C" fn WarningMessage_write(obj: &crate::lightning::ln::msgs::WarningMessage) -> crate::c_types::derived::CVec_u8Z {
9169 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9172 pub(crate) extern "C" fn WarningMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9173 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeWarningMessage) })
9176 /// Read a WarningMessage from a byte array, created by WarningMessage_write
9177 pub extern "C" fn WarningMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_WarningMessageDecodeErrorZ {
9178 let res: Result<lightning::ln::msgs::WarningMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9179 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() };
9183 /// Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read
9184 pub extern "C" fn UnsignedNodeAnnouncement_write(obj: &crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
9185 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9188 pub(crate) extern "C" fn UnsignedNodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9189 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedNodeAnnouncement) })
9192 /// Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write
9193 pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedNodeAnnouncementDecodeErrorZ {
9194 let res: Result<lightning::ln::msgs::UnsignedNodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9195 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() };
9199 /// Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read
9200 pub extern "C" fn NodeAnnouncement_write(obj: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
9201 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9204 pub(crate) extern "C" fn NodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9205 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncement) })
9208 /// Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write
9209 pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementDecodeErrorZ {
9210 let res: Result<lightning::ln::msgs::NodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9211 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() };
9215 /// Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write
9216 pub extern "C" fn QueryShortChannelIds_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryShortChannelIdsDecodeErrorZ {
9217 let res: Result<lightning::ln::msgs::QueryShortChannelIds, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9218 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() };
9222 /// Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read
9223 pub extern "C" fn QueryShortChannelIds_write(obj: &crate::lightning::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CVec_u8Z {
9224 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9227 pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9228 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) })
9231 /// Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read
9232 pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z {
9233 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9236 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9237 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) })
9240 /// Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write
9241 pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyShortChannelIdsEndDecodeErrorZ {
9242 let res: Result<lightning::ln::msgs::ReplyShortChannelIdsEnd, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9243 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() };
9246 /// Calculates the overflow safe ending block height for the query.
9248 /// Overflow returns `0xffffffff`, otherwise returns `first_blocknum + number_of_blocks`.
9251 pub extern "C" fn QueryChannelRange_end_blocknum(this_arg: &crate::lightning::ln::msgs::QueryChannelRange) -> u32 {
9252 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.end_blocknum();
9257 /// Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read
9258 pub extern "C" fn QueryChannelRange_write(obj: &crate::lightning::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CVec_u8Z {
9259 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9262 pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9263 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) })
9266 /// Read a QueryChannelRange from a byte array, created by QueryChannelRange_write
9267 pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ {
9268 let res: Result<lightning::ln::msgs::QueryChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9269 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() };
9273 /// Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write
9274 pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyChannelRangeDecodeErrorZ {
9275 let res: Result<lightning::ln::msgs::ReplyChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9276 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() };
9280 /// Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read
9281 pub extern "C" fn ReplyChannelRange_write(obj: &crate::lightning::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CVec_u8Z {
9282 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9285 pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9286 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) })
9289 /// Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read
9290 pub extern "C" fn GossipTimestampFilter_write(obj: &crate::lightning::ln::msgs::GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z {
9291 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
9294 pub(crate) extern "C" fn GossipTimestampFilter_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
9295 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeGossipTimestampFilter) })
9298 /// Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write
9299 pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_GossipTimestampFilterDecodeErrorZ {
9300 let res: Result<lightning::ln::msgs::GossipTimestampFilter, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
9301 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() };