1 // This file is Copyright its original authors, visible in version control
2 // history and in the source files from which this was generated.
4 // This file is licensed under the license available in the LICENSE or LICENSE.md
5 // file in the root of this repository or, if no such file exists, the same
6 // license as that which applies to the original source files from which this
7 // source was automatically generated.
9 //! Wire messages, traits representing wire message handlers, and a few error types live here.
11 //! For a normal node you probably don't need to use anything here, however, if you wish to split a
12 //! node into an internet-facing route/message socket handling daemon and a separate daemon (or
13 //! server entirely) which handles only channel-related messages you may wish to implement
14 //! ChannelMessageHandler yourself and use it to re-serialize messages and pass them across
17 //! Note that if you go with such an architecture (instead of passing raw socket events to a
18 //! non-internet-facing system) you trust the frontend internet-facing system to not lie about the
19 //! source node_id of the message, however this does allow you to significantly reduce bandwidth
20 //! between the systems as routing messages can represent a significant chunk of bandwidth usage
21 //! (especially for non-channel-publicly-announcing nodes). As an alternate design which avoids
22 //! this issue, if you have sufficient bidirectional bandwidth between your systems, you may send
23 //! raw socket events into your non-internet-facing system and then send routing events back to
24 //! track the network on the less-secure system.
26 use alloc::str::FromStr;
27 use core::ffi::c_void;
28 use core::convert::Infallible;
29 use bitcoin::hashes::Hash;
30 use crate::c_types::*;
31 #[cfg(feature="no-std")]
32 use alloc::{vec::Vec, boxed::Box};
35 use lightning::ln::msgs::DecodeError as nativeDecodeErrorImport;
36 pub(crate) type nativeDecodeError = nativeDecodeErrorImport;
38 /// An error in decoding a message or struct.
41 pub struct DecodeError {
42 /// A pointer to the opaque Rust object.
44 /// Nearly everywhere, inner must be non-null, however in places where
45 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
46 pub inner: *mut nativeDecodeError,
47 /// Indicates that this is the only struct which contains the same pointer.
49 /// Rust functions which take ownership of an object provided via an argument require
50 /// this to be true and invalidate the object pointed to by inner.
54 impl Drop for DecodeError {
56 if self.is_owned && !<*mut nativeDecodeError>::is_null(self.inner) {
57 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
61 /// Frees any resources used by the DecodeError, if is_owned is set and inner is non-NULL.
63 pub extern "C" fn DecodeError_free(this_obj: DecodeError) { }
65 /// Used only if an object of this type is returned as a trait impl by a method
66 pub(crate) extern "C" fn DecodeError_free_void(this_ptr: *mut c_void) {
67 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDecodeError); }
71 pub(crate) fn get_native_ref(&self) -> &'static nativeDecodeError {
72 unsafe { &*ObjOps::untweak_ptr(self.inner) }
74 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeDecodeError {
75 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
77 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
78 pub(crate) fn take_inner(mut self) -> *mut nativeDecodeError {
79 assert!(self.is_owned);
80 let ret = ObjOps::untweak_ptr(self.inner);
81 self.inner = core::ptr::null_mut();
85 impl Clone for DecodeError {
86 fn clone(&self) -> Self {
88 inner: if <*mut nativeDecodeError>::is_null(self.inner) { core::ptr::null_mut() } else {
89 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
95 /// Used only if an object of this type is returned as a trait impl by a method
96 pub(crate) extern "C" fn DecodeError_clone_void(this_ptr: *const c_void) -> *mut c_void {
97 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDecodeError)).clone() })) as *mut c_void
100 /// Creates a copy of the DecodeError
101 pub extern "C" fn DecodeError_clone(orig: &DecodeError) -> DecodeError {
105 use lightning::ln::msgs::Init as nativeInitImport;
106 pub(crate) type nativeInit = nativeInitImport;
108 /// An init message to be sent or received from a peer
112 /// A pointer to the opaque Rust object.
114 /// Nearly everywhere, inner must be non-null, however in places where
115 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
116 pub inner: *mut nativeInit,
117 /// Indicates that this is the only struct which contains the same pointer.
119 /// Rust functions which take ownership of an object provided via an argument require
120 /// this to be true and invalidate the object pointed to by inner.
126 if self.is_owned && !<*mut nativeInit>::is_null(self.inner) {
127 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
131 /// Frees any resources used by the Init, if is_owned is set and inner is non-NULL.
133 pub extern "C" fn Init_free(this_obj: Init) { }
135 /// Used only if an object of this type is returned as a trait impl by a method
136 pub(crate) extern "C" fn Init_free_void(this_ptr: *mut c_void) {
137 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeInit); }
141 pub(crate) fn get_native_ref(&self) -> &'static nativeInit {
142 unsafe { &*ObjOps::untweak_ptr(self.inner) }
144 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInit {
145 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
147 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
148 pub(crate) fn take_inner(mut self) -> *mut nativeInit {
149 assert!(self.is_owned);
150 let ret = ObjOps::untweak_ptr(self.inner);
151 self.inner = core::ptr::null_mut();
155 /// The relevant features which the sender supports
157 pub extern "C" fn Init_get_features(this_ptr: &Init) -> crate::lightning::ln::features::InitFeatures {
158 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
159 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 }
161 /// The relevant features which the sender supports
163 pub extern "C" fn Init_set_features(this_ptr: &mut Init, mut val: crate::lightning::ln::features::InitFeatures) {
164 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
166 /// Constructs a new Init given each field
169 pub extern "C" fn Init_new(mut features_arg: crate::lightning::ln::features::InitFeatures) -> Init {
170 Init { inner: ObjOps::heap_alloc(nativeInit {
171 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
174 impl Clone for Init {
175 fn clone(&self) -> Self {
177 inner: if <*mut nativeInit>::is_null(self.inner) { core::ptr::null_mut() } else {
178 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
184 /// Used only if an object of this type is returned as a trait impl by a method
185 pub(crate) extern "C" fn Init_clone_void(this_ptr: *const c_void) -> *mut c_void {
186 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInit)).clone() })) as *mut c_void
189 /// Creates a copy of the Init
190 pub extern "C" fn Init_clone(orig: &Init) -> Init {
194 use lightning::ln::msgs::ErrorMessage as nativeErrorMessageImport;
195 pub(crate) type nativeErrorMessage = nativeErrorMessageImport;
197 /// An error message to be sent or received from a peer
200 pub struct ErrorMessage {
201 /// A pointer to the opaque Rust object.
203 /// Nearly everywhere, inner must be non-null, however in places where
204 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
205 pub inner: *mut nativeErrorMessage,
206 /// Indicates that this is the only struct which contains the same pointer.
208 /// Rust functions which take ownership of an object provided via an argument require
209 /// this to be true and invalidate the object pointed to by inner.
213 impl Drop for ErrorMessage {
215 if self.is_owned && !<*mut nativeErrorMessage>::is_null(self.inner) {
216 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
220 /// Frees any resources used by the ErrorMessage, if is_owned is set and inner is non-NULL.
222 pub extern "C" fn ErrorMessage_free(this_obj: ErrorMessage) { }
224 /// Used only if an object of this type is returned as a trait impl by a method
225 pub(crate) extern "C" fn ErrorMessage_free_void(this_ptr: *mut c_void) {
226 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeErrorMessage); }
230 pub(crate) fn get_native_ref(&self) -> &'static nativeErrorMessage {
231 unsafe { &*ObjOps::untweak_ptr(self.inner) }
233 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeErrorMessage {
234 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
236 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
237 pub(crate) fn take_inner(mut self) -> *mut nativeErrorMessage {
238 assert!(self.is_owned);
239 let ret = ObjOps::untweak_ptr(self.inner);
240 self.inner = core::ptr::null_mut();
244 /// The channel ID involved in the error.
246 /// All-0s indicates a general error unrelated to a specific channel, after which all channels
247 /// with the sending peer should be closed.
249 pub extern "C" fn ErrorMessage_get_channel_id(this_ptr: &ErrorMessage) -> *const [u8; 32] {
250 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
253 /// The channel ID involved in the error.
255 /// All-0s indicates a general error unrelated to a specific channel, after which all channels
256 /// with the sending peer should be closed.
258 pub extern "C" fn ErrorMessage_set_channel_id(this_ptr: &mut ErrorMessage, mut val: crate::c_types::ThirtyTwoBytes) {
259 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
261 /// A possibly human-readable error description.
262 /// The string should be sanitized before it is used (e.g. emitted to logs or printed to
263 /// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
264 /// the terminal emulator or the logging subsystem.
266 pub extern "C" fn ErrorMessage_get_data(this_ptr: &ErrorMessage) -> crate::c_types::Str {
267 let mut inner_val = &mut this_ptr.get_native_mut_ref().data;
268 inner_val.as_str().into()
270 /// A possibly human-readable error description.
271 /// The string should be sanitized before it is used (e.g. emitted to logs or printed to
272 /// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
273 /// the terminal emulator or the logging subsystem.
275 pub extern "C" fn ErrorMessage_set_data(this_ptr: &mut ErrorMessage, mut val: crate::c_types::Str) {
276 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string();
278 /// Constructs a new ErrorMessage given each field
281 pub extern "C" fn ErrorMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::Str) -> ErrorMessage {
282 ErrorMessage { inner: ObjOps::heap_alloc(nativeErrorMessage {
283 channel_id: channel_id_arg.data,
284 data: data_arg.into_string(),
287 impl Clone for ErrorMessage {
288 fn clone(&self) -> Self {
290 inner: if <*mut nativeErrorMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
291 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
297 /// Used only if an object of this type is returned as a trait impl by a method
298 pub(crate) extern "C" fn ErrorMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
299 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeErrorMessage)).clone() })) as *mut c_void
302 /// Creates a copy of the ErrorMessage
303 pub extern "C" fn ErrorMessage_clone(orig: &ErrorMessage) -> ErrorMessage {
307 use lightning::ln::msgs::WarningMessage as nativeWarningMessageImport;
308 pub(crate) type nativeWarningMessage = nativeWarningMessageImport;
310 /// A warning message to be sent or received from a peer
313 pub struct WarningMessage {
314 /// A pointer to the opaque Rust object.
316 /// Nearly everywhere, inner must be non-null, however in places where
317 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
318 pub inner: *mut nativeWarningMessage,
319 /// Indicates that this is the only struct which contains the same pointer.
321 /// Rust functions which take ownership of an object provided via an argument require
322 /// this to be true and invalidate the object pointed to by inner.
326 impl Drop for WarningMessage {
328 if self.is_owned && !<*mut nativeWarningMessage>::is_null(self.inner) {
329 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
333 /// Frees any resources used by the WarningMessage, if is_owned is set and inner is non-NULL.
335 pub extern "C" fn WarningMessage_free(this_obj: WarningMessage) { }
337 /// Used only if an object of this type is returned as a trait impl by a method
338 pub(crate) extern "C" fn WarningMessage_free_void(this_ptr: *mut c_void) {
339 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeWarningMessage); }
342 impl WarningMessage {
343 pub(crate) fn get_native_ref(&self) -> &'static nativeWarningMessage {
344 unsafe { &*ObjOps::untweak_ptr(self.inner) }
346 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeWarningMessage {
347 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
349 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
350 pub(crate) fn take_inner(mut self) -> *mut nativeWarningMessage {
351 assert!(self.is_owned);
352 let ret = ObjOps::untweak_ptr(self.inner);
353 self.inner = core::ptr::null_mut();
357 /// The channel ID involved in the warning.
359 /// All-0s indicates a warning unrelated to a specific channel.
361 pub extern "C" fn WarningMessage_get_channel_id(this_ptr: &WarningMessage) -> *const [u8; 32] {
362 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
365 /// The channel ID involved in the warning.
367 /// All-0s indicates a warning unrelated to a specific channel.
369 pub extern "C" fn WarningMessage_set_channel_id(this_ptr: &mut WarningMessage, mut val: crate::c_types::ThirtyTwoBytes) {
370 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
372 /// A possibly human-readable warning description.
373 /// The string should be sanitized before it is used (e.g. emitted to logs or printed to
374 /// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
375 /// the terminal emulator or the logging subsystem.
377 pub extern "C" fn WarningMessage_get_data(this_ptr: &WarningMessage) -> crate::c_types::Str {
378 let mut inner_val = &mut this_ptr.get_native_mut_ref().data;
379 inner_val.as_str().into()
381 /// A possibly human-readable warning description.
382 /// The string should be sanitized before it is used (e.g. emitted to logs or printed to
383 /// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
384 /// the terminal emulator or the logging subsystem.
386 pub extern "C" fn WarningMessage_set_data(this_ptr: &mut WarningMessage, mut val: crate::c_types::Str) {
387 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string();
389 /// Constructs a new WarningMessage given each field
392 pub extern "C" fn WarningMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::Str) -> WarningMessage {
393 WarningMessage { inner: ObjOps::heap_alloc(nativeWarningMessage {
394 channel_id: channel_id_arg.data,
395 data: data_arg.into_string(),
398 impl Clone for WarningMessage {
399 fn clone(&self) -> Self {
401 inner: if <*mut nativeWarningMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
402 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
408 /// Used only if an object of this type is returned as a trait impl by a method
409 pub(crate) extern "C" fn WarningMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
410 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeWarningMessage)).clone() })) as *mut c_void
413 /// Creates a copy of the WarningMessage
414 pub extern "C" fn WarningMessage_clone(orig: &WarningMessage) -> WarningMessage {
418 use lightning::ln::msgs::Ping as nativePingImport;
419 pub(crate) type nativePing = nativePingImport;
421 /// A ping message to be sent or received from a peer
425 /// A pointer to the opaque Rust object.
427 /// Nearly everywhere, inner must be non-null, however in places where
428 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
429 pub inner: *mut nativePing,
430 /// Indicates that this is the only struct which contains the same pointer.
432 /// Rust functions which take ownership of an object provided via an argument require
433 /// this to be true and invalidate the object pointed to by inner.
439 if self.is_owned && !<*mut nativePing>::is_null(self.inner) {
440 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
444 /// Frees any resources used by the Ping, if is_owned is set and inner is non-NULL.
446 pub extern "C" fn Ping_free(this_obj: Ping) { }
448 /// Used only if an object of this type is returned as a trait impl by a method
449 pub(crate) extern "C" fn Ping_free_void(this_ptr: *mut c_void) {
450 unsafe { let _ = Box::from_raw(this_ptr as *mut nativePing); }
454 pub(crate) fn get_native_ref(&self) -> &'static nativePing {
455 unsafe { &*ObjOps::untweak_ptr(self.inner) }
457 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePing {
458 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
460 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
461 pub(crate) fn take_inner(mut self) -> *mut nativePing {
462 assert!(self.is_owned);
463 let ret = ObjOps::untweak_ptr(self.inner);
464 self.inner = core::ptr::null_mut();
468 /// The desired response length
470 pub extern "C" fn Ping_get_ponglen(this_ptr: &Ping) -> u16 {
471 let mut inner_val = &mut this_ptr.get_native_mut_ref().ponglen;
474 /// The desired response length
476 pub extern "C" fn Ping_set_ponglen(this_ptr: &mut Ping, mut val: u16) {
477 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.ponglen = val;
479 /// The ping packet size.
480 /// This field is not sent on the wire. byteslen zeros are sent.
482 pub extern "C" fn Ping_get_byteslen(this_ptr: &Ping) -> u16 {
483 let mut inner_val = &mut this_ptr.get_native_mut_ref().byteslen;
486 /// The ping packet size.
487 /// This field is not sent on the wire. byteslen zeros are sent.
489 pub extern "C" fn Ping_set_byteslen(this_ptr: &mut Ping, mut val: u16) {
490 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.byteslen = val;
492 /// Constructs a new Ping given each field
495 pub extern "C" fn Ping_new(mut ponglen_arg: u16, mut byteslen_arg: u16) -> Ping {
496 Ping { inner: ObjOps::heap_alloc(nativePing {
497 ponglen: ponglen_arg,
498 byteslen: byteslen_arg,
501 impl Clone for Ping {
502 fn clone(&self) -> Self {
504 inner: if <*mut nativePing>::is_null(self.inner) { core::ptr::null_mut() } else {
505 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
511 /// Used only if an object of this type is returned as a trait impl by a method
512 pub(crate) extern "C" fn Ping_clone_void(this_ptr: *const c_void) -> *mut c_void {
513 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePing)).clone() })) as *mut c_void
516 /// Creates a copy of the Ping
517 pub extern "C" fn Ping_clone(orig: &Ping) -> Ping {
521 use lightning::ln::msgs::Pong as nativePongImport;
522 pub(crate) type nativePong = nativePongImport;
524 /// A pong message to be sent or received from a peer
528 /// A pointer to the opaque Rust object.
530 /// Nearly everywhere, inner must be non-null, however in places where
531 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
532 pub inner: *mut nativePong,
533 /// Indicates that this is the only struct which contains the same pointer.
535 /// Rust functions which take ownership of an object provided via an argument require
536 /// this to be true and invalidate the object pointed to by inner.
542 if self.is_owned && !<*mut nativePong>::is_null(self.inner) {
543 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
547 /// Frees any resources used by the Pong, if is_owned is set and inner is non-NULL.
549 pub extern "C" fn Pong_free(this_obj: Pong) { }
551 /// Used only if an object of this type is returned as a trait impl by a method
552 pub(crate) extern "C" fn Pong_free_void(this_ptr: *mut c_void) {
553 unsafe { let _ = Box::from_raw(this_ptr as *mut nativePong); }
557 pub(crate) fn get_native_ref(&self) -> &'static nativePong {
558 unsafe { &*ObjOps::untweak_ptr(self.inner) }
560 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePong {
561 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
563 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
564 pub(crate) fn take_inner(mut self) -> *mut nativePong {
565 assert!(self.is_owned);
566 let ret = ObjOps::untweak_ptr(self.inner);
567 self.inner = core::ptr::null_mut();
571 /// The pong packet size.
572 /// This field is not sent on the wire. byteslen zeros are sent.
574 pub extern "C" fn Pong_get_byteslen(this_ptr: &Pong) -> u16 {
575 let mut inner_val = &mut this_ptr.get_native_mut_ref().byteslen;
578 /// The pong packet size.
579 /// This field is not sent on the wire. byteslen zeros are sent.
581 pub extern "C" fn Pong_set_byteslen(this_ptr: &mut Pong, mut val: u16) {
582 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.byteslen = val;
584 /// Constructs a new Pong given each field
587 pub extern "C" fn Pong_new(mut byteslen_arg: u16) -> Pong {
588 Pong { inner: ObjOps::heap_alloc(nativePong {
589 byteslen: byteslen_arg,
592 impl Clone for Pong {
593 fn clone(&self) -> Self {
595 inner: if <*mut nativePong>::is_null(self.inner) { core::ptr::null_mut() } else {
596 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
602 /// Used only if an object of this type is returned as a trait impl by a method
603 pub(crate) extern "C" fn Pong_clone_void(this_ptr: *const c_void) -> *mut c_void {
604 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePong)).clone() })) as *mut c_void
607 /// Creates a copy of the Pong
608 pub extern "C" fn Pong_clone(orig: &Pong) -> Pong {
612 use lightning::ln::msgs::OpenChannel as nativeOpenChannelImport;
613 pub(crate) type nativeOpenChannel = nativeOpenChannelImport;
615 /// An open_channel message to be sent or received from a peer
618 pub struct OpenChannel {
619 /// A pointer to the opaque Rust object.
621 /// Nearly everywhere, inner must be non-null, however in places where
622 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
623 pub inner: *mut nativeOpenChannel,
624 /// Indicates that this is the only struct which contains the same pointer.
626 /// Rust functions which take ownership of an object provided via an argument require
627 /// this to be true and invalidate the object pointed to by inner.
631 impl Drop for OpenChannel {
633 if self.is_owned && !<*mut nativeOpenChannel>::is_null(self.inner) {
634 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
638 /// Frees any resources used by the OpenChannel, if is_owned is set and inner is non-NULL.
640 pub extern "C" fn OpenChannel_free(this_obj: OpenChannel) { }
642 /// Used only if an object of this type is returned as a trait impl by a method
643 pub(crate) extern "C" fn OpenChannel_free_void(this_ptr: *mut c_void) {
644 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeOpenChannel); }
648 pub(crate) fn get_native_ref(&self) -> &'static nativeOpenChannel {
649 unsafe { &*ObjOps::untweak_ptr(self.inner) }
651 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOpenChannel {
652 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
654 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
655 pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannel {
656 assert!(self.is_owned);
657 let ret = ObjOps::untweak_ptr(self.inner);
658 self.inner = core::ptr::null_mut();
662 /// The genesis hash of the blockchain where the channel is to be opened
664 pub extern "C" fn OpenChannel_get_chain_hash(this_ptr: &OpenChannel) -> *const [u8; 32] {
665 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
668 /// The genesis hash of the blockchain where the channel is to be opened
670 pub extern "C" fn OpenChannel_set_chain_hash(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
671 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
673 /// A temporary channel ID, until the funding outpoint is announced
675 pub extern "C" fn OpenChannel_get_temporary_channel_id(this_ptr: &OpenChannel) -> *const [u8; 32] {
676 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
679 /// A temporary channel ID, until the funding outpoint is announced
681 pub extern "C" fn OpenChannel_set_temporary_channel_id(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
682 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
684 /// The channel value
686 pub extern "C" fn OpenChannel_get_funding_satoshis(this_ptr: &OpenChannel) -> u64 {
687 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
690 /// The channel value
692 pub extern "C" fn OpenChannel_set_funding_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
693 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
695 /// The amount to push to the counterparty as part of the open, in milli-satoshi
697 pub extern "C" fn OpenChannel_get_push_msat(this_ptr: &OpenChannel) -> u64 {
698 let mut inner_val = &mut this_ptr.get_native_mut_ref().push_msat;
701 /// The amount to push to the counterparty as part of the open, in milli-satoshi
703 pub extern "C" fn OpenChannel_set_push_msat(this_ptr: &mut OpenChannel, mut val: u64) {
704 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.push_msat = val;
706 /// The threshold below which outputs on transactions broadcast by sender will be omitted
708 pub extern "C" fn OpenChannel_get_dust_limit_satoshis(this_ptr: &OpenChannel) -> u64 {
709 let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
712 /// The threshold below which outputs on transactions broadcast by sender will be omitted
714 pub extern "C" fn OpenChannel_set_dust_limit_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
715 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
717 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
719 pub extern "C" fn OpenChannel_get_max_htlc_value_in_flight_msat(this_ptr: &OpenChannel) -> u64 {
720 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
723 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
725 pub extern "C" fn OpenChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut OpenChannel, mut val: u64) {
726 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
728 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
730 pub extern "C" fn OpenChannel_get_channel_reserve_satoshis(this_ptr: &OpenChannel) -> u64 {
731 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
734 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
736 pub extern "C" fn OpenChannel_set_channel_reserve_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
737 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
739 /// The minimum HTLC size incoming to sender, in milli-satoshi
741 pub extern "C" fn OpenChannel_get_htlc_minimum_msat(this_ptr: &OpenChannel) -> u64 {
742 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
745 /// The minimum HTLC size incoming to sender, in milli-satoshi
747 pub extern "C" fn OpenChannel_set_htlc_minimum_msat(this_ptr: &mut OpenChannel, mut val: u64) {
748 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
750 /// The feerate per 1000-weight of sender generated transactions, until updated by update_fee
752 pub extern "C" fn OpenChannel_get_feerate_per_kw(this_ptr: &OpenChannel) -> u32 {
753 let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
756 /// The feerate per 1000-weight of sender generated transactions, until updated by update_fee
758 pub extern "C" fn OpenChannel_set_feerate_per_kw(this_ptr: &mut OpenChannel, mut val: u32) {
759 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
761 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
763 pub extern "C" fn OpenChannel_get_to_self_delay(this_ptr: &OpenChannel) -> u16 {
764 let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
767 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
769 pub extern "C" fn OpenChannel_set_to_self_delay(this_ptr: &mut OpenChannel, mut val: u16) {
770 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
772 /// The maximum number of inbound HTLCs towards sender
774 pub extern "C" fn OpenChannel_get_max_accepted_htlcs(this_ptr: &OpenChannel) -> u16 {
775 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
778 /// The maximum number of inbound HTLCs towards sender
780 pub extern "C" fn OpenChannel_set_max_accepted_htlcs(this_ptr: &mut OpenChannel, mut val: u16) {
781 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
783 /// The sender's key controlling the funding transaction
785 pub extern "C" fn OpenChannel_get_funding_pubkey(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
786 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
787 crate::c_types::PublicKey::from_rust(&inner_val)
789 /// The sender's key controlling the funding transaction
791 pub extern "C" fn OpenChannel_set_funding_pubkey(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
792 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
794 /// Used to derive a revocation key for transactions broadcast by counterparty
796 pub extern "C" fn OpenChannel_get_revocation_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
797 let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
798 crate::c_types::PublicKey::from_rust(&inner_val)
800 /// Used to derive a revocation key for transactions broadcast by counterparty
802 pub extern "C" fn OpenChannel_set_revocation_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
803 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
805 /// A payment key to sender for transactions broadcast by counterparty
807 pub extern "C" fn OpenChannel_get_payment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
808 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_point;
809 crate::c_types::PublicKey::from_rust(&inner_val)
811 /// A payment key to sender for transactions broadcast by counterparty
813 pub extern "C" fn OpenChannel_set_payment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
814 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_point = val.into_rust();
816 /// Used to derive a payment key to sender for transactions broadcast by sender
818 pub extern "C" fn OpenChannel_get_delayed_payment_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
819 let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
820 crate::c_types::PublicKey::from_rust(&inner_val)
822 /// Used to derive a payment key to sender for transactions broadcast by sender
824 pub extern "C" fn OpenChannel_set_delayed_payment_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
825 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
827 /// Used to derive an HTLC payment key to sender
829 pub extern "C" fn OpenChannel_get_htlc_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
830 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
831 crate::c_types::PublicKey::from_rust(&inner_val)
833 /// Used to derive an HTLC payment key to sender
835 pub extern "C" fn OpenChannel_set_htlc_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
836 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
838 /// The first to-be-broadcast-by-sender transaction's per commitment point
840 pub extern "C" fn OpenChannel_get_first_per_commitment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
841 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
842 crate::c_types::PublicKey::from_rust(&inner_val)
844 /// The first to-be-broadcast-by-sender transaction's per commitment point
846 pub extern "C" fn OpenChannel_set_first_per_commitment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
847 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
851 pub extern "C" fn OpenChannel_get_channel_flags(this_ptr: &OpenChannel) -> u8 {
852 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_flags;
857 pub extern "C" fn OpenChannel_set_channel_flags(this_ptr: &mut OpenChannel, mut val: u8) {
858 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_flags = val;
860 /// The channel type that this channel will represent. If none is set, we derive the channel
861 /// type from the intersection of our feature bits with our counterparty's feature bits from
862 /// the Init message.
864 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
866 pub extern "C" fn OpenChannel_get_channel_type(this_ptr: &OpenChannel) -> crate::lightning::ln::features::ChannelTypeFeatures {
867 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
868 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 };
871 /// The channel type that this channel will represent. If none is set, we derive the channel
872 /// type from the intersection of our feature bits with our counterparty's feature bits from
873 /// the Init message.
875 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
877 pub extern "C" fn OpenChannel_set_channel_type(this_ptr: &mut OpenChannel, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
878 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
879 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
881 impl Clone for OpenChannel {
882 fn clone(&self) -> Self {
884 inner: if <*mut nativeOpenChannel>::is_null(self.inner) { core::ptr::null_mut() } else {
885 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
891 /// Used only if an object of this type is returned as a trait impl by a method
892 pub(crate) extern "C" fn OpenChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
893 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOpenChannel)).clone() })) as *mut c_void
896 /// Creates a copy of the OpenChannel
897 pub extern "C" fn OpenChannel_clone(orig: &OpenChannel) -> OpenChannel {
901 use lightning::ln::msgs::AcceptChannel as nativeAcceptChannelImport;
902 pub(crate) type nativeAcceptChannel = nativeAcceptChannelImport;
904 /// An accept_channel message to be sent or received from a peer
907 pub struct AcceptChannel {
908 /// A pointer to the opaque Rust object.
910 /// Nearly everywhere, inner must be non-null, however in places where
911 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
912 pub inner: *mut nativeAcceptChannel,
913 /// Indicates that this is the only struct which contains the same pointer.
915 /// Rust functions which take ownership of an object provided via an argument require
916 /// this to be true and invalidate the object pointed to by inner.
920 impl Drop for AcceptChannel {
922 if self.is_owned && !<*mut nativeAcceptChannel>::is_null(self.inner) {
923 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
927 /// Frees any resources used by the AcceptChannel, if is_owned is set and inner is non-NULL.
929 pub extern "C" fn AcceptChannel_free(this_obj: AcceptChannel) { }
931 /// Used only if an object of this type is returned as a trait impl by a method
932 pub(crate) extern "C" fn AcceptChannel_free_void(this_ptr: *mut c_void) {
933 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeAcceptChannel); }
937 pub(crate) fn get_native_ref(&self) -> &'static nativeAcceptChannel {
938 unsafe { &*ObjOps::untweak_ptr(self.inner) }
940 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAcceptChannel {
941 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
943 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
944 pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannel {
945 assert!(self.is_owned);
946 let ret = ObjOps::untweak_ptr(self.inner);
947 self.inner = core::ptr::null_mut();
951 /// A temporary channel ID, until the funding outpoint is announced
953 pub extern "C" fn AcceptChannel_get_temporary_channel_id(this_ptr: &AcceptChannel) -> *const [u8; 32] {
954 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
957 /// A temporary channel ID, until the funding outpoint is announced
959 pub extern "C" fn AcceptChannel_set_temporary_channel_id(this_ptr: &mut AcceptChannel, mut val: crate::c_types::ThirtyTwoBytes) {
960 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
962 /// The threshold below which outputs on transactions broadcast by sender will be omitted
964 pub extern "C" fn AcceptChannel_get_dust_limit_satoshis(this_ptr: &AcceptChannel) -> u64 {
965 let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
968 /// The threshold below which outputs on transactions broadcast by sender will be omitted
970 pub extern "C" fn AcceptChannel_set_dust_limit_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
971 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
973 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
975 pub extern "C" fn AcceptChannel_get_max_htlc_value_in_flight_msat(this_ptr: &AcceptChannel) -> u64 {
976 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
979 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
981 pub extern "C" fn AcceptChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
982 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
984 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
986 pub extern "C" fn AcceptChannel_get_channel_reserve_satoshis(this_ptr: &AcceptChannel) -> u64 {
987 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
990 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
992 pub extern "C" fn AcceptChannel_set_channel_reserve_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
993 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
995 /// The minimum HTLC size incoming to sender, in milli-satoshi
997 pub extern "C" fn AcceptChannel_get_htlc_minimum_msat(this_ptr: &AcceptChannel) -> u64 {
998 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
1001 /// The minimum HTLC size incoming to sender, in milli-satoshi
1003 pub extern "C" fn AcceptChannel_set_htlc_minimum_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
1004 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
1006 /// Minimum depth of the funding transaction before the channel is considered open
1008 pub extern "C" fn AcceptChannel_get_minimum_depth(this_ptr: &AcceptChannel) -> u32 {
1009 let mut inner_val = &mut this_ptr.get_native_mut_ref().minimum_depth;
1012 /// Minimum depth of the funding transaction before the channel is considered open
1014 pub extern "C" fn AcceptChannel_set_minimum_depth(this_ptr: &mut AcceptChannel, mut val: u32) {
1015 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.minimum_depth = val;
1017 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
1019 pub extern "C" fn AcceptChannel_get_to_self_delay(this_ptr: &AcceptChannel) -> u16 {
1020 let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
1023 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
1025 pub extern "C" fn AcceptChannel_set_to_self_delay(this_ptr: &mut AcceptChannel, mut val: u16) {
1026 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
1028 /// The maximum number of inbound HTLCs towards sender
1030 pub extern "C" fn AcceptChannel_get_max_accepted_htlcs(this_ptr: &AcceptChannel) -> u16 {
1031 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
1034 /// The maximum number of inbound HTLCs towards sender
1036 pub extern "C" fn AcceptChannel_set_max_accepted_htlcs(this_ptr: &mut AcceptChannel, mut val: u16) {
1037 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
1039 /// The sender's key controlling the funding transaction
1041 pub extern "C" fn AcceptChannel_get_funding_pubkey(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1042 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
1043 crate::c_types::PublicKey::from_rust(&inner_val)
1045 /// The sender's key controlling the funding transaction
1047 pub extern "C" fn AcceptChannel_set_funding_pubkey(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1048 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
1050 /// Used to derive a revocation key for transactions broadcast by counterparty
1052 pub extern "C" fn AcceptChannel_get_revocation_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1053 let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
1054 crate::c_types::PublicKey::from_rust(&inner_val)
1056 /// Used to derive a revocation key for transactions broadcast by counterparty
1058 pub extern "C" fn AcceptChannel_set_revocation_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1059 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
1061 /// A payment key to sender for transactions broadcast by counterparty
1063 pub extern "C" fn AcceptChannel_get_payment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1064 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_point;
1065 crate::c_types::PublicKey::from_rust(&inner_val)
1067 /// A payment key to sender for transactions broadcast by counterparty
1069 pub extern "C" fn AcceptChannel_set_payment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1070 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_point = val.into_rust();
1072 /// Used to derive a payment key to sender for transactions broadcast by sender
1074 pub extern "C" fn AcceptChannel_get_delayed_payment_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1075 let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
1076 crate::c_types::PublicKey::from_rust(&inner_val)
1078 /// Used to derive a payment key to sender for transactions broadcast by sender
1080 pub extern "C" fn AcceptChannel_set_delayed_payment_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1081 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
1083 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
1085 pub extern "C" fn AcceptChannel_get_htlc_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1086 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
1087 crate::c_types::PublicKey::from_rust(&inner_val)
1089 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
1091 pub extern "C" fn AcceptChannel_set_htlc_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1092 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
1094 /// The first to-be-broadcast-by-sender transaction's per commitment point
1096 pub extern "C" fn AcceptChannel_get_first_per_commitment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1097 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
1098 crate::c_types::PublicKey::from_rust(&inner_val)
1100 /// The first to-be-broadcast-by-sender transaction's per commitment point
1102 pub extern "C" fn AcceptChannel_set_first_per_commitment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1103 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
1105 /// The channel type that this channel will represent. If none is set, we derive the channel
1106 /// type from the intersection of our feature bits with our counterparty's feature bits from
1107 /// the Init message.
1109 /// This is required to match the equivalent field in [`OpenChannel::channel_type`].
1111 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1113 pub extern "C" fn AcceptChannel_get_channel_type(this_ptr: &AcceptChannel) -> crate::lightning::ln::features::ChannelTypeFeatures {
1114 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1115 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 };
1118 /// The channel type that this channel will represent. If none is set, we derive the channel
1119 /// type from the intersection of our feature bits with our counterparty's feature bits from
1120 /// the Init message.
1122 /// This is required to match the equivalent field in [`OpenChannel::channel_type`].
1124 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1126 pub extern "C" fn AcceptChannel_set_channel_type(this_ptr: &mut AcceptChannel, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1127 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1128 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1130 impl Clone for AcceptChannel {
1131 fn clone(&self) -> Self {
1133 inner: if <*mut nativeAcceptChannel>::is_null(self.inner) { core::ptr::null_mut() } else {
1134 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1140 /// Used only if an object of this type is returned as a trait impl by a method
1141 pub(crate) extern "C" fn AcceptChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
1142 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAcceptChannel)).clone() })) as *mut c_void
1145 /// Creates a copy of the AcceptChannel
1146 pub extern "C" fn AcceptChannel_clone(orig: &AcceptChannel) -> AcceptChannel {
1150 use lightning::ln::msgs::FundingCreated as nativeFundingCreatedImport;
1151 pub(crate) type nativeFundingCreated = nativeFundingCreatedImport;
1153 /// A funding_created message to be sent or received from a peer
1156 pub struct FundingCreated {
1157 /// A pointer to the opaque Rust object.
1159 /// Nearly everywhere, inner must be non-null, however in places where
1160 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1161 pub inner: *mut nativeFundingCreated,
1162 /// Indicates that this is the only struct which contains the same pointer.
1164 /// Rust functions which take ownership of an object provided via an argument require
1165 /// this to be true and invalidate the object pointed to by inner.
1169 impl Drop for FundingCreated {
1170 fn drop(&mut self) {
1171 if self.is_owned && !<*mut nativeFundingCreated>::is_null(self.inner) {
1172 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1176 /// Frees any resources used by the FundingCreated, if is_owned is set and inner is non-NULL.
1178 pub extern "C" fn FundingCreated_free(this_obj: FundingCreated) { }
1180 /// Used only if an object of this type is returned as a trait impl by a method
1181 pub(crate) extern "C" fn FundingCreated_free_void(this_ptr: *mut c_void) {
1182 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingCreated); }
1185 impl FundingCreated {
1186 pub(crate) fn get_native_ref(&self) -> &'static nativeFundingCreated {
1187 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1189 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingCreated {
1190 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1192 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1193 pub(crate) fn take_inner(mut self) -> *mut nativeFundingCreated {
1194 assert!(self.is_owned);
1195 let ret = ObjOps::untweak_ptr(self.inner);
1196 self.inner = core::ptr::null_mut();
1200 /// A temporary channel ID, until the funding is established
1202 pub extern "C" fn FundingCreated_get_temporary_channel_id(this_ptr: &FundingCreated) -> *const [u8; 32] {
1203 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
1206 /// A temporary channel ID, until the funding is established
1208 pub extern "C" fn FundingCreated_set_temporary_channel_id(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
1209 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
1211 /// The funding transaction ID
1213 pub extern "C" fn FundingCreated_get_funding_txid(this_ptr: &FundingCreated) -> *const [u8; 32] {
1214 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_txid;
1215 inner_val.as_inner()
1217 /// The funding transaction ID
1219 pub extern "C" fn FundingCreated_set_funding_txid(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
1220 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_txid = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
1222 /// The specific output index funding this channel
1224 pub extern "C" fn FundingCreated_get_funding_output_index(this_ptr: &FundingCreated) -> u16 {
1225 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_index;
1228 /// The specific output index funding this channel
1230 pub extern "C" fn FundingCreated_set_funding_output_index(this_ptr: &mut FundingCreated, mut val: u16) {
1231 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_index = val;
1233 /// The signature of the channel initiator (funder) on the initial commitment transaction
1235 pub extern "C" fn FundingCreated_get_signature(this_ptr: &FundingCreated) -> crate::c_types::Signature {
1236 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
1237 crate::c_types::Signature::from_rust(&inner_val)
1239 /// The signature of the channel initiator (funder) on the initial commitment transaction
1241 pub extern "C" fn FundingCreated_set_signature(this_ptr: &mut FundingCreated, mut val: crate::c_types::Signature) {
1242 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
1244 /// Constructs a new FundingCreated given each field
1247 pub extern "C" fn FundingCreated_new(mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_txid_arg: crate::c_types::ThirtyTwoBytes, mut funding_output_index_arg: u16, mut signature_arg: crate::c_types::Signature) -> FundingCreated {
1248 FundingCreated { inner: ObjOps::heap_alloc(nativeFundingCreated {
1249 temporary_channel_id: temporary_channel_id_arg.data,
1250 funding_txid: ::bitcoin::hash_types::Txid::from_slice(&funding_txid_arg.data[..]).unwrap(),
1251 funding_output_index: funding_output_index_arg,
1252 signature: signature_arg.into_rust(),
1253 }), is_owned: true }
1255 impl Clone for FundingCreated {
1256 fn clone(&self) -> Self {
1258 inner: if <*mut nativeFundingCreated>::is_null(self.inner) { core::ptr::null_mut() } else {
1259 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1265 /// Used only if an object of this type is returned as a trait impl by a method
1266 pub(crate) extern "C" fn FundingCreated_clone_void(this_ptr: *const c_void) -> *mut c_void {
1267 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingCreated)).clone() })) as *mut c_void
1270 /// Creates a copy of the FundingCreated
1271 pub extern "C" fn FundingCreated_clone(orig: &FundingCreated) -> FundingCreated {
1275 use lightning::ln::msgs::FundingSigned as nativeFundingSignedImport;
1276 pub(crate) type nativeFundingSigned = nativeFundingSignedImport;
1278 /// A funding_signed message to be sent or received from a peer
1281 pub struct FundingSigned {
1282 /// A pointer to the opaque Rust object.
1284 /// Nearly everywhere, inner must be non-null, however in places where
1285 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1286 pub inner: *mut nativeFundingSigned,
1287 /// Indicates that this is the only struct which contains the same pointer.
1289 /// Rust functions which take ownership of an object provided via an argument require
1290 /// this to be true and invalidate the object pointed to by inner.
1294 impl Drop for FundingSigned {
1295 fn drop(&mut self) {
1296 if self.is_owned && !<*mut nativeFundingSigned>::is_null(self.inner) {
1297 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1301 /// Frees any resources used by the FundingSigned, if is_owned is set and inner is non-NULL.
1303 pub extern "C" fn FundingSigned_free(this_obj: FundingSigned) { }
1305 /// Used only if an object of this type is returned as a trait impl by a method
1306 pub(crate) extern "C" fn FundingSigned_free_void(this_ptr: *mut c_void) {
1307 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingSigned); }
1310 impl FundingSigned {
1311 pub(crate) fn get_native_ref(&self) -> &'static nativeFundingSigned {
1312 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1314 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingSigned {
1315 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1317 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1318 pub(crate) fn take_inner(mut self) -> *mut nativeFundingSigned {
1319 assert!(self.is_owned);
1320 let ret = ObjOps::untweak_ptr(self.inner);
1321 self.inner = core::ptr::null_mut();
1327 pub extern "C" fn FundingSigned_get_channel_id(this_ptr: &FundingSigned) -> *const [u8; 32] {
1328 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1333 pub extern "C" fn FundingSigned_set_channel_id(this_ptr: &mut FundingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
1334 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1336 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
1338 pub extern "C" fn FundingSigned_get_signature(this_ptr: &FundingSigned) -> crate::c_types::Signature {
1339 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
1340 crate::c_types::Signature::from_rust(&inner_val)
1342 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
1344 pub extern "C" fn FundingSigned_set_signature(this_ptr: &mut FundingSigned, mut val: crate::c_types::Signature) {
1345 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
1347 /// Constructs a new FundingSigned given each field
1350 pub extern "C" fn FundingSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut signature_arg: crate::c_types::Signature) -> FundingSigned {
1351 FundingSigned { inner: ObjOps::heap_alloc(nativeFundingSigned {
1352 channel_id: channel_id_arg.data,
1353 signature: signature_arg.into_rust(),
1354 }), is_owned: true }
1356 impl Clone for FundingSigned {
1357 fn clone(&self) -> Self {
1359 inner: if <*mut nativeFundingSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
1360 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1366 /// Used only if an object of this type is returned as a trait impl by a method
1367 pub(crate) extern "C" fn FundingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
1368 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingSigned)).clone() })) as *mut c_void
1371 /// Creates a copy of the FundingSigned
1372 pub extern "C" fn FundingSigned_clone(orig: &FundingSigned) -> FundingSigned {
1376 use lightning::ln::msgs::FundingLocked as nativeFundingLockedImport;
1377 pub(crate) type nativeFundingLocked = nativeFundingLockedImport;
1379 /// A funding_locked message to be sent or received from a peer
1382 pub struct FundingLocked {
1383 /// A pointer to the opaque Rust object.
1385 /// Nearly everywhere, inner must be non-null, however in places where
1386 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1387 pub inner: *mut nativeFundingLocked,
1388 /// Indicates that this is the only struct which contains the same pointer.
1390 /// Rust functions which take ownership of an object provided via an argument require
1391 /// this to be true and invalidate the object pointed to by inner.
1395 impl Drop for FundingLocked {
1396 fn drop(&mut self) {
1397 if self.is_owned && !<*mut nativeFundingLocked>::is_null(self.inner) {
1398 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1402 /// Frees any resources used by the FundingLocked, if is_owned is set and inner is non-NULL.
1404 pub extern "C" fn FundingLocked_free(this_obj: FundingLocked) { }
1406 /// Used only if an object of this type is returned as a trait impl by a method
1407 pub(crate) extern "C" fn FundingLocked_free_void(this_ptr: *mut c_void) {
1408 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingLocked); }
1411 impl FundingLocked {
1412 pub(crate) fn get_native_ref(&self) -> &'static nativeFundingLocked {
1413 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1415 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingLocked {
1416 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1418 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1419 pub(crate) fn take_inner(mut self) -> *mut nativeFundingLocked {
1420 assert!(self.is_owned);
1421 let ret = ObjOps::untweak_ptr(self.inner);
1422 self.inner = core::ptr::null_mut();
1428 pub extern "C" fn FundingLocked_get_channel_id(this_ptr: &FundingLocked) -> *const [u8; 32] {
1429 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1434 pub extern "C" fn FundingLocked_set_channel_id(this_ptr: &mut FundingLocked, mut val: crate::c_types::ThirtyTwoBytes) {
1435 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1437 /// The per-commitment point of the second commitment transaction
1439 pub extern "C" fn FundingLocked_get_next_per_commitment_point(this_ptr: &FundingLocked) -> crate::c_types::PublicKey {
1440 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
1441 crate::c_types::PublicKey::from_rust(&inner_val)
1443 /// The per-commitment point of the second commitment transaction
1445 pub extern "C" fn FundingLocked_set_next_per_commitment_point(this_ptr: &mut FundingLocked, mut val: crate::c_types::PublicKey) {
1446 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
1448 /// Constructs a new FundingLocked given each field
1451 pub extern "C" fn FundingLocked_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut next_per_commitment_point_arg: crate::c_types::PublicKey) -> FundingLocked {
1452 FundingLocked { inner: ObjOps::heap_alloc(nativeFundingLocked {
1453 channel_id: channel_id_arg.data,
1454 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
1455 }), is_owned: true }
1457 impl Clone for FundingLocked {
1458 fn clone(&self) -> Self {
1460 inner: if <*mut nativeFundingLocked>::is_null(self.inner) { core::ptr::null_mut() } else {
1461 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1467 /// Used only if an object of this type is returned as a trait impl by a method
1468 pub(crate) extern "C" fn FundingLocked_clone_void(this_ptr: *const c_void) -> *mut c_void {
1469 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingLocked)).clone() })) as *mut c_void
1472 /// Creates a copy of the FundingLocked
1473 pub extern "C" fn FundingLocked_clone(orig: &FundingLocked) -> FundingLocked {
1477 use lightning::ln::msgs::Shutdown as nativeShutdownImport;
1478 pub(crate) type nativeShutdown = nativeShutdownImport;
1480 /// A shutdown message to be sent or received from a peer
1483 pub struct Shutdown {
1484 /// A pointer to the opaque Rust object.
1486 /// Nearly everywhere, inner must be non-null, however in places where
1487 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1488 pub inner: *mut nativeShutdown,
1489 /// Indicates that this is the only struct which contains the same pointer.
1491 /// Rust functions which take ownership of an object provided via an argument require
1492 /// this to be true and invalidate the object pointed to by inner.
1496 impl Drop for Shutdown {
1497 fn drop(&mut self) {
1498 if self.is_owned && !<*mut nativeShutdown>::is_null(self.inner) {
1499 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1503 /// Frees any resources used by the Shutdown, if is_owned is set and inner is non-NULL.
1505 pub extern "C" fn Shutdown_free(this_obj: Shutdown) { }
1507 /// Used only if an object of this type is returned as a trait impl by a method
1508 pub(crate) extern "C" fn Shutdown_free_void(this_ptr: *mut c_void) {
1509 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeShutdown); }
1513 pub(crate) fn get_native_ref(&self) -> &'static nativeShutdown {
1514 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1516 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeShutdown {
1517 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1519 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1520 pub(crate) fn take_inner(mut self) -> *mut nativeShutdown {
1521 assert!(self.is_owned);
1522 let ret = ObjOps::untweak_ptr(self.inner);
1523 self.inner = core::ptr::null_mut();
1529 pub extern "C" fn Shutdown_get_channel_id(this_ptr: &Shutdown) -> *const [u8; 32] {
1530 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1535 pub extern "C" fn Shutdown_set_channel_id(this_ptr: &mut Shutdown, mut val: crate::c_types::ThirtyTwoBytes) {
1536 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1538 /// The destination of this peer's funds on closing.
1539 /// Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
1541 pub extern "C" fn Shutdown_get_scriptpubkey(this_ptr: &Shutdown) -> crate::c_types::u8slice {
1542 let mut inner_val = &mut this_ptr.get_native_mut_ref().scriptpubkey;
1543 crate::c_types::u8slice::from_slice(&inner_val[..])
1545 /// The destination of this peer's funds on closing.
1546 /// Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
1548 pub extern "C" fn Shutdown_set_scriptpubkey(this_ptr: &mut Shutdown, mut val: crate::c_types::derived::CVec_u8Z) {
1549 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.scriptpubkey = ::bitcoin::blockdata::script::Script::from(val.into_rust());
1551 /// Constructs a new Shutdown given each field
1554 pub extern "C" fn Shutdown_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut scriptpubkey_arg: crate::c_types::derived::CVec_u8Z) -> Shutdown {
1555 Shutdown { inner: ObjOps::heap_alloc(nativeShutdown {
1556 channel_id: channel_id_arg.data,
1557 scriptpubkey: ::bitcoin::blockdata::script::Script::from(scriptpubkey_arg.into_rust()),
1558 }), is_owned: true }
1560 impl Clone for Shutdown {
1561 fn clone(&self) -> Self {
1563 inner: if <*mut nativeShutdown>::is_null(self.inner) { core::ptr::null_mut() } else {
1564 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1570 /// Used only if an object of this type is returned as a trait impl by a method
1571 pub(crate) extern "C" fn Shutdown_clone_void(this_ptr: *const c_void) -> *mut c_void {
1572 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeShutdown)).clone() })) as *mut c_void
1575 /// Creates a copy of the Shutdown
1576 pub extern "C" fn Shutdown_clone(orig: &Shutdown) -> Shutdown {
1580 use lightning::ln::msgs::ClosingSignedFeeRange as nativeClosingSignedFeeRangeImport;
1581 pub(crate) type nativeClosingSignedFeeRange = nativeClosingSignedFeeRangeImport;
1583 /// The minimum and maximum fees which the sender is willing to place on the closing transaction.
1584 /// This is provided in [`ClosingSigned`] by both sides to indicate the fee range they are willing
1588 pub struct ClosingSignedFeeRange {
1589 /// A pointer to the opaque Rust object.
1591 /// Nearly everywhere, inner must be non-null, however in places where
1592 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1593 pub inner: *mut nativeClosingSignedFeeRange,
1594 /// Indicates that this is the only struct which contains the same pointer.
1596 /// Rust functions which take ownership of an object provided via an argument require
1597 /// this to be true and invalidate the object pointed to by inner.
1601 impl Drop for ClosingSignedFeeRange {
1602 fn drop(&mut self) {
1603 if self.is_owned && !<*mut nativeClosingSignedFeeRange>::is_null(self.inner) {
1604 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1608 /// Frees any resources used by the ClosingSignedFeeRange, if is_owned is set and inner is non-NULL.
1610 pub extern "C" fn ClosingSignedFeeRange_free(this_obj: ClosingSignedFeeRange) { }
1612 /// Used only if an object of this type is returned as a trait impl by a method
1613 pub(crate) extern "C" fn ClosingSignedFeeRange_free_void(this_ptr: *mut c_void) {
1614 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeClosingSignedFeeRange); }
1617 impl ClosingSignedFeeRange {
1618 pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSignedFeeRange {
1619 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1621 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSignedFeeRange {
1622 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1624 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1625 pub(crate) fn take_inner(mut self) -> *mut nativeClosingSignedFeeRange {
1626 assert!(self.is_owned);
1627 let ret = ObjOps::untweak_ptr(self.inner);
1628 self.inner = core::ptr::null_mut();
1632 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
1635 pub extern "C" fn ClosingSignedFeeRange_get_min_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
1636 let mut inner_val = &mut this_ptr.get_native_mut_ref().min_fee_satoshis;
1639 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
1642 pub extern "C" fn ClosingSignedFeeRange_set_min_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
1643 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_fee_satoshis = val;
1645 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
1648 pub extern "C" fn ClosingSignedFeeRange_get_max_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
1649 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_fee_satoshis;
1652 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
1655 pub extern "C" fn ClosingSignedFeeRange_set_max_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
1656 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_fee_satoshis = val;
1658 /// Constructs a new ClosingSignedFeeRange given each field
1661 pub extern "C" fn ClosingSignedFeeRange_new(mut min_fee_satoshis_arg: u64, mut max_fee_satoshis_arg: u64) -> ClosingSignedFeeRange {
1662 ClosingSignedFeeRange { inner: ObjOps::heap_alloc(nativeClosingSignedFeeRange {
1663 min_fee_satoshis: min_fee_satoshis_arg,
1664 max_fee_satoshis: max_fee_satoshis_arg,
1665 }), is_owned: true }
1667 impl Clone for ClosingSignedFeeRange {
1668 fn clone(&self) -> Self {
1670 inner: if <*mut nativeClosingSignedFeeRange>::is_null(self.inner) { core::ptr::null_mut() } else {
1671 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1677 /// Used only if an object of this type is returned as a trait impl by a method
1678 pub(crate) extern "C" fn ClosingSignedFeeRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
1679 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClosingSignedFeeRange)).clone() })) as *mut c_void
1682 /// Creates a copy of the ClosingSignedFeeRange
1683 pub extern "C" fn ClosingSignedFeeRange_clone(orig: &ClosingSignedFeeRange) -> ClosingSignedFeeRange {
1687 use lightning::ln::msgs::ClosingSigned as nativeClosingSignedImport;
1688 pub(crate) type nativeClosingSigned = nativeClosingSignedImport;
1690 /// A closing_signed message to be sent or received from a peer
1693 pub struct ClosingSigned {
1694 /// A pointer to the opaque Rust object.
1696 /// Nearly everywhere, inner must be non-null, however in places where
1697 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1698 pub inner: *mut nativeClosingSigned,
1699 /// Indicates that this is the only struct which contains the same pointer.
1701 /// Rust functions which take ownership of an object provided via an argument require
1702 /// this to be true and invalidate the object pointed to by inner.
1706 impl Drop for ClosingSigned {
1707 fn drop(&mut self) {
1708 if self.is_owned && !<*mut nativeClosingSigned>::is_null(self.inner) {
1709 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1713 /// Frees any resources used by the ClosingSigned, if is_owned is set and inner is non-NULL.
1715 pub extern "C" fn ClosingSigned_free(this_obj: ClosingSigned) { }
1717 /// Used only if an object of this type is returned as a trait impl by a method
1718 pub(crate) extern "C" fn ClosingSigned_free_void(this_ptr: *mut c_void) {
1719 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeClosingSigned); }
1722 impl ClosingSigned {
1723 pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSigned {
1724 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1726 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSigned {
1727 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1729 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1730 pub(crate) fn take_inner(mut self) -> *mut nativeClosingSigned {
1731 assert!(self.is_owned);
1732 let ret = ObjOps::untweak_ptr(self.inner);
1733 self.inner = core::ptr::null_mut();
1739 pub extern "C" fn ClosingSigned_get_channel_id(this_ptr: &ClosingSigned) -> *const [u8; 32] {
1740 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1745 pub extern "C" fn ClosingSigned_set_channel_id(this_ptr: &mut ClosingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
1746 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1748 /// The proposed total fee for the closing transaction
1750 pub extern "C" fn ClosingSigned_get_fee_satoshis(this_ptr: &ClosingSigned) -> u64 {
1751 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_satoshis;
1754 /// The proposed total fee for the closing transaction
1756 pub extern "C" fn ClosingSigned_set_fee_satoshis(this_ptr: &mut ClosingSigned, mut val: u64) {
1757 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_satoshis = val;
1759 /// A signature on the closing transaction
1761 pub extern "C" fn ClosingSigned_get_signature(this_ptr: &ClosingSigned) -> crate::c_types::Signature {
1762 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
1763 crate::c_types::Signature::from_rust(&inner_val)
1765 /// A signature on the closing transaction
1767 pub extern "C" fn ClosingSigned_set_signature(this_ptr: &mut ClosingSigned, mut val: crate::c_types::Signature) {
1768 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
1770 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
1773 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1775 pub extern "C" fn ClosingSigned_get_fee_range(this_ptr: &ClosingSigned) -> crate::lightning::ln::msgs::ClosingSignedFeeRange {
1776 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_range;
1777 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 };
1780 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
1783 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1785 pub extern "C" fn ClosingSigned_set_fee_range(this_ptr: &mut ClosingSigned, mut val: crate::lightning::ln::msgs::ClosingSignedFeeRange) {
1786 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1787 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_range = local_val;
1789 /// Constructs a new ClosingSigned given each field
1792 pub extern "C" fn ClosingSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut fee_satoshis_arg: u64, mut signature_arg: crate::c_types::Signature, mut fee_range_arg: crate::lightning::ln::msgs::ClosingSignedFeeRange) -> ClosingSigned {
1793 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()) } }) };
1794 ClosingSigned { inner: ObjOps::heap_alloc(nativeClosingSigned {
1795 channel_id: channel_id_arg.data,
1796 fee_satoshis: fee_satoshis_arg,
1797 signature: signature_arg.into_rust(),
1798 fee_range: local_fee_range_arg,
1799 }), is_owned: true }
1801 impl Clone for ClosingSigned {
1802 fn clone(&self) -> Self {
1804 inner: if <*mut nativeClosingSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
1805 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1811 /// Used only if an object of this type is returned as a trait impl by a method
1812 pub(crate) extern "C" fn ClosingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
1813 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClosingSigned)).clone() })) as *mut c_void
1816 /// Creates a copy of the ClosingSigned
1817 pub extern "C" fn ClosingSigned_clone(orig: &ClosingSigned) -> ClosingSigned {
1821 use lightning::ln::msgs::UpdateAddHTLC as nativeUpdateAddHTLCImport;
1822 pub(crate) type nativeUpdateAddHTLC = nativeUpdateAddHTLCImport;
1824 /// An update_add_htlc message to be sent or received from a peer
1827 pub struct UpdateAddHTLC {
1828 /// A pointer to the opaque Rust object.
1830 /// Nearly everywhere, inner must be non-null, however in places where
1831 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1832 pub inner: *mut nativeUpdateAddHTLC,
1833 /// Indicates that this is the only struct which contains the same pointer.
1835 /// Rust functions which take ownership of an object provided via an argument require
1836 /// this to be true and invalidate the object pointed to by inner.
1840 impl Drop for UpdateAddHTLC {
1841 fn drop(&mut self) {
1842 if self.is_owned && !<*mut nativeUpdateAddHTLC>::is_null(self.inner) {
1843 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1847 /// Frees any resources used by the UpdateAddHTLC, if is_owned is set and inner is non-NULL.
1849 pub extern "C" fn UpdateAddHTLC_free(this_obj: UpdateAddHTLC) { }
1851 /// Used only if an object of this type is returned as a trait impl by a method
1852 pub(crate) extern "C" fn UpdateAddHTLC_free_void(this_ptr: *mut c_void) {
1853 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateAddHTLC); }
1856 impl UpdateAddHTLC {
1857 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateAddHTLC {
1858 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1860 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateAddHTLC {
1861 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1863 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1864 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateAddHTLC {
1865 assert!(self.is_owned);
1866 let ret = ObjOps::untweak_ptr(self.inner);
1867 self.inner = core::ptr::null_mut();
1873 pub extern "C" fn UpdateAddHTLC_get_channel_id(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
1874 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1879 pub extern "C" fn UpdateAddHTLC_set_channel_id(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1880 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1884 pub extern "C" fn UpdateAddHTLC_get_htlc_id(this_ptr: &UpdateAddHTLC) -> u64 {
1885 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
1890 pub extern "C" fn UpdateAddHTLC_set_htlc_id(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
1891 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
1893 /// The HTLC value in milli-satoshi
1895 pub extern "C" fn UpdateAddHTLC_get_amount_msat(this_ptr: &UpdateAddHTLC) -> u64 {
1896 let mut inner_val = &mut this_ptr.get_native_mut_ref().amount_msat;
1899 /// The HTLC value in milli-satoshi
1901 pub extern "C" fn UpdateAddHTLC_set_amount_msat(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
1902 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.amount_msat = val;
1904 /// The payment hash, the pre-image of which controls HTLC redemption
1906 pub extern "C" fn UpdateAddHTLC_get_payment_hash(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
1907 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_hash;
1910 /// The payment hash, the pre-image of which controls HTLC redemption
1912 pub extern "C" fn UpdateAddHTLC_set_payment_hash(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1913 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_hash = ::lightning::ln::PaymentHash(val.data);
1915 /// The expiry height of the HTLC
1917 pub extern "C" fn UpdateAddHTLC_get_cltv_expiry(this_ptr: &UpdateAddHTLC) -> u32 {
1918 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry;
1921 /// The expiry height of the HTLC
1923 pub extern "C" fn UpdateAddHTLC_set_cltv_expiry(this_ptr: &mut UpdateAddHTLC, mut val: u32) {
1924 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry = val;
1926 impl Clone for UpdateAddHTLC {
1927 fn clone(&self) -> Self {
1929 inner: if <*mut nativeUpdateAddHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
1930 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1936 /// Used only if an object of this type is returned as a trait impl by a method
1937 pub(crate) extern "C" fn UpdateAddHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1938 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateAddHTLC)).clone() })) as *mut c_void
1941 /// Creates a copy of the UpdateAddHTLC
1942 pub extern "C" fn UpdateAddHTLC_clone(orig: &UpdateAddHTLC) -> UpdateAddHTLC {
1946 use lightning::ln::msgs::UpdateFulfillHTLC as nativeUpdateFulfillHTLCImport;
1947 pub(crate) type nativeUpdateFulfillHTLC = nativeUpdateFulfillHTLCImport;
1949 /// An update_fulfill_htlc message to be sent or received from a peer
1952 pub struct UpdateFulfillHTLC {
1953 /// A pointer to the opaque Rust object.
1955 /// Nearly everywhere, inner must be non-null, however in places where
1956 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1957 pub inner: *mut nativeUpdateFulfillHTLC,
1958 /// Indicates that this is the only struct which contains the same pointer.
1960 /// Rust functions which take ownership of an object provided via an argument require
1961 /// this to be true and invalidate the object pointed to by inner.
1965 impl Drop for UpdateFulfillHTLC {
1966 fn drop(&mut self) {
1967 if self.is_owned && !<*mut nativeUpdateFulfillHTLC>::is_null(self.inner) {
1968 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1972 /// Frees any resources used by the UpdateFulfillHTLC, if is_owned is set and inner is non-NULL.
1974 pub extern "C" fn UpdateFulfillHTLC_free(this_obj: UpdateFulfillHTLC) { }
1976 /// Used only if an object of this type is returned as a trait impl by a method
1977 pub(crate) extern "C" fn UpdateFulfillHTLC_free_void(this_ptr: *mut c_void) {
1978 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFulfillHTLC); }
1981 impl UpdateFulfillHTLC {
1982 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFulfillHTLC {
1983 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1985 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFulfillHTLC {
1986 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1988 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1989 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFulfillHTLC {
1990 assert!(self.is_owned);
1991 let ret = ObjOps::untweak_ptr(self.inner);
1992 self.inner = core::ptr::null_mut();
1998 pub extern "C" fn UpdateFulfillHTLC_get_channel_id(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
1999 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2004 pub extern "C" fn UpdateFulfillHTLC_set_channel_id(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
2005 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2009 pub extern "C" fn UpdateFulfillHTLC_get_htlc_id(this_ptr: &UpdateFulfillHTLC) -> u64 {
2010 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
2015 pub extern "C" fn UpdateFulfillHTLC_set_htlc_id(this_ptr: &mut UpdateFulfillHTLC, mut val: u64) {
2016 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
2018 /// The pre-image of the payment hash, allowing HTLC redemption
2020 pub extern "C" fn UpdateFulfillHTLC_get_payment_preimage(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
2021 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_preimage;
2024 /// The pre-image of the payment hash, allowing HTLC redemption
2026 pub extern "C" fn UpdateFulfillHTLC_set_payment_preimage(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
2027 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_preimage = ::lightning::ln::PaymentPreimage(val.data);
2029 /// Constructs a new UpdateFulfillHTLC given each field
2032 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 {
2033 UpdateFulfillHTLC { inner: ObjOps::heap_alloc(nativeUpdateFulfillHTLC {
2034 channel_id: channel_id_arg.data,
2035 htlc_id: htlc_id_arg,
2036 payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_arg.data),
2037 }), is_owned: true }
2039 impl Clone for UpdateFulfillHTLC {
2040 fn clone(&self) -> Self {
2042 inner: if <*mut nativeUpdateFulfillHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
2043 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2049 /// Used only if an object of this type is returned as a trait impl by a method
2050 pub(crate) extern "C" fn UpdateFulfillHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
2051 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFulfillHTLC)).clone() })) as *mut c_void
2054 /// Creates a copy of the UpdateFulfillHTLC
2055 pub extern "C" fn UpdateFulfillHTLC_clone(orig: &UpdateFulfillHTLC) -> UpdateFulfillHTLC {
2059 use lightning::ln::msgs::UpdateFailHTLC as nativeUpdateFailHTLCImport;
2060 pub(crate) type nativeUpdateFailHTLC = nativeUpdateFailHTLCImport;
2062 /// An update_fail_htlc message to be sent or received from a peer
2065 pub struct UpdateFailHTLC {
2066 /// A pointer to the opaque Rust object.
2068 /// Nearly everywhere, inner must be non-null, however in places where
2069 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2070 pub inner: *mut nativeUpdateFailHTLC,
2071 /// Indicates that this is the only struct which contains the same pointer.
2073 /// Rust functions which take ownership of an object provided via an argument require
2074 /// this to be true and invalidate the object pointed to by inner.
2078 impl Drop for UpdateFailHTLC {
2079 fn drop(&mut self) {
2080 if self.is_owned && !<*mut nativeUpdateFailHTLC>::is_null(self.inner) {
2081 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2085 /// Frees any resources used by the UpdateFailHTLC, if is_owned is set and inner is non-NULL.
2087 pub extern "C" fn UpdateFailHTLC_free(this_obj: UpdateFailHTLC) { }
2089 /// Used only if an object of this type is returned as a trait impl by a method
2090 pub(crate) extern "C" fn UpdateFailHTLC_free_void(this_ptr: *mut c_void) {
2091 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFailHTLC); }
2094 impl UpdateFailHTLC {
2095 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailHTLC {
2096 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2098 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailHTLC {
2099 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2101 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2102 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailHTLC {
2103 assert!(self.is_owned);
2104 let ret = ObjOps::untweak_ptr(self.inner);
2105 self.inner = core::ptr::null_mut();
2111 pub extern "C" fn UpdateFailHTLC_get_channel_id(this_ptr: &UpdateFailHTLC) -> *const [u8; 32] {
2112 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2117 pub extern "C" fn UpdateFailHTLC_set_channel_id(this_ptr: &mut UpdateFailHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
2118 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2122 pub extern "C" fn UpdateFailHTLC_get_htlc_id(this_ptr: &UpdateFailHTLC) -> u64 {
2123 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
2128 pub extern "C" fn UpdateFailHTLC_set_htlc_id(this_ptr: &mut UpdateFailHTLC, mut val: u64) {
2129 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
2131 impl Clone for UpdateFailHTLC {
2132 fn clone(&self) -> Self {
2134 inner: if <*mut nativeUpdateFailHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
2135 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2141 /// Used only if an object of this type is returned as a trait impl by a method
2142 pub(crate) extern "C" fn UpdateFailHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
2143 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailHTLC)).clone() })) as *mut c_void
2146 /// Creates a copy of the UpdateFailHTLC
2147 pub extern "C" fn UpdateFailHTLC_clone(orig: &UpdateFailHTLC) -> UpdateFailHTLC {
2151 use lightning::ln::msgs::UpdateFailMalformedHTLC as nativeUpdateFailMalformedHTLCImport;
2152 pub(crate) type nativeUpdateFailMalformedHTLC = nativeUpdateFailMalformedHTLCImport;
2154 /// An update_fail_malformed_htlc message to be sent or received from a peer
2157 pub struct UpdateFailMalformedHTLC {
2158 /// A pointer to the opaque Rust object.
2160 /// Nearly everywhere, inner must be non-null, however in places where
2161 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2162 pub inner: *mut nativeUpdateFailMalformedHTLC,
2163 /// Indicates that this is the only struct which contains the same pointer.
2165 /// Rust functions which take ownership of an object provided via an argument require
2166 /// this to be true and invalidate the object pointed to by inner.
2170 impl Drop for UpdateFailMalformedHTLC {
2171 fn drop(&mut self) {
2172 if self.is_owned && !<*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) {
2173 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2177 /// Frees any resources used by the UpdateFailMalformedHTLC, if is_owned is set and inner is non-NULL.
2179 pub extern "C" fn UpdateFailMalformedHTLC_free(this_obj: UpdateFailMalformedHTLC) { }
2181 /// Used only if an object of this type is returned as a trait impl by a method
2182 pub(crate) extern "C" fn UpdateFailMalformedHTLC_free_void(this_ptr: *mut c_void) {
2183 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFailMalformedHTLC); }
2186 impl UpdateFailMalformedHTLC {
2187 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailMalformedHTLC {
2188 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2190 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailMalformedHTLC {
2191 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2193 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2194 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailMalformedHTLC {
2195 assert!(self.is_owned);
2196 let ret = ObjOps::untweak_ptr(self.inner);
2197 self.inner = core::ptr::null_mut();
2203 pub extern "C" fn UpdateFailMalformedHTLC_get_channel_id(this_ptr: &UpdateFailMalformedHTLC) -> *const [u8; 32] {
2204 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2209 pub extern "C" fn UpdateFailMalformedHTLC_set_channel_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
2210 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2214 pub extern "C" fn UpdateFailMalformedHTLC_get_htlc_id(this_ptr: &UpdateFailMalformedHTLC) -> u64 {
2215 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
2220 pub extern "C" fn UpdateFailMalformedHTLC_set_htlc_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u64) {
2221 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
2223 /// The failure code
2225 pub extern "C" fn UpdateFailMalformedHTLC_get_failure_code(this_ptr: &UpdateFailMalformedHTLC) -> u16 {
2226 let mut inner_val = &mut this_ptr.get_native_mut_ref().failure_code;
2229 /// The failure code
2231 pub extern "C" fn UpdateFailMalformedHTLC_set_failure_code(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u16) {
2232 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.failure_code = val;
2234 impl Clone for UpdateFailMalformedHTLC {
2235 fn clone(&self) -> Self {
2237 inner: if <*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
2238 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2244 /// Used only if an object of this type is returned as a trait impl by a method
2245 pub(crate) extern "C" fn UpdateFailMalformedHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
2246 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailMalformedHTLC)).clone() })) as *mut c_void
2249 /// Creates a copy of the UpdateFailMalformedHTLC
2250 pub extern "C" fn UpdateFailMalformedHTLC_clone(orig: &UpdateFailMalformedHTLC) -> UpdateFailMalformedHTLC {
2254 use lightning::ln::msgs::CommitmentSigned as nativeCommitmentSignedImport;
2255 pub(crate) type nativeCommitmentSigned = nativeCommitmentSignedImport;
2257 /// A commitment_signed message to be sent or received from a peer
2260 pub struct CommitmentSigned {
2261 /// A pointer to the opaque Rust object.
2263 /// Nearly everywhere, inner must be non-null, however in places where
2264 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2265 pub inner: *mut nativeCommitmentSigned,
2266 /// Indicates that this is the only struct which contains the same pointer.
2268 /// Rust functions which take ownership of an object provided via an argument require
2269 /// this to be true and invalidate the object pointed to by inner.
2273 impl Drop for CommitmentSigned {
2274 fn drop(&mut self) {
2275 if self.is_owned && !<*mut nativeCommitmentSigned>::is_null(self.inner) {
2276 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2280 /// Frees any resources used by the CommitmentSigned, if is_owned is set and inner is non-NULL.
2282 pub extern "C" fn CommitmentSigned_free(this_obj: CommitmentSigned) { }
2284 /// Used only if an object of this type is returned as a trait impl by a method
2285 pub(crate) extern "C" fn CommitmentSigned_free_void(this_ptr: *mut c_void) {
2286 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentSigned); }
2289 impl CommitmentSigned {
2290 pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentSigned {
2291 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2293 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentSigned {
2294 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2296 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2297 pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentSigned {
2298 assert!(self.is_owned);
2299 let ret = ObjOps::untweak_ptr(self.inner);
2300 self.inner = core::ptr::null_mut();
2306 pub extern "C" fn CommitmentSigned_get_channel_id(this_ptr: &CommitmentSigned) -> *const [u8; 32] {
2307 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2312 pub extern "C" fn CommitmentSigned_set_channel_id(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::ThirtyTwoBytes) {
2313 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2315 /// A signature on the commitment transaction
2317 pub extern "C" fn CommitmentSigned_get_signature(this_ptr: &CommitmentSigned) -> crate::c_types::Signature {
2318 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
2319 crate::c_types::Signature::from_rust(&inner_val)
2321 /// A signature on the commitment transaction
2323 pub extern "C" fn CommitmentSigned_set_signature(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::Signature) {
2324 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
2326 /// Signatures on the HTLC transactions
2328 pub extern "C" fn CommitmentSigned_set_htlc_signatures(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::derived::CVec_SignatureZ) {
2329 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_rust() }); };
2330 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_signatures = local_val;
2332 /// Constructs a new CommitmentSigned given each field
2335 pub extern "C" fn CommitmentSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut signature_arg: crate::c_types::Signature, mut htlc_signatures_arg: crate::c_types::derived::CVec_SignatureZ) -> CommitmentSigned {
2336 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() }); };
2337 CommitmentSigned { inner: ObjOps::heap_alloc(nativeCommitmentSigned {
2338 channel_id: channel_id_arg.data,
2339 signature: signature_arg.into_rust(),
2340 htlc_signatures: local_htlc_signatures_arg,
2341 }), is_owned: true }
2343 impl Clone for CommitmentSigned {
2344 fn clone(&self) -> Self {
2346 inner: if <*mut nativeCommitmentSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
2347 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2353 /// Used only if an object of this type is returned as a trait impl by a method
2354 pub(crate) extern "C" fn CommitmentSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
2355 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentSigned)).clone() })) as *mut c_void
2358 /// Creates a copy of the CommitmentSigned
2359 pub extern "C" fn CommitmentSigned_clone(orig: &CommitmentSigned) -> CommitmentSigned {
2363 use lightning::ln::msgs::RevokeAndACK as nativeRevokeAndACKImport;
2364 pub(crate) type nativeRevokeAndACK = nativeRevokeAndACKImport;
2366 /// A revoke_and_ack message to be sent or received from a peer
2369 pub struct RevokeAndACK {
2370 /// A pointer to the opaque Rust object.
2372 /// Nearly everywhere, inner must be non-null, however in places where
2373 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2374 pub inner: *mut nativeRevokeAndACK,
2375 /// Indicates that this is the only struct which contains the same pointer.
2377 /// Rust functions which take ownership of an object provided via an argument require
2378 /// this to be true and invalidate the object pointed to by inner.
2382 impl Drop for RevokeAndACK {
2383 fn drop(&mut self) {
2384 if self.is_owned && !<*mut nativeRevokeAndACK>::is_null(self.inner) {
2385 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2389 /// Frees any resources used by the RevokeAndACK, if is_owned is set and inner is non-NULL.
2391 pub extern "C" fn RevokeAndACK_free(this_obj: RevokeAndACK) { }
2393 /// Used only if an object of this type is returned as a trait impl by a method
2394 pub(crate) extern "C" fn RevokeAndACK_free_void(this_ptr: *mut c_void) {
2395 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRevokeAndACK); }
2399 pub(crate) fn get_native_ref(&self) -> &'static nativeRevokeAndACK {
2400 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2402 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRevokeAndACK {
2403 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2405 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2406 pub(crate) fn take_inner(mut self) -> *mut nativeRevokeAndACK {
2407 assert!(self.is_owned);
2408 let ret = ObjOps::untweak_ptr(self.inner);
2409 self.inner = core::ptr::null_mut();
2415 pub extern "C" fn RevokeAndACK_get_channel_id(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
2416 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2421 pub extern "C" fn RevokeAndACK_set_channel_id(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
2422 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2424 /// The secret corresponding to the per-commitment point
2426 pub extern "C" fn RevokeAndACK_get_per_commitment_secret(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
2427 let mut inner_val = &mut this_ptr.get_native_mut_ref().per_commitment_secret;
2430 /// The secret corresponding to the per-commitment point
2432 pub extern "C" fn RevokeAndACK_set_per_commitment_secret(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
2433 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.per_commitment_secret = val.data;
2435 /// The next sender-broadcast commitment transaction's per-commitment point
2437 pub extern "C" fn RevokeAndACK_get_next_per_commitment_point(this_ptr: &RevokeAndACK) -> crate::c_types::PublicKey {
2438 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
2439 crate::c_types::PublicKey::from_rust(&inner_val)
2441 /// The next sender-broadcast commitment transaction's per-commitment point
2443 pub extern "C" fn RevokeAndACK_set_next_per_commitment_point(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::PublicKey) {
2444 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
2446 /// Constructs a new RevokeAndACK given each field
2449 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 {
2450 RevokeAndACK { inner: ObjOps::heap_alloc(nativeRevokeAndACK {
2451 channel_id: channel_id_arg.data,
2452 per_commitment_secret: per_commitment_secret_arg.data,
2453 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
2454 }), is_owned: true }
2456 impl Clone for RevokeAndACK {
2457 fn clone(&self) -> Self {
2459 inner: if <*mut nativeRevokeAndACK>::is_null(self.inner) { core::ptr::null_mut() } else {
2460 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2466 /// Used only if an object of this type is returned as a trait impl by a method
2467 pub(crate) extern "C" fn RevokeAndACK_clone_void(this_ptr: *const c_void) -> *mut c_void {
2468 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRevokeAndACK)).clone() })) as *mut c_void
2471 /// Creates a copy of the RevokeAndACK
2472 pub extern "C" fn RevokeAndACK_clone(orig: &RevokeAndACK) -> RevokeAndACK {
2476 use lightning::ln::msgs::UpdateFee as nativeUpdateFeeImport;
2477 pub(crate) type nativeUpdateFee = nativeUpdateFeeImport;
2479 /// An update_fee message to be sent or received from a peer
2482 pub struct UpdateFee {
2483 /// A pointer to the opaque Rust object.
2485 /// Nearly everywhere, inner must be non-null, however in places where
2486 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2487 pub inner: *mut nativeUpdateFee,
2488 /// Indicates that this is the only struct which contains the same pointer.
2490 /// Rust functions which take ownership of an object provided via an argument require
2491 /// this to be true and invalidate the object pointed to by inner.
2495 impl Drop for UpdateFee {
2496 fn drop(&mut self) {
2497 if self.is_owned && !<*mut nativeUpdateFee>::is_null(self.inner) {
2498 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2502 /// Frees any resources used by the UpdateFee, if is_owned is set and inner is non-NULL.
2504 pub extern "C" fn UpdateFee_free(this_obj: UpdateFee) { }
2506 /// Used only if an object of this type is returned as a trait impl by a method
2507 pub(crate) extern "C" fn UpdateFee_free_void(this_ptr: *mut c_void) {
2508 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFee); }
2512 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFee {
2513 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2515 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFee {
2516 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2518 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2519 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFee {
2520 assert!(self.is_owned);
2521 let ret = ObjOps::untweak_ptr(self.inner);
2522 self.inner = core::ptr::null_mut();
2528 pub extern "C" fn UpdateFee_get_channel_id(this_ptr: &UpdateFee) -> *const [u8; 32] {
2529 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2534 pub extern "C" fn UpdateFee_set_channel_id(this_ptr: &mut UpdateFee, mut val: crate::c_types::ThirtyTwoBytes) {
2535 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2537 /// Fee rate per 1000-weight of the transaction
2539 pub extern "C" fn UpdateFee_get_feerate_per_kw(this_ptr: &UpdateFee) -> u32 {
2540 let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
2543 /// Fee rate per 1000-weight of the transaction
2545 pub extern "C" fn UpdateFee_set_feerate_per_kw(this_ptr: &mut UpdateFee, mut val: u32) {
2546 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
2548 /// Constructs a new UpdateFee given each field
2551 pub extern "C" fn UpdateFee_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut feerate_per_kw_arg: u32) -> UpdateFee {
2552 UpdateFee { inner: ObjOps::heap_alloc(nativeUpdateFee {
2553 channel_id: channel_id_arg.data,
2554 feerate_per_kw: feerate_per_kw_arg,
2555 }), is_owned: true }
2557 impl Clone for UpdateFee {
2558 fn clone(&self) -> Self {
2560 inner: if <*mut nativeUpdateFee>::is_null(self.inner) { core::ptr::null_mut() } else {
2561 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2567 /// Used only if an object of this type is returned as a trait impl by a method
2568 pub(crate) extern "C" fn UpdateFee_clone_void(this_ptr: *const c_void) -> *mut c_void {
2569 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFee)).clone() })) as *mut c_void
2572 /// Creates a copy of the UpdateFee
2573 pub extern "C" fn UpdateFee_clone(orig: &UpdateFee) -> UpdateFee {
2577 use lightning::ln::msgs::DataLossProtect as nativeDataLossProtectImport;
2578 pub(crate) type nativeDataLossProtect = nativeDataLossProtectImport;
2580 /// Proof that the sender knows the per-commitment secret of the previous commitment transaction.
2581 /// This is used to convince the recipient that the channel is at a certain commitment
2582 /// number even if they lost that data due to a local failure. Of course, the peer may lie
2583 /// and even later commitments may have been revoked.
2586 pub struct DataLossProtect {
2587 /// A pointer to the opaque Rust object.
2589 /// Nearly everywhere, inner must be non-null, however in places where
2590 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2591 pub inner: *mut nativeDataLossProtect,
2592 /// Indicates that this is the only struct which contains the same pointer.
2594 /// Rust functions which take ownership of an object provided via an argument require
2595 /// this to be true and invalidate the object pointed to by inner.
2599 impl Drop for DataLossProtect {
2600 fn drop(&mut self) {
2601 if self.is_owned && !<*mut nativeDataLossProtect>::is_null(self.inner) {
2602 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2606 /// Frees any resources used by the DataLossProtect, if is_owned is set and inner is non-NULL.
2608 pub extern "C" fn DataLossProtect_free(this_obj: DataLossProtect) { }
2610 /// Used only if an object of this type is returned as a trait impl by a method
2611 pub(crate) extern "C" fn DataLossProtect_free_void(this_ptr: *mut c_void) {
2612 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDataLossProtect); }
2615 impl DataLossProtect {
2616 pub(crate) fn get_native_ref(&self) -> &'static nativeDataLossProtect {
2617 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2619 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeDataLossProtect {
2620 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2622 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2623 pub(crate) fn take_inner(mut self) -> *mut nativeDataLossProtect {
2624 assert!(self.is_owned);
2625 let ret = ObjOps::untweak_ptr(self.inner);
2626 self.inner = core::ptr::null_mut();
2630 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
2631 /// belonging to the recipient
2633 pub extern "C" fn DataLossProtect_get_your_last_per_commitment_secret(this_ptr: &DataLossProtect) -> *const [u8; 32] {
2634 let mut inner_val = &mut this_ptr.get_native_mut_ref().your_last_per_commitment_secret;
2637 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
2638 /// belonging to the recipient
2640 pub extern "C" fn DataLossProtect_set_your_last_per_commitment_secret(this_ptr: &mut DataLossProtect, mut val: crate::c_types::ThirtyTwoBytes) {
2641 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.your_last_per_commitment_secret = val.data;
2643 /// The sender's per-commitment point for their current commitment transaction
2645 pub extern "C" fn DataLossProtect_get_my_current_per_commitment_point(this_ptr: &DataLossProtect) -> crate::c_types::PublicKey {
2646 let mut inner_val = &mut this_ptr.get_native_mut_ref().my_current_per_commitment_point;
2647 crate::c_types::PublicKey::from_rust(&inner_val)
2649 /// The sender's per-commitment point for their current commitment transaction
2651 pub extern "C" fn DataLossProtect_set_my_current_per_commitment_point(this_ptr: &mut DataLossProtect, mut val: crate::c_types::PublicKey) {
2652 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.my_current_per_commitment_point = val.into_rust();
2654 /// Constructs a new DataLossProtect given each field
2657 pub extern "C" fn DataLossProtect_new(mut your_last_per_commitment_secret_arg: crate::c_types::ThirtyTwoBytes, mut my_current_per_commitment_point_arg: crate::c_types::PublicKey) -> DataLossProtect {
2658 DataLossProtect { inner: ObjOps::heap_alloc(nativeDataLossProtect {
2659 your_last_per_commitment_secret: your_last_per_commitment_secret_arg.data,
2660 my_current_per_commitment_point: my_current_per_commitment_point_arg.into_rust(),
2661 }), is_owned: true }
2663 impl Clone for DataLossProtect {
2664 fn clone(&self) -> Self {
2666 inner: if <*mut nativeDataLossProtect>::is_null(self.inner) { core::ptr::null_mut() } else {
2667 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2673 /// Used only if an object of this type is returned as a trait impl by a method
2674 pub(crate) extern "C" fn DataLossProtect_clone_void(this_ptr: *const c_void) -> *mut c_void {
2675 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDataLossProtect)).clone() })) as *mut c_void
2678 /// Creates a copy of the DataLossProtect
2679 pub extern "C" fn DataLossProtect_clone(orig: &DataLossProtect) -> DataLossProtect {
2683 use lightning::ln::msgs::ChannelReestablish as nativeChannelReestablishImport;
2684 pub(crate) type nativeChannelReestablish = nativeChannelReestablishImport;
2686 /// A channel_reestablish message to be sent or received from a peer
2689 pub struct ChannelReestablish {
2690 /// A pointer to the opaque Rust object.
2692 /// Nearly everywhere, inner must be non-null, however in places where
2693 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2694 pub inner: *mut nativeChannelReestablish,
2695 /// Indicates that this is the only struct which contains the same pointer.
2697 /// Rust functions which take ownership of an object provided via an argument require
2698 /// this to be true and invalidate the object pointed to by inner.
2702 impl Drop for ChannelReestablish {
2703 fn drop(&mut self) {
2704 if self.is_owned && !<*mut nativeChannelReestablish>::is_null(self.inner) {
2705 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2709 /// Frees any resources used by the ChannelReestablish, if is_owned is set and inner is non-NULL.
2711 pub extern "C" fn ChannelReestablish_free(this_obj: ChannelReestablish) { }
2713 /// Used only if an object of this type is returned as a trait impl by a method
2714 pub(crate) extern "C" fn ChannelReestablish_free_void(this_ptr: *mut c_void) {
2715 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelReestablish); }
2718 impl ChannelReestablish {
2719 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelReestablish {
2720 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2722 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelReestablish {
2723 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2725 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2726 pub(crate) fn take_inner(mut self) -> *mut nativeChannelReestablish {
2727 assert!(self.is_owned);
2728 let ret = ObjOps::untweak_ptr(self.inner);
2729 self.inner = core::ptr::null_mut();
2735 pub extern "C" fn ChannelReestablish_get_channel_id(this_ptr: &ChannelReestablish) -> *const [u8; 32] {
2736 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2741 pub extern "C" fn ChannelReestablish_set_channel_id(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) {
2742 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2744 /// The next commitment number for the sender
2746 pub extern "C" fn ChannelReestablish_get_next_local_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
2747 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_local_commitment_number;
2750 /// The next commitment number for the sender
2752 pub extern "C" fn ChannelReestablish_set_next_local_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
2753 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_local_commitment_number = val;
2755 /// The next commitment number for the recipient
2757 pub extern "C" fn ChannelReestablish_get_next_remote_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
2758 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_remote_commitment_number;
2761 /// The next commitment number for the recipient
2763 pub extern "C" fn ChannelReestablish_set_next_remote_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
2764 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_remote_commitment_number = val;
2766 impl Clone for ChannelReestablish {
2767 fn clone(&self) -> Self {
2769 inner: if <*mut nativeChannelReestablish>::is_null(self.inner) { core::ptr::null_mut() } else {
2770 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2776 /// Used only if an object of this type is returned as a trait impl by a method
2777 pub(crate) extern "C" fn ChannelReestablish_clone_void(this_ptr: *const c_void) -> *mut c_void {
2778 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelReestablish)).clone() })) as *mut c_void
2781 /// Creates a copy of the ChannelReestablish
2782 pub extern "C" fn ChannelReestablish_clone(orig: &ChannelReestablish) -> ChannelReestablish {
2786 use lightning::ln::msgs::AnnouncementSignatures as nativeAnnouncementSignaturesImport;
2787 pub(crate) type nativeAnnouncementSignatures = nativeAnnouncementSignaturesImport;
2789 /// An announcement_signatures message to be sent or received from a peer
2792 pub struct AnnouncementSignatures {
2793 /// A pointer to the opaque Rust object.
2795 /// Nearly everywhere, inner must be non-null, however in places where
2796 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2797 pub inner: *mut nativeAnnouncementSignatures,
2798 /// Indicates that this is the only struct which contains the same pointer.
2800 /// Rust functions which take ownership of an object provided via an argument require
2801 /// this to be true and invalidate the object pointed to by inner.
2805 impl Drop for AnnouncementSignatures {
2806 fn drop(&mut self) {
2807 if self.is_owned && !<*mut nativeAnnouncementSignatures>::is_null(self.inner) {
2808 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2812 /// Frees any resources used by the AnnouncementSignatures, if is_owned is set and inner is non-NULL.
2814 pub extern "C" fn AnnouncementSignatures_free(this_obj: AnnouncementSignatures) { }
2816 /// Used only if an object of this type is returned as a trait impl by a method
2817 pub(crate) extern "C" fn AnnouncementSignatures_free_void(this_ptr: *mut c_void) {
2818 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeAnnouncementSignatures); }
2821 impl AnnouncementSignatures {
2822 pub(crate) fn get_native_ref(&self) -> &'static nativeAnnouncementSignatures {
2823 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2825 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAnnouncementSignatures {
2826 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2828 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2829 pub(crate) fn take_inner(mut self) -> *mut nativeAnnouncementSignatures {
2830 assert!(self.is_owned);
2831 let ret = ObjOps::untweak_ptr(self.inner);
2832 self.inner = core::ptr::null_mut();
2838 pub extern "C" fn AnnouncementSignatures_get_channel_id(this_ptr: &AnnouncementSignatures) -> *const [u8; 32] {
2839 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2844 pub extern "C" fn AnnouncementSignatures_set_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
2845 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2847 /// The short channel ID
2849 pub extern "C" fn AnnouncementSignatures_get_short_channel_id(this_ptr: &AnnouncementSignatures) -> u64 {
2850 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
2853 /// The short channel ID
2855 pub extern "C" fn AnnouncementSignatures_set_short_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: u64) {
2856 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
2858 /// A signature by the node key
2860 pub extern "C" fn AnnouncementSignatures_get_node_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
2861 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature;
2862 crate::c_types::Signature::from_rust(&inner_val)
2864 /// A signature by the node key
2866 pub extern "C" fn AnnouncementSignatures_set_node_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
2867 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature = val.into_rust();
2869 /// A signature by the funding key
2871 pub extern "C" fn AnnouncementSignatures_get_bitcoin_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
2872 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature;
2873 crate::c_types::Signature::from_rust(&inner_val)
2875 /// A signature by the funding key
2877 pub extern "C" fn AnnouncementSignatures_set_bitcoin_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
2878 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature = val.into_rust();
2880 /// Constructs a new AnnouncementSignatures given each field
2883 pub extern "C" fn AnnouncementSignatures_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_id_arg: u64, mut node_signature_arg: crate::c_types::Signature, mut bitcoin_signature_arg: crate::c_types::Signature) -> AnnouncementSignatures {
2884 AnnouncementSignatures { inner: ObjOps::heap_alloc(nativeAnnouncementSignatures {
2885 channel_id: channel_id_arg.data,
2886 short_channel_id: short_channel_id_arg,
2887 node_signature: node_signature_arg.into_rust(),
2888 bitcoin_signature: bitcoin_signature_arg.into_rust(),
2889 }), is_owned: true }
2891 impl Clone for AnnouncementSignatures {
2892 fn clone(&self) -> Self {
2894 inner: if <*mut nativeAnnouncementSignatures>::is_null(self.inner) { core::ptr::null_mut() } else {
2895 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2901 /// Used only if an object of this type is returned as a trait impl by a method
2902 pub(crate) extern "C" fn AnnouncementSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
2903 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAnnouncementSignatures)).clone() })) as *mut c_void
2906 /// Creates a copy of the AnnouncementSignatures
2907 pub extern "C" fn AnnouncementSignatures_clone(orig: &AnnouncementSignatures) -> AnnouncementSignatures {
2910 /// An address which can be used to connect to a remote peer
2914 pub enum NetAddress {
2915 /// An IPv4 address/port on which the peer is listening.
2917 /// The 4-byte IPv4 address
2918 addr: crate::c_types::FourBytes,
2919 /// The port on which the node is listening
2922 /// An IPv6 address/port on which the peer is listening.
2924 /// The 16-byte IPv6 address
2925 addr: crate::c_types::SixteenBytes,
2926 /// The port on which the node is listening
2929 /// An old-style Tor onion address/port on which the peer is listening.
2931 /// This field is deprecated and the Tor network generally no longer supports V2 Onion
2932 /// addresses. Thus, the details are not parsed here.
2933 OnionV2(crate::c_types::TwelveBytes),
2934 /// A new-style Tor onion address/port on which the peer is listening.
2935 /// To create the human-readable \"hostname\", concatenate ed25519_pubkey, checksum, and version,
2936 /// wrap as base32 and append \".onion\".
2938 /// The ed25519 long-term public key of the peer
2939 ed25519_pubkey: crate::c_types::ThirtyTwoBytes,
2940 /// The checksum of the pubkey and version, as included in the onion address
2942 /// The version byte, as defined by the Tor Onion v3 spec.
2944 /// The port on which the node is listening
2948 use lightning::ln::msgs::NetAddress as nativeNetAddress;
2951 pub(crate) fn to_native(&self) -> nativeNetAddress {
2953 NetAddress::IPv4 {ref addr, ref port, } => {
2954 let mut addr_nonref = (*addr).clone();
2955 let mut port_nonref = (*port).clone();
2956 nativeNetAddress::IPv4 {
2957 addr: addr_nonref.data,
2961 NetAddress::IPv6 {ref addr, ref port, } => {
2962 let mut addr_nonref = (*addr).clone();
2963 let mut port_nonref = (*port).clone();
2964 nativeNetAddress::IPv6 {
2965 addr: addr_nonref.data,
2969 NetAddress::OnionV2 (ref a, ) => {
2970 let mut a_nonref = (*a).clone();
2971 nativeNetAddress::OnionV2 (
2975 NetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
2976 let mut ed25519_pubkey_nonref = (*ed25519_pubkey).clone();
2977 let mut checksum_nonref = (*checksum).clone();
2978 let mut version_nonref = (*version).clone();
2979 let mut port_nonref = (*port).clone();
2980 nativeNetAddress::OnionV3 {
2981 ed25519_pubkey: ed25519_pubkey_nonref.data,
2982 checksum: checksum_nonref,
2983 version: version_nonref,
2990 pub(crate) fn into_native(self) -> nativeNetAddress {
2992 NetAddress::IPv4 {mut addr, mut port, } => {
2993 nativeNetAddress::IPv4 {
2998 NetAddress::IPv6 {mut addr, mut port, } => {
2999 nativeNetAddress::IPv6 {
3004 NetAddress::OnionV2 (mut a, ) => {
3005 nativeNetAddress::OnionV2 (
3009 NetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
3010 nativeNetAddress::OnionV3 {
3011 ed25519_pubkey: ed25519_pubkey.data,
3020 pub(crate) fn from_native(native: &nativeNetAddress) -> Self {
3022 nativeNetAddress::IPv4 {ref addr, ref port, } => {
3023 let mut addr_nonref = (*addr).clone();
3024 let mut port_nonref = (*port).clone();
3026 addr: crate::c_types::FourBytes { data: addr_nonref },
3030 nativeNetAddress::IPv6 {ref addr, ref port, } => {
3031 let mut addr_nonref = (*addr).clone();
3032 let mut port_nonref = (*port).clone();
3034 addr: crate::c_types::SixteenBytes { data: addr_nonref },
3038 nativeNetAddress::OnionV2 (ref a, ) => {
3039 let mut a_nonref = (*a).clone();
3040 NetAddress::OnionV2 (
3041 crate::c_types::TwelveBytes { data: a_nonref },
3044 nativeNetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
3045 let mut ed25519_pubkey_nonref = (*ed25519_pubkey).clone();
3046 let mut checksum_nonref = (*checksum).clone();
3047 let mut version_nonref = (*version).clone();
3048 let mut port_nonref = (*port).clone();
3049 NetAddress::OnionV3 {
3050 ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey_nonref },
3051 checksum: checksum_nonref,
3052 version: version_nonref,
3059 pub(crate) fn native_into(native: nativeNetAddress) -> Self {
3061 nativeNetAddress::IPv4 {mut addr, mut port, } => {
3063 addr: crate::c_types::FourBytes { data: addr },
3067 nativeNetAddress::IPv6 {mut addr, mut port, } => {
3069 addr: crate::c_types::SixteenBytes { data: addr },
3073 nativeNetAddress::OnionV2 (mut a, ) => {
3074 NetAddress::OnionV2 (
3075 crate::c_types::TwelveBytes { data: a },
3078 nativeNetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
3079 NetAddress::OnionV3 {
3080 ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey },
3089 /// Frees any resources used by the NetAddress
3091 pub extern "C" fn NetAddress_free(this_ptr: NetAddress) { }
3092 /// Creates a copy of the NetAddress
3094 pub extern "C" fn NetAddress_clone(orig: &NetAddress) -> NetAddress {
3098 /// Utility method to constructs a new IPv4-variant NetAddress
3099 pub extern "C" fn NetAddress_ipv4(addr: crate::c_types::FourBytes, port: u16) -> NetAddress {
3106 /// Utility method to constructs a new IPv6-variant NetAddress
3107 pub extern "C" fn NetAddress_ipv6(addr: crate::c_types::SixteenBytes, port: u16) -> NetAddress {
3114 /// Utility method to constructs a new OnionV2-variant NetAddress
3115 pub extern "C" fn NetAddress_onion_v2(a: crate::c_types::TwelveBytes) -> NetAddress {
3116 NetAddress::OnionV2(a, )
3119 /// Utility method to constructs a new OnionV3-variant NetAddress
3120 pub extern "C" fn NetAddress_onion_v3(ed25519_pubkey: crate::c_types::ThirtyTwoBytes, checksum: u16, version: u8, port: u16) -> NetAddress {
3121 NetAddress::OnionV3 {
3129 /// Serialize the NetAddress object into a byte array which can be read by NetAddress_read
3130 pub extern "C" fn NetAddress_write(obj: &NetAddress) -> crate::c_types::derived::CVec_u8Z {
3131 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
3134 /// Read a NetAddress from a byte array, created by NetAddress_write
3135 pub extern "C" fn NetAddress_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NetAddressDecodeErrorZ {
3136 let res: Result<lightning::ln::msgs::NetAddress, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
3137 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::NetAddress::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
3141 use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport;
3142 pub(crate) type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport;
3144 /// The unsigned part of a node_announcement
3147 pub struct UnsignedNodeAnnouncement {
3148 /// A pointer to the opaque Rust object.
3150 /// Nearly everywhere, inner must be non-null, however in places where
3151 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3152 pub inner: *mut nativeUnsignedNodeAnnouncement,
3153 /// Indicates that this is the only struct which contains the same pointer.
3155 /// Rust functions which take ownership of an object provided via an argument require
3156 /// this to be true and invalidate the object pointed to by inner.
3160 impl Drop for UnsignedNodeAnnouncement {
3161 fn drop(&mut self) {
3162 if self.is_owned && !<*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) {
3163 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3167 /// Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL.
3169 pub extern "C" fn UnsignedNodeAnnouncement_free(this_obj: UnsignedNodeAnnouncement) { }
3171 /// Used only if an object of this type is returned as a trait impl by a method
3172 pub(crate) extern "C" fn UnsignedNodeAnnouncement_free_void(this_ptr: *mut c_void) {
3173 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedNodeAnnouncement); }
3176 impl UnsignedNodeAnnouncement {
3177 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedNodeAnnouncement {
3178 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3180 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedNodeAnnouncement {
3181 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3183 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3184 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedNodeAnnouncement {
3185 assert!(self.is_owned);
3186 let ret = ObjOps::untweak_ptr(self.inner);
3187 self.inner = core::ptr::null_mut();
3191 /// The advertised features
3193 pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::ln::features::NodeFeatures {
3194 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
3195 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 }
3197 /// The advertised features
3199 pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::ln::features::NodeFeatures) {
3200 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
3202 /// A strictly monotonic announcement counter, with gaps allowed
3204 pub extern "C" fn UnsignedNodeAnnouncement_get_timestamp(this_ptr: &UnsignedNodeAnnouncement) -> u32 {
3205 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
3208 /// A strictly monotonic announcement counter, with gaps allowed
3210 pub extern "C" fn UnsignedNodeAnnouncement_set_timestamp(this_ptr: &mut UnsignedNodeAnnouncement, mut val: u32) {
3211 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
3213 /// The node_id this announcement originated from (don't rebroadcast the node_announcement back
3216 pub extern "C" fn UnsignedNodeAnnouncement_get_node_id(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::PublicKey {
3217 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id;
3218 crate::c_types::PublicKey::from_rust(&inner_val)
3220 /// The node_id this announcement originated from (don't rebroadcast the node_announcement back
3223 pub extern "C" fn UnsignedNodeAnnouncement_set_node_id(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::PublicKey) {
3224 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id = val.into_rust();
3226 /// An RGB color for UI purposes
3228 pub extern "C" fn UnsignedNodeAnnouncement_get_rgb(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 3] {
3229 let mut inner_val = &mut this_ptr.get_native_mut_ref().rgb;
3232 /// An RGB color for UI purposes
3234 pub extern "C" fn UnsignedNodeAnnouncement_set_rgb(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThreeBytes) {
3235 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.rgb = val.data;
3237 /// An alias, for UI purposes. This should be sanitized before use. There is no guarantee
3240 pub extern "C" fn UnsignedNodeAnnouncement_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 32] {
3241 let mut inner_val = &mut this_ptr.get_native_mut_ref().alias;
3244 /// An alias, for UI purposes. This should be sanitized before use. There is no guarantee
3247 pub extern "C" fn UnsignedNodeAnnouncement_set_alias(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
3248 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.alias = val.data;
3250 /// List of addresses on which this node is reachable
3252 pub extern "C" fn UnsignedNodeAnnouncement_set_addresses(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_NetAddressZ) {
3253 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
3254 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.addresses = local_val;
3256 impl Clone for UnsignedNodeAnnouncement {
3257 fn clone(&self) -> Self {
3259 inner: if <*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
3260 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3266 /// Used only if an object of this type is returned as a trait impl by a method
3267 pub(crate) extern "C" fn UnsignedNodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3268 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedNodeAnnouncement)).clone() })) as *mut c_void
3271 /// Creates a copy of the UnsignedNodeAnnouncement
3272 pub extern "C" fn UnsignedNodeAnnouncement_clone(orig: &UnsignedNodeAnnouncement) -> UnsignedNodeAnnouncement {
3276 use lightning::ln::msgs::NodeAnnouncement as nativeNodeAnnouncementImport;
3277 pub(crate) type nativeNodeAnnouncement = nativeNodeAnnouncementImport;
3279 /// A node_announcement message to be sent or received from a peer
3282 pub struct NodeAnnouncement {
3283 /// A pointer to the opaque Rust object.
3285 /// Nearly everywhere, inner must be non-null, however in places where
3286 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3287 pub inner: *mut nativeNodeAnnouncement,
3288 /// Indicates that this is the only struct which contains the same pointer.
3290 /// Rust functions which take ownership of an object provided via an argument require
3291 /// this to be true and invalidate the object pointed to by inner.
3295 impl Drop for NodeAnnouncement {
3296 fn drop(&mut self) {
3297 if self.is_owned && !<*mut nativeNodeAnnouncement>::is_null(self.inner) {
3298 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3302 /// Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL.
3304 pub extern "C" fn NodeAnnouncement_free(this_obj: NodeAnnouncement) { }
3306 /// Used only if an object of this type is returned as a trait impl by a method
3307 pub(crate) extern "C" fn NodeAnnouncement_free_void(this_ptr: *mut c_void) {
3308 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeAnnouncement); }
3311 impl NodeAnnouncement {
3312 pub(crate) fn get_native_ref(&self) -> &'static nativeNodeAnnouncement {
3313 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3315 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeAnnouncement {
3316 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3318 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3319 pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncement {
3320 assert!(self.is_owned);
3321 let ret = ObjOps::untweak_ptr(self.inner);
3322 self.inner = core::ptr::null_mut();
3326 /// The signature by the node key
3328 pub extern "C" fn NodeAnnouncement_get_signature(this_ptr: &NodeAnnouncement) -> crate::c_types::Signature {
3329 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
3330 crate::c_types::Signature::from_rust(&inner_val)
3332 /// The signature by the node key
3334 pub extern "C" fn NodeAnnouncement_set_signature(this_ptr: &mut NodeAnnouncement, mut val: crate::c_types::Signature) {
3335 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
3337 /// The actual content of the announcement
3339 pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> crate::lightning::ln::msgs::UnsignedNodeAnnouncement {
3340 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
3341 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 }
3343 /// The actual content of the announcement
3345 pub extern "C" fn NodeAnnouncement_set_contents(this_ptr: &mut NodeAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) {
3346 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
3348 /// Constructs a new NodeAnnouncement given each field
3351 pub extern "C" fn NodeAnnouncement_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> NodeAnnouncement {
3352 NodeAnnouncement { inner: ObjOps::heap_alloc(nativeNodeAnnouncement {
3353 signature: signature_arg.into_rust(),
3354 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
3355 }), is_owned: true }
3357 impl Clone for NodeAnnouncement {
3358 fn clone(&self) -> Self {
3360 inner: if <*mut nativeNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
3361 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3367 /// Used only if an object of this type is returned as a trait impl by a method
3368 pub(crate) extern "C" fn NodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3369 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeAnnouncement)).clone() })) as *mut c_void
3372 /// Creates a copy of the NodeAnnouncement
3373 pub extern "C" fn NodeAnnouncement_clone(orig: &NodeAnnouncement) -> NodeAnnouncement {
3377 use lightning::ln::msgs::UnsignedChannelAnnouncement as nativeUnsignedChannelAnnouncementImport;
3378 pub(crate) type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport;
3380 /// The unsigned part of a channel_announcement
3383 pub struct UnsignedChannelAnnouncement {
3384 /// A pointer to the opaque Rust object.
3386 /// Nearly everywhere, inner must be non-null, however in places where
3387 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3388 pub inner: *mut nativeUnsignedChannelAnnouncement,
3389 /// Indicates that this is the only struct which contains the same pointer.
3391 /// Rust functions which take ownership of an object provided via an argument require
3392 /// this to be true and invalidate the object pointed to by inner.
3396 impl Drop for UnsignedChannelAnnouncement {
3397 fn drop(&mut self) {
3398 if self.is_owned && !<*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) {
3399 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3403 /// Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL.
3405 pub extern "C" fn UnsignedChannelAnnouncement_free(this_obj: UnsignedChannelAnnouncement) { }
3407 /// Used only if an object of this type is returned as a trait impl by a method
3408 pub(crate) extern "C" fn UnsignedChannelAnnouncement_free_void(this_ptr: *mut c_void) {
3409 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelAnnouncement); }
3412 impl UnsignedChannelAnnouncement {
3413 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelAnnouncement {
3414 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3416 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelAnnouncement {
3417 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3419 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3420 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelAnnouncement {
3421 assert!(self.is_owned);
3422 let ret = ObjOps::untweak_ptr(self.inner);
3423 self.inner = core::ptr::null_mut();
3427 /// The advertised channel features
3429 pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::ln::features::ChannelFeatures {
3430 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
3431 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 }
3433 /// The advertised channel features
3435 pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::ln::features::ChannelFeatures) {
3436 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
3438 /// The genesis hash of the blockchain where the channel is to be opened
3440 pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &UnsignedChannelAnnouncement) -> *const [u8; 32] {
3441 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
3442 inner_val.as_inner()
3444 /// The genesis hash of the blockchain where the channel is to be opened
3446 pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
3447 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3449 /// The short channel ID
3451 pub extern "C" fn UnsignedChannelAnnouncement_get_short_channel_id(this_ptr: &UnsignedChannelAnnouncement) -> u64 {
3452 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
3455 /// The short channel ID
3457 pub extern "C" fn UnsignedChannelAnnouncement_set_short_channel_id(this_ptr: &mut UnsignedChannelAnnouncement, mut val: u64) {
3458 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
3460 /// One of the two node_ids which are endpoints of this channel
3462 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3463 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_1;
3464 crate::c_types::PublicKey::from_rust(&inner_val)
3466 /// One of the two node_ids which are endpoints of this channel
3468 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3469 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_1 = val.into_rust();
3471 /// The other of the two node_ids which are endpoints of this channel
3473 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3474 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_2;
3475 crate::c_types::PublicKey::from_rust(&inner_val)
3477 /// The other of the two node_ids which are endpoints of this channel
3479 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3480 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_2 = val.into_rust();
3482 /// The funding key for the first node
3484 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3485 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_1;
3486 crate::c_types::PublicKey::from_rust(&inner_val)
3488 /// The funding key for the first node
3490 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3491 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_1 = val.into_rust();
3493 /// The funding key for the second node
3495 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3496 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_2;
3497 crate::c_types::PublicKey::from_rust(&inner_val)
3499 /// The funding key for the second node
3501 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3502 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_2 = val.into_rust();
3504 impl Clone for UnsignedChannelAnnouncement {
3505 fn clone(&self) -> Self {
3507 inner: if <*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
3508 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3514 /// Used only if an object of this type is returned as a trait impl by a method
3515 pub(crate) extern "C" fn UnsignedChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3516 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelAnnouncement)).clone() })) as *mut c_void
3519 /// Creates a copy of the UnsignedChannelAnnouncement
3520 pub extern "C" fn UnsignedChannelAnnouncement_clone(orig: &UnsignedChannelAnnouncement) -> UnsignedChannelAnnouncement {
3524 use lightning::ln::msgs::ChannelAnnouncement as nativeChannelAnnouncementImport;
3525 pub(crate) type nativeChannelAnnouncement = nativeChannelAnnouncementImport;
3527 /// A channel_announcement message to be sent or received from a peer
3530 pub struct ChannelAnnouncement {
3531 /// A pointer to the opaque Rust object.
3533 /// Nearly everywhere, inner must be non-null, however in places where
3534 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3535 pub inner: *mut nativeChannelAnnouncement,
3536 /// Indicates that this is the only struct which contains the same pointer.
3538 /// Rust functions which take ownership of an object provided via an argument require
3539 /// this to be true and invalidate the object pointed to by inner.
3543 impl Drop for ChannelAnnouncement {
3544 fn drop(&mut self) {
3545 if self.is_owned && !<*mut nativeChannelAnnouncement>::is_null(self.inner) {
3546 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3550 /// Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL.
3552 pub extern "C" fn ChannelAnnouncement_free(this_obj: ChannelAnnouncement) { }
3554 /// Used only if an object of this type is returned as a trait impl by a method
3555 pub(crate) extern "C" fn ChannelAnnouncement_free_void(this_ptr: *mut c_void) {
3556 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelAnnouncement); }
3559 impl ChannelAnnouncement {
3560 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelAnnouncement {
3561 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3563 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelAnnouncement {
3564 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3566 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3567 pub(crate) fn take_inner(mut self) -> *mut nativeChannelAnnouncement {
3568 assert!(self.is_owned);
3569 let ret = ObjOps::untweak_ptr(self.inner);
3570 self.inner = core::ptr::null_mut();
3574 /// Authentication of the announcement by the first public node
3576 pub extern "C" fn ChannelAnnouncement_get_node_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3577 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_1;
3578 crate::c_types::Signature::from_rust(&inner_val)
3580 /// Authentication of the announcement by the first public node
3582 pub extern "C" fn ChannelAnnouncement_set_node_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3583 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_1 = val.into_rust();
3585 /// Authentication of the announcement by the second public node
3587 pub extern "C" fn ChannelAnnouncement_get_node_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3588 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_2;
3589 crate::c_types::Signature::from_rust(&inner_val)
3591 /// Authentication of the announcement by the second public node
3593 pub extern "C" fn ChannelAnnouncement_set_node_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3594 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_2 = val.into_rust();
3596 /// Proof of funding UTXO ownership by the first public node
3598 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3599 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_1;
3600 crate::c_types::Signature::from_rust(&inner_val)
3602 /// Proof of funding UTXO ownership by the first public node
3604 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3605 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_1 = val.into_rust();
3607 /// Proof of funding UTXO ownership by the second public node
3609 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3610 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_2;
3611 crate::c_types::Signature::from_rust(&inner_val)
3613 /// Proof of funding UTXO ownership by the second public node
3615 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3616 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_2 = val.into_rust();
3618 /// The actual announcement
3620 pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncement) -> crate::lightning::ln::msgs::UnsignedChannelAnnouncement {
3621 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
3622 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 }
3624 /// The actual announcement
3626 pub extern "C" fn ChannelAnnouncement_set_contents(this_ptr: &mut ChannelAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) {
3627 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
3629 /// Constructs a new ChannelAnnouncement given each field
3632 pub extern "C" fn ChannelAnnouncement_new(mut node_signature_1_arg: crate::c_types::Signature, mut node_signature_2_arg: crate::c_types::Signature, mut bitcoin_signature_1_arg: crate::c_types::Signature, mut bitcoin_signature_2_arg: crate::c_types::Signature, mut contents_arg: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> ChannelAnnouncement {
3633 ChannelAnnouncement { inner: ObjOps::heap_alloc(nativeChannelAnnouncement {
3634 node_signature_1: node_signature_1_arg.into_rust(),
3635 node_signature_2: node_signature_2_arg.into_rust(),
3636 bitcoin_signature_1: bitcoin_signature_1_arg.into_rust(),
3637 bitcoin_signature_2: bitcoin_signature_2_arg.into_rust(),
3638 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
3639 }), is_owned: true }
3641 impl Clone for ChannelAnnouncement {
3642 fn clone(&self) -> Self {
3644 inner: if <*mut nativeChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
3645 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3651 /// Used only if an object of this type is returned as a trait impl by a method
3652 pub(crate) extern "C" fn ChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3653 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelAnnouncement)).clone() })) as *mut c_void
3656 /// Creates a copy of the ChannelAnnouncement
3657 pub extern "C" fn ChannelAnnouncement_clone(orig: &ChannelAnnouncement) -> ChannelAnnouncement {
3661 use lightning::ln::msgs::UnsignedChannelUpdate as nativeUnsignedChannelUpdateImport;
3662 pub(crate) type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport;
3664 /// The unsigned part of a channel_update
3667 pub struct UnsignedChannelUpdate {
3668 /// A pointer to the opaque Rust object.
3670 /// Nearly everywhere, inner must be non-null, however in places where
3671 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3672 pub inner: *mut nativeUnsignedChannelUpdate,
3673 /// Indicates that this is the only struct which contains the same pointer.
3675 /// Rust functions which take ownership of an object provided via an argument require
3676 /// this to be true and invalidate the object pointed to by inner.
3680 impl Drop for UnsignedChannelUpdate {
3681 fn drop(&mut self) {
3682 if self.is_owned && !<*mut nativeUnsignedChannelUpdate>::is_null(self.inner) {
3683 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3687 /// Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL.
3689 pub extern "C" fn UnsignedChannelUpdate_free(this_obj: UnsignedChannelUpdate) { }
3691 /// Used only if an object of this type is returned as a trait impl by a method
3692 pub(crate) extern "C" fn UnsignedChannelUpdate_free_void(this_ptr: *mut c_void) {
3693 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelUpdate); }
3696 impl UnsignedChannelUpdate {
3697 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelUpdate {
3698 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3700 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelUpdate {
3701 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3703 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3704 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelUpdate {
3705 assert!(self.is_owned);
3706 let ret = ObjOps::untweak_ptr(self.inner);
3707 self.inner = core::ptr::null_mut();
3711 /// The genesis hash of the blockchain where the channel is to be opened
3713 pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChannelUpdate) -> *const [u8; 32] {
3714 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
3715 inner_val.as_inner()
3717 /// The genesis hash of the blockchain where the channel is to be opened
3719 pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::ThirtyTwoBytes) {
3720 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3722 /// The short channel ID
3724 pub extern "C" fn UnsignedChannelUpdate_get_short_channel_id(this_ptr: &UnsignedChannelUpdate) -> u64 {
3725 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
3728 /// The short channel ID
3730 pub extern "C" fn UnsignedChannelUpdate_set_short_channel_id(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
3731 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
3733 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
3735 pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannelUpdate) -> u32 {
3736 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
3739 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
3741 pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3742 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
3746 pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 {
3747 let mut inner_val = &mut this_ptr.get_native_mut_ref().flags;
3752 pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) {
3753 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.flags = val;
3755 /// The number of blocks such that if:
3756 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
3757 /// then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines
3758 /// the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a
3759 /// cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10,
3760 /// then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before
3761 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
3762 /// constructing the route.
3764 pub extern "C" fn UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr: &UnsignedChannelUpdate) -> u16 {
3765 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
3768 /// The number of blocks such that if:
3769 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
3770 /// then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines
3771 /// the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a
3772 /// cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10,
3773 /// then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before
3774 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
3775 /// constructing the route.
3777 pub extern "C" fn UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr: &mut UnsignedChannelUpdate, mut val: u16) {
3778 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
3780 /// The minimum HTLC size incoming to sender, in milli-satoshi
3782 pub extern "C" fn UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
3783 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
3786 /// The minimum HTLC size incoming to sender, in milli-satoshi
3788 pub extern "C" fn UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
3789 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
3791 /// The base HTLC fee charged by sender, in milli-satoshi
3793 pub extern "C" fn UnsignedChannelUpdate_get_fee_base_msat(this_ptr: &UnsignedChannelUpdate) -> u32 {
3794 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat;
3797 /// The base HTLC fee charged by sender, in milli-satoshi
3799 pub extern "C" fn UnsignedChannelUpdate_set_fee_base_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3800 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val;
3802 /// The amount to fee multiplier, in micro-satoshi
3804 pub extern "C" fn UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr: &UnsignedChannelUpdate) -> u32 {
3805 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths;
3808 /// The amount to fee multiplier, in micro-satoshi
3810 pub extern "C" fn UnsignedChannelUpdate_set_fee_proportional_millionths(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3811 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val;
3813 impl Clone for UnsignedChannelUpdate {
3814 fn clone(&self) -> Self {
3816 inner: if <*mut nativeUnsignedChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
3817 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3823 /// Used only if an object of this type is returned as a trait impl by a method
3824 pub(crate) extern "C" fn UnsignedChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
3825 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelUpdate)).clone() })) as *mut c_void
3828 /// Creates a copy of the UnsignedChannelUpdate
3829 pub extern "C" fn UnsignedChannelUpdate_clone(orig: &UnsignedChannelUpdate) -> UnsignedChannelUpdate {
3833 use lightning::ln::msgs::ChannelUpdate as nativeChannelUpdateImport;
3834 pub(crate) type nativeChannelUpdate = nativeChannelUpdateImport;
3836 /// A channel_update message to be sent or received from a peer
3839 pub struct ChannelUpdate {
3840 /// A pointer to the opaque Rust object.
3842 /// Nearly everywhere, inner must be non-null, however in places where
3843 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3844 pub inner: *mut nativeChannelUpdate,
3845 /// Indicates that this is the only struct which contains the same pointer.
3847 /// Rust functions which take ownership of an object provided via an argument require
3848 /// this to be true and invalidate the object pointed to by inner.
3852 impl Drop for ChannelUpdate {
3853 fn drop(&mut self) {
3854 if self.is_owned && !<*mut nativeChannelUpdate>::is_null(self.inner) {
3855 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3859 /// Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL.
3861 pub extern "C" fn ChannelUpdate_free(this_obj: ChannelUpdate) { }
3863 /// Used only if an object of this type is returned as a trait impl by a method
3864 pub(crate) extern "C" fn ChannelUpdate_free_void(this_ptr: *mut c_void) {
3865 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelUpdate); }
3868 impl ChannelUpdate {
3869 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelUpdate {
3870 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3872 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelUpdate {
3873 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3875 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3876 pub(crate) fn take_inner(mut self) -> *mut nativeChannelUpdate {
3877 assert!(self.is_owned);
3878 let ret = ObjOps::untweak_ptr(self.inner);
3879 self.inner = core::ptr::null_mut();
3883 /// A signature of the channel update
3885 pub extern "C" fn ChannelUpdate_get_signature(this_ptr: &ChannelUpdate) -> crate::c_types::Signature {
3886 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
3887 crate::c_types::Signature::from_rust(&inner_val)
3889 /// A signature of the channel update
3891 pub extern "C" fn ChannelUpdate_set_signature(this_ptr: &mut ChannelUpdate, mut val: crate::c_types::Signature) {
3892 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
3894 /// The actual channel update
3896 pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate::lightning::ln::msgs::UnsignedChannelUpdate {
3897 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
3898 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 }
3900 /// The actual channel update
3902 pub extern "C" fn ChannelUpdate_set_contents(this_ptr: &mut ChannelUpdate, mut val: crate::lightning::ln::msgs::UnsignedChannelUpdate) {
3903 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
3905 /// Constructs a new ChannelUpdate given each field
3908 pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> ChannelUpdate {
3909 ChannelUpdate { inner: ObjOps::heap_alloc(nativeChannelUpdate {
3910 signature: signature_arg.into_rust(),
3911 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
3912 }), is_owned: true }
3914 impl Clone for ChannelUpdate {
3915 fn clone(&self) -> Self {
3917 inner: if <*mut nativeChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
3918 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3924 /// Used only if an object of this type is returned as a trait impl by a method
3925 pub(crate) extern "C" fn ChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
3926 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelUpdate)).clone() })) as *mut c_void
3929 /// Creates a copy of the ChannelUpdate
3930 pub extern "C" fn ChannelUpdate_clone(orig: &ChannelUpdate) -> ChannelUpdate {
3934 use lightning::ln::msgs::QueryChannelRange as nativeQueryChannelRangeImport;
3935 pub(crate) type nativeQueryChannelRange = nativeQueryChannelRangeImport;
3937 /// A query_channel_range message is used to query a peer for channel
3938 /// UTXOs in a range of blocks. The recipient of a query makes a best
3939 /// effort to reply to the query using one or more reply_channel_range
3943 pub struct QueryChannelRange {
3944 /// A pointer to the opaque Rust object.
3946 /// Nearly everywhere, inner must be non-null, however in places where
3947 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3948 pub inner: *mut nativeQueryChannelRange,
3949 /// Indicates that this is the only struct which contains the same pointer.
3951 /// Rust functions which take ownership of an object provided via an argument require
3952 /// this to be true and invalidate the object pointed to by inner.
3956 impl Drop for QueryChannelRange {
3957 fn drop(&mut self) {
3958 if self.is_owned && !<*mut nativeQueryChannelRange>::is_null(self.inner) {
3959 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3963 /// Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL.
3965 pub extern "C" fn QueryChannelRange_free(this_obj: QueryChannelRange) { }
3967 /// Used only if an object of this type is returned as a trait impl by a method
3968 pub(crate) extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) {
3969 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryChannelRange); }
3972 impl QueryChannelRange {
3973 pub(crate) fn get_native_ref(&self) -> &'static nativeQueryChannelRange {
3974 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3976 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryChannelRange {
3977 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3979 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3980 pub(crate) fn take_inner(mut self) -> *mut nativeQueryChannelRange {
3981 assert!(self.is_owned);
3982 let ret = ObjOps::untweak_ptr(self.inner);
3983 self.inner = core::ptr::null_mut();
3987 /// The genesis hash of the blockchain being queried
3989 pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *const [u8; 32] {
3990 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
3991 inner_val.as_inner()
3993 /// The genesis hash of the blockchain being queried
3995 pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
3996 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3998 /// The height of the first block for the channel UTXOs being queried
4000 pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 {
4001 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
4004 /// The height of the first block for the channel UTXOs being queried
4006 pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChannelRange, mut val: u32) {
4007 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
4009 /// The number of blocks to include in the query results
4011 pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 {
4012 let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
4015 /// The number of blocks to include in the query results
4017 pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryChannelRange, mut val: u32) {
4018 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
4020 /// Constructs a new QueryChannelRange given each field
4023 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 {
4024 QueryChannelRange { inner: ObjOps::heap_alloc(nativeQueryChannelRange {
4025 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4026 first_blocknum: first_blocknum_arg,
4027 number_of_blocks: number_of_blocks_arg,
4028 }), is_owned: true }
4030 impl Clone for QueryChannelRange {
4031 fn clone(&self) -> Self {
4033 inner: if <*mut nativeQueryChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
4034 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4040 /// Used only if an object of this type is returned as a trait impl by a method
4041 pub(crate) extern "C" fn QueryChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
4042 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryChannelRange)).clone() })) as *mut c_void
4045 /// Creates a copy of the QueryChannelRange
4046 pub extern "C" fn QueryChannelRange_clone(orig: &QueryChannelRange) -> QueryChannelRange {
4050 use lightning::ln::msgs::ReplyChannelRange as nativeReplyChannelRangeImport;
4051 pub(crate) type nativeReplyChannelRange = nativeReplyChannelRangeImport;
4053 /// A reply_channel_range message is a reply to a query_channel_range
4054 /// message. Multiple reply_channel_range messages can be sent in reply
4055 /// to a single query_channel_range message. The query recipient makes a
4056 /// best effort to respond based on their local network view which may
4057 /// not be a perfect view of the network. The short_channel_ids in the
4058 /// reply are encoded. We only support encoding_type=0 uncompressed
4059 /// serialization and do not support encoding_type=1 zlib serialization.
4062 pub struct ReplyChannelRange {
4063 /// A pointer to the opaque Rust object.
4065 /// Nearly everywhere, inner must be non-null, however in places where
4066 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4067 pub inner: *mut nativeReplyChannelRange,
4068 /// Indicates that this is the only struct which contains the same pointer.
4070 /// Rust functions which take ownership of an object provided via an argument require
4071 /// this to be true and invalidate the object pointed to by inner.
4075 impl Drop for ReplyChannelRange {
4076 fn drop(&mut self) {
4077 if self.is_owned && !<*mut nativeReplyChannelRange>::is_null(self.inner) {
4078 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4082 /// Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL.
4084 pub extern "C" fn ReplyChannelRange_free(this_obj: ReplyChannelRange) { }
4086 /// Used only if an object of this type is returned as a trait impl by a method
4087 pub(crate) extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) {
4088 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyChannelRange); }
4091 impl ReplyChannelRange {
4092 pub(crate) fn get_native_ref(&self) -> &'static nativeReplyChannelRange {
4093 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4095 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyChannelRange {
4096 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4098 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4099 pub(crate) fn take_inner(mut self) -> *mut nativeReplyChannelRange {
4100 assert!(self.is_owned);
4101 let ret = ObjOps::untweak_ptr(self.inner);
4102 self.inner = core::ptr::null_mut();
4106 /// The genesis hash of the blockchain being queried
4108 pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *const [u8; 32] {
4109 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4110 inner_val.as_inner()
4112 /// The genesis hash of the blockchain being queried
4114 pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
4115 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4117 /// The height of the first block in the range of the reply
4119 pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 {
4120 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
4123 /// The height of the first block in the range of the reply
4125 pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChannelRange, mut val: u32) {
4126 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
4128 /// The number of blocks included in the range of the reply
4130 pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 {
4131 let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
4134 /// The number of blocks included in the range of the reply
4136 pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyChannelRange, mut val: u32) {
4137 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
4139 /// True when this is the final reply for a query
4141 pub extern "C" fn ReplyChannelRange_get_sync_complete(this_ptr: &ReplyChannelRange) -> bool {
4142 let mut inner_val = &mut this_ptr.get_native_mut_ref().sync_complete;
4145 /// True when this is the final reply for a query
4147 pub extern "C" fn ReplyChannelRange_set_sync_complete(this_ptr: &mut ReplyChannelRange, mut val: bool) {
4148 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sync_complete = val;
4150 /// The short_channel_ids in the channel range
4152 pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::derived::CVec_u64Z) {
4153 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
4154 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
4156 /// Constructs a new ReplyChannelRange given each field
4159 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 {
4160 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 }); };
4161 ReplyChannelRange { inner: ObjOps::heap_alloc(nativeReplyChannelRange {
4162 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4163 first_blocknum: first_blocknum_arg,
4164 number_of_blocks: number_of_blocks_arg,
4165 sync_complete: sync_complete_arg,
4166 short_channel_ids: local_short_channel_ids_arg,
4167 }), is_owned: true }
4169 impl Clone for ReplyChannelRange {
4170 fn clone(&self) -> Self {
4172 inner: if <*mut nativeReplyChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
4173 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4179 /// Used only if an object of this type is returned as a trait impl by a method
4180 pub(crate) extern "C" fn ReplyChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
4181 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyChannelRange)).clone() })) as *mut c_void
4184 /// Creates a copy of the ReplyChannelRange
4185 pub extern "C" fn ReplyChannelRange_clone(orig: &ReplyChannelRange) -> ReplyChannelRange {
4189 use lightning::ln::msgs::QueryShortChannelIds as nativeQueryShortChannelIdsImport;
4190 pub(crate) type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport;
4192 /// A query_short_channel_ids message is used to query a peer for
4193 /// routing gossip messages related to one or more short_channel_ids.
4194 /// The query recipient will reply with the latest, if available,
4195 /// channel_announcement, channel_update and node_announcement messages
4196 /// it maintains for the requested short_channel_ids followed by a
4197 /// reply_short_channel_ids_end message. The short_channel_ids sent in
4198 /// this query are encoded. We only support encoding_type=0 uncompressed
4199 /// serialization and do not support encoding_type=1 zlib serialization.
4202 pub struct QueryShortChannelIds {
4203 /// A pointer to the opaque Rust object.
4205 /// Nearly everywhere, inner must be non-null, however in places where
4206 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4207 pub inner: *mut nativeQueryShortChannelIds,
4208 /// Indicates that this is the only struct which contains the same pointer.
4210 /// Rust functions which take ownership of an object provided via an argument require
4211 /// this to be true and invalidate the object pointed to by inner.
4215 impl Drop for QueryShortChannelIds {
4216 fn drop(&mut self) {
4217 if self.is_owned && !<*mut nativeQueryShortChannelIds>::is_null(self.inner) {
4218 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4222 /// Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL.
4224 pub extern "C" fn QueryShortChannelIds_free(this_obj: QueryShortChannelIds) { }
4226 /// Used only if an object of this type is returned as a trait impl by a method
4227 pub(crate) extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) {
4228 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryShortChannelIds); }
4231 impl QueryShortChannelIds {
4232 pub(crate) fn get_native_ref(&self) -> &'static nativeQueryShortChannelIds {
4233 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4235 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryShortChannelIds {
4236 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4238 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4239 pub(crate) fn take_inner(mut self) -> *mut nativeQueryShortChannelIds {
4240 assert!(self.is_owned);
4241 let ret = ObjOps::untweak_ptr(self.inner);
4242 self.inner = core::ptr::null_mut();
4246 /// The genesis hash of the blockchain being queried
4248 pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *const [u8; 32] {
4249 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4250 inner_val.as_inner()
4252 /// The genesis hash of the blockchain being queried
4254 pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::ThirtyTwoBytes) {
4255 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4257 /// The short_channel_ids that are being queried
4259 pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::derived::CVec_u64Z) {
4260 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
4261 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
4263 /// Constructs a new QueryShortChannelIds given each field
4266 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 {
4267 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 }); };
4268 QueryShortChannelIds { inner: ObjOps::heap_alloc(nativeQueryShortChannelIds {
4269 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4270 short_channel_ids: local_short_channel_ids_arg,
4271 }), is_owned: true }
4273 impl Clone for QueryShortChannelIds {
4274 fn clone(&self) -> Self {
4276 inner: if <*mut nativeQueryShortChannelIds>::is_null(self.inner) { core::ptr::null_mut() } else {
4277 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4283 /// Used only if an object of this type is returned as a trait impl by a method
4284 pub(crate) extern "C" fn QueryShortChannelIds_clone_void(this_ptr: *const c_void) -> *mut c_void {
4285 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryShortChannelIds)).clone() })) as *mut c_void
4288 /// Creates a copy of the QueryShortChannelIds
4289 pub extern "C" fn QueryShortChannelIds_clone(orig: &QueryShortChannelIds) -> QueryShortChannelIds {
4293 use lightning::ln::msgs::ReplyShortChannelIdsEnd as nativeReplyShortChannelIdsEndImport;
4294 pub(crate) type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport;
4296 /// A reply_short_channel_ids_end message is sent as a reply to a
4297 /// query_short_channel_ids message. The query recipient makes a best
4298 /// effort to respond based on their local network view which may not be
4299 /// a perfect view of the network.
4302 pub struct ReplyShortChannelIdsEnd {
4303 /// A pointer to the opaque Rust object.
4305 /// Nearly everywhere, inner must be non-null, however in places where
4306 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4307 pub inner: *mut nativeReplyShortChannelIdsEnd,
4308 /// Indicates that this is the only struct which contains the same pointer.
4310 /// Rust functions which take ownership of an object provided via an argument require
4311 /// this to be true and invalidate the object pointed to by inner.
4315 impl Drop for ReplyShortChannelIdsEnd {
4316 fn drop(&mut self) {
4317 if self.is_owned && !<*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) {
4318 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4322 /// Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL.
4324 pub extern "C" fn ReplyShortChannelIdsEnd_free(this_obj: ReplyShortChannelIdsEnd) { }
4326 /// Used only if an object of this type is returned as a trait impl by a method
4327 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) {
4328 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyShortChannelIdsEnd); }
4331 impl ReplyShortChannelIdsEnd {
4332 pub(crate) fn get_native_ref(&self) -> &'static nativeReplyShortChannelIdsEnd {
4333 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4335 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyShortChannelIdsEnd {
4336 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4338 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4339 pub(crate) fn take_inner(mut self) -> *mut nativeReplyShortChannelIdsEnd {
4340 assert!(self.is_owned);
4341 let ret = ObjOps::untweak_ptr(self.inner);
4342 self.inner = core::ptr::null_mut();
4346 /// The genesis hash of the blockchain that was queried
4348 pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *const [u8; 32] {
4349 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4350 inner_val.as_inner()
4352 /// The genesis hash of the blockchain that was queried
4354 pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) {
4355 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4357 /// Indicates if the query recipient maintains up-to-date channel
4358 /// information for the chain_hash
4360 pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool {
4361 let mut inner_val = &mut this_ptr.get_native_mut_ref().full_information;
4364 /// Indicates if the query recipient maintains up-to-date channel
4365 /// information for the chain_hash
4367 pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: bool) {
4368 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.full_information = val;
4370 /// Constructs a new ReplyShortChannelIdsEnd given each field
4373 pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd {
4374 ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(nativeReplyShortChannelIdsEnd {
4375 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4376 full_information: full_information_arg,
4377 }), is_owned: true }
4379 impl Clone for ReplyShortChannelIdsEnd {
4380 fn clone(&self) -> Self {
4382 inner: if <*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) { core::ptr::null_mut() } else {
4383 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4389 /// Used only if an object of this type is returned as a trait impl by a method
4390 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_void) -> *mut c_void {
4391 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyShortChannelIdsEnd)).clone() })) as *mut c_void
4394 /// Creates a copy of the ReplyShortChannelIdsEnd
4395 pub extern "C" fn ReplyShortChannelIdsEnd_clone(orig: &ReplyShortChannelIdsEnd) -> ReplyShortChannelIdsEnd {
4399 use lightning::ln::msgs::GossipTimestampFilter as nativeGossipTimestampFilterImport;
4400 pub(crate) type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport;
4402 /// A gossip_timestamp_filter message is used by a node to request
4403 /// gossip relay for messages in the requested time range when the
4404 /// gossip_queries feature has been negotiated.
4407 pub struct GossipTimestampFilter {
4408 /// A pointer to the opaque Rust object.
4410 /// Nearly everywhere, inner must be non-null, however in places where
4411 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4412 pub inner: *mut nativeGossipTimestampFilter,
4413 /// Indicates that this is the only struct which contains the same pointer.
4415 /// Rust functions which take ownership of an object provided via an argument require
4416 /// this to be true and invalidate the object pointed to by inner.
4420 impl Drop for GossipTimestampFilter {
4421 fn drop(&mut self) {
4422 if self.is_owned && !<*mut nativeGossipTimestampFilter>::is_null(self.inner) {
4423 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4427 /// Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL.
4429 pub extern "C" fn GossipTimestampFilter_free(this_obj: GossipTimestampFilter) { }
4431 /// Used only if an object of this type is returned as a trait impl by a method
4432 pub(crate) extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) {
4433 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeGossipTimestampFilter); }
4436 impl GossipTimestampFilter {
4437 pub(crate) fn get_native_ref(&self) -> &'static nativeGossipTimestampFilter {
4438 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4440 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeGossipTimestampFilter {
4441 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4443 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4444 pub(crate) fn take_inner(mut self) -> *mut nativeGossipTimestampFilter {
4445 assert!(self.is_owned);
4446 let ret = ObjOps::untweak_ptr(self.inner);
4447 self.inner = core::ptr::null_mut();
4451 /// The genesis hash of the blockchain for channel and node information
4453 pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *const [u8; 32] {
4454 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4455 inner_val.as_inner()
4457 /// The genesis hash of the blockchain for channel and node information
4459 pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) {
4460 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4462 /// The starting unix timestamp
4464 pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 {
4465 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_timestamp;
4468 /// The starting unix timestamp
4470 pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
4471 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_timestamp = val;
4473 /// The range of information in seconds
4475 pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 {
4476 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp_range;
4479 /// The range of information in seconds
4481 pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
4482 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp_range = val;
4484 /// Constructs a new GossipTimestampFilter given each field
4487 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 {
4488 GossipTimestampFilter { inner: ObjOps::heap_alloc(nativeGossipTimestampFilter {
4489 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4490 first_timestamp: first_timestamp_arg,
4491 timestamp_range: timestamp_range_arg,
4492 }), is_owned: true }
4494 impl Clone for GossipTimestampFilter {
4495 fn clone(&self) -> Self {
4497 inner: if <*mut nativeGossipTimestampFilter>::is_null(self.inner) { core::ptr::null_mut() } else {
4498 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4504 /// Used only if an object of this type is returned as a trait impl by a method
4505 pub(crate) extern "C" fn GossipTimestampFilter_clone_void(this_ptr: *const c_void) -> *mut c_void {
4506 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeGossipTimestampFilter)).clone() })) as *mut c_void
4509 /// Creates a copy of the GossipTimestampFilter
4510 pub extern "C" fn GossipTimestampFilter_clone(orig: &GossipTimestampFilter) -> GossipTimestampFilter {
4513 /// Used to put an error message in a LightningError
4517 pub enum ErrorAction {
4518 /// The peer took some action which made us think they were useless. Disconnect them.
4520 /// An error message which we should make an effort to send before we disconnect.
4522 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
4523 msg: crate::lightning::ln::msgs::ErrorMessage,
4525 /// The peer did something harmless that we weren't able to process, just log and ignore
4527 /// The peer did something harmless that we weren't able to meaningfully process.
4528 /// If the error is logged, log it at the given level.
4529 IgnoreAndLog(crate::lightning::util::logger::Level),
4530 /// The peer provided us with a gossip message which we'd already seen. In most cases this
4531 /// should be ignored, but it may result in the message being forwarded if it is a duplicate of
4532 /// our own channel announcements.
4533 IgnoreDuplicateGossip,
4534 /// The peer did something incorrect. Tell them.
4536 /// The message to send.
4537 msg: crate::lightning::ln::msgs::ErrorMessage,
4539 /// The peer did something incorrect. Tell them without closing any channels.
4540 SendWarningMessage {
4541 /// The message to send.
4542 msg: crate::lightning::ln::msgs::WarningMessage,
4543 /// The peer may have done something harmless that we weren't able to meaningfully process,
4544 /// though we should still tell them about it.
4545 /// If this event is logged, log it at the given level.
4546 log_level: crate::lightning::util::logger::Level,
4549 use lightning::ln::msgs::ErrorAction as nativeErrorAction;
4552 pub(crate) fn to_native(&self) -> nativeErrorAction {
4554 ErrorAction::DisconnectPeer {ref msg, } => {
4555 let mut msg_nonref = (*msg).clone();
4556 let mut local_msg_nonref = if msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg_nonref.take_inner()) } }) };
4557 nativeErrorAction::DisconnectPeer {
4558 msg: local_msg_nonref,
4561 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
4562 ErrorAction::IgnoreAndLog (ref a, ) => {
4563 let mut a_nonref = (*a).clone();
4564 nativeErrorAction::IgnoreAndLog (
4565 a_nonref.into_native(),
4568 ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
4569 ErrorAction::SendErrorMessage {ref msg, } => {
4570 let mut msg_nonref = (*msg).clone();
4571 nativeErrorAction::SendErrorMessage {
4572 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
4575 ErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
4576 let mut msg_nonref = (*msg).clone();
4577 let mut log_level_nonref = (*log_level).clone();
4578 nativeErrorAction::SendWarningMessage {
4579 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
4580 log_level: log_level_nonref.into_native(),
4586 pub(crate) fn into_native(self) -> nativeErrorAction {
4588 ErrorAction::DisconnectPeer {mut msg, } => {
4589 let mut local_msg = if msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg.take_inner()) } }) };
4590 nativeErrorAction::DisconnectPeer {
4594 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
4595 ErrorAction::IgnoreAndLog (mut a, ) => {
4596 nativeErrorAction::IgnoreAndLog (
4600 ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
4601 ErrorAction::SendErrorMessage {mut msg, } => {
4602 nativeErrorAction::SendErrorMessage {
4603 msg: *unsafe { Box::from_raw(msg.take_inner()) },
4606 ErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
4607 nativeErrorAction::SendWarningMessage {
4608 msg: *unsafe { Box::from_raw(msg.take_inner()) },
4609 log_level: log_level.into_native(),
4615 pub(crate) fn from_native(native: &nativeErrorAction) -> Self {
4617 nativeErrorAction::DisconnectPeer {ref msg, } => {
4618 let mut msg_nonref = (*msg).clone();
4619 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 };
4620 ErrorAction::DisconnectPeer {
4621 msg: local_msg_nonref,
4624 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
4625 nativeErrorAction::IgnoreAndLog (ref a, ) => {
4626 let mut a_nonref = (*a).clone();
4627 ErrorAction::IgnoreAndLog (
4628 crate::lightning::util::logger::Level::native_into(a_nonref),
4631 nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
4632 nativeErrorAction::SendErrorMessage {ref msg, } => {
4633 let mut msg_nonref = (*msg).clone();
4634 ErrorAction::SendErrorMessage {
4635 msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
4638 nativeErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
4639 let mut msg_nonref = (*msg).clone();
4640 let mut log_level_nonref = (*log_level).clone();
4641 ErrorAction::SendWarningMessage {
4642 msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
4643 log_level: crate::lightning::util::logger::Level::native_into(log_level_nonref),
4649 pub(crate) fn native_into(native: nativeErrorAction) -> Self {
4651 nativeErrorAction::DisconnectPeer {mut msg, } => {
4652 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 };
4653 ErrorAction::DisconnectPeer {
4657 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
4658 nativeErrorAction::IgnoreAndLog (mut a, ) => {
4659 ErrorAction::IgnoreAndLog (
4660 crate::lightning::util::logger::Level::native_into(a),
4663 nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
4664 nativeErrorAction::SendErrorMessage {mut msg, } => {
4665 ErrorAction::SendErrorMessage {
4666 msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
4669 nativeErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
4670 ErrorAction::SendWarningMessage {
4671 msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
4672 log_level: crate::lightning::util::logger::Level::native_into(log_level),
4678 /// Frees any resources used by the ErrorAction
4680 pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { }
4681 /// Creates a copy of the ErrorAction
4683 pub extern "C" fn ErrorAction_clone(orig: &ErrorAction) -> ErrorAction {
4687 /// Utility method to constructs a new DisconnectPeer-variant ErrorAction
4688 pub extern "C" fn ErrorAction_disconnect_peer(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
4689 ErrorAction::DisconnectPeer {
4694 /// Utility method to constructs a new IgnoreError-variant ErrorAction
4695 pub extern "C" fn ErrorAction_ignore_error() -> ErrorAction {
4696 ErrorAction::IgnoreError}
4698 /// Utility method to constructs a new IgnoreAndLog-variant ErrorAction
4699 pub extern "C" fn ErrorAction_ignore_and_log(a: crate::lightning::util::logger::Level) -> ErrorAction {
4700 ErrorAction::IgnoreAndLog(a, )
4703 /// Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction
4704 pub extern "C" fn ErrorAction_ignore_duplicate_gossip() -> ErrorAction {
4705 ErrorAction::IgnoreDuplicateGossip}
4707 /// Utility method to constructs a new SendErrorMessage-variant ErrorAction
4708 pub extern "C" fn ErrorAction_send_error_message(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
4709 ErrorAction::SendErrorMessage {
4714 /// Utility method to constructs a new SendWarningMessage-variant ErrorAction
4715 pub extern "C" fn ErrorAction_send_warning_message(msg: crate::lightning::ln::msgs::WarningMessage, log_level: crate::lightning::util::logger::Level) -> ErrorAction {
4716 ErrorAction::SendWarningMessage {
4722 use lightning::ln::msgs::LightningError as nativeLightningErrorImport;
4723 pub(crate) type nativeLightningError = nativeLightningErrorImport;
4725 /// An Err type for failure to process messages.
4728 pub struct LightningError {
4729 /// A pointer to the opaque Rust object.
4731 /// Nearly everywhere, inner must be non-null, however in places where
4732 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4733 pub inner: *mut nativeLightningError,
4734 /// Indicates that this is the only struct which contains the same pointer.
4736 /// Rust functions which take ownership of an object provided via an argument require
4737 /// this to be true and invalidate the object pointed to by inner.
4741 impl Drop for LightningError {
4742 fn drop(&mut self) {
4743 if self.is_owned && !<*mut nativeLightningError>::is_null(self.inner) {
4744 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4748 /// Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL.
4750 pub extern "C" fn LightningError_free(this_obj: LightningError) { }
4752 /// Used only if an object of this type is returned as a trait impl by a method
4753 pub(crate) extern "C" fn LightningError_free_void(this_ptr: *mut c_void) {
4754 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeLightningError); }
4757 impl LightningError {
4758 pub(crate) fn get_native_ref(&self) -> &'static nativeLightningError {
4759 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4761 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLightningError {
4762 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4764 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4765 pub(crate) fn take_inner(mut self) -> *mut nativeLightningError {
4766 assert!(self.is_owned);
4767 let ret = ObjOps::untweak_ptr(self.inner);
4768 self.inner = core::ptr::null_mut();
4772 /// A human-readable message describing the error
4774 pub extern "C" fn LightningError_get_err(this_ptr: &LightningError) -> crate::c_types::Str {
4775 let mut inner_val = &mut this_ptr.get_native_mut_ref().err;
4776 inner_val.as_str().into()
4778 /// A human-readable message describing the error
4780 pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: crate::c_types::Str) {
4781 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.err = val.into_string();
4783 /// The action which should be taken against the offending peer.
4785 pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate::lightning::ln::msgs::ErrorAction {
4786 let mut inner_val = &mut this_ptr.get_native_mut_ref().action;
4787 crate::lightning::ln::msgs::ErrorAction::from_native(inner_val)
4789 /// The action which should be taken against the offending peer.
4791 pub extern "C" fn LightningError_set_action(this_ptr: &mut LightningError, mut val: crate::lightning::ln::msgs::ErrorAction) {
4792 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.action = val.into_native();
4794 /// Constructs a new LightningError given each field
4797 pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::Str, mut action_arg: crate::lightning::ln::msgs::ErrorAction) -> LightningError {
4798 LightningError { inner: ObjOps::heap_alloc(nativeLightningError {
4799 err: err_arg.into_string(),
4800 action: action_arg.into_native(),
4801 }), is_owned: true }
4803 impl Clone for LightningError {
4804 fn clone(&self) -> Self {
4806 inner: if <*mut nativeLightningError>::is_null(self.inner) { core::ptr::null_mut() } else {
4807 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4813 /// Used only if an object of this type is returned as a trait impl by a method
4814 pub(crate) extern "C" fn LightningError_clone_void(this_ptr: *const c_void) -> *mut c_void {
4815 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeLightningError)).clone() })) as *mut c_void
4818 /// Creates a copy of the LightningError
4819 pub extern "C" fn LightningError_clone(orig: &LightningError) -> LightningError {
4823 use lightning::ln::msgs::CommitmentUpdate as nativeCommitmentUpdateImport;
4824 pub(crate) type nativeCommitmentUpdate = nativeCommitmentUpdateImport;
4826 /// Struct used to return values from revoke_and_ack messages, containing a bunch of commitment
4827 /// transaction updates if they were pending.
4830 pub struct CommitmentUpdate {
4831 /// A pointer to the opaque Rust object.
4833 /// Nearly everywhere, inner must be non-null, however in places where
4834 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4835 pub inner: *mut nativeCommitmentUpdate,
4836 /// Indicates that this is the only struct which contains the same pointer.
4838 /// Rust functions which take ownership of an object provided via an argument require
4839 /// this to be true and invalidate the object pointed to by inner.
4843 impl Drop for CommitmentUpdate {
4844 fn drop(&mut self) {
4845 if self.is_owned && !<*mut nativeCommitmentUpdate>::is_null(self.inner) {
4846 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4850 /// Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL.
4852 pub extern "C" fn CommitmentUpdate_free(this_obj: CommitmentUpdate) { }
4854 /// Used only if an object of this type is returned as a trait impl by a method
4855 pub(crate) extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) {
4856 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentUpdate); }
4859 impl CommitmentUpdate {
4860 pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentUpdate {
4861 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4863 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentUpdate {
4864 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4866 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4867 pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentUpdate {
4868 assert!(self.is_owned);
4869 let ret = ObjOps::untweak_ptr(self.inner);
4870 self.inner = core::ptr::null_mut();
4874 /// update_add_htlc messages which should be sent
4876 pub extern "C" fn CommitmentUpdate_get_update_add_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateAddHTLCZ {
4877 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_add_htlcs;
4878 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 } }); };
4879 local_inner_val.into()
4881 /// update_add_htlc messages which should be sent
4883 pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) {
4884 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4885 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_add_htlcs = local_val;
4887 /// update_fulfill_htlc messages which should be sent
4889 pub extern "C" fn CommitmentUpdate_get_update_fulfill_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFulfillHTLCZ {
4890 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fulfill_htlcs;
4891 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 } }); };
4892 local_inner_val.into()
4894 /// update_fulfill_htlc messages which should be sent
4896 pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) {
4897 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4898 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fulfill_htlcs = local_val;
4900 /// update_fail_htlc messages which should be sent
4902 pub extern "C" fn CommitmentUpdate_get_update_fail_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailHTLCZ {
4903 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_htlcs;
4904 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 } }); };
4905 local_inner_val.into()
4907 /// update_fail_htlc messages which should be sent
4909 pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) {
4910 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4911 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_htlcs = local_val;
4913 /// update_fail_malformed_htlc messages which should be sent
4915 pub extern "C" fn CommitmentUpdate_get_update_fail_malformed_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ {
4916 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_malformed_htlcs;
4917 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 } }); };
4918 local_inner_val.into()
4920 /// update_fail_malformed_htlc messages which should be sent
4922 pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) {
4923 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4924 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_malformed_htlcs = local_val;
4926 /// An update_fee message which should be sent
4928 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
4930 pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::UpdateFee {
4931 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fee;
4932 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 };
4935 /// An update_fee message which should be sent
4937 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
4939 pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::UpdateFee) {
4940 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
4941 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fee = local_val;
4943 /// Finally, the commitment_signed message which should be sent
4945 pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::CommitmentSigned {
4946 let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_signed;
4947 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 }
4949 /// Finally, the commitment_signed message which should be sent
4951 pub extern "C" fn CommitmentUpdate_set_commitment_signed(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::CommitmentSigned) {
4952 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_signed = *unsafe { Box::from_raw(val.take_inner()) };
4954 /// Constructs a new CommitmentUpdate given each field
4957 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 {
4958 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()) } }); };
4959 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()) } }); };
4960 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()) } }); };
4961 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()) } }); };
4962 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()) } }) };
4963 CommitmentUpdate { inner: ObjOps::heap_alloc(nativeCommitmentUpdate {
4964 update_add_htlcs: local_update_add_htlcs_arg,
4965 update_fulfill_htlcs: local_update_fulfill_htlcs_arg,
4966 update_fail_htlcs: local_update_fail_htlcs_arg,
4967 update_fail_malformed_htlcs: local_update_fail_malformed_htlcs_arg,
4968 update_fee: local_update_fee_arg,
4969 commitment_signed: *unsafe { Box::from_raw(commitment_signed_arg.take_inner()) },
4970 }), is_owned: true }
4972 impl Clone for CommitmentUpdate {
4973 fn clone(&self) -> Self {
4975 inner: if <*mut nativeCommitmentUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
4976 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4982 /// Used only if an object of this type is returned as a trait impl by a method
4983 pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
4984 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentUpdate)).clone() })) as *mut c_void
4987 /// Creates a copy of the CommitmentUpdate
4988 pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentUpdate {
4991 /// A trait to describe an object which can receive channel messages.
4993 /// Messages MAY be called in parallel when they originate from different their_node_ids, however
4994 /// they MUST NOT be called in parallel when the two calls have the same their_node_id.
4996 pub struct ChannelMessageHandler {
4997 /// An opaque pointer which is passed to your function implementations as an argument.
4998 /// This has no meaning in the LDK, and can be NULL or any other value.
4999 pub this_arg: *mut c_void,
5000 /// Handle an incoming open_channel message from the given peer.
5001 pub handle_open_channel: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, their_features: crate::lightning::ln::features::InitFeatures, msg: &crate::lightning::ln::msgs::OpenChannel),
5002 /// Handle an incoming accept_channel message from the given peer.
5003 pub handle_accept_channel: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, their_features: crate::lightning::ln::features::InitFeatures, msg: &crate::lightning::ln::msgs::AcceptChannel),
5004 /// Handle an incoming funding_created message from the given peer.
5005 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),
5006 /// Handle an incoming funding_signed message from the given peer.
5007 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),
5008 /// Handle an incoming funding_locked message from the given peer.
5009 pub handle_funding_locked: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::FundingLocked),
5010 /// Handle an incoming shutdown message from the given peer.
5011 pub handle_shutdown: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, their_features: &crate::lightning::ln::features::InitFeatures, msg: &crate::lightning::ln::msgs::Shutdown),
5012 /// Handle an incoming closing_signed message from the given peer.
5013 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),
5014 /// Handle an incoming update_add_htlc message from the given peer.
5015 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),
5016 /// Handle an incoming update_fulfill_htlc message from the given peer.
5017 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),
5018 /// Handle an incoming update_fail_htlc message from the given peer.
5019 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),
5020 /// Handle an incoming update_fail_malformed_htlc message from the given peer.
5021 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),
5022 /// Handle an incoming commitment_signed message from the given peer.
5023 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),
5024 /// Handle an incoming revoke_and_ack message from the given peer.
5025 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),
5026 /// Handle an incoming update_fee message from the given peer.
5027 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),
5028 /// Handle an incoming announcement_signatures message from the given peer.
5029 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),
5030 /// Indicates a connection to the peer failed/an existing connection was lost. If no connection
5031 /// is believed to be possible in the future (eg they're sending us messages we don't
5032 /// understand or indicate they require unknown feature bits), no_connection_possible is set
5033 /// and any outstanding channels should be failed.
5034 pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, no_connection_possible: bool),
5035 /// Handle a peer reconnecting, possibly generating channel_reestablish message(s).
5036 pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Init),
5037 /// Handle an incoming channel_reestablish message from the given peer.
5038 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),
5039 /// Handle an incoming channel update from the given peer.
5040 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),
5041 /// Handle an incoming error message from the given peer.
5042 pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ErrorMessage),
5043 /// Implementation of MessageSendEventsProvider for this object.
5044 pub MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider,
5045 /// Frees any resources associated with this object given its this_arg pointer.
5046 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
5047 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
5049 unsafe impl Send for ChannelMessageHandler {}
5050 unsafe impl Sync for ChannelMessageHandler {}
5052 pub(crate) extern "C" fn ChannelMessageHandler_clone_fields(orig: &ChannelMessageHandler) -> ChannelMessageHandler {
5053 ChannelMessageHandler {
5054 this_arg: orig.this_arg,
5055 handle_open_channel: Clone::clone(&orig.handle_open_channel),
5056 handle_accept_channel: Clone::clone(&orig.handle_accept_channel),
5057 handle_funding_created: Clone::clone(&orig.handle_funding_created),
5058 handle_funding_signed: Clone::clone(&orig.handle_funding_signed),
5059 handle_funding_locked: Clone::clone(&orig.handle_funding_locked),
5060 handle_shutdown: Clone::clone(&orig.handle_shutdown),
5061 handle_closing_signed: Clone::clone(&orig.handle_closing_signed),
5062 handle_update_add_htlc: Clone::clone(&orig.handle_update_add_htlc),
5063 handle_update_fulfill_htlc: Clone::clone(&orig.handle_update_fulfill_htlc),
5064 handle_update_fail_htlc: Clone::clone(&orig.handle_update_fail_htlc),
5065 handle_update_fail_malformed_htlc: Clone::clone(&orig.handle_update_fail_malformed_htlc),
5066 handle_commitment_signed: Clone::clone(&orig.handle_commitment_signed),
5067 handle_revoke_and_ack: Clone::clone(&orig.handle_revoke_and_ack),
5068 handle_update_fee: Clone::clone(&orig.handle_update_fee),
5069 handle_announcement_signatures: Clone::clone(&orig.handle_announcement_signatures),
5070 peer_disconnected: Clone::clone(&orig.peer_disconnected),
5071 peer_connected: Clone::clone(&orig.peer_connected),
5072 handle_channel_reestablish: Clone::clone(&orig.handle_channel_reestablish),
5073 handle_channel_update: Clone::clone(&orig.handle_channel_update),
5074 handle_error: Clone::clone(&orig.handle_error),
5075 MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
5076 free: Clone::clone(&orig.free),
5079 impl lightning::util::events::MessageSendEventsProvider for ChannelMessageHandler {
5080 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
5081 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
5082 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
5087 use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler;
5088 impl rustChannelMessageHandler for ChannelMessageHandler {
5089 fn handle_open_channel(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut their_features: lightning::ln::features::InitFeatures, mut msg: &lightning::ln::msgs::OpenChannel) {
5090 (self.handle_open_channel)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(their_features), is_owned: true }, &crate::lightning::ln::msgs::OpenChannel { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::OpenChannel<>) as *mut _) }, is_owned: false })
5092 fn handle_accept_channel(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut their_features: lightning::ln::features::InitFeatures, mut msg: &lightning::ln::msgs::AcceptChannel) {
5093 (self.handle_accept_channel)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(their_features), is_owned: true }, &crate::lightning::ln::msgs::AcceptChannel { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::AcceptChannel<>) as *mut _) }, is_owned: false })
5095 fn handle_funding_created(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::FundingCreated) {
5096 (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 })
5098 fn handle_funding_signed(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::FundingSigned) {
5099 (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 })
5101 fn handle_funding_locked(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::FundingLocked) {
5102 (self.handle_funding_locked)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::FundingLocked { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::FundingLocked<>) as *mut _) }, is_owned: false })
5104 fn handle_shutdown(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut their_features: &lightning::ln::features::InitFeatures, mut msg: &lightning::ln::msgs::Shutdown) {
5105 (self.handle_shutdown)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::features::InitFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((their_features as *const lightning::ln::features::InitFeatures<>) as *mut _) }, is_owned: false }, &crate::lightning::ln::msgs::Shutdown { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::Shutdown<>) as *mut _) }, is_owned: false })
5107 fn handle_closing_signed(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ClosingSigned) {
5108 (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 })
5110 fn handle_update_add_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateAddHTLC) {
5111 (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 })
5113 fn handle_update_fulfill_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFulfillHTLC) {
5114 (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 })
5116 fn handle_update_fail_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailHTLC) {
5117 (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 })
5119 fn handle_update_fail_malformed_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) {
5120 (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 })
5122 fn handle_commitment_signed(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::CommitmentSigned) {
5123 (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 })
5125 fn handle_revoke_and_ack(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::RevokeAndACK) {
5126 (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 })
5128 fn handle_update_fee(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFee) {
5129 (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 })
5131 fn handle_announcement_signatures(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::AnnouncementSignatures) {
5132 (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 })
5134 fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut no_connection_possible: bool) {
5135 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), no_connection_possible)
5137 fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::Init) {
5138 (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 })
5140 fn handle_channel_reestablish(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ChannelReestablish) {
5141 (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 })
5143 fn handle_channel_update(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ChannelUpdate) {
5144 (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 })
5146 fn handle_error(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ErrorMessage) {
5147 (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 })
5151 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
5152 // directly as a Deref trait in higher-level structs:
5153 impl core::ops::Deref for ChannelMessageHandler {
5155 fn deref(&self) -> &Self {
5159 /// Calls the free function if one is set
5161 pub extern "C" fn ChannelMessageHandler_free(this_ptr: ChannelMessageHandler) { }
5162 impl Drop for ChannelMessageHandler {
5163 fn drop(&mut self) {
5164 if let Some(f) = self.free {
5169 /// A trait to describe an object which can receive routing messages.
5171 /// # Implementor DoS Warnings
5173 /// For `gossip_queries` messages there are potential DoS vectors when handling
5174 /// inbound queries. Implementors using an on-disk network graph should be aware of
5175 /// repeated disk I/O for queries accessing different parts of the network graph.
5177 pub struct RoutingMessageHandler {
5178 /// An opaque pointer which is passed to your function implementations as an argument.
5179 /// This has no meaning in the LDK, and can be NULL or any other value.
5180 pub this_arg: *mut c_void,
5181 /// Handle an incoming node_announcement message, returning true if it should be forwarded on,
5182 /// false or returning an Err otherwise.
5184 pub handle_node_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
5185 /// Handle a channel_announcement message, returning true if it should be forwarded on, false
5186 /// or returning an Err otherwise.
5188 pub handle_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
5189 /// Handle an incoming channel_update message, returning true if it should be forwarded on,
5190 /// false or returning an Err otherwise.
5192 pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ,
5193 /// Gets a subset of the channel announcements and updates required to dump our routing table
5194 /// to a remote node, starting at the short_channel_id indicated by starting_point and
5195 /// including the batch_amount entries immediately higher in numerical value than starting_point.
5197 pub get_next_channel_announcements: extern "C" fn (this_arg: *const c_void, starting_point: u64, batch_amount: u8) -> crate::c_types::derived::CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ,
5198 /// Gets a subset of the node announcements required to dump our routing table to a remote node,
5199 /// starting at the node *after* the provided publickey and including batch_amount entries
5200 /// immediately higher (as defined by <PublicKey as Ord>::cmp) than starting_point.
5201 /// If None is provided for starting_point, we start at the first node.
5203 /// Note that starting_point (or a relevant inner pointer) may be NULL or all-0s to represent None
5205 pub get_next_node_announcements: extern "C" fn (this_arg: *const c_void, starting_point: crate::c_types::PublicKey, batch_amount: u8) -> crate::c_types::derived::CVec_NodeAnnouncementZ,
5206 /// Called when a connection is established with a peer. This can be used to
5207 /// perform routing table synchronization using a strategy defined by the
5209 pub sync_routing_table: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, init: &crate::lightning::ln::msgs::Init),
5210 /// Handles the reply of a query we initiated to learn about channels
5211 /// for a given range of blocks. We can expect to receive one or more
5212 /// replies to a single query.
5214 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,
5215 /// Handles the reply of a query we initiated asking for routing gossip
5216 /// messages for a list of channels. We should receive this message when
5217 /// a node has completed its best effort to send us the pertaining routing
5218 /// gossip messages.
5220 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,
5221 /// Handles when a peer asks us to send a list of short_channel_ids
5222 /// for the requested range of blocks.
5224 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,
5225 /// Handles when a peer asks us to send routing gossip messages for a
5226 /// list of short_channel_ids.
5228 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,
5229 /// Implementation of MessageSendEventsProvider for this object.
5230 pub MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider,
5231 /// Frees any resources associated with this object given its this_arg pointer.
5232 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
5233 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
5235 unsafe impl Send for RoutingMessageHandler {}
5236 unsafe impl Sync for RoutingMessageHandler {}
5238 pub(crate) extern "C" fn RoutingMessageHandler_clone_fields(orig: &RoutingMessageHandler) -> RoutingMessageHandler {
5239 RoutingMessageHandler {
5240 this_arg: orig.this_arg,
5241 handle_node_announcement: Clone::clone(&orig.handle_node_announcement),
5242 handle_channel_announcement: Clone::clone(&orig.handle_channel_announcement),
5243 handle_channel_update: Clone::clone(&orig.handle_channel_update),
5244 get_next_channel_announcements: Clone::clone(&orig.get_next_channel_announcements),
5245 get_next_node_announcements: Clone::clone(&orig.get_next_node_announcements),
5246 sync_routing_table: Clone::clone(&orig.sync_routing_table),
5247 handle_reply_channel_range: Clone::clone(&orig.handle_reply_channel_range),
5248 handle_reply_short_channel_ids_end: Clone::clone(&orig.handle_reply_short_channel_ids_end),
5249 handle_query_channel_range: Clone::clone(&orig.handle_query_channel_range),
5250 handle_query_short_channel_ids: Clone::clone(&orig.handle_query_short_channel_ids),
5251 MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
5252 free: Clone::clone(&orig.free),
5255 impl lightning::util::events::MessageSendEventsProvider for RoutingMessageHandler {
5256 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
5257 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
5258 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
5263 use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler;
5264 impl rustRoutingMessageHandler for RoutingMessageHandler {
5265 fn handle_node_announcement(&self, mut msg: &lightning::ln::msgs::NodeAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
5266 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 });
5267 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()) } })};
5270 fn handle_channel_announcement(&self, mut msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
5271 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 });
5272 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()) } })};
5275 fn handle_channel_update(&self, mut msg: &lightning::ln::msgs::ChannelUpdate) -> Result<bool, lightning::ln::msgs::LightningError> {
5276 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 });
5277 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()) } })};
5280 fn get_next_channel_announcements(&self, mut starting_point: u64, mut batch_amount: u8) -> Vec<(lightning::ln::msgs::ChannelAnnouncement, Option<lightning::ln::msgs::ChannelUpdate>, Option<lightning::ln::msgs::ChannelUpdate>)> {
5281 let mut ret = (self.get_next_channel_announcements)(self.this_arg, starting_point, batch_amount);
5282 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = item.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 }); };
5285 fn get_next_node_announcements(&self, mut starting_point: Option<&bitcoin::secp256k1::key::PublicKey>, mut batch_amount: u8) -> Vec<lightning::ln::msgs::NodeAnnouncement> {
5286 let mut local_starting_point = if starting_point.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(starting_point.unwrap())) } };
5287 let mut ret = (self.get_next_node_announcements)(self.this_arg, local_starting_point, batch_amount);
5288 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
5291 fn sync_routing_table(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut init: &lightning::ln::msgs::Init) {
5292 (self.sync_routing_table)(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 })
5294 fn handle_reply_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: lightning::ln::msgs::ReplyChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
5295 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 });
5296 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()) } })};
5299 fn handle_reply_short_channel_ids_end(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: lightning::ln::msgs::ReplyShortChannelIdsEnd) -> Result<(), lightning::ln::msgs::LightningError> {
5300 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 });
5301 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()) } })};
5304 fn handle_query_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: lightning::ln::msgs::QueryChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
5305 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 });
5306 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()) } })};
5309 fn handle_query_short_channel_ids(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: lightning::ln::msgs::QueryShortChannelIds) -> Result<(), lightning::ln::msgs::LightningError> {
5310 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 });
5311 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()) } })};
5316 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
5317 // directly as a Deref trait in higher-level structs:
5318 impl core::ops::Deref for RoutingMessageHandler {
5320 fn deref(&self) -> &Self {
5324 /// Calls the free function if one is set
5326 pub extern "C" fn RoutingMessageHandler_free(this_ptr: RoutingMessageHandler) { }
5327 impl Drop for RoutingMessageHandler {
5328 fn drop(&mut self) {
5329 if let Some(f) = self.free {
5334 mod fuzzy_internal_msgs {
5336 use alloc::str::FromStr;
5337 use core::ffi::c_void;
5338 use core::convert::Infallible;
5339 use bitcoin::hashes::Hash;
5340 use crate::c_types::*;
5341 #[cfg(feature="no-std")]
5342 use alloc::{vec::Vec, boxed::Box};
5346 /// Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read
5347 pub extern "C" fn AcceptChannel_write(obj: &AcceptChannel) -> crate::c_types::derived::CVec_u8Z {
5348 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5351 pub(crate) extern "C" fn AcceptChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5352 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannel) })
5355 /// Read a AcceptChannel from a byte array, created by AcceptChannel_write
5356 pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelDecodeErrorZ {
5357 let res: Result<lightning::ln::msgs::AcceptChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5358 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 { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
5362 /// Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read
5363 pub extern "C" fn AnnouncementSignatures_write(obj: &AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z {
5364 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5367 pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5368 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAnnouncementSignatures) })
5371 /// Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write
5372 pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AnnouncementSignaturesDecodeErrorZ {
5373 let res: Result<lightning::ln::msgs::AnnouncementSignatures, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5374 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 { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
5378 /// Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read
5379 pub extern "C" fn ChannelReestablish_write(obj: &ChannelReestablish) -> crate::c_types::derived::CVec_u8Z {
5380 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5383 pub(crate) extern "C" fn ChannelReestablish_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5384 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReestablish) })
5387 /// Read a ChannelReestablish from a byte array, created by ChannelReestablish_write
5388 pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReestablishDecodeErrorZ {
5389 let res: Result<lightning::ln::msgs::ChannelReestablish, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5390 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 { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
5394 /// Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read
5395 pub extern "C" fn ClosingSigned_write(obj: &ClosingSigned) -> crate::c_types::derived::CVec_u8Z {
5396 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5399 pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5400 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSigned) })
5403 /// Read a ClosingSigned from a byte array, created by ClosingSigned_write
5404 pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedDecodeErrorZ {
5405 let res: Result<lightning::ln::msgs::ClosingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5406 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 { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
5410 /// Serialize the ClosingSignedFeeRange object into a byte array which can be read by ClosingSignedFeeRange_read
5411 pub extern "C" fn ClosingSignedFeeRange_write(obj: &ClosingSignedFeeRange) -> crate::c_types::derived::CVec_u8Z {
5412 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5415 pub(crate) extern "C" fn ClosingSignedFeeRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5416 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSignedFeeRange) })
5419 /// Read a ClosingSignedFeeRange from a byte array, created by ClosingSignedFeeRange_write
5420 pub extern "C" fn ClosingSignedFeeRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedFeeRangeDecodeErrorZ {
5421 let res: Result<lightning::ln::msgs::ClosingSignedFeeRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5422 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 { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
5426 /// Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read
5427 pub extern "C" fn CommitmentSigned_write(obj: &CommitmentSigned) -> crate::c_types::derived::CVec_u8Z {
5428 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5431 pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5432 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentSigned) })
5435 /// Read a CommitmentSigned from a byte array, created by CommitmentSigned_write
5436 pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CommitmentSignedDecodeErrorZ {
5437 let res: Result<lightning::ln::msgs::CommitmentSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5438 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 { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
5442 /// Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read
5443 pub extern "C" fn FundingCreated_write(obj: &FundingCreated) -> crate::c_types::derived::CVec_u8Z {
5444 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5447 pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5448 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingCreated) })
5451 /// Read a FundingCreated from a byte array, created by FundingCreated_write
5452 pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingCreatedDecodeErrorZ {
5453 let res: Result<lightning::ln::msgs::FundingCreated, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5454 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 { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
5458 /// Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read
5459 pub extern "C" fn FundingSigned_write(obj: &FundingSigned) -> crate::c_types::derived::CVec_u8Z {
5460 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5463 pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5464 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingSigned) })
5467 /// Read a FundingSigned from a byte array, created by FundingSigned_write
5468 pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingSignedDecodeErrorZ {
5469 let res: Result<lightning::ln::msgs::FundingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5470 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 { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
5474 /// Serialize the FundingLocked object into a byte array which can be read by FundingLocked_read
5475 pub extern "C" fn FundingLocked_write(obj: &FundingLocked) -> crate::c_types::derived::CVec_u8Z {
5476 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5479 pub(crate) extern "C" fn FundingLocked_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5480 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingLocked) })
5483 /// Read a FundingLocked from a byte array, created by FundingLocked_write
5484 pub extern "C" fn FundingLocked_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingLockedDecodeErrorZ {
5485 let res: Result<lightning::ln::msgs::FundingLocked, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5486 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::FundingLocked { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
5490 /// Serialize the Init object into a byte array which can be read by Init_read
5491 pub extern "C" fn Init_write(obj: &Init) -> crate::c_types::derived::CVec_u8Z {
5492 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5495 pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5496 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInit) })
5499 /// Read a Init from a byte array, created by Init_write
5500 pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitDecodeErrorZ {
5501 let res: Result<lightning::ln::msgs::Init, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5502 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 { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
5506 /// Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read
5507 pub extern "C" fn OpenChannel_write(obj: &OpenChannel) -> crate::c_types::derived::CVec_u8Z {
5508 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5511 pub(crate) extern "C" fn OpenChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5512 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannel) })
5515 /// Read a OpenChannel from a byte array, created by OpenChannel_write
5516 pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelDecodeErrorZ {
5517 let res: Result<lightning::ln::msgs::OpenChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5518 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 { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
5522 /// Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read
5523 pub extern "C" fn RevokeAndACK_write(obj: &RevokeAndACK) -> crate::c_types::derived::CVec_u8Z {
5524 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5527 pub(crate) extern "C" fn RevokeAndACK_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5528 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevokeAndACK) })
5531 /// Read a RevokeAndACK from a byte array, created by RevokeAndACK_write
5532 pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RevokeAndACKDecodeErrorZ {
5533 let res: Result<lightning::ln::msgs::RevokeAndACK, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5534 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 { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
5538 /// Serialize the Shutdown object into a byte array which can be read by Shutdown_read
5539 pub extern "C" fn Shutdown_write(obj: &Shutdown) -> crate::c_types::derived::CVec_u8Z {
5540 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5543 pub(crate) extern "C" fn Shutdown_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5544 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeShutdown) })
5547 /// Read a Shutdown from a byte array, created by Shutdown_write
5548 pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ShutdownDecodeErrorZ {
5549 let res: Result<lightning::ln::msgs::Shutdown, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5550 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 { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
5554 /// Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read
5555 pub extern "C" fn UpdateFailHTLC_write(obj: &UpdateFailHTLC) -> crate::c_types::derived::CVec_u8Z {
5556 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5559 pub(crate) extern "C" fn UpdateFailHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5560 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailHTLC) })
5563 /// Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write
5564 pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailHTLCDecodeErrorZ {
5565 let res: Result<lightning::ln::msgs::UpdateFailHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5566 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 { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
5570 /// Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read
5571 pub extern "C" fn UpdateFailMalformedHTLC_write(obj: &UpdateFailMalformedHTLC) -> crate::c_types::derived::CVec_u8Z {
5572 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5575 pub(crate) extern "C" fn UpdateFailMalformedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5576 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailMalformedHTLC) })
5579 /// Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write
5580 pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailMalformedHTLCDecodeErrorZ {
5581 let res: Result<lightning::ln::msgs::UpdateFailMalformedHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5582 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 { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
5586 /// Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read
5587 pub extern "C" fn UpdateFee_write(obj: &UpdateFee) -> crate::c_types::derived::CVec_u8Z {
5588 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5591 pub(crate) extern "C" fn UpdateFee_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5592 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFee) })
5595 /// Read a UpdateFee from a byte array, created by UpdateFee_write
5596 pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFeeDecodeErrorZ {
5597 let res: Result<lightning::ln::msgs::UpdateFee, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5598 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 { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
5602 /// Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read
5603 pub extern "C" fn UpdateFulfillHTLC_write(obj: &UpdateFulfillHTLC) -> crate::c_types::derived::CVec_u8Z {
5604 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5607 pub(crate) extern "C" fn UpdateFulfillHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5608 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFulfillHTLC) })
5611 /// Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write
5612 pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFulfillHTLCDecodeErrorZ {
5613 let res: Result<lightning::ln::msgs::UpdateFulfillHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5614 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 { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
5618 /// Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read
5619 pub extern "C" fn UpdateAddHTLC_write(obj: &UpdateAddHTLC) -> crate::c_types::derived::CVec_u8Z {
5620 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5623 pub(crate) extern "C" fn UpdateAddHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5624 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateAddHTLC) })
5627 /// Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write
5628 pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateAddHTLCDecodeErrorZ {
5629 let res: Result<lightning::ln::msgs::UpdateAddHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5630 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 { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
5634 /// Serialize the Ping object into a byte array which can be read by Ping_read
5635 pub extern "C" fn Ping_write(obj: &Ping) -> crate::c_types::derived::CVec_u8Z {
5636 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5639 pub(crate) extern "C" fn Ping_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5640 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePing) })
5643 /// Read a Ping from a byte array, created by Ping_write
5644 pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PingDecodeErrorZ {
5645 let res: Result<lightning::ln::msgs::Ping, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5646 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 { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
5650 /// Serialize the Pong object into a byte array which can be read by Pong_read
5651 pub extern "C" fn Pong_write(obj: &Pong) -> crate::c_types::derived::CVec_u8Z {
5652 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5655 pub(crate) extern "C" fn Pong_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5656 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePong) })
5659 /// Read a Pong from a byte array, created by Pong_write
5660 pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PongDecodeErrorZ {
5661 let res: Result<lightning::ln::msgs::Pong, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5662 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 { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
5666 /// Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read
5667 pub extern "C" fn UnsignedChannelAnnouncement_write(obj: &UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
5668 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5671 pub(crate) extern "C" fn UnsignedChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5672 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelAnnouncement) })
5675 /// Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write
5676 pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelAnnouncementDecodeErrorZ {
5677 let res: Result<lightning::ln::msgs::UnsignedChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5678 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 { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
5682 /// Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read
5683 pub extern "C" fn ChannelAnnouncement_write(obj: &ChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
5684 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5687 pub(crate) extern "C" fn ChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5688 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelAnnouncement) })
5691 /// Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write
5692 pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelAnnouncementDecodeErrorZ {
5693 let res: Result<lightning::ln::msgs::ChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5694 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 { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
5698 /// Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read
5699 pub extern "C" fn UnsignedChannelUpdate_write(obj: &UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
5700 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5703 pub(crate) extern "C" fn UnsignedChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5704 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelUpdate) })
5707 /// Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write
5708 pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelUpdateDecodeErrorZ {
5709 let res: Result<lightning::ln::msgs::UnsignedChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5710 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 { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
5714 /// Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read
5715 pub extern "C" fn ChannelUpdate_write(obj: &ChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
5716 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5719 pub(crate) extern "C" fn ChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5720 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdate) })
5723 /// Read a ChannelUpdate from a byte array, created by ChannelUpdate_write
5724 pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelUpdateDecodeErrorZ {
5725 let res: Result<lightning::ln::msgs::ChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5726 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 { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
5730 /// Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read
5731 pub extern "C" fn ErrorMessage_write(obj: &ErrorMessage) -> crate::c_types::derived::CVec_u8Z {
5732 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5735 pub(crate) extern "C" fn ErrorMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5736 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeErrorMessage) })
5739 /// Read a ErrorMessage from a byte array, created by ErrorMessage_write
5740 pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ErrorMessageDecodeErrorZ {
5741 let res: Result<lightning::ln::msgs::ErrorMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5742 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 { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
5746 /// Serialize the WarningMessage object into a byte array which can be read by WarningMessage_read
5747 pub extern "C" fn WarningMessage_write(obj: &WarningMessage) -> crate::c_types::derived::CVec_u8Z {
5748 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5751 pub(crate) extern "C" fn WarningMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5752 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeWarningMessage) })
5755 /// Read a WarningMessage from a byte array, created by WarningMessage_write
5756 pub extern "C" fn WarningMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_WarningMessageDecodeErrorZ {
5757 let res: Result<lightning::ln::msgs::WarningMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5758 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 { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
5762 /// Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read
5763 pub extern "C" fn UnsignedNodeAnnouncement_write(obj: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
5764 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5767 pub(crate) extern "C" fn UnsignedNodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5768 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedNodeAnnouncement) })
5771 /// Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write
5772 pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedNodeAnnouncementDecodeErrorZ {
5773 let res: Result<lightning::ln::msgs::UnsignedNodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5774 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 { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
5778 /// Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read
5779 pub extern "C" fn NodeAnnouncement_write(obj: &NodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
5780 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5783 pub(crate) extern "C" fn NodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5784 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncement) })
5787 /// Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write
5788 pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementDecodeErrorZ {
5789 let res: Result<lightning::ln::msgs::NodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5790 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 { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
5794 /// Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write
5795 pub extern "C" fn QueryShortChannelIds_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryShortChannelIdsDecodeErrorZ {
5796 let res: Result<lightning::ln::msgs::QueryShortChannelIds, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5797 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 { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
5801 /// Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read
5802 pub extern "C" fn QueryShortChannelIds_write(obj: &QueryShortChannelIds) -> crate::c_types::derived::CVec_u8Z {
5803 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5806 pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5807 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) })
5810 /// Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read
5811 pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z {
5812 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5815 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5816 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) })
5819 /// Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write
5820 pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyShortChannelIdsEndDecodeErrorZ {
5821 let res: Result<lightning::ln::msgs::ReplyShortChannelIdsEnd, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5822 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 { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
5825 ///\n\t * Calculates the overflow safe ending block height for the query.\n\t * Overflow returns `0xffffffff`, otherwise returns `first_blocknum + number_of_blocks`\n\t
5828 pub extern "C" fn QueryChannelRange_end_blocknum(this_arg: &QueryChannelRange) -> u32 {
5829 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.end_blocknum();
5834 /// Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read
5835 pub extern "C" fn QueryChannelRange_write(obj: &QueryChannelRange) -> crate::c_types::derived::CVec_u8Z {
5836 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5839 pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5840 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) })
5843 /// Read a QueryChannelRange from a byte array, created by QueryChannelRange_write
5844 pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ {
5845 let res: Result<lightning::ln::msgs::QueryChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5846 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 { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
5850 /// Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write
5851 pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyChannelRangeDecodeErrorZ {
5852 let res: Result<lightning::ln::msgs::ReplyChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5853 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 { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
5857 /// Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read
5858 pub extern "C" fn ReplyChannelRange_write(obj: &ReplyChannelRange) -> crate::c_types::derived::CVec_u8Z {
5859 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5862 pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5863 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) })
5866 /// Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read
5867 pub extern "C" fn GossipTimestampFilter_write(obj: &GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z {
5868 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5871 pub(crate) extern "C" fn GossipTimestampFilter_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5872 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeGossipTimestampFilter) })
5875 /// Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write
5876 pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_GossipTimestampFilterDecodeErrorZ {
5877 let res: Result<lightning::ln::msgs::GossipTimestampFilter, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5878 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 { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };