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 /// The receipient's network address. This adds the option to report a remote IP address
167 /// back to a connecting peer using the init message. A node can decide to use that information
168 /// to discover a potential update to its public IPv4 address (NAT) and use
169 /// that for a node_announcement update message containing the new address.
171 pub extern "C" fn Init_get_remote_network_address(this_ptr: &Init) -> crate::c_types::derived::COption_NetAddressZ {
172 let mut inner_val = &mut this_ptr.get_native_mut_ref().remote_network_address;
173 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_NetAddressZ::None } else { crate::c_types::derived::COption_NetAddressZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { crate::lightning::ln::msgs::NetAddress::native_into(inner_val.clone().unwrap()) }) };
176 /// The receipient's network address. This adds the option to report a remote IP address
177 /// back to a connecting peer using the init message. A node can decide to use that information
178 /// to discover a potential update to its public IPv4 address (NAT) and use
179 /// that for a node_announcement update message containing the new address.
181 pub extern "C" fn Init_set_remote_network_address(this_ptr: &mut Init, mut val: crate::c_types::derived::COption_NetAddressZ) {
182 let mut local_val = { /* val*/ let val_opt = val; { } if val_opt.is_none() { None } else { Some({ val_opt.take().into_native() }) } };
183 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.remote_network_address = local_val;
185 /// Constructs a new Init given each field
188 pub extern "C" fn Init_new(mut features_arg: crate::lightning::ln::features::InitFeatures, mut remote_network_address_arg: crate::c_types::derived::COption_NetAddressZ) -> Init {
189 let mut local_remote_network_address_arg = { /* remote_network_address_arg*/ let remote_network_address_arg_opt = remote_network_address_arg; { } if remote_network_address_arg_opt.is_none() { None } else { Some({ remote_network_address_arg_opt.take().into_native() }) } };
190 Init { inner: ObjOps::heap_alloc(nativeInit {
191 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
192 remote_network_address: local_remote_network_address_arg,
195 impl Clone for Init {
196 fn clone(&self) -> Self {
198 inner: if <*mut nativeInit>::is_null(self.inner) { core::ptr::null_mut() } else {
199 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
205 /// Used only if an object of this type is returned as a trait impl by a method
206 pub(crate) extern "C" fn Init_clone_void(this_ptr: *const c_void) -> *mut c_void {
207 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInit)).clone() })) as *mut c_void
210 /// Creates a copy of the Init
211 pub extern "C" fn Init_clone(orig: &Init) -> Init {
215 use lightning::ln::msgs::ErrorMessage as nativeErrorMessageImport;
216 pub(crate) type nativeErrorMessage = nativeErrorMessageImport;
218 /// An error message to be sent or received from a peer
221 pub struct ErrorMessage {
222 /// A pointer to the opaque Rust object.
224 /// Nearly everywhere, inner must be non-null, however in places where
225 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
226 pub inner: *mut nativeErrorMessage,
227 /// Indicates that this is the only struct which contains the same pointer.
229 /// Rust functions which take ownership of an object provided via an argument require
230 /// this to be true and invalidate the object pointed to by inner.
234 impl Drop for ErrorMessage {
236 if self.is_owned && !<*mut nativeErrorMessage>::is_null(self.inner) {
237 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
241 /// Frees any resources used by the ErrorMessage, if is_owned is set and inner is non-NULL.
243 pub extern "C" fn ErrorMessage_free(this_obj: ErrorMessage) { }
245 /// Used only if an object of this type is returned as a trait impl by a method
246 pub(crate) extern "C" fn ErrorMessage_free_void(this_ptr: *mut c_void) {
247 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeErrorMessage); }
251 pub(crate) fn get_native_ref(&self) -> &'static nativeErrorMessage {
252 unsafe { &*ObjOps::untweak_ptr(self.inner) }
254 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeErrorMessage {
255 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
257 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
258 pub(crate) fn take_inner(mut self) -> *mut nativeErrorMessage {
259 assert!(self.is_owned);
260 let ret = ObjOps::untweak_ptr(self.inner);
261 self.inner = core::ptr::null_mut();
265 /// The channel ID involved in the error.
267 /// All-0s indicates a general error unrelated to a specific channel, after which all channels
268 /// with the sending peer should be closed.
270 pub extern "C" fn ErrorMessage_get_channel_id(this_ptr: &ErrorMessage) -> *const [u8; 32] {
271 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
274 /// The channel ID involved in the error.
276 /// All-0s indicates a general error unrelated to a specific channel, after which all channels
277 /// with the sending peer should be closed.
279 pub extern "C" fn ErrorMessage_set_channel_id(this_ptr: &mut ErrorMessage, mut val: crate::c_types::ThirtyTwoBytes) {
280 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
282 /// A possibly human-readable error description.
283 /// The string should be sanitized before it is used (e.g. emitted to logs or printed to
284 /// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
285 /// the terminal emulator or the logging subsystem.
287 pub extern "C" fn ErrorMessage_get_data(this_ptr: &ErrorMessage) -> crate::c_types::Str {
288 let mut inner_val = &mut this_ptr.get_native_mut_ref().data;
289 inner_val.as_str().into()
291 /// A possibly human-readable error description.
292 /// The string should be sanitized before it is used (e.g. emitted to logs or printed to
293 /// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
294 /// the terminal emulator or the logging subsystem.
296 pub extern "C" fn ErrorMessage_set_data(this_ptr: &mut ErrorMessage, mut val: crate::c_types::Str) {
297 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string();
299 /// Constructs a new ErrorMessage given each field
302 pub extern "C" fn ErrorMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::Str) -> ErrorMessage {
303 ErrorMessage { inner: ObjOps::heap_alloc(nativeErrorMessage {
304 channel_id: channel_id_arg.data,
305 data: data_arg.into_string(),
308 impl Clone for ErrorMessage {
309 fn clone(&self) -> Self {
311 inner: if <*mut nativeErrorMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
312 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
318 /// Used only if an object of this type is returned as a trait impl by a method
319 pub(crate) extern "C" fn ErrorMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
320 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeErrorMessage)).clone() })) as *mut c_void
323 /// Creates a copy of the ErrorMessage
324 pub extern "C" fn ErrorMessage_clone(orig: &ErrorMessage) -> ErrorMessage {
328 use lightning::ln::msgs::WarningMessage as nativeWarningMessageImport;
329 pub(crate) type nativeWarningMessage = nativeWarningMessageImport;
331 /// A warning message to be sent or received from a peer
334 pub struct WarningMessage {
335 /// A pointer to the opaque Rust object.
337 /// Nearly everywhere, inner must be non-null, however in places where
338 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
339 pub inner: *mut nativeWarningMessage,
340 /// Indicates that this is the only struct which contains the same pointer.
342 /// Rust functions which take ownership of an object provided via an argument require
343 /// this to be true and invalidate the object pointed to by inner.
347 impl Drop for WarningMessage {
349 if self.is_owned && !<*mut nativeWarningMessage>::is_null(self.inner) {
350 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
354 /// Frees any resources used by the WarningMessage, if is_owned is set and inner is non-NULL.
356 pub extern "C" fn WarningMessage_free(this_obj: WarningMessage) { }
358 /// Used only if an object of this type is returned as a trait impl by a method
359 pub(crate) extern "C" fn WarningMessage_free_void(this_ptr: *mut c_void) {
360 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeWarningMessage); }
363 impl WarningMessage {
364 pub(crate) fn get_native_ref(&self) -> &'static nativeWarningMessage {
365 unsafe { &*ObjOps::untweak_ptr(self.inner) }
367 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeWarningMessage {
368 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
370 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
371 pub(crate) fn take_inner(mut self) -> *mut nativeWarningMessage {
372 assert!(self.is_owned);
373 let ret = ObjOps::untweak_ptr(self.inner);
374 self.inner = core::ptr::null_mut();
378 /// The channel ID involved in the warning.
380 /// All-0s indicates a warning unrelated to a specific channel.
382 pub extern "C" fn WarningMessage_get_channel_id(this_ptr: &WarningMessage) -> *const [u8; 32] {
383 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
386 /// The channel ID involved in the warning.
388 /// All-0s indicates a warning unrelated to a specific channel.
390 pub extern "C" fn WarningMessage_set_channel_id(this_ptr: &mut WarningMessage, mut val: crate::c_types::ThirtyTwoBytes) {
391 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
393 /// A possibly human-readable warning description.
394 /// The string should be sanitized before it is used (e.g. emitted to logs or printed to
395 /// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
396 /// the terminal emulator or the logging subsystem.
398 pub extern "C" fn WarningMessage_get_data(this_ptr: &WarningMessage) -> crate::c_types::Str {
399 let mut inner_val = &mut this_ptr.get_native_mut_ref().data;
400 inner_val.as_str().into()
402 /// A possibly human-readable warning description.
403 /// The string should be sanitized before it is used (e.g. emitted to logs or printed to
404 /// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
405 /// the terminal emulator or the logging subsystem.
407 pub extern "C" fn WarningMessage_set_data(this_ptr: &mut WarningMessage, mut val: crate::c_types::Str) {
408 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string();
410 /// Constructs a new WarningMessage given each field
413 pub extern "C" fn WarningMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::Str) -> WarningMessage {
414 WarningMessage { inner: ObjOps::heap_alloc(nativeWarningMessage {
415 channel_id: channel_id_arg.data,
416 data: data_arg.into_string(),
419 impl Clone for WarningMessage {
420 fn clone(&self) -> Self {
422 inner: if <*mut nativeWarningMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
423 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
429 /// Used only if an object of this type is returned as a trait impl by a method
430 pub(crate) extern "C" fn WarningMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
431 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeWarningMessage)).clone() })) as *mut c_void
434 /// Creates a copy of the WarningMessage
435 pub extern "C" fn WarningMessage_clone(orig: &WarningMessage) -> WarningMessage {
439 use lightning::ln::msgs::Ping as nativePingImport;
440 pub(crate) type nativePing = nativePingImport;
442 /// A ping message to be sent or received from a peer
446 /// A pointer to the opaque Rust object.
448 /// Nearly everywhere, inner must be non-null, however in places where
449 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
450 pub inner: *mut nativePing,
451 /// Indicates that this is the only struct which contains the same pointer.
453 /// Rust functions which take ownership of an object provided via an argument require
454 /// this to be true and invalidate the object pointed to by inner.
460 if self.is_owned && !<*mut nativePing>::is_null(self.inner) {
461 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
465 /// Frees any resources used by the Ping, if is_owned is set and inner is non-NULL.
467 pub extern "C" fn Ping_free(this_obj: Ping) { }
469 /// Used only if an object of this type is returned as a trait impl by a method
470 pub(crate) extern "C" fn Ping_free_void(this_ptr: *mut c_void) {
471 unsafe { let _ = Box::from_raw(this_ptr as *mut nativePing); }
475 pub(crate) fn get_native_ref(&self) -> &'static nativePing {
476 unsafe { &*ObjOps::untweak_ptr(self.inner) }
478 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePing {
479 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
481 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
482 pub(crate) fn take_inner(mut self) -> *mut nativePing {
483 assert!(self.is_owned);
484 let ret = ObjOps::untweak_ptr(self.inner);
485 self.inner = core::ptr::null_mut();
489 /// The desired response length
491 pub extern "C" fn Ping_get_ponglen(this_ptr: &Ping) -> u16 {
492 let mut inner_val = &mut this_ptr.get_native_mut_ref().ponglen;
495 /// The desired response length
497 pub extern "C" fn Ping_set_ponglen(this_ptr: &mut Ping, mut val: u16) {
498 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.ponglen = val;
500 /// The ping packet size.
501 /// This field is not sent on the wire. byteslen zeros are sent.
503 pub extern "C" fn Ping_get_byteslen(this_ptr: &Ping) -> u16 {
504 let mut inner_val = &mut this_ptr.get_native_mut_ref().byteslen;
507 /// The ping packet size.
508 /// This field is not sent on the wire. byteslen zeros are sent.
510 pub extern "C" fn Ping_set_byteslen(this_ptr: &mut Ping, mut val: u16) {
511 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.byteslen = val;
513 /// Constructs a new Ping given each field
516 pub extern "C" fn Ping_new(mut ponglen_arg: u16, mut byteslen_arg: u16) -> Ping {
517 Ping { inner: ObjOps::heap_alloc(nativePing {
518 ponglen: ponglen_arg,
519 byteslen: byteslen_arg,
522 impl Clone for Ping {
523 fn clone(&self) -> Self {
525 inner: if <*mut nativePing>::is_null(self.inner) { core::ptr::null_mut() } else {
526 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
532 /// Used only if an object of this type is returned as a trait impl by a method
533 pub(crate) extern "C" fn Ping_clone_void(this_ptr: *const c_void) -> *mut c_void {
534 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePing)).clone() })) as *mut c_void
537 /// Creates a copy of the Ping
538 pub extern "C" fn Ping_clone(orig: &Ping) -> Ping {
542 use lightning::ln::msgs::Pong as nativePongImport;
543 pub(crate) type nativePong = nativePongImport;
545 /// A pong message to be sent or received from a peer
549 /// A pointer to the opaque Rust object.
551 /// Nearly everywhere, inner must be non-null, however in places where
552 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
553 pub inner: *mut nativePong,
554 /// Indicates that this is the only struct which contains the same pointer.
556 /// Rust functions which take ownership of an object provided via an argument require
557 /// this to be true and invalidate the object pointed to by inner.
563 if self.is_owned && !<*mut nativePong>::is_null(self.inner) {
564 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
568 /// Frees any resources used by the Pong, if is_owned is set and inner is non-NULL.
570 pub extern "C" fn Pong_free(this_obj: Pong) { }
572 /// Used only if an object of this type is returned as a trait impl by a method
573 pub(crate) extern "C" fn Pong_free_void(this_ptr: *mut c_void) {
574 unsafe { let _ = Box::from_raw(this_ptr as *mut nativePong); }
578 pub(crate) fn get_native_ref(&self) -> &'static nativePong {
579 unsafe { &*ObjOps::untweak_ptr(self.inner) }
581 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePong {
582 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
584 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
585 pub(crate) fn take_inner(mut self) -> *mut nativePong {
586 assert!(self.is_owned);
587 let ret = ObjOps::untweak_ptr(self.inner);
588 self.inner = core::ptr::null_mut();
592 /// The pong packet size.
593 /// This field is not sent on the wire. byteslen zeros are sent.
595 pub extern "C" fn Pong_get_byteslen(this_ptr: &Pong) -> u16 {
596 let mut inner_val = &mut this_ptr.get_native_mut_ref().byteslen;
599 /// The pong packet size.
600 /// This field is not sent on the wire. byteslen zeros are sent.
602 pub extern "C" fn Pong_set_byteslen(this_ptr: &mut Pong, mut val: u16) {
603 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.byteslen = val;
605 /// Constructs a new Pong given each field
608 pub extern "C" fn Pong_new(mut byteslen_arg: u16) -> Pong {
609 Pong { inner: ObjOps::heap_alloc(nativePong {
610 byteslen: byteslen_arg,
613 impl Clone for Pong {
614 fn clone(&self) -> Self {
616 inner: if <*mut nativePong>::is_null(self.inner) { core::ptr::null_mut() } else {
617 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
623 /// Used only if an object of this type is returned as a trait impl by a method
624 pub(crate) extern "C" fn Pong_clone_void(this_ptr: *const c_void) -> *mut c_void {
625 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePong)).clone() })) as *mut c_void
628 /// Creates a copy of the Pong
629 pub extern "C" fn Pong_clone(orig: &Pong) -> Pong {
633 use lightning::ln::msgs::OpenChannel as nativeOpenChannelImport;
634 pub(crate) type nativeOpenChannel = nativeOpenChannelImport;
636 /// An open_channel message to be sent or received from a peer
639 pub struct OpenChannel {
640 /// A pointer to the opaque Rust object.
642 /// Nearly everywhere, inner must be non-null, however in places where
643 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
644 pub inner: *mut nativeOpenChannel,
645 /// Indicates that this is the only struct which contains the same pointer.
647 /// Rust functions which take ownership of an object provided via an argument require
648 /// this to be true and invalidate the object pointed to by inner.
652 impl Drop for OpenChannel {
654 if self.is_owned && !<*mut nativeOpenChannel>::is_null(self.inner) {
655 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
659 /// Frees any resources used by the OpenChannel, if is_owned is set and inner is non-NULL.
661 pub extern "C" fn OpenChannel_free(this_obj: OpenChannel) { }
663 /// Used only if an object of this type is returned as a trait impl by a method
664 pub(crate) extern "C" fn OpenChannel_free_void(this_ptr: *mut c_void) {
665 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeOpenChannel); }
669 pub(crate) fn get_native_ref(&self) -> &'static nativeOpenChannel {
670 unsafe { &*ObjOps::untweak_ptr(self.inner) }
672 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOpenChannel {
673 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
675 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
676 pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannel {
677 assert!(self.is_owned);
678 let ret = ObjOps::untweak_ptr(self.inner);
679 self.inner = core::ptr::null_mut();
683 /// The genesis hash of the blockchain where the channel is to be opened
685 pub extern "C" fn OpenChannel_get_chain_hash(this_ptr: &OpenChannel) -> *const [u8; 32] {
686 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
689 /// The genesis hash of the blockchain where the channel is to be opened
691 pub extern "C" fn OpenChannel_set_chain_hash(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
692 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
694 /// A temporary channel ID, until the funding outpoint is announced
696 pub extern "C" fn OpenChannel_get_temporary_channel_id(this_ptr: &OpenChannel) -> *const [u8; 32] {
697 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
700 /// A temporary channel ID, until the funding outpoint is announced
702 pub extern "C" fn OpenChannel_set_temporary_channel_id(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
703 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
705 /// The channel value
707 pub extern "C" fn OpenChannel_get_funding_satoshis(this_ptr: &OpenChannel) -> u64 {
708 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
711 /// The channel value
713 pub extern "C" fn OpenChannel_set_funding_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
714 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
716 /// The amount to push to the counterparty as part of the open, in milli-satoshi
718 pub extern "C" fn OpenChannel_get_push_msat(this_ptr: &OpenChannel) -> u64 {
719 let mut inner_val = &mut this_ptr.get_native_mut_ref().push_msat;
722 /// The amount to push to the counterparty as part of the open, in milli-satoshi
724 pub extern "C" fn OpenChannel_set_push_msat(this_ptr: &mut OpenChannel, mut val: u64) {
725 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.push_msat = val;
727 /// The threshold below which outputs on transactions broadcast by sender will be omitted
729 pub extern "C" fn OpenChannel_get_dust_limit_satoshis(this_ptr: &OpenChannel) -> u64 {
730 let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
733 /// The threshold below which outputs on transactions broadcast by sender will be omitted
735 pub extern "C" fn OpenChannel_set_dust_limit_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
736 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
738 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
740 pub extern "C" fn OpenChannel_get_max_htlc_value_in_flight_msat(this_ptr: &OpenChannel) -> u64 {
741 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
744 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
746 pub extern "C" fn OpenChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut OpenChannel, mut val: u64) {
747 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
749 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
751 pub extern "C" fn OpenChannel_get_channel_reserve_satoshis(this_ptr: &OpenChannel) -> u64 {
752 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
755 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
757 pub extern "C" fn OpenChannel_set_channel_reserve_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
758 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
760 /// The minimum HTLC size incoming to sender, in milli-satoshi
762 pub extern "C" fn OpenChannel_get_htlc_minimum_msat(this_ptr: &OpenChannel) -> u64 {
763 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
766 /// The minimum HTLC size incoming to sender, in milli-satoshi
768 pub extern "C" fn OpenChannel_set_htlc_minimum_msat(this_ptr: &mut OpenChannel, mut val: u64) {
769 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
771 /// The feerate per 1000-weight of sender generated transactions, until updated by update_fee
773 pub extern "C" fn OpenChannel_get_feerate_per_kw(this_ptr: &OpenChannel) -> u32 {
774 let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
777 /// The feerate per 1000-weight of sender generated transactions, until updated by update_fee
779 pub extern "C" fn OpenChannel_set_feerate_per_kw(this_ptr: &mut OpenChannel, mut val: u32) {
780 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
782 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
784 pub extern "C" fn OpenChannel_get_to_self_delay(this_ptr: &OpenChannel) -> u16 {
785 let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
788 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
790 pub extern "C" fn OpenChannel_set_to_self_delay(this_ptr: &mut OpenChannel, mut val: u16) {
791 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
793 /// The maximum number of inbound HTLCs towards sender
795 pub extern "C" fn OpenChannel_get_max_accepted_htlcs(this_ptr: &OpenChannel) -> u16 {
796 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
799 /// The maximum number of inbound HTLCs towards sender
801 pub extern "C" fn OpenChannel_set_max_accepted_htlcs(this_ptr: &mut OpenChannel, mut val: u16) {
802 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
804 /// The sender's key controlling the funding transaction
806 pub extern "C" fn OpenChannel_get_funding_pubkey(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
807 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
808 crate::c_types::PublicKey::from_rust(&inner_val)
810 /// The sender's key controlling the funding transaction
812 pub extern "C" fn OpenChannel_set_funding_pubkey(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
813 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
815 /// Used to derive a revocation key for transactions broadcast by counterparty
817 pub extern "C" fn OpenChannel_get_revocation_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
818 let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
819 crate::c_types::PublicKey::from_rust(&inner_val)
821 /// Used to derive a revocation key for transactions broadcast by counterparty
823 pub extern "C" fn OpenChannel_set_revocation_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
824 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
826 /// A payment key to sender for transactions broadcast by counterparty
828 pub extern "C" fn OpenChannel_get_payment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
829 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_point;
830 crate::c_types::PublicKey::from_rust(&inner_val)
832 /// A payment key to sender for transactions broadcast by counterparty
834 pub extern "C" fn OpenChannel_set_payment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
835 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_point = val.into_rust();
837 /// Used to derive a payment key to sender for transactions broadcast by sender
839 pub extern "C" fn OpenChannel_get_delayed_payment_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
840 let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
841 crate::c_types::PublicKey::from_rust(&inner_val)
843 /// Used to derive a payment key to sender for transactions broadcast by sender
845 pub extern "C" fn OpenChannel_set_delayed_payment_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
846 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
848 /// Used to derive an HTLC payment key to sender
850 pub extern "C" fn OpenChannel_get_htlc_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
851 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
852 crate::c_types::PublicKey::from_rust(&inner_val)
854 /// Used to derive an HTLC payment key to sender
856 pub extern "C" fn OpenChannel_set_htlc_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
857 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
859 /// The first to-be-broadcast-by-sender transaction's per commitment point
861 pub extern "C" fn OpenChannel_get_first_per_commitment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
862 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
863 crate::c_types::PublicKey::from_rust(&inner_val)
865 /// The first to-be-broadcast-by-sender transaction's per commitment point
867 pub extern "C" fn OpenChannel_set_first_per_commitment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
868 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
872 pub extern "C" fn OpenChannel_get_channel_flags(this_ptr: &OpenChannel) -> u8 {
873 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_flags;
878 pub extern "C" fn OpenChannel_set_channel_flags(this_ptr: &mut OpenChannel, mut val: u8) {
879 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_flags = val;
881 /// The channel type that this channel will represent. If none is set, we derive the channel
882 /// type from the intersection of our feature bits with our counterparty's feature bits from
883 /// the Init message.
885 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
887 pub extern "C" fn OpenChannel_get_channel_type(this_ptr: &OpenChannel) -> crate::lightning::ln::features::ChannelTypeFeatures {
888 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
889 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 };
892 /// The channel type that this channel will represent. If none is set, we derive the channel
893 /// type from the intersection of our feature bits with our counterparty's feature bits from
894 /// the Init message.
896 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
898 pub extern "C" fn OpenChannel_set_channel_type(this_ptr: &mut OpenChannel, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
899 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
900 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
902 impl Clone for OpenChannel {
903 fn clone(&self) -> Self {
905 inner: if <*mut nativeOpenChannel>::is_null(self.inner) { core::ptr::null_mut() } else {
906 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
912 /// Used only if an object of this type is returned as a trait impl by a method
913 pub(crate) extern "C" fn OpenChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
914 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOpenChannel)).clone() })) as *mut c_void
917 /// Creates a copy of the OpenChannel
918 pub extern "C" fn OpenChannel_clone(orig: &OpenChannel) -> OpenChannel {
922 use lightning::ln::msgs::AcceptChannel as nativeAcceptChannelImport;
923 pub(crate) type nativeAcceptChannel = nativeAcceptChannelImport;
925 /// An accept_channel message to be sent or received from a peer
928 pub struct AcceptChannel {
929 /// A pointer to the opaque Rust object.
931 /// Nearly everywhere, inner must be non-null, however in places where
932 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
933 pub inner: *mut nativeAcceptChannel,
934 /// Indicates that this is the only struct which contains the same pointer.
936 /// Rust functions which take ownership of an object provided via an argument require
937 /// this to be true and invalidate the object pointed to by inner.
941 impl Drop for AcceptChannel {
943 if self.is_owned && !<*mut nativeAcceptChannel>::is_null(self.inner) {
944 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
948 /// Frees any resources used by the AcceptChannel, if is_owned is set and inner is non-NULL.
950 pub extern "C" fn AcceptChannel_free(this_obj: AcceptChannel) { }
952 /// Used only if an object of this type is returned as a trait impl by a method
953 pub(crate) extern "C" fn AcceptChannel_free_void(this_ptr: *mut c_void) {
954 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeAcceptChannel); }
958 pub(crate) fn get_native_ref(&self) -> &'static nativeAcceptChannel {
959 unsafe { &*ObjOps::untweak_ptr(self.inner) }
961 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAcceptChannel {
962 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
964 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
965 pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannel {
966 assert!(self.is_owned);
967 let ret = ObjOps::untweak_ptr(self.inner);
968 self.inner = core::ptr::null_mut();
972 /// A temporary channel ID, until the funding outpoint is announced
974 pub extern "C" fn AcceptChannel_get_temporary_channel_id(this_ptr: &AcceptChannel) -> *const [u8; 32] {
975 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
978 /// A temporary channel ID, until the funding outpoint is announced
980 pub extern "C" fn AcceptChannel_set_temporary_channel_id(this_ptr: &mut AcceptChannel, mut val: crate::c_types::ThirtyTwoBytes) {
981 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
983 /// The threshold below which outputs on transactions broadcast by sender will be omitted
985 pub extern "C" fn AcceptChannel_get_dust_limit_satoshis(this_ptr: &AcceptChannel) -> u64 {
986 let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
989 /// The threshold below which outputs on transactions broadcast by sender will be omitted
991 pub extern "C" fn AcceptChannel_set_dust_limit_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
992 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
994 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
996 pub extern "C" fn AcceptChannel_get_max_htlc_value_in_flight_msat(this_ptr: &AcceptChannel) -> u64 {
997 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
1000 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
1002 pub extern "C" fn AcceptChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
1003 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
1005 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1007 pub extern "C" fn AcceptChannel_get_channel_reserve_satoshis(this_ptr: &AcceptChannel) -> u64 {
1008 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
1011 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
1013 pub extern "C" fn AcceptChannel_set_channel_reserve_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
1014 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
1016 /// The minimum HTLC size incoming to sender, in milli-satoshi
1018 pub extern "C" fn AcceptChannel_get_htlc_minimum_msat(this_ptr: &AcceptChannel) -> u64 {
1019 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
1022 /// The minimum HTLC size incoming to sender, in milli-satoshi
1024 pub extern "C" fn AcceptChannel_set_htlc_minimum_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
1025 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
1027 /// Minimum depth of the funding transaction before the channel is considered open
1029 pub extern "C" fn AcceptChannel_get_minimum_depth(this_ptr: &AcceptChannel) -> u32 {
1030 let mut inner_val = &mut this_ptr.get_native_mut_ref().minimum_depth;
1033 /// Minimum depth of the funding transaction before the channel is considered open
1035 pub extern "C" fn AcceptChannel_set_minimum_depth(this_ptr: &mut AcceptChannel, mut val: u32) {
1036 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.minimum_depth = val;
1038 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
1040 pub extern "C" fn AcceptChannel_get_to_self_delay(this_ptr: &AcceptChannel) -> u16 {
1041 let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
1044 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
1046 pub extern "C" fn AcceptChannel_set_to_self_delay(this_ptr: &mut AcceptChannel, mut val: u16) {
1047 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
1049 /// The maximum number of inbound HTLCs towards sender
1051 pub extern "C" fn AcceptChannel_get_max_accepted_htlcs(this_ptr: &AcceptChannel) -> u16 {
1052 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
1055 /// The maximum number of inbound HTLCs towards sender
1057 pub extern "C" fn AcceptChannel_set_max_accepted_htlcs(this_ptr: &mut AcceptChannel, mut val: u16) {
1058 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
1060 /// The sender's key controlling the funding transaction
1062 pub extern "C" fn AcceptChannel_get_funding_pubkey(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1063 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
1064 crate::c_types::PublicKey::from_rust(&inner_val)
1066 /// The sender's key controlling the funding transaction
1068 pub extern "C" fn AcceptChannel_set_funding_pubkey(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1069 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
1071 /// Used to derive a revocation key for transactions broadcast by counterparty
1073 pub extern "C" fn AcceptChannel_get_revocation_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1074 let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
1075 crate::c_types::PublicKey::from_rust(&inner_val)
1077 /// Used to derive a revocation key for transactions broadcast by counterparty
1079 pub extern "C" fn AcceptChannel_set_revocation_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1080 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
1082 /// A payment key to sender for transactions broadcast by counterparty
1084 pub extern "C" fn AcceptChannel_get_payment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1085 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_point;
1086 crate::c_types::PublicKey::from_rust(&inner_val)
1088 /// A payment key to sender for transactions broadcast by counterparty
1090 pub extern "C" fn AcceptChannel_set_payment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1091 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_point = val.into_rust();
1093 /// Used to derive a payment key to sender for transactions broadcast by sender
1095 pub extern "C" fn AcceptChannel_get_delayed_payment_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1096 let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
1097 crate::c_types::PublicKey::from_rust(&inner_val)
1099 /// Used to derive a payment key to sender for transactions broadcast by sender
1101 pub extern "C" fn AcceptChannel_set_delayed_payment_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1102 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
1104 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
1106 pub extern "C" fn AcceptChannel_get_htlc_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1107 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
1108 crate::c_types::PublicKey::from_rust(&inner_val)
1110 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
1112 pub extern "C" fn AcceptChannel_set_htlc_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1113 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
1115 /// The first to-be-broadcast-by-sender transaction's per commitment point
1117 pub extern "C" fn AcceptChannel_get_first_per_commitment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
1118 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
1119 crate::c_types::PublicKey::from_rust(&inner_val)
1121 /// The first to-be-broadcast-by-sender transaction's per commitment point
1123 pub extern "C" fn AcceptChannel_set_first_per_commitment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
1124 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
1126 /// The channel type that this channel will represent. If none is set, we derive the channel
1127 /// type from the intersection of our feature bits with our counterparty's feature bits from
1128 /// the Init message.
1130 /// This is required to match the equivalent field in [`OpenChannel::channel_type`].
1132 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1134 pub extern "C" fn AcceptChannel_get_channel_type(this_ptr: &AcceptChannel) -> crate::lightning::ln::features::ChannelTypeFeatures {
1135 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1136 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 };
1139 /// The channel type that this channel will represent. If none is set, we derive the channel
1140 /// type from the intersection of our feature bits with our counterparty's feature bits from
1141 /// the Init message.
1143 /// This is required to match the equivalent field in [`OpenChannel::channel_type`].
1145 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1147 pub extern "C" fn AcceptChannel_set_channel_type(this_ptr: &mut AcceptChannel, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1148 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1149 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1151 impl Clone for AcceptChannel {
1152 fn clone(&self) -> Self {
1154 inner: if <*mut nativeAcceptChannel>::is_null(self.inner) { core::ptr::null_mut() } else {
1155 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1161 /// Used only if an object of this type is returned as a trait impl by a method
1162 pub(crate) extern "C" fn AcceptChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
1163 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAcceptChannel)).clone() })) as *mut c_void
1166 /// Creates a copy of the AcceptChannel
1167 pub extern "C" fn AcceptChannel_clone(orig: &AcceptChannel) -> AcceptChannel {
1171 use lightning::ln::msgs::FundingCreated as nativeFundingCreatedImport;
1172 pub(crate) type nativeFundingCreated = nativeFundingCreatedImport;
1174 /// A funding_created message to be sent or received from a peer
1177 pub struct FundingCreated {
1178 /// A pointer to the opaque Rust object.
1180 /// Nearly everywhere, inner must be non-null, however in places where
1181 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1182 pub inner: *mut nativeFundingCreated,
1183 /// Indicates that this is the only struct which contains the same pointer.
1185 /// Rust functions which take ownership of an object provided via an argument require
1186 /// this to be true and invalidate the object pointed to by inner.
1190 impl Drop for FundingCreated {
1191 fn drop(&mut self) {
1192 if self.is_owned && !<*mut nativeFundingCreated>::is_null(self.inner) {
1193 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1197 /// Frees any resources used by the FundingCreated, if is_owned is set and inner is non-NULL.
1199 pub extern "C" fn FundingCreated_free(this_obj: FundingCreated) { }
1201 /// Used only if an object of this type is returned as a trait impl by a method
1202 pub(crate) extern "C" fn FundingCreated_free_void(this_ptr: *mut c_void) {
1203 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingCreated); }
1206 impl FundingCreated {
1207 pub(crate) fn get_native_ref(&self) -> &'static nativeFundingCreated {
1208 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1210 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingCreated {
1211 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1213 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1214 pub(crate) fn take_inner(mut self) -> *mut nativeFundingCreated {
1215 assert!(self.is_owned);
1216 let ret = ObjOps::untweak_ptr(self.inner);
1217 self.inner = core::ptr::null_mut();
1221 /// A temporary channel ID, until the funding is established
1223 pub extern "C" fn FundingCreated_get_temporary_channel_id(this_ptr: &FundingCreated) -> *const [u8; 32] {
1224 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
1227 /// A temporary channel ID, until the funding is established
1229 pub extern "C" fn FundingCreated_set_temporary_channel_id(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
1230 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
1232 /// The funding transaction ID
1234 pub extern "C" fn FundingCreated_get_funding_txid(this_ptr: &FundingCreated) -> *const [u8; 32] {
1235 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_txid;
1236 inner_val.as_inner()
1238 /// The funding transaction ID
1240 pub extern "C" fn FundingCreated_set_funding_txid(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
1241 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_txid = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
1243 /// The specific output index funding this channel
1245 pub extern "C" fn FundingCreated_get_funding_output_index(this_ptr: &FundingCreated) -> u16 {
1246 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_index;
1249 /// The specific output index funding this channel
1251 pub extern "C" fn FundingCreated_set_funding_output_index(this_ptr: &mut FundingCreated, mut val: u16) {
1252 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_index = val;
1254 /// The signature of the channel initiator (funder) on the initial commitment transaction
1256 pub extern "C" fn FundingCreated_get_signature(this_ptr: &FundingCreated) -> crate::c_types::Signature {
1257 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
1258 crate::c_types::Signature::from_rust(&inner_val)
1260 /// The signature of the channel initiator (funder) on the initial commitment transaction
1262 pub extern "C" fn FundingCreated_set_signature(this_ptr: &mut FundingCreated, mut val: crate::c_types::Signature) {
1263 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
1265 /// Constructs a new FundingCreated given each field
1268 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 {
1269 FundingCreated { inner: ObjOps::heap_alloc(nativeFundingCreated {
1270 temporary_channel_id: temporary_channel_id_arg.data,
1271 funding_txid: ::bitcoin::hash_types::Txid::from_slice(&funding_txid_arg.data[..]).unwrap(),
1272 funding_output_index: funding_output_index_arg,
1273 signature: signature_arg.into_rust(),
1274 }), is_owned: true }
1276 impl Clone for FundingCreated {
1277 fn clone(&self) -> Self {
1279 inner: if <*mut nativeFundingCreated>::is_null(self.inner) { core::ptr::null_mut() } else {
1280 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1286 /// Used only if an object of this type is returned as a trait impl by a method
1287 pub(crate) extern "C" fn FundingCreated_clone_void(this_ptr: *const c_void) -> *mut c_void {
1288 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingCreated)).clone() })) as *mut c_void
1291 /// Creates a copy of the FundingCreated
1292 pub extern "C" fn FundingCreated_clone(orig: &FundingCreated) -> FundingCreated {
1296 use lightning::ln::msgs::FundingSigned as nativeFundingSignedImport;
1297 pub(crate) type nativeFundingSigned = nativeFundingSignedImport;
1299 /// A funding_signed message to be sent or received from a peer
1302 pub struct FundingSigned {
1303 /// A pointer to the opaque Rust object.
1305 /// Nearly everywhere, inner must be non-null, however in places where
1306 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1307 pub inner: *mut nativeFundingSigned,
1308 /// Indicates that this is the only struct which contains the same pointer.
1310 /// Rust functions which take ownership of an object provided via an argument require
1311 /// this to be true and invalidate the object pointed to by inner.
1315 impl Drop for FundingSigned {
1316 fn drop(&mut self) {
1317 if self.is_owned && !<*mut nativeFundingSigned>::is_null(self.inner) {
1318 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1322 /// Frees any resources used by the FundingSigned, if is_owned is set and inner is non-NULL.
1324 pub extern "C" fn FundingSigned_free(this_obj: FundingSigned) { }
1326 /// Used only if an object of this type is returned as a trait impl by a method
1327 pub(crate) extern "C" fn FundingSigned_free_void(this_ptr: *mut c_void) {
1328 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingSigned); }
1331 impl FundingSigned {
1332 pub(crate) fn get_native_ref(&self) -> &'static nativeFundingSigned {
1333 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1335 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingSigned {
1336 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1338 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1339 pub(crate) fn take_inner(mut self) -> *mut nativeFundingSigned {
1340 assert!(self.is_owned);
1341 let ret = ObjOps::untweak_ptr(self.inner);
1342 self.inner = core::ptr::null_mut();
1348 pub extern "C" fn FundingSigned_get_channel_id(this_ptr: &FundingSigned) -> *const [u8; 32] {
1349 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1354 pub extern "C" fn FundingSigned_set_channel_id(this_ptr: &mut FundingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
1355 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1357 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
1359 pub extern "C" fn FundingSigned_get_signature(this_ptr: &FundingSigned) -> crate::c_types::Signature {
1360 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
1361 crate::c_types::Signature::from_rust(&inner_val)
1363 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
1365 pub extern "C" fn FundingSigned_set_signature(this_ptr: &mut FundingSigned, mut val: crate::c_types::Signature) {
1366 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
1368 /// Constructs a new FundingSigned given each field
1371 pub extern "C" fn FundingSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut signature_arg: crate::c_types::Signature) -> FundingSigned {
1372 FundingSigned { inner: ObjOps::heap_alloc(nativeFundingSigned {
1373 channel_id: channel_id_arg.data,
1374 signature: signature_arg.into_rust(),
1375 }), is_owned: true }
1377 impl Clone for FundingSigned {
1378 fn clone(&self) -> Self {
1380 inner: if <*mut nativeFundingSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
1381 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1387 /// Used only if an object of this type is returned as a trait impl by a method
1388 pub(crate) extern "C" fn FundingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
1389 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingSigned)).clone() })) as *mut c_void
1392 /// Creates a copy of the FundingSigned
1393 pub extern "C" fn FundingSigned_clone(orig: &FundingSigned) -> FundingSigned {
1397 use lightning::ln::msgs::ChannelReady as nativeChannelReadyImport;
1398 pub(crate) type nativeChannelReady = nativeChannelReadyImport;
1400 /// A channel_ready message to be sent or received from a peer
1403 pub struct ChannelReady {
1404 /// A pointer to the opaque Rust object.
1406 /// Nearly everywhere, inner must be non-null, however in places where
1407 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1408 pub inner: *mut nativeChannelReady,
1409 /// Indicates that this is the only struct which contains the same pointer.
1411 /// Rust functions which take ownership of an object provided via an argument require
1412 /// this to be true and invalidate the object pointed to by inner.
1416 impl Drop for ChannelReady {
1417 fn drop(&mut self) {
1418 if self.is_owned && !<*mut nativeChannelReady>::is_null(self.inner) {
1419 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1423 /// Frees any resources used by the ChannelReady, if is_owned is set and inner is non-NULL.
1425 pub extern "C" fn ChannelReady_free(this_obj: ChannelReady) { }
1427 /// Used only if an object of this type is returned as a trait impl by a method
1428 pub(crate) extern "C" fn ChannelReady_free_void(this_ptr: *mut c_void) {
1429 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelReady); }
1433 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelReady {
1434 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1436 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelReady {
1437 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1439 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1440 pub(crate) fn take_inner(mut self) -> *mut nativeChannelReady {
1441 assert!(self.is_owned);
1442 let ret = ObjOps::untweak_ptr(self.inner);
1443 self.inner = core::ptr::null_mut();
1449 pub extern "C" fn ChannelReady_get_channel_id(this_ptr: &ChannelReady) -> *const [u8; 32] {
1450 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1455 pub extern "C" fn ChannelReady_set_channel_id(this_ptr: &mut ChannelReady, mut val: crate::c_types::ThirtyTwoBytes) {
1456 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1458 /// The per-commitment point of the second commitment transaction
1460 pub extern "C" fn ChannelReady_get_next_per_commitment_point(this_ptr: &ChannelReady) -> crate::c_types::PublicKey {
1461 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
1462 crate::c_types::PublicKey::from_rust(&inner_val)
1464 /// The per-commitment point of the second commitment transaction
1466 pub extern "C" fn ChannelReady_set_next_per_commitment_point(this_ptr: &mut ChannelReady, mut val: crate::c_types::PublicKey) {
1467 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
1469 /// If set, provides a short_channel_id alias for this channel. The sender will accept payments
1470 /// to be forwarded over this SCID and forward them to this messages' recipient.
1472 pub extern "C" fn ChannelReady_get_short_channel_id_alias(this_ptr: &ChannelReady) -> crate::c_types::derived::COption_u64Z {
1473 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id_alias;
1474 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) };
1477 /// If set, provides a short_channel_id alias for this channel. The sender will accept payments
1478 /// to be forwarded over this SCID and forward them to this messages' recipient.
1480 pub extern "C" fn ChannelReady_set_short_channel_id_alias(this_ptr: &mut ChannelReady, mut val: crate::c_types::derived::COption_u64Z) {
1481 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1482 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id_alias = local_val;
1484 /// Constructs a new ChannelReady given each field
1487 pub extern "C" fn ChannelReady_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut next_per_commitment_point_arg: crate::c_types::PublicKey, mut short_channel_id_alias_arg: crate::c_types::derived::COption_u64Z) -> ChannelReady {
1488 let mut local_short_channel_id_alias_arg = if short_channel_id_alias_arg.is_some() { Some( { short_channel_id_alias_arg.take() }) } else { None };
1489 ChannelReady { inner: ObjOps::heap_alloc(nativeChannelReady {
1490 channel_id: channel_id_arg.data,
1491 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
1492 short_channel_id_alias: local_short_channel_id_alias_arg,
1493 }), is_owned: true }
1495 impl Clone for ChannelReady {
1496 fn clone(&self) -> Self {
1498 inner: if <*mut nativeChannelReady>::is_null(self.inner) { core::ptr::null_mut() } else {
1499 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1505 /// Used only if an object of this type is returned as a trait impl by a method
1506 pub(crate) extern "C" fn ChannelReady_clone_void(this_ptr: *const c_void) -> *mut c_void {
1507 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelReady)).clone() })) as *mut c_void
1510 /// Creates a copy of the ChannelReady
1511 pub extern "C" fn ChannelReady_clone(orig: &ChannelReady) -> ChannelReady {
1515 use lightning::ln::msgs::Shutdown as nativeShutdownImport;
1516 pub(crate) type nativeShutdown = nativeShutdownImport;
1518 /// A shutdown message to be sent or received from a peer
1521 pub struct Shutdown {
1522 /// A pointer to the opaque Rust object.
1524 /// Nearly everywhere, inner must be non-null, however in places where
1525 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1526 pub inner: *mut nativeShutdown,
1527 /// Indicates that this is the only struct which contains the same pointer.
1529 /// Rust functions which take ownership of an object provided via an argument require
1530 /// this to be true and invalidate the object pointed to by inner.
1534 impl Drop for Shutdown {
1535 fn drop(&mut self) {
1536 if self.is_owned && !<*mut nativeShutdown>::is_null(self.inner) {
1537 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1541 /// Frees any resources used by the Shutdown, if is_owned is set and inner is non-NULL.
1543 pub extern "C" fn Shutdown_free(this_obj: Shutdown) { }
1545 /// Used only if an object of this type is returned as a trait impl by a method
1546 pub(crate) extern "C" fn Shutdown_free_void(this_ptr: *mut c_void) {
1547 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeShutdown); }
1551 pub(crate) fn get_native_ref(&self) -> &'static nativeShutdown {
1552 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1554 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeShutdown {
1555 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1557 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1558 pub(crate) fn take_inner(mut self) -> *mut nativeShutdown {
1559 assert!(self.is_owned);
1560 let ret = ObjOps::untweak_ptr(self.inner);
1561 self.inner = core::ptr::null_mut();
1567 pub extern "C" fn Shutdown_get_channel_id(this_ptr: &Shutdown) -> *const [u8; 32] {
1568 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1573 pub extern "C" fn Shutdown_set_channel_id(this_ptr: &mut Shutdown, mut val: crate::c_types::ThirtyTwoBytes) {
1574 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1576 /// The destination of this peer's funds on closing.
1577 /// Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
1579 pub extern "C" fn Shutdown_get_scriptpubkey(this_ptr: &Shutdown) -> crate::c_types::u8slice {
1580 let mut inner_val = &mut this_ptr.get_native_mut_ref().scriptpubkey;
1581 crate::c_types::u8slice::from_slice(&inner_val[..])
1583 /// The destination of this peer's funds on closing.
1584 /// Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
1586 pub extern "C" fn Shutdown_set_scriptpubkey(this_ptr: &mut Shutdown, mut val: crate::c_types::derived::CVec_u8Z) {
1587 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.scriptpubkey = ::bitcoin::blockdata::script::Script::from(val.into_rust());
1589 /// Constructs a new Shutdown given each field
1592 pub extern "C" fn Shutdown_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut scriptpubkey_arg: crate::c_types::derived::CVec_u8Z) -> Shutdown {
1593 Shutdown { inner: ObjOps::heap_alloc(nativeShutdown {
1594 channel_id: channel_id_arg.data,
1595 scriptpubkey: ::bitcoin::blockdata::script::Script::from(scriptpubkey_arg.into_rust()),
1596 }), is_owned: true }
1598 impl Clone for Shutdown {
1599 fn clone(&self) -> Self {
1601 inner: if <*mut nativeShutdown>::is_null(self.inner) { core::ptr::null_mut() } else {
1602 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1608 /// Used only if an object of this type is returned as a trait impl by a method
1609 pub(crate) extern "C" fn Shutdown_clone_void(this_ptr: *const c_void) -> *mut c_void {
1610 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeShutdown)).clone() })) as *mut c_void
1613 /// Creates a copy of the Shutdown
1614 pub extern "C" fn Shutdown_clone(orig: &Shutdown) -> Shutdown {
1618 use lightning::ln::msgs::ClosingSignedFeeRange as nativeClosingSignedFeeRangeImport;
1619 pub(crate) type nativeClosingSignedFeeRange = nativeClosingSignedFeeRangeImport;
1621 /// The minimum and maximum fees which the sender is willing to place on the closing transaction.
1622 /// This is provided in [`ClosingSigned`] by both sides to indicate the fee range they are willing
1626 pub struct ClosingSignedFeeRange {
1627 /// A pointer to the opaque Rust object.
1629 /// Nearly everywhere, inner must be non-null, however in places where
1630 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1631 pub inner: *mut nativeClosingSignedFeeRange,
1632 /// Indicates that this is the only struct which contains the same pointer.
1634 /// Rust functions which take ownership of an object provided via an argument require
1635 /// this to be true and invalidate the object pointed to by inner.
1639 impl Drop for ClosingSignedFeeRange {
1640 fn drop(&mut self) {
1641 if self.is_owned && !<*mut nativeClosingSignedFeeRange>::is_null(self.inner) {
1642 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1646 /// Frees any resources used by the ClosingSignedFeeRange, if is_owned is set and inner is non-NULL.
1648 pub extern "C" fn ClosingSignedFeeRange_free(this_obj: ClosingSignedFeeRange) { }
1650 /// Used only if an object of this type is returned as a trait impl by a method
1651 pub(crate) extern "C" fn ClosingSignedFeeRange_free_void(this_ptr: *mut c_void) {
1652 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeClosingSignedFeeRange); }
1655 impl ClosingSignedFeeRange {
1656 pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSignedFeeRange {
1657 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1659 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSignedFeeRange {
1660 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1662 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1663 pub(crate) fn take_inner(mut self) -> *mut nativeClosingSignedFeeRange {
1664 assert!(self.is_owned);
1665 let ret = ObjOps::untweak_ptr(self.inner);
1666 self.inner = core::ptr::null_mut();
1670 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
1673 pub extern "C" fn ClosingSignedFeeRange_get_min_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
1674 let mut inner_val = &mut this_ptr.get_native_mut_ref().min_fee_satoshis;
1677 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
1680 pub extern "C" fn ClosingSignedFeeRange_set_min_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
1681 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_fee_satoshis = val;
1683 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
1686 pub extern "C" fn ClosingSignedFeeRange_get_max_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
1687 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_fee_satoshis;
1690 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
1693 pub extern "C" fn ClosingSignedFeeRange_set_max_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
1694 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_fee_satoshis = val;
1696 /// Constructs a new ClosingSignedFeeRange given each field
1699 pub extern "C" fn ClosingSignedFeeRange_new(mut min_fee_satoshis_arg: u64, mut max_fee_satoshis_arg: u64) -> ClosingSignedFeeRange {
1700 ClosingSignedFeeRange { inner: ObjOps::heap_alloc(nativeClosingSignedFeeRange {
1701 min_fee_satoshis: min_fee_satoshis_arg,
1702 max_fee_satoshis: max_fee_satoshis_arg,
1703 }), is_owned: true }
1705 impl Clone for ClosingSignedFeeRange {
1706 fn clone(&self) -> Self {
1708 inner: if <*mut nativeClosingSignedFeeRange>::is_null(self.inner) { core::ptr::null_mut() } else {
1709 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1715 /// Used only if an object of this type is returned as a trait impl by a method
1716 pub(crate) extern "C" fn ClosingSignedFeeRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
1717 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClosingSignedFeeRange)).clone() })) as *mut c_void
1720 /// Creates a copy of the ClosingSignedFeeRange
1721 pub extern "C" fn ClosingSignedFeeRange_clone(orig: &ClosingSignedFeeRange) -> ClosingSignedFeeRange {
1725 use lightning::ln::msgs::ClosingSigned as nativeClosingSignedImport;
1726 pub(crate) type nativeClosingSigned = nativeClosingSignedImport;
1728 /// A closing_signed message to be sent or received from a peer
1731 pub struct ClosingSigned {
1732 /// A pointer to the opaque Rust object.
1734 /// Nearly everywhere, inner must be non-null, however in places where
1735 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1736 pub inner: *mut nativeClosingSigned,
1737 /// Indicates that this is the only struct which contains the same pointer.
1739 /// Rust functions which take ownership of an object provided via an argument require
1740 /// this to be true and invalidate the object pointed to by inner.
1744 impl Drop for ClosingSigned {
1745 fn drop(&mut self) {
1746 if self.is_owned && !<*mut nativeClosingSigned>::is_null(self.inner) {
1747 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1751 /// Frees any resources used by the ClosingSigned, if is_owned is set and inner is non-NULL.
1753 pub extern "C" fn ClosingSigned_free(this_obj: ClosingSigned) { }
1755 /// Used only if an object of this type is returned as a trait impl by a method
1756 pub(crate) extern "C" fn ClosingSigned_free_void(this_ptr: *mut c_void) {
1757 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeClosingSigned); }
1760 impl ClosingSigned {
1761 pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSigned {
1762 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1764 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSigned {
1765 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1767 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1768 pub(crate) fn take_inner(mut self) -> *mut nativeClosingSigned {
1769 assert!(self.is_owned);
1770 let ret = ObjOps::untweak_ptr(self.inner);
1771 self.inner = core::ptr::null_mut();
1777 pub extern "C" fn ClosingSigned_get_channel_id(this_ptr: &ClosingSigned) -> *const [u8; 32] {
1778 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1783 pub extern "C" fn ClosingSigned_set_channel_id(this_ptr: &mut ClosingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
1784 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1786 /// The proposed total fee for the closing transaction
1788 pub extern "C" fn ClosingSigned_get_fee_satoshis(this_ptr: &ClosingSigned) -> u64 {
1789 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_satoshis;
1792 /// The proposed total fee for the closing transaction
1794 pub extern "C" fn ClosingSigned_set_fee_satoshis(this_ptr: &mut ClosingSigned, mut val: u64) {
1795 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_satoshis = val;
1797 /// A signature on the closing transaction
1799 pub extern "C" fn ClosingSigned_get_signature(this_ptr: &ClosingSigned) -> crate::c_types::Signature {
1800 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
1801 crate::c_types::Signature::from_rust(&inner_val)
1803 /// A signature on the closing transaction
1805 pub extern "C" fn ClosingSigned_set_signature(this_ptr: &mut ClosingSigned, mut val: crate::c_types::Signature) {
1806 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
1808 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
1811 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1813 pub extern "C" fn ClosingSigned_get_fee_range(this_ptr: &ClosingSigned) -> crate::lightning::ln::msgs::ClosingSignedFeeRange {
1814 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_range;
1815 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 };
1818 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
1821 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1823 pub extern "C" fn ClosingSigned_set_fee_range(this_ptr: &mut ClosingSigned, mut val: crate::lightning::ln::msgs::ClosingSignedFeeRange) {
1824 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1825 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_range = local_val;
1827 /// Constructs a new ClosingSigned given each field
1830 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 {
1831 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()) } }) };
1832 ClosingSigned { inner: ObjOps::heap_alloc(nativeClosingSigned {
1833 channel_id: channel_id_arg.data,
1834 fee_satoshis: fee_satoshis_arg,
1835 signature: signature_arg.into_rust(),
1836 fee_range: local_fee_range_arg,
1837 }), is_owned: true }
1839 impl Clone for ClosingSigned {
1840 fn clone(&self) -> Self {
1842 inner: if <*mut nativeClosingSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
1843 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1849 /// Used only if an object of this type is returned as a trait impl by a method
1850 pub(crate) extern "C" fn ClosingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
1851 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClosingSigned)).clone() })) as *mut c_void
1854 /// Creates a copy of the ClosingSigned
1855 pub extern "C" fn ClosingSigned_clone(orig: &ClosingSigned) -> ClosingSigned {
1859 use lightning::ln::msgs::UpdateAddHTLC as nativeUpdateAddHTLCImport;
1860 pub(crate) type nativeUpdateAddHTLC = nativeUpdateAddHTLCImport;
1862 /// An update_add_htlc message to be sent or received from a peer
1865 pub struct UpdateAddHTLC {
1866 /// A pointer to the opaque Rust object.
1868 /// Nearly everywhere, inner must be non-null, however in places where
1869 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1870 pub inner: *mut nativeUpdateAddHTLC,
1871 /// Indicates that this is the only struct which contains the same pointer.
1873 /// Rust functions which take ownership of an object provided via an argument require
1874 /// this to be true and invalidate the object pointed to by inner.
1878 impl Drop for UpdateAddHTLC {
1879 fn drop(&mut self) {
1880 if self.is_owned && !<*mut nativeUpdateAddHTLC>::is_null(self.inner) {
1881 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1885 /// Frees any resources used by the UpdateAddHTLC, if is_owned is set and inner is non-NULL.
1887 pub extern "C" fn UpdateAddHTLC_free(this_obj: UpdateAddHTLC) { }
1889 /// Used only if an object of this type is returned as a trait impl by a method
1890 pub(crate) extern "C" fn UpdateAddHTLC_free_void(this_ptr: *mut c_void) {
1891 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateAddHTLC); }
1894 impl UpdateAddHTLC {
1895 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateAddHTLC {
1896 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1898 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateAddHTLC {
1899 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1901 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1902 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateAddHTLC {
1903 assert!(self.is_owned);
1904 let ret = ObjOps::untweak_ptr(self.inner);
1905 self.inner = core::ptr::null_mut();
1911 pub extern "C" fn UpdateAddHTLC_get_channel_id(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
1912 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1917 pub extern "C" fn UpdateAddHTLC_set_channel_id(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1918 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1922 pub extern "C" fn UpdateAddHTLC_get_htlc_id(this_ptr: &UpdateAddHTLC) -> u64 {
1923 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
1928 pub extern "C" fn UpdateAddHTLC_set_htlc_id(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
1929 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
1931 /// The HTLC value in milli-satoshi
1933 pub extern "C" fn UpdateAddHTLC_get_amount_msat(this_ptr: &UpdateAddHTLC) -> u64 {
1934 let mut inner_val = &mut this_ptr.get_native_mut_ref().amount_msat;
1937 /// The HTLC value in milli-satoshi
1939 pub extern "C" fn UpdateAddHTLC_set_amount_msat(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
1940 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.amount_msat = val;
1942 /// The payment hash, the pre-image of which controls HTLC redemption
1944 pub extern "C" fn UpdateAddHTLC_get_payment_hash(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
1945 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_hash;
1948 /// The payment hash, the pre-image of which controls HTLC redemption
1950 pub extern "C" fn UpdateAddHTLC_set_payment_hash(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1951 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_hash = ::lightning::ln::PaymentHash(val.data);
1953 /// The expiry height of the HTLC
1955 pub extern "C" fn UpdateAddHTLC_get_cltv_expiry(this_ptr: &UpdateAddHTLC) -> u32 {
1956 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry;
1959 /// The expiry height of the HTLC
1961 pub extern "C" fn UpdateAddHTLC_set_cltv_expiry(this_ptr: &mut UpdateAddHTLC, mut val: u32) {
1962 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry = val;
1964 impl Clone for UpdateAddHTLC {
1965 fn clone(&self) -> Self {
1967 inner: if <*mut nativeUpdateAddHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
1968 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1974 /// Used only if an object of this type is returned as a trait impl by a method
1975 pub(crate) extern "C" fn UpdateAddHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1976 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateAddHTLC)).clone() })) as *mut c_void
1979 /// Creates a copy of the UpdateAddHTLC
1980 pub extern "C" fn UpdateAddHTLC_clone(orig: &UpdateAddHTLC) -> UpdateAddHTLC {
1984 use lightning::ln::msgs::UpdateFulfillHTLC as nativeUpdateFulfillHTLCImport;
1985 pub(crate) type nativeUpdateFulfillHTLC = nativeUpdateFulfillHTLCImport;
1987 /// An update_fulfill_htlc message to be sent or received from a peer
1990 pub struct UpdateFulfillHTLC {
1991 /// A pointer to the opaque Rust object.
1993 /// Nearly everywhere, inner must be non-null, however in places where
1994 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1995 pub inner: *mut nativeUpdateFulfillHTLC,
1996 /// Indicates that this is the only struct which contains the same pointer.
1998 /// Rust functions which take ownership of an object provided via an argument require
1999 /// this to be true and invalidate the object pointed to by inner.
2003 impl Drop for UpdateFulfillHTLC {
2004 fn drop(&mut self) {
2005 if self.is_owned && !<*mut nativeUpdateFulfillHTLC>::is_null(self.inner) {
2006 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2010 /// Frees any resources used by the UpdateFulfillHTLC, if is_owned is set and inner is non-NULL.
2012 pub extern "C" fn UpdateFulfillHTLC_free(this_obj: UpdateFulfillHTLC) { }
2014 /// Used only if an object of this type is returned as a trait impl by a method
2015 pub(crate) extern "C" fn UpdateFulfillHTLC_free_void(this_ptr: *mut c_void) {
2016 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFulfillHTLC); }
2019 impl UpdateFulfillHTLC {
2020 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFulfillHTLC {
2021 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2023 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFulfillHTLC {
2024 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2026 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2027 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFulfillHTLC {
2028 assert!(self.is_owned);
2029 let ret = ObjOps::untweak_ptr(self.inner);
2030 self.inner = core::ptr::null_mut();
2036 pub extern "C" fn UpdateFulfillHTLC_get_channel_id(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
2037 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2042 pub extern "C" fn UpdateFulfillHTLC_set_channel_id(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
2043 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2047 pub extern "C" fn UpdateFulfillHTLC_get_htlc_id(this_ptr: &UpdateFulfillHTLC) -> u64 {
2048 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
2053 pub extern "C" fn UpdateFulfillHTLC_set_htlc_id(this_ptr: &mut UpdateFulfillHTLC, mut val: u64) {
2054 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
2056 /// The pre-image of the payment hash, allowing HTLC redemption
2058 pub extern "C" fn UpdateFulfillHTLC_get_payment_preimage(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
2059 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_preimage;
2062 /// The pre-image of the payment hash, allowing HTLC redemption
2064 pub extern "C" fn UpdateFulfillHTLC_set_payment_preimage(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
2065 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_preimage = ::lightning::ln::PaymentPreimage(val.data);
2067 /// Constructs a new UpdateFulfillHTLC given each field
2070 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 {
2071 UpdateFulfillHTLC { inner: ObjOps::heap_alloc(nativeUpdateFulfillHTLC {
2072 channel_id: channel_id_arg.data,
2073 htlc_id: htlc_id_arg,
2074 payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_arg.data),
2075 }), is_owned: true }
2077 impl Clone for UpdateFulfillHTLC {
2078 fn clone(&self) -> Self {
2080 inner: if <*mut nativeUpdateFulfillHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
2081 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2087 /// Used only if an object of this type is returned as a trait impl by a method
2088 pub(crate) extern "C" fn UpdateFulfillHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
2089 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFulfillHTLC)).clone() })) as *mut c_void
2092 /// Creates a copy of the UpdateFulfillHTLC
2093 pub extern "C" fn UpdateFulfillHTLC_clone(orig: &UpdateFulfillHTLC) -> UpdateFulfillHTLC {
2097 use lightning::ln::msgs::UpdateFailHTLC as nativeUpdateFailHTLCImport;
2098 pub(crate) type nativeUpdateFailHTLC = nativeUpdateFailHTLCImport;
2100 /// An update_fail_htlc message to be sent or received from a peer
2103 pub struct UpdateFailHTLC {
2104 /// A pointer to the opaque Rust object.
2106 /// Nearly everywhere, inner must be non-null, however in places where
2107 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2108 pub inner: *mut nativeUpdateFailHTLC,
2109 /// Indicates that this is the only struct which contains the same pointer.
2111 /// Rust functions which take ownership of an object provided via an argument require
2112 /// this to be true and invalidate the object pointed to by inner.
2116 impl Drop for UpdateFailHTLC {
2117 fn drop(&mut self) {
2118 if self.is_owned && !<*mut nativeUpdateFailHTLC>::is_null(self.inner) {
2119 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2123 /// Frees any resources used by the UpdateFailHTLC, if is_owned is set and inner is non-NULL.
2125 pub extern "C" fn UpdateFailHTLC_free(this_obj: UpdateFailHTLC) { }
2127 /// Used only if an object of this type is returned as a trait impl by a method
2128 pub(crate) extern "C" fn UpdateFailHTLC_free_void(this_ptr: *mut c_void) {
2129 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFailHTLC); }
2132 impl UpdateFailHTLC {
2133 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailHTLC {
2134 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2136 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailHTLC {
2137 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2139 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2140 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailHTLC {
2141 assert!(self.is_owned);
2142 let ret = ObjOps::untweak_ptr(self.inner);
2143 self.inner = core::ptr::null_mut();
2149 pub extern "C" fn UpdateFailHTLC_get_channel_id(this_ptr: &UpdateFailHTLC) -> *const [u8; 32] {
2150 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2155 pub extern "C" fn UpdateFailHTLC_set_channel_id(this_ptr: &mut UpdateFailHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
2156 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2160 pub extern "C" fn UpdateFailHTLC_get_htlc_id(this_ptr: &UpdateFailHTLC) -> u64 {
2161 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
2166 pub extern "C" fn UpdateFailHTLC_set_htlc_id(this_ptr: &mut UpdateFailHTLC, mut val: u64) {
2167 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
2169 impl Clone for UpdateFailHTLC {
2170 fn clone(&self) -> Self {
2172 inner: if <*mut nativeUpdateFailHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
2173 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2179 /// Used only if an object of this type is returned as a trait impl by a method
2180 pub(crate) extern "C" fn UpdateFailHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
2181 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailHTLC)).clone() })) as *mut c_void
2184 /// Creates a copy of the UpdateFailHTLC
2185 pub extern "C" fn UpdateFailHTLC_clone(orig: &UpdateFailHTLC) -> UpdateFailHTLC {
2189 use lightning::ln::msgs::UpdateFailMalformedHTLC as nativeUpdateFailMalformedHTLCImport;
2190 pub(crate) type nativeUpdateFailMalformedHTLC = nativeUpdateFailMalformedHTLCImport;
2192 /// An update_fail_malformed_htlc message to be sent or received from a peer
2195 pub struct UpdateFailMalformedHTLC {
2196 /// A pointer to the opaque Rust object.
2198 /// Nearly everywhere, inner must be non-null, however in places where
2199 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2200 pub inner: *mut nativeUpdateFailMalformedHTLC,
2201 /// Indicates that this is the only struct which contains the same pointer.
2203 /// Rust functions which take ownership of an object provided via an argument require
2204 /// this to be true and invalidate the object pointed to by inner.
2208 impl Drop for UpdateFailMalformedHTLC {
2209 fn drop(&mut self) {
2210 if self.is_owned && !<*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) {
2211 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2215 /// Frees any resources used by the UpdateFailMalformedHTLC, if is_owned is set and inner is non-NULL.
2217 pub extern "C" fn UpdateFailMalformedHTLC_free(this_obj: UpdateFailMalformedHTLC) { }
2219 /// Used only if an object of this type is returned as a trait impl by a method
2220 pub(crate) extern "C" fn UpdateFailMalformedHTLC_free_void(this_ptr: *mut c_void) {
2221 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFailMalformedHTLC); }
2224 impl UpdateFailMalformedHTLC {
2225 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailMalformedHTLC {
2226 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2228 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailMalformedHTLC {
2229 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2231 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2232 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailMalformedHTLC {
2233 assert!(self.is_owned);
2234 let ret = ObjOps::untweak_ptr(self.inner);
2235 self.inner = core::ptr::null_mut();
2241 pub extern "C" fn UpdateFailMalformedHTLC_get_channel_id(this_ptr: &UpdateFailMalformedHTLC) -> *const [u8; 32] {
2242 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2247 pub extern "C" fn UpdateFailMalformedHTLC_set_channel_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
2248 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2252 pub extern "C" fn UpdateFailMalformedHTLC_get_htlc_id(this_ptr: &UpdateFailMalformedHTLC) -> u64 {
2253 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
2258 pub extern "C" fn UpdateFailMalformedHTLC_set_htlc_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u64) {
2259 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
2261 /// The failure code
2263 pub extern "C" fn UpdateFailMalformedHTLC_get_failure_code(this_ptr: &UpdateFailMalformedHTLC) -> u16 {
2264 let mut inner_val = &mut this_ptr.get_native_mut_ref().failure_code;
2267 /// The failure code
2269 pub extern "C" fn UpdateFailMalformedHTLC_set_failure_code(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u16) {
2270 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.failure_code = val;
2272 impl Clone for UpdateFailMalformedHTLC {
2273 fn clone(&self) -> Self {
2275 inner: if <*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
2276 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2282 /// Used only if an object of this type is returned as a trait impl by a method
2283 pub(crate) extern "C" fn UpdateFailMalformedHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
2284 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailMalformedHTLC)).clone() })) as *mut c_void
2287 /// Creates a copy of the UpdateFailMalformedHTLC
2288 pub extern "C" fn UpdateFailMalformedHTLC_clone(orig: &UpdateFailMalformedHTLC) -> UpdateFailMalformedHTLC {
2292 use lightning::ln::msgs::CommitmentSigned as nativeCommitmentSignedImport;
2293 pub(crate) type nativeCommitmentSigned = nativeCommitmentSignedImport;
2295 /// A commitment_signed message to be sent or received from a peer
2298 pub struct CommitmentSigned {
2299 /// A pointer to the opaque Rust object.
2301 /// Nearly everywhere, inner must be non-null, however in places where
2302 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2303 pub inner: *mut nativeCommitmentSigned,
2304 /// Indicates that this is the only struct which contains the same pointer.
2306 /// Rust functions which take ownership of an object provided via an argument require
2307 /// this to be true and invalidate the object pointed to by inner.
2311 impl Drop for CommitmentSigned {
2312 fn drop(&mut self) {
2313 if self.is_owned && !<*mut nativeCommitmentSigned>::is_null(self.inner) {
2314 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2318 /// Frees any resources used by the CommitmentSigned, if is_owned is set and inner is non-NULL.
2320 pub extern "C" fn CommitmentSigned_free(this_obj: CommitmentSigned) { }
2322 /// Used only if an object of this type is returned as a trait impl by a method
2323 pub(crate) extern "C" fn CommitmentSigned_free_void(this_ptr: *mut c_void) {
2324 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentSigned); }
2327 impl CommitmentSigned {
2328 pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentSigned {
2329 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2331 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentSigned {
2332 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2334 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2335 pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentSigned {
2336 assert!(self.is_owned);
2337 let ret = ObjOps::untweak_ptr(self.inner);
2338 self.inner = core::ptr::null_mut();
2344 pub extern "C" fn CommitmentSigned_get_channel_id(this_ptr: &CommitmentSigned) -> *const [u8; 32] {
2345 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2350 pub extern "C" fn CommitmentSigned_set_channel_id(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::ThirtyTwoBytes) {
2351 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2353 /// A signature on the commitment transaction
2355 pub extern "C" fn CommitmentSigned_get_signature(this_ptr: &CommitmentSigned) -> crate::c_types::Signature {
2356 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
2357 crate::c_types::Signature::from_rust(&inner_val)
2359 /// A signature on the commitment transaction
2361 pub extern "C" fn CommitmentSigned_set_signature(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::Signature) {
2362 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
2364 /// Signatures on the HTLC transactions
2366 /// Returns a copy of the field.
2368 pub extern "C" fn CommitmentSigned_get_htlc_signatures(this_ptr: &CommitmentSigned) -> crate::c_types::derived::CVec_SignatureZ {
2369 let mut inner_val = this_ptr.get_native_mut_ref().htlc_signatures.clone();
2370 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { crate::c_types::Signature::from_rust(&item) }); };
2371 local_inner_val.into()
2373 /// Signatures on the HTLC transactions
2375 pub extern "C" fn CommitmentSigned_set_htlc_signatures(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::derived::CVec_SignatureZ) {
2376 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_rust() }); };
2377 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_signatures = local_val;
2379 /// Constructs a new CommitmentSigned given each field
2382 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 {
2383 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() }); };
2384 CommitmentSigned { inner: ObjOps::heap_alloc(nativeCommitmentSigned {
2385 channel_id: channel_id_arg.data,
2386 signature: signature_arg.into_rust(),
2387 htlc_signatures: local_htlc_signatures_arg,
2388 }), is_owned: true }
2390 impl Clone for CommitmentSigned {
2391 fn clone(&self) -> Self {
2393 inner: if <*mut nativeCommitmentSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
2394 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2400 /// Used only if an object of this type is returned as a trait impl by a method
2401 pub(crate) extern "C" fn CommitmentSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
2402 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentSigned)).clone() })) as *mut c_void
2405 /// Creates a copy of the CommitmentSigned
2406 pub extern "C" fn CommitmentSigned_clone(orig: &CommitmentSigned) -> CommitmentSigned {
2410 use lightning::ln::msgs::RevokeAndACK as nativeRevokeAndACKImport;
2411 pub(crate) type nativeRevokeAndACK = nativeRevokeAndACKImport;
2413 /// A revoke_and_ack message to be sent or received from a peer
2416 pub struct RevokeAndACK {
2417 /// A pointer to the opaque Rust object.
2419 /// Nearly everywhere, inner must be non-null, however in places where
2420 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2421 pub inner: *mut nativeRevokeAndACK,
2422 /// Indicates that this is the only struct which contains the same pointer.
2424 /// Rust functions which take ownership of an object provided via an argument require
2425 /// this to be true and invalidate the object pointed to by inner.
2429 impl Drop for RevokeAndACK {
2430 fn drop(&mut self) {
2431 if self.is_owned && !<*mut nativeRevokeAndACK>::is_null(self.inner) {
2432 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2436 /// Frees any resources used by the RevokeAndACK, if is_owned is set and inner is non-NULL.
2438 pub extern "C" fn RevokeAndACK_free(this_obj: RevokeAndACK) { }
2440 /// Used only if an object of this type is returned as a trait impl by a method
2441 pub(crate) extern "C" fn RevokeAndACK_free_void(this_ptr: *mut c_void) {
2442 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRevokeAndACK); }
2446 pub(crate) fn get_native_ref(&self) -> &'static nativeRevokeAndACK {
2447 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2449 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRevokeAndACK {
2450 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2452 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2453 pub(crate) fn take_inner(mut self) -> *mut nativeRevokeAndACK {
2454 assert!(self.is_owned);
2455 let ret = ObjOps::untweak_ptr(self.inner);
2456 self.inner = core::ptr::null_mut();
2462 pub extern "C" fn RevokeAndACK_get_channel_id(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
2463 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2468 pub extern "C" fn RevokeAndACK_set_channel_id(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
2469 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2471 /// The secret corresponding to the per-commitment point
2473 pub extern "C" fn RevokeAndACK_get_per_commitment_secret(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
2474 let mut inner_val = &mut this_ptr.get_native_mut_ref().per_commitment_secret;
2477 /// The secret corresponding to the per-commitment point
2479 pub extern "C" fn RevokeAndACK_set_per_commitment_secret(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
2480 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.per_commitment_secret = val.data;
2482 /// The next sender-broadcast commitment transaction's per-commitment point
2484 pub extern "C" fn RevokeAndACK_get_next_per_commitment_point(this_ptr: &RevokeAndACK) -> crate::c_types::PublicKey {
2485 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
2486 crate::c_types::PublicKey::from_rust(&inner_val)
2488 /// The next sender-broadcast commitment transaction's per-commitment point
2490 pub extern "C" fn RevokeAndACK_set_next_per_commitment_point(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::PublicKey) {
2491 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
2493 /// Constructs a new RevokeAndACK given each field
2496 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 {
2497 RevokeAndACK { inner: ObjOps::heap_alloc(nativeRevokeAndACK {
2498 channel_id: channel_id_arg.data,
2499 per_commitment_secret: per_commitment_secret_arg.data,
2500 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
2501 }), is_owned: true }
2503 impl Clone for RevokeAndACK {
2504 fn clone(&self) -> Self {
2506 inner: if <*mut nativeRevokeAndACK>::is_null(self.inner) { core::ptr::null_mut() } else {
2507 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2513 /// Used only if an object of this type is returned as a trait impl by a method
2514 pub(crate) extern "C" fn RevokeAndACK_clone_void(this_ptr: *const c_void) -> *mut c_void {
2515 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRevokeAndACK)).clone() })) as *mut c_void
2518 /// Creates a copy of the RevokeAndACK
2519 pub extern "C" fn RevokeAndACK_clone(orig: &RevokeAndACK) -> RevokeAndACK {
2523 use lightning::ln::msgs::UpdateFee as nativeUpdateFeeImport;
2524 pub(crate) type nativeUpdateFee = nativeUpdateFeeImport;
2526 /// An update_fee message to be sent or received from a peer
2529 pub struct UpdateFee {
2530 /// A pointer to the opaque Rust object.
2532 /// Nearly everywhere, inner must be non-null, however in places where
2533 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2534 pub inner: *mut nativeUpdateFee,
2535 /// Indicates that this is the only struct which contains the same pointer.
2537 /// Rust functions which take ownership of an object provided via an argument require
2538 /// this to be true and invalidate the object pointed to by inner.
2542 impl Drop for UpdateFee {
2543 fn drop(&mut self) {
2544 if self.is_owned && !<*mut nativeUpdateFee>::is_null(self.inner) {
2545 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2549 /// Frees any resources used by the UpdateFee, if is_owned is set and inner is non-NULL.
2551 pub extern "C" fn UpdateFee_free(this_obj: UpdateFee) { }
2553 /// Used only if an object of this type is returned as a trait impl by a method
2554 pub(crate) extern "C" fn UpdateFee_free_void(this_ptr: *mut c_void) {
2555 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFee); }
2559 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFee {
2560 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2562 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFee {
2563 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2565 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2566 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFee {
2567 assert!(self.is_owned);
2568 let ret = ObjOps::untweak_ptr(self.inner);
2569 self.inner = core::ptr::null_mut();
2575 pub extern "C" fn UpdateFee_get_channel_id(this_ptr: &UpdateFee) -> *const [u8; 32] {
2576 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2581 pub extern "C" fn UpdateFee_set_channel_id(this_ptr: &mut UpdateFee, mut val: crate::c_types::ThirtyTwoBytes) {
2582 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2584 /// Fee rate per 1000-weight of the transaction
2586 pub extern "C" fn UpdateFee_get_feerate_per_kw(this_ptr: &UpdateFee) -> u32 {
2587 let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
2590 /// Fee rate per 1000-weight of the transaction
2592 pub extern "C" fn UpdateFee_set_feerate_per_kw(this_ptr: &mut UpdateFee, mut val: u32) {
2593 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
2595 /// Constructs a new UpdateFee given each field
2598 pub extern "C" fn UpdateFee_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut feerate_per_kw_arg: u32) -> UpdateFee {
2599 UpdateFee { inner: ObjOps::heap_alloc(nativeUpdateFee {
2600 channel_id: channel_id_arg.data,
2601 feerate_per_kw: feerate_per_kw_arg,
2602 }), is_owned: true }
2604 impl Clone for UpdateFee {
2605 fn clone(&self) -> Self {
2607 inner: if <*mut nativeUpdateFee>::is_null(self.inner) { core::ptr::null_mut() } else {
2608 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2614 /// Used only if an object of this type is returned as a trait impl by a method
2615 pub(crate) extern "C" fn UpdateFee_clone_void(this_ptr: *const c_void) -> *mut c_void {
2616 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFee)).clone() })) as *mut c_void
2619 /// Creates a copy of the UpdateFee
2620 pub extern "C" fn UpdateFee_clone(orig: &UpdateFee) -> UpdateFee {
2624 use lightning::ln::msgs::DataLossProtect as nativeDataLossProtectImport;
2625 pub(crate) type nativeDataLossProtect = nativeDataLossProtectImport;
2627 /// Proof that the sender knows the per-commitment secret of the previous commitment transaction.
2628 /// This is used to convince the recipient that the channel is at a certain commitment
2629 /// number even if they lost that data due to a local failure. Of course, the peer may lie
2630 /// and even later commitments may have been revoked.
2633 pub struct DataLossProtect {
2634 /// A pointer to the opaque Rust object.
2636 /// Nearly everywhere, inner must be non-null, however in places where
2637 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2638 pub inner: *mut nativeDataLossProtect,
2639 /// Indicates that this is the only struct which contains the same pointer.
2641 /// Rust functions which take ownership of an object provided via an argument require
2642 /// this to be true and invalidate the object pointed to by inner.
2646 impl Drop for DataLossProtect {
2647 fn drop(&mut self) {
2648 if self.is_owned && !<*mut nativeDataLossProtect>::is_null(self.inner) {
2649 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2653 /// Frees any resources used by the DataLossProtect, if is_owned is set and inner is non-NULL.
2655 pub extern "C" fn DataLossProtect_free(this_obj: DataLossProtect) { }
2657 /// Used only if an object of this type is returned as a trait impl by a method
2658 pub(crate) extern "C" fn DataLossProtect_free_void(this_ptr: *mut c_void) {
2659 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDataLossProtect); }
2662 impl DataLossProtect {
2663 pub(crate) fn get_native_ref(&self) -> &'static nativeDataLossProtect {
2664 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2666 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeDataLossProtect {
2667 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2669 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2670 pub(crate) fn take_inner(mut self) -> *mut nativeDataLossProtect {
2671 assert!(self.is_owned);
2672 let ret = ObjOps::untweak_ptr(self.inner);
2673 self.inner = core::ptr::null_mut();
2677 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
2678 /// belonging to the recipient
2680 pub extern "C" fn DataLossProtect_get_your_last_per_commitment_secret(this_ptr: &DataLossProtect) -> *const [u8; 32] {
2681 let mut inner_val = &mut this_ptr.get_native_mut_ref().your_last_per_commitment_secret;
2684 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
2685 /// belonging to the recipient
2687 pub extern "C" fn DataLossProtect_set_your_last_per_commitment_secret(this_ptr: &mut DataLossProtect, mut val: crate::c_types::ThirtyTwoBytes) {
2688 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.your_last_per_commitment_secret = val.data;
2690 /// The sender's per-commitment point for their current commitment transaction
2692 pub extern "C" fn DataLossProtect_get_my_current_per_commitment_point(this_ptr: &DataLossProtect) -> crate::c_types::PublicKey {
2693 let mut inner_val = &mut this_ptr.get_native_mut_ref().my_current_per_commitment_point;
2694 crate::c_types::PublicKey::from_rust(&inner_val)
2696 /// The sender's per-commitment point for their current commitment transaction
2698 pub extern "C" fn DataLossProtect_set_my_current_per_commitment_point(this_ptr: &mut DataLossProtect, mut val: crate::c_types::PublicKey) {
2699 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.my_current_per_commitment_point = val.into_rust();
2701 /// Constructs a new DataLossProtect given each field
2704 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 {
2705 DataLossProtect { inner: ObjOps::heap_alloc(nativeDataLossProtect {
2706 your_last_per_commitment_secret: your_last_per_commitment_secret_arg.data,
2707 my_current_per_commitment_point: my_current_per_commitment_point_arg.into_rust(),
2708 }), is_owned: true }
2710 impl Clone for DataLossProtect {
2711 fn clone(&self) -> Self {
2713 inner: if <*mut nativeDataLossProtect>::is_null(self.inner) { core::ptr::null_mut() } else {
2714 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2720 /// Used only if an object of this type is returned as a trait impl by a method
2721 pub(crate) extern "C" fn DataLossProtect_clone_void(this_ptr: *const c_void) -> *mut c_void {
2722 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDataLossProtect)).clone() })) as *mut c_void
2725 /// Creates a copy of the DataLossProtect
2726 pub extern "C" fn DataLossProtect_clone(orig: &DataLossProtect) -> DataLossProtect {
2730 use lightning::ln::msgs::ChannelReestablish as nativeChannelReestablishImport;
2731 pub(crate) type nativeChannelReestablish = nativeChannelReestablishImport;
2733 /// A channel_reestablish message to be sent or received from a peer
2736 pub struct ChannelReestablish {
2737 /// A pointer to the opaque Rust object.
2739 /// Nearly everywhere, inner must be non-null, however in places where
2740 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2741 pub inner: *mut nativeChannelReestablish,
2742 /// Indicates that this is the only struct which contains the same pointer.
2744 /// Rust functions which take ownership of an object provided via an argument require
2745 /// this to be true and invalidate the object pointed to by inner.
2749 impl Drop for ChannelReestablish {
2750 fn drop(&mut self) {
2751 if self.is_owned && !<*mut nativeChannelReestablish>::is_null(self.inner) {
2752 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2756 /// Frees any resources used by the ChannelReestablish, if is_owned is set and inner is non-NULL.
2758 pub extern "C" fn ChannelReestablish_free(this_obj: ChannelReestablish) { }
2760 /// Used only if an object of this type is returned as a trait impl by a method
2761 pub(crate) extern "C" fn ChannelReestablish_free_void(this_ptr: *mut c_void) {
2762 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelReestablish); }
2765 impl ChannelReestablish {
2766 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelReestablish {
2767 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2769 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelReestablish {
2770 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2772 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2773 pub(crate) fn take_inner(mut self) -> *mut nativeChannelReestablish {
2774 assert!(self.is_owned);
2775 let ret = ObjOps::untweak_ptr(self.inner);
2776 self.inner = core::ptr::null_mut();
2782 pub extern "C" fn ChannelReestablish_get_channel_id(this_ptr: &ChannelReestablish) -> *const [u8; 32] {
2783 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2788 pub extern "C" fn ChannelReestablish_set_channel_id(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) {
2789 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2791 /// The next commitment number for the sender
2793 pub extern "C" fn ChannelReestablish_get_next_local_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
2794 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_local_commitment_number;
2797 /// The next commitment number for the sender
2799 pub extern "C" fn ChannelReestablish_set_next_local_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
2800 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_local_commitment_number = val;
2802 /// The next commitment number for the recipient
2804 pub extern "C" fn ChannelReestablish_get_next_remote_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
2805 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_remote_commitment_number;
2808 /// The next commitment number for the recipient
2810 pub extern "C" fn ChannelReestablish_set_next_remote_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
2811 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_remote_commitment_number = val;
2813 impl Clone for ChannelReestablish {
2814 fn clone(&self) -> Self {
2816 inner: if <*mut nativeChannelReestablish>::is_null(self.inner) { core::ptr::null_mut() } else {
2817 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2823 /// Used only if an object of this type is returned as a trait impl by a method
2824 pub(crate) extern "C" fn ChannelReestablish_clone_void(this_ptr: *const c_void) -> *mut c_void {
2825 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelReestablish)).clone() })) as *mut c_void
2828 /// Creates a copy of the ChannelReestablish
2829 pub extern "C" fn ChannelReestablish_clone(orig: &ChannelReestablish) -> ChannelReestablish {
2833 use lightning::ln::msgs::AnnouncementSignatures as nativeAnnouncementSignaturesImport;
2834 pub(crate) type nativeAnnouncementSignatures = nativeAnnouncementSignaturesImport;
2836 /// An announcement_signatures message to be sent or received from a peer
2839 pub struct AnnouncementSignatures {
2840 /// A pointer to the opaque Rust object.
2842 /// Nearly everywhere, inner must be non-null, however in places where
2843 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2844 pub inner: *mut nativeAnnouncementSignatures,
2845 /// Indicates that this is the only struct which contains the same pointer.
2847 /// Rust functions which take ownership of an object provided via an argument require
2848 /// this to be true and invalidate the object pointed to by inner.
2852 impl Drop for AnnouncementSignatures {
2853 fn drop(&mut self) {
2854 if self.is_owned && !<*mut nativeAnnouncementSignatures>::is_null(self.inner) {
2855 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2859 /// Frees any resources used by the AnnouncementSignatures, if is_owned is set and inner is non-NULL.
2861 pub extern "C" fn AnnouncementSignatures_free(this_obj: AnnouncementSignatures) { }
2863 /// Used only if an object of this type is returned as a trait impl by a method
2864 pub(crate) extern "C" fn AnnouncementSignatures_free_void(this_ptr: *mut c_void) {
2865 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeAnnouncementSignatures); }
2868 impl AnnouncementSignatures {
2869 pub(crate) fn get_native_ref(&self) -> &'static nativeAnnouncementSignatures {
2870 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2872 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAnnouncementSignatures {
2873 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2875 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2876 pub(crate) fn take_inner(mut self) -> *mut nativeAnnouncementSignatures {
2877 assert!(self.is_owned);
2878 let ret = ObjOps::untweak_ptr(self.inner);
2879 self.inner = core::ptr::null_mut();
2885 pub extern "C" fn AnnouncementSignatures_get_channel_id(this_ptr: &AnnouncementSignatures) -> *const [u8; 32] {
2886 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2891 pub extern "C" fn AnnouncementSignatures_set_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
2892 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2894 /// The short channel ID
2896 pub extern "C" fn AnnouncementSignatures_get_short_channel_id(this_ptr: &AnnouncementSignatures) -> u64 {
2897 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
2900 /// The short channel ID
2902 pub extern "C" fn AnnouncementSignatures_set_short_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: u64) {
2903 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
2905 /// A signature by the node key
2907 pub extern "C" fn AnnouncementSignatures_get_node_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
2908 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature;
2909 crate::c_types::Signature::from_rust(&inner_val)
2911 /// A signature by the node key
2913 pub extern "C" fn AnnouncementSignatures_set_node_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
2914 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature = val.into_rust();
2916 /// A signature by the funding key
2918 pub extern "C" fn AnnouncementSignatures_get_bitcoin_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
2919 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature;
2920 crate::c_types::Signature::from_rust(&inner_val)
2922 /// A signature by the funding key
2924 pub extern "C" fn AnnouncementSignatures_set_bitcoin_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
2925 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature = val.into_rust();
2927 /// Constructs a new AnnouncementSignatures given each field
2930 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 {
2931 AnnouncementSignatures { inner: ObjOps::heap_alloc(nativeAnnouncementSignatures {
2932 channel_id: channel_id_arg.data,
2933 short_channel_id: short_channel_id_arg,
2934 node_signature: node_signature_arg.into_rust(),
2935 bitcoin_signature: bitcoin_signature_arg.into_rust(),
2936 }), is_owned: true }
2938 impl Clone for AnnouncementSignatures {
2939 fn clone(&self) -> Self {
2941 inner: if <*mut nativeAnnouncementSignatures>::is_null(self.inner) { core::ptr::null_mut() } else {
2942 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2948 /// Used only if an object of this type is returned as a trait impl by a method
2949 pub(crate) extern "C" fn AnnouncementSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
2950 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAnnouncementSignatures)).clone() })) as *mut c_void
2953 /// Creates a copy of the AnnouncementSignatures
2954 pub extern "C" fn AnnouncementSignatures_clone(orig: &AnnouncementSignatures) -> AnnouncementSignatures {
2957 /// An address which can be used to connect to a remote peer
2961 pub enum NetAddress {
2962 /// An IPv4 address/port on which the peer is listening.
2964 /// The 4-byte IPv4 address
2965 addr: crate::c_types::FourBytes,
2966 /// The port on which the node is listening
2969 /// An IPv6 address/port on which the peer is listening.
2971 /// The 16-byte IPv6 address
2972 addr: crate::c_types::SixteenBytes,
2973 /// The port on which the node is listening
2976 /// An old-style Tor onion address/port on which the peer is listening.
2978 /// This field is deprecated and the Tor network generally no longer supports V2 Onion
2979 /// addresses. Thus, the details are not parsed here.
2981 crate::c_types::TwelveBytes),
2982 /// A new-style Tor onion address/port on which the peer is listening.
2983 /// To create the human-readable \"hostname\", concatenate ed25519_pubkey, checksum, and version,
2984 /// wrap as base32 and append \".onion\".
2986 /// The ed25519 long-term public key of the peer
2987 ed25519_pubkey: crate::c_types::ThirtyTwoBytes,
2988 /// The checksum of the pubkey and version, as included in the onion address
2990 /// The version byte, as defined by the Tor Onion v3 spec.
2992 /// The port on which the node is listening
2995 /// A hostname/port on which the peer is listening.
2997 /// The hostname on which the node is listening.
2998 hostname: crate::lightning::util::ser::Hostname,
2999 /// The port on which the node is listening.
3003 use lightning::ln::msgs::NetAddress as NetAddressImport;
3004 pub(crate) type nativeNetAddress = NetAddressImport;
3008 pub(crate) fn to_native(&self) -> nativeNetAddress {
3010 NetAddress::IPv4 {ref addr, ref port, } => {
3011 let mut addr_nonref = (*addr).clone();
3012 let mut port_nonref = (*port).clone();
3013 nativeNetAddress::IPv4 {
3014 addr: addr_nonref.data,
3018 NetAddress::IPv6 {ref addr, ref port, } => {
3019 let mut addr_nonref = (*addr).clone();
3020 let mut port_nonref = (*port).clone();
3021 nativeNetAddress::IPv6 {
3022 addr: addr_nonref.data,
3026 NetAddress::OnionV2 (ref a, ) => {
3027 let mut a_nonref = (*a).clone();
3028 nativeNetAddress::OnionV2 (
3032 NetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
3033 let mut ed25519_pubkey_nonref = (*ed25519_pubkey).clone();
3034 let mut checksum_nonref = (*checksum).clone();
3035 let mut version_nonref = (*version).clone();
3036 let mut port_nonref = (*port).clone();
3037 nativeNetAddress::OnionV3 {
3038 ed25519_pubkey: ed25519_pubkey_nonref.data,
3039 checksum: checksum_nonref,
3040 version: version_nonref,
3044 NetAddress::Hostname {ref hostname, ref port, } => {
3045 let mut hostname_nonref = (*hostname).clone();
3046 let mut port_nonref = (*port).clone();
3047 nativeNetAddress::Hostname {
3048 hostname: *unsafe { Box::from_raw(hostname_nonref.take_inner()) },
3055 pub(crate) fn into_native(self) -> nativeNetAddress {
3057 NetAddress::IPv4 {mut addr, mut port, } => {
3058 nativeNetAddress::IPv4 {
3063 NetAddress::IPv6 {mut addr, mut port, } => {
3064 nativeNetAddress::IPv6 {
3069 NetAddress::OnionV2 (mut a, ) => {
3070 nativeNetAddress::OnionV2 (
3074 NetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
3075 nativeNetAddress::OnionV3 {
3076 ed25519_pubkey: ed25519_pubkey.data,
3082 NetAddress::Hostname {mut hostname, mut port, } => {
3083 nativeNetAddress::Hostname {
3084 hostname: *unsafe { Box::from_raw(hostname.take_inner()) },
3091 pub(crate) fn from_native(native: &nativeNetAddress) -> Self {
3093 nativeNetAddress::IPv4 {ref addr, ref port, } => {
3094 let mut addr_nonref = (*addr).clone();
3095 let mut port_nonref = (*port).clone();
3097 addr: crate::c_types::FourBytes { data: addr_nonref },
3101 nativeNetAddress::IPv6 {ref addr, ref port, } => {
3102 let mut addr_nonref = (*addr).clone();
3103 let mut port_nonref = (*port).clone();
3105 addr: crate::c_types::SixteenBytes { data: addr_nonref },
3109 nativeNetAddress::OnionV2 (ref a, ) => {
3110 let mut a_nonref = (*a).clone();
3111 NetAddress::OnionV2 (
3112 crate::c_types::TwelveBytes { data: a_nonref },
3115 nativeNetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
3116 let mut ed25519_pubkey_nonref = (*ed25519_pubkey).clone();
3117 let mut checksum_nonref = (*checksum).clone();
3118 let mut version_nonref = (*version).clone();
3119 let mut port_nonref = (*port).clone();
3120 NetAddress::OnionV3 {
3121 ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey_nonref },
3122 checksum: checksum_nonref,
3123 version: version_nonref,
3127 nativeNetAddress::Hostname {ref hostname, ref port, } => {
3128 let mut hostname_nonref = (*hostname).clone();
3129 let mut port_nonref = (*port).clone();
3130 NetAddress::Hostname {
3131 hostname: crate::lightning::util::ser::Hostname { inner: ObjOps::heap_alloc(hostname_nonref), is_owned: true },
3138 pub(crate) fn native_into(native: nativeNetAddress) -> Self {
3140 nativeNetAddress::IPv4 {mut addr, mut port, } => {
3142 addr: crate::c_types::FourBytes { data: addr },
3146 nativeNetAddress::IPv6 {mut addr, mut port, } => {
3148 addr: crate::c_types::SixteenBytes { data: addr },
3152 nativeNetAddress::OnionV2 (mut a, ) => {
3153 NetAddress::OnionV2 (
3154 crate::c_types::TwelveBytes { data: a },
3157 nativeNetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
3158 NetAddress::OnionV3 {
3159 ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey },
3165 nativeNetAddress::Hostname {mut hostname, mut port, } => {
3166 NetAddress::Hostname {
3167 hostname: crate::lightning::util::ser::Hostname { inner: ObjOps::heap_alloc(hostname), is_owned: true },
3174 /// Frees any resources used by the NetAddress
3176 pub extern "C" fn NetAddress_free(this_ptr: NetAddress) { }
3177 /// Creates a copy of the NetAddress
3179 pub extern "C" fn NetAddress_clone(orig: &NetAddress) -> NetAddress {
3183 /// Utility method to constructs a new IPv4-variant NetAddress
3184 pub extern "C" fn NetAddress_ipv4(addr: crate::c_types::FourBytes, port: u16) -> NetAddress {
3191 /// Utility method to constructs a new IPv6-variant NetAddress
3192 pub extern "C" fn NetAddress_ipv6(addr: crate::c_types::SixteenBytes, port: u16) -> NetAddress {
3199 /// Utility method to constructs a new OnionV2-variant NetAddress
3200 pub extern "C" fn NetAddress_onion_v2(a: crate::c_types::TwelveBytes) -> NetAddress {
3201 NetAddress::OnionV2(a, )
3204 /// Utility method to constructs a new OnionV3-variant NetAddress
3205 pub extern "C" fn NetAddress_onion_v3(ed25519_pubkey: crate::c_types::ThirtyTwoBytes, checksum: u16, version: u8, port: u16) -> NetAddress {
3206 NetAddress::OnionV3 {
3214 /// Utility method to constructs a new Hostname-variant NetAddress
3215 pub extern "C" fn NetAddress_hostname(hostname: crate::lightning::util::ser::Hostname, port: u16) -> NetAddress {
3216 NetAddress::Hostname {
3222 /// Serialize the NetAddress object into a byte array which can be read by NetAddress_read
3223 pub extern "C" fn NetAddress_write(obj: &crate::lightning::ln::msgs::NetAddress) -> crate::c_types::derived::CVec_u8Z {
3224 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
3227 /// Read a NetAddress from a byte array, created by NetAddress_write
3228 pub extern "C" fn NetAddress_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NetAddressDecodeErrorZ {
3229 let res: Result<lightning::ln::msgs::NetAddress, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
3230 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() };
3234 use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport;
3235 pub(crate) type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport;
3237 /// The unsigned part of a node_announcement
3240 pub struct UnsignedNodeAnnouncement {
3241 /// A pointer to the opaque Rust object.
3243 /// Nearly everywhere, inner must be non-null, however in places where
3244 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3245 pub inner: *mut nativeUnsignedNodeAnnouncement,
3246 /// Indicates that this is the only struct which contains the same pointer.
3248 /// Rust functions which take ownership of an object provided via an argument require
3249 /// this to be true and invalidate the object pointed to by inner.
3253 impl Drop for UnsignedNodeAnnouncement {
3254 fn drop(&mut self) {
3255 if self.is_owned && !<*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) {
3256 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3260 /// Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL.
3262 pub extern "C" fn UnsignedNodeAnnouncement_free(this_obj: UnsignedNodeAnnouncement) { }
3264 /// Used only if an object of this type is returned as a trait impl by a method
3265 pub(crate) extern "C" fn UnsignedNodeAnnouncement_free_void(this_ptr: *mut c_void) {
3266 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedNodeAnnouncement); }
3269 impl UnsignedNodeAnnouncement {
3270 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedNodeAnnouncement {
3271 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3273 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedNodeAnnouncement {
3274 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3276 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3277 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedNodeAnnouncement {
3278 assert!(self.is_owned);
3279 let ret = ObjOps::untweak_ptr(self.inner);
3280 self.inner = core::ptr::null_mut();
3284 /// The advertised features
3286 pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::ln::features::NodeFeatures {
3287 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
3288 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 }
3290 /// The advertised features
3292 pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::ln::features::NodeFeatures) {
3293 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
3295 /// A strictly monotonic announcement counter, with gaps allowed
3297 pub extern "C" fn UnsignedNodeAnnouncement_get_timestamp(this_ptr: &UnsignedNodeAnnouncement) -> u32 {
3298 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
3301 /// A strictly monotonic announcement counter, with gaps allowed
3303 pub extern "C" fn UnsignedNodeAnnouncement_set_timestamp(this_ptr: &mut UnsignedNodeAnnouncement, mut val: u32) {
3304 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
3306 /// The node_id this announcement originated from (don't rebroadcast the node_announcement back
3309 pub extern "C" fn UnsignedNodeAnnouncement_get_node_id(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::PublicKey {
3310 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id;
3311 crate::c_types::PublicKey::from_rust(&inner_val)
3313 /// The node_id this announcement originated from (don't rebroadcast the node_announcement back
3316 pub extern "C" fn UnsignedNodeAnnouncement_set_node_id(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::PublicKey) {
3317 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id = val.into_rust();
3319 /// An RGB color for UI purposes
3321 pub extern "C" fn UnsignedNodeAnnouncement_get_rgb(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 3] {
3322 let mut inner_val = &mut this_ptr.get_native_mut_ref().rgb;
3325 /// An RGB color for UI purposes
3327 pub extern "C" fn UnsignedNodeAnnouncement_set_rgb(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThreeBytes) {
3328 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.rgb = val.data;
3330 /// An alias, for UI purposes. This should be sanitized before use. There is no guarantee
3333 pub extern "C" fn UnsignedNodeAnnouncement_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 32] {
3334 let mut inner_val = &mut this_ptr.get_native_mut_ref().alias;
3337 /// An alias, for UI purposes. This should be sanitized before use. There is no guarantee
3340 pub extern "C" fn UnsignedNodeAnnouncement_set_alias(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
3341 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.alias = val.data;
3343 /// List of addresses on which this node is reachable
3345 /// Returns a copy of the field.
3347 pub extern "C" fn UnsignedNodeAnnouncement_get_addresses(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_NetAddressZ {
3348 let mut inner_val = this_ptr.get_native_mut_ref().addresses.clone();
3349 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { crate::lightning::ln::msgs::NetAddress::native_into(item) }); };
3350 local_inner_val.into()
3352 /// List of addresses on which this node is reachable
3354 pub extern "C" fn UnsignedNodeAnnouncement_set_addresses(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_NetAddressZ) {
3355 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
3356 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.addresses = local_val;
3358 impl Clone for UnsignedNodeAnnouncement {
3359 fn clone(&self) -> Self {
3361 inner: if <*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
3362 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3368 /// Used only if an object of this type is returned as a trait impl by a method
3369 pub(crate) extern "C" fn UnsignedNodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3370 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedNodeAnnouncement)).clone() })) as *mut c_void
3373 /// Creates a copy of the UnsignedNodeAnnouncement
3374 pub extern "C" fn UnsignedNodeAnnouncement_clone(orig: &UnsignedNodeAnnouncement) -> UnsignedNodeAnnouncement {
3378 use lightning::ln::msgs::NodeAnnouncement as nativeNodeAnnouncementImport;
3379 pub(crate) type nativeNodeAnnouncement = nativeNodeAnnouncementImport;
3381 /// A node_announcement message to be sent or received from a peer
3384 pub struct NodeAnnouncement {
3385 /// A pointer to the opaque Rust object.
3387 /// Nearly everywhere, inner must be non-null, however in places where
3388 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3389 pub inner: *mut nativeNodeAnnouncement,
3390 /// Indicates that this is the only struct which contains the same pointer.
3392 /// Rust functions which take ownership of an object provided via an argument require
3393 /// this to be true and invalidate the object pointed to by inner.
3397 impl Drop for NodeAnnouncement {
3398 fn drop(&mut self) {
3399 if self.is_owned && !<*mut nativeNodeAnnouncement>::is_null(self.inner) {
3400 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3404 /// Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL.
3406 pub extern "C" fn NodeAnnouncement_free(this_obj: NodeAnnouncement) { }
3408 /// Used only if an object of this type is returned as a trait impl by a method
3409 pub(crate) extern "C" fn NodeAnnouncement_free_void(this_ptr: *mut c_void) {
3410 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeAnnouncement); }
3413 impl NodeAnnouncement {
3414 pub(crate) fn get_native_ref(&self) -> &'static nativeNodeAnnouncement {
3415 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3417 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeAnnouncement {
3418 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3420 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3421 pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncement {
3422 assert!(self.is_owned);
3423 let ret = ObjOps::untweak_ptr(self.inner);
3424 self.inner = core::ptr::null_mut();
3428 /// The signature by the node key
3430 pub extern "C" fn NodeAnnouncement_get_signature(this_ptr: &NodeAnnouncement) -> crate::c_types::Signature {
3431 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
3432 crate::c_types::Signature::from_rust(&inner_val)
3434 /// The signature by the node key
3436 pub extern "C" fn NodeAnnouncement_set_signature(this_ptr: &mut NodeAnnouncement, mut val: crate::c_types::Signature) {
3437 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
3439 /// The actual content of the announcement
3441 pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> crate::lightning::ln::msgs::UnsignedNodeAnnouncement {
3442 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
3443 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 }
3445 /// The actual content of the announcement
3447 pub extern "C" fn NodeAnnouncement_set_contents(this_ptr: &mut NodeAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) {
3448 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
3450 /// Constructs a new NodeAnnouncement given each field
3453 pub extern "C" fn NodeAnnouncement_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> NodeAnnouncement {
3454 NodeAnnouncement { inner: ObjOps::heap_alloc(nativeNodeAnnouncement {
3455 signature: signature_arg.into_rust(),
3456 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
3457 }), is_owned: true }
3459 impl Clone for NodeAnnouncement {
3460 fn clone(&self) -> Self {
3462 inner: if <*mut nativeNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
3463 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3469 /// Used only if an object of this type is returned as a trait impl by a method
3470 pub(crate) extern "C" fn NodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3471 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeAnnouncement)).clone() })) as *mut c_void
3474 /// Creates a copy of the NodeAnnouncement
3475 pub extern "C" fn NodeAnnouncement_clone(orig: &NodeAnnouncement) -> NodeAnnouncement {
3479 use lightning::ln::msgs::UnsignedChannelAnnouncement as nativeUnsignedChannelAnnouncementImport;
3480 pub(crate) type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport;
3482 /// The unsigned part of a channel_announcement
3485 pub struct UnsignedChannelAnnouncement {
3486 /// A pointer to the opaque Rust object.
3488 /// Nearly everywhere, inner must be non-null, however in places where
3489 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3490 pub inner: *mut nativeUnsignedChannelAnnouncement,
3491 /// Indicates that this is the only struct which contains the same pointer.
3493 /// Rust functions which take ownership of an object provided via an argument require
3494 /// this to be true and invalidate the object pointed to by inner.
3498 impl Drop for UnsignedChannelAnnouncement {
3499 fn drop(&mut self) {
3500 if self.is_owned && !<*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) {
3501 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3505 /// Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL.
3507 pub extern "C" fn UnsignedChannelAnnouncement_free(this_obj: UnsignedChannelAnnouncement) { }
3509 /// Used only if an object of this type is returned as a trait impl by a method
3510 pub(crate) extern "C" fn UnsignedChannelAnnouncement_free_void(this_ptr: *mut c_void) {
3511 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelAnnouncement); }
3514 impl UnsignedChannelAnnouncement {
3515 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelAnnouncement {
3516 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3518 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelAnnouncement {
3519 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3521 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3522 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelAnnouncement {
3523 assert!(self.is_owned);
3524 let ret = ObjOps::untweak_ptr(self.inner);
3525 self.inner = core::ptr::null_mut();
3529 /// The advertised channel features
3531 pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::ln::features::ChannelFeatures {
3532 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
3533 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 }
3535 /// The advertised channel features
3537 pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::ln::features::ChannelFeatures) {
3538 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
3540 /// The genesis hash of the blockchain where the channel is to be opened
3542 pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &UnsignedChannelAnnouncement) -> *const [u8; 32] {
3543 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
3544 inner_val.as_inner()
3546 /// The genesis hash of the blockchain where the channel is to be opened
3548 pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
3549 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3551 /// The short channel ID
3553 pub extern "C" fn UnsignedChannelAnnouncement_get_short_channel_id(this_ptr: &UnsignedChannelAnnouncement) -> u64 {
3554 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
3557 /// The short channel ID
3559 pub extern "C" fn UnsignedChannelAnnouncement_set_short_channel_id(this_ptr: &mut UnsignedChannelAnnouncement, mut val: u64) {
3560 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
3562 /// One of the two node_ids which are endpoints of this channel
3564 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3565 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_1;
3566 crate::c_types::PublicKey::from_rust(&inner_val)
3568 /// One of the two node_ids which are endpoints of this channel
3570 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3571 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_1 = val.into_rust();
3573 /// The other of the two node_ids which are endpoints of this channel
3575 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3576 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_2;
3577 crate::c_types::PublicKey::from_rust(&inner_val)
3579 /// The other of the two node_ids which are endpoints of this channel
3581 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3582 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_2 = val.into_rust();
3584 /// The funding key for the first node
3586 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3587 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_1;
3588 crate::c_types::PublicKey::from_rust(&inner_val)
3590 /// The funding key for the first node
3592 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3593 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_1 = val.into_rust();
3595 /// The funding key for the second node
3597 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3598 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_2;
3599 crate::c_types::PublicKey::from_rust(&inner_val)
3601 /// The funding key for the second node
3603 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3604 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_2 = val.into_rust();
3606 impl Clone for UnsignedChannelAnnouncement {
3607 fn clone(&self) -> Self {
3609 inner: if <*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
3610 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3616 /// Used only if an object of this type is returned as a trait impl by a method
3617 pub(crate) extern "C" fn UnsignedChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3618 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelAnnouncement)).clone() })) as *mut c_void
3621 /// Creates a copy of the UnsignedChannelAnnouncement
3622 pub extern "C" fn UnsignedChannelAnnouncement_clone(orig: &UnsignedChannelAnnouncement) -> UnsignedChannelAnnouncement {
3626 use lightning::ln::msgs::ChannelAnnouncement as nativeChannelAnnouncementImport;
3627 pub(crate) type nativeChannelAnnouncement = nativeChannelAnnouncementImport;
3629 /// A channel_announcement message to be sent or received from a peer
3632 pub struct ChannelAnnouncement {
3633 /// A pointer to the opaque Rust object.
3635 /// Nearly everywhere, inner must be non-null, however in places where
3636 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3637 pub inner: *mut nativeChannelAnnouncement,
3638 /// Indicates that this is the only struct which contains the same pointer.
3640 /// Rust functions which take ownership of an object provided via an argument require
3641 /// this to be true and invalidate the object pointed to by inner.
3645 impl Drop for ChannelAnnouncement {
3646 fn drop(&mut self) {
3647 if self.is_owned && !<*mut nativeChannelAnnouncement>::is_null(self.inner) {
3648 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3652 /// Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL.
3654 pub extern "C" fn ChannelAnnouncement_free(this_obj: ChannelAnnouncement) { }
3656 /// Used only if an object of this type is returned as a trait impl by a method
3657 pub(crate) extern "C" fn ChannelAnnouncement_free_void(this_ptr: *mut c_void) {
3658 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelAnnouncement); }
3661 impl ChannelAnnouncement {
3662 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelAnnouncement {
3663 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3665 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelAnnouncement {
3666 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3668 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3669 pub(crate) fn take_inner(mut self) -> *mut nativeChannelAnnouncement {
3670 assert!(self.is_owned);
3671 let ret = ObjOps::untweak_ptr(self.inner);
3672 self.inner = core::ptr::null_mut();
3676 /// Authentication of the announcement by the first public node
3678 pub extern "C" fn ChannelAnnouncement_get_node_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3679 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_1;
3680 crate::c_types::Signature::from_rust(&inner_val)
3682 /// Authentication of the announcement by the first public node
3684 pub extern "C" fn ChannelAnnouncement_set_node_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3685 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_1 = val.into_rust();
3687 /// Authentication of the announcement by the second public node
3689 pub extern "C" fn ChannelAnnouncement_get_node_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3690 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_2;
3691 crate::c_types::Signature::from_rust(&inner_val)
3693 /// Authentication of the announcement by the second public node
3695 pub extern "C" fn ChannelAnnouncement_set_node_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3696 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_2 = val.into_rust();
3698 /// Proof of funding UTXO ownership by the first public node
3700 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3701 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_1;
3702 crate::c_types::Signature::from_rust(&inner_val)
3704 /// Proof of funding UTXO ownership by the first public node
3706 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3707 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_1 = val.into_rust();
3709 /// Proof of funding UTXO ownership by the second public node
3711 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3712 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_2;
3713 crate::c_types::Signature::from_rust(&inner_val)
3715 /// Proof of funding UTXO ownership by the second public node
3717 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3718 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_2 = val.into_rust();
3720 /// The actual announcement
3722 pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncement) -> crate::lightning::ln::msgs::UnsignedChannelAnnouncement {
3723 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
3724 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 }
3726 /// The actual announcement
3728 pub extern "C" fn ChannelAnnouncement_set_contents(this_ptr: &mut ChannelAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) {
3729 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
3731 /// Constructs a new ChannelAnnouncement given each field
3734 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 {
3735 ChannelAnnouncement { inner: ObjOps::heap_alloc(nativeChannelAnnouncement {
3736 node_signature_1: node_signature_1_arg.into_rust(),
3737 node_signature_2: node_signature_2_arg.into_rust(),
3738 bitcoin_signature_1: bitcoin_signature_1_arg.into_rust(),
3739 bitcoin_signature_2: bitcoin_signature_2_arg.into_rust(),
3740 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
3741 }), is_owned: true }
3743 impl Clone for ChannelAnnouncement {
3744 fn clone(&self) -> Self {
3746 inner: if <*mut nativeChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
3747 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3753 /// Used only if an object of this type is returned as a trait impl by a method
3754 pub(crate) extern "C" fn ChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3755 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelAnnouncement)).clone() })) as *mut c_void
3758 /// Creates a copy of the ChannelAnnouncement
3759 pub extern "C" fn ChannelAnnouncement_clone(orig: &ChannelAnnouncement) -> ChannelAnnouncement {
3763 use lightning::ln::msgs::UnsignedChannelUpdate as nativeUnsignedChannelUpdateImport;
3764 pub(crate) type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport;
3766 /// The unsigned part of a channel_update
3769 pub struct UnsignedChannelUpdate {
3770 /// A pointer to the opaque Rust object.
3772 /// Nearly everywhere, inner must be non-null, however in places where
3773 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3774 pub inner: *mut nativeUnsignedChannelUpdate,
3775 /// Indicates that this is the only struct which contains the same pointer.
3777 /// Rust functions which take ownership of an object provided via an argument require
3778 /// this to be true and invalidate the object pointed to by inner.
3782 impl Drop for UnsignedChannelUpdate {
3783 fn drop(&mut self) {
3784 if self.is_owned && !<*mut nativeUnsignedChannelUpdate>::is_null(self.inner) {
3785 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3789 /// Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL.
3791 pub extern "C" fn UnsignedChannelUpdate_free(this_obj: UnsignedChannelUpdate) { }
3793 /// Used only if an object of this type is returned as a trait impl by a method
3794 pub(crate) extern "C" fn UnsignedChannelUpdate_free_void(this_ptr: *mut c_void) {
3795 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelUpdate); }
3798 impl UnsignedChannelUpdate {
3799 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelUpdate {
3800 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3802 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelUpdate {
3803 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3805 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3806 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelUpdate {
3807 assert!(self.is_owned);
3808 let ret = ObjOps::untweak_ptr(self.inner);
3809 self.inner = core::ptr::null_mut();
3813 /// The genesis hash of the blockchain where the channel is to be opened
3815 pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChannelUpdate) -> *const [u8; 32] {
3816 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
3817 inner_val.as_inner()
3819 /// The genesis hash of the blockchain where the channel is to be opened
3821 pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::ThirtyTwoBytes) {
3822 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3824 /// The short channel ID
3826 pub extern "C" fn UnsignedChannelUpdate_get_short_channel_id(this_ptr: &UnsignedChannelUpdate) -> u64 {
3827 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
3830 /// The short channel ID
3832 pub extern "C" fn UnsignedChannelUpdate_set_short_channel_id(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
3833 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
3835 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
3837 pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannelUpdate) -> u32 {
3838 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
3841 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
3843 pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3844 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
3848 pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 {
3849 let mut inner_val = &mut this_ptr.get_native_mut_ref().flags;
3854 pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) {
3855 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.flags = val;
3857 /// The number of blocks such that if:
3858 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
3859 /// then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines
3860 /// the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a
3861 /// cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10,
3862 /// then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before
3863 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
3864 /// constructing the route.
3866 pub extern "C" fn UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr: &UnsignedChannelUpdate) -> u16 {
3867 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
3870 /// The number of blocks such that if:
3871 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
3872 /// then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines
3873 /// the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a
3874 /// cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10,
3875 /// then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before
3876 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
3877 /// constructing the route.
3879 pub extern "C" fn UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr: &mut UnsignedChannelUpdate, mut val: u16) {
3880 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
3882 /// The minimum HTLC size incoming to sender, in milli-satoshi
3884 pub extern "C" fn UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
3885 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
3888 /// The minimum HTLC size incoming to sender, in milli-satoshi
3890 pub extern "C" fn UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
3891 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
3893 /// The maximum HTLC value incoming to sender, in milli-satoshi. Used to be optional.
3895 pub extern "C" fn UnsignedChannelUpdate_get_htlc_maximum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
3896 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat;
3899 /// The maximum HTLC value incoming to sender, in milli-satoshi. Used to be optional.
3901 pub extern "C" fn UnsignedChannelUpdate_set_htlc_maximum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
3902 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = val;
3904 /// The base HTLC fee charged by sender, in milli-satoshi
3906 pub extern "C" fn UnsignedChannelUpdate_get_fee_base_msat(this_ptr: &UnsignedChannelUpdate) -> u32 {
3907 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat;
3910 /// The base HTLC fee charged by sender, in milli-satoshi
3912 pub extern "C" fn UnsignedChannelUpdate_set_fee_base_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3913 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val;
3915 /// The amount to fee multiplier, in micro-satoshi
3917 pub extern "C" fn UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr: &UnsignedChannelUpdate) -> u32 {
3918 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths;
3921 /// The amount to fee multiplier, in micro-satoshi
3923 pub extern "C" fn UnsignedChannelUpdate_set_fee_proportional_millionths(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3924 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val;
3926 /// Excess data which was signed as a part of the message which we do not (yet) understand how
3927 /// to decode. This is stored to ensure forward-compatibility as new fields are added to the
3928 /// lightning gossip
3930 /// Returns a copy of the field.
3932 pub extern "C" fn UnsignedChannelUpdate_get_excess_data(this_ptr: &UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
3933 let mut inner_val = this_ptr.get_native_mut_ref().excess_data.clone();
3934 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
3935 local_inner_val.into()
3937 /// Excess data which was signed as a part of the message which we do not (yet) understand how
3938 /// to decode. This is stored to ensure forward-compatibility as new fields are added to the
3939 /// lightning gossip
3941 pub extern "C" fn UnsignedChannelUpdate_set_excess_data(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::derived::CVec_u8Z) {
3942 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
3943 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_data = local_val;
3945 /// Constructs a new UnsignedChannelUpdate given each field
3948 pub extern "C" fn UnsignedChannelUpdate_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_id_arg: u64, mut timestamp_arg: u32, mut flags_arg: u8, mut cltv_expiry_delta_arg: u16, mut htlc_minimum_msat_arg: u64, mut htlc_maximum_msat_arg: u64, mut fee_base_msat_arg: u32, mut fee_proportional_millionths_arg: u32, mut excess_data_arg: crate::c_types::derived::CVec_u8Z) -> UnsignedChannelUpdate {
3949 let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); };
3950 UnsignedChannelUpdate { inner: ObjOps::heap_alloc(nativeUnsignedChannelUpdate {
3951 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3952 short_channel_id: short_channel_id_arg,
3953 timestamp: timestamp_arg,
3955 cltv_expiry_delta: cltv_expiry_delta_arg,
3956 htlc_minimum_msat: htlc_minimum_msat_arg,
3957 htlc_maximum_msat: htlc_maximum_msat_arg,
3958 fee_base_msat: fee_base_msat_arg,
3959 fee_proportional_millionths: fee_proportional_millionths_arg,
3960 excess_data: local_excess_data_arg,
3961 }), is_owned: true }
3963 impl Clone for UnsignedChannelUpdate {
3964 fn clone(&self) -> Self {
3966 inner: if <*mut nativeUnsignedChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
3967 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3973 /// Used only if an object of this type is returned as a trait impl by a method
3974 pub(crate) extern "C" fn UnsignedChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
3975 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelUpdate)).clone() })) as *mut c_void
3978 /// Creates a copy of the UnsignedChannelUpdate
3979 pub extern "C" fn UnsignedChannelUpdate_clone(orig: &UnsignedChannelUpdate) -> UnsignedChannelUpdate {
3983 use lightning::ln::msgs::ChannelUpdate as nativeChannelUpdateImport;
3984 pub(crate) type nativeChannelUpdate = nativeChannelUpdateImport;
3986 /// A channel_update message to be sent or received from a peer
3989 pub struct ChannelUpdate {
3990 /// A pointer to the opaque Rust object.
3992 /// Nearly everywhere, inner must be non-null, however in places where
3993 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3994 pub inner: *mut nativeChannelUpdate,
3995 /// Indicates that this is the only struct which contains the same pointer.
3997 /// Rust functions which take ownership of an object provided via an argument require
3998 /// this to be true and invalidate the object pointed to by inner.
4002 impl Drop for ChannelUpdate {
4003 fn drop(&mut self) {
4004 if self.is_owned && !<*mut nativeChannelUpdate>::is_null(self.inner) {
4005 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4009 /// Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL.
4011 pub extern "C" fn ChannelUpdate_free(this_obj: ChannelUpdate) { }
4013 /// Used only if an object of this type is returned as a trait impl by a method
4014 pub(crate) extern "C" fn ChannelUpdate_free_void(this_ptr: *mut c_void) {
4015 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelUpdate); }
4018 impl ChannelUpdate {
4019 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelUpdate {
4020 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4022 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelUpdate {
4023 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4025 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4026 pub(crate) fn take_inner(mut self) -> *mut nativeChannelUpdate {
4027 assert!(self.is_owned);
4028 let ret = ObjOps::untweak_ptr(self.inner);
4029 self.inner = core::ptr::null_mut();
4033 /// A signature of the channel update
4035 pub extern "C" fn ChannelUpdate_get_signature(this_ptr: &ChannelUpdate) -> crate::c_types::Signature {
4036 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
4037 crate::c_types::Signature::from_rust(&inner_val)
4039 /// A signature of the channel update
4041 pub extern "C" fn ChannelUpdate_set_signature(this_ptr: &mut ChannelUpdate, mut val: crate::c_types::Signature) {
4042 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
4044 /// The actual channel update
4046 pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate::lightning::ln::msgs::UnsignedChannelUpdate {
4047 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
4048 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 }
4050 /// The actual channel update
4052 pub extern "C" fn ChannelUpdate_set_contents(this_ptr: &mut ChannelUpdate, mut val: crate::lightning::ln::msgs::UnsignedChannelUpdate) {
4053 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
4055 /// Constructs a new ChannelUpdate given each field
4058 pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> ChannelUpdate {
4059 ChannelUpdate { inner: ObjOps::heap_alloc(nativeChannelUpdate {
4060 signature: signature_arg.into_rust(),
4061 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
4062 }), is_owned: true }
4064 impl Clone for ChannelUpdate {
4065 fn clone(&self) -> Self {
4067 inner: if <*mut nativeChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
4068 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4074 /// Used only if an object of this type is returned as a trait impl by a method
4075 pub(crate) extern "C" fn ChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
4076 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelUpdate)).clone() })) as *mut c_void
4079 /// Creates a copy of the ChannelUpdate
4080 pub extern "C" fn ChannelUpdate_clone(orig: &ChannelUpdate) -> ChannelUpdate {
4084 use lightning::ln::msgs::QueryChannelRange as nativeQueryChannelRangeImport;
4085 pub(crate) type nativeQueryChannelRange = nativeQueryChannelRangeImport;
4087 /// A query_channel_range message is used to query a peer for channel
4088 /// UTXOs in a range of blocks. The recipient of a query makes a best
4089 /// effort to reply to the query using one or more reply_channel_range
4093 pub struct QueryChannelRange {
4094 /// A pointer to the opaque Rust object.
4096 /// Nearly everywhere, inner must be non-null, however in places where
4097 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4098 pub inner: *mut nativeQueryChannelRange,
4099 /// Indicates that this is the only struct which contains the same pointer.
4101 /// Rust functions which take ownership of an object provided via an argument require
4102 /// this to be true and invalidate the object pointed to by inner.
4106 impl Drop for QueryChannelRange {
4107 fn drop(&mut self) {
4108 if self.is_owned && !<*mut nativeQueryChannelRange>::is_null(self.inner) {
4109 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4113 /// Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL.
4115 pub extern "C" fn QueryChannelRange_free(this_obj: QueryChannelRange) { }
4117 /// Used only if an object of this type is returned as a trait impl by a method
4118 pub(crate) extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) {
4119 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryChannelRange); }
4122 impl QueryChannelRange {
4123 pub(crate) fn get_native_ref(&self) -> &'static nativeQueryChannelRange {
4124 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4126 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryChannelRange {
4127 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4129 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4130 pub(crate) fn take_inner(mut self) -> *mut nativeQueryChannelRange {
4131 assert!(self.is_owned);
4132 let ret = ObjOps::untweak_ptr(self.inner);
4133 self.inner = core::ptr::null_mut();
4137 /// The genesis hash of the blockchain being queried
4139 pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *const [u8; 32] {
4140 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4141 inner_val.as_inner()
4143 /// The genesis hash of the blockchain being queried
4145 pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
4146 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4148 /// The height of the first block for the channel UTXOs being queried
4150 pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 {
4151 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
4154 /// The height of the first block for the channel UTXOs being queried
4156 pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChannelRange, mut val: u32) {
4157 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
4159 /// The number of blocks to include in the query results
4161 pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 {
4162 let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
4165 /// The number of blocks to include in the query results
4167 pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryChannelRange, mut val: u32) {
4168 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
4170 /// Constructs a new QueryChannelRange given each field
4173 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 {
4174 QueryChannelRange { inner: ObjOps::heap_alloc(nativeQueryChannelRange {
4175 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4176 first_blocknum: first_blocknum_arg,
4177 number_of_blocks: number_of_blocks_arg,
4178 }), is_owned: true }
4180 impl Clone for QueryChannelRange {
4181 fn clone(&self) -> Self {
4183 inner: if <*mut nativeQueryChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
4184 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4190 /// Used only if an object of this type is returned as a trait impl by a method
4191 pub(crate) extern "C" fn QueryChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
4192 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryChannelRange)).clone() })) as *mut c_void
4195 /// Creates a copy of the QueryChannelRange
4196 pub extern "C" fn QueryChannelRange_clone(orig: &QueryChannelRange) -> QueryChannelRange {
4200 use lightning::ln::msgs::ReplyChannelRange as nativeReplyChannelRangeImport;
4201 pub(crate) type nativeReplyChannelRange = nativeReplyChannelRangeImport;
4203 /// A reply_channel_range message is a reply to a query_channel_range
4204 /// message. Multiple reply_channel_range messages can be sent in reply
4205 /// to a single query_channel_range message. The query recipient makes a
4206 /// best effort to respond based on their local network view which may
4207 /// not be a perfect view of the network. The short_channel_ids in the
4208 /// reply are encoded. We only support encoding_type=0 uncompressed
4209 /// serialization and do not support encoding_type=1 zlib serialization.
4212 pub struct ReplyChannelRange {
4213 /// A pointer to the opaque Rust object.
4215 /// Nearly everywhere, inner must be non-null, however in places where
4216 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4217 pub inner: *mut nativeReplyChannelRange,
4218 /// Indicates that this is the only struct which contains the same pointer.
4220 /// Rust functions which take ownership of an object provided via an argument require
4221 /// this to be true and invalidate the object pointed to by inner.
4225 impl Drop for ReplyChannelRange {
4226 fn drop(&mut self) {
4227 if self.is_owned && !<*mut nativeReplyChannelRange>::is_null(self.inner) {
4228 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4232 /// Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL.
4234 pub extern "C" fn ReplyChannelRange_free(this_obj: ReplyChannelRange) { }
4236 /// Used only if an object of this type is returned as a trait impl by a method
4237 pub(crate) extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) {
4238 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyChannelRange); }
4241 impl ReplyChannelRange {
4242 pub(crate) fn get_native_ref(&self) -> &'static nativeReplyChannelRange {
4243 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4245 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyChannelRange {
4246 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4248 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4249 pub(crate) fn take_inner(mut self) -> *mut nativeReplyChannelRange {
4250 assert!(self.is_owned);
4251 let ret = ObjOps::untweak_ptr(self.inner);
4252 self.inner = core::ptr::null_mut();
4256 /// The genesis hash of the blockchain being queried
4258 pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *const [u8; 32] {
4259 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4260 inner_val.as_inner()
4262 /// The genesis hash of the blockchain being queried
4264 pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
4265 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4267 /// The height of the first block in the range of the reply
4269 pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 {
4270 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
4273 /// The height of the first block in the range of the reply
4275 pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChannelRange, mut val: u32) {
4276 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
4278 /// The number of blocks included in the range of the reply
4280 pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 {
4281 let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
4284 /// The number of blocks included in the range of the reply
4286 pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyChannelRange, mut val: u32) {
4287 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
4289 /// True when this is the final reply for a query
4291 pub extern "C" fn ReplyChannelRange_get_sync_complete(this_ptr: &ReplyChannelRange) -> bool {
4292 let mut inner_val = &mut this_ptr.get_native_mut_ref().sync_complete;
4295 /// True when this is the final reply for a query
4297 pub extern "C" fn ReplyChannelRange_set_sync_complete(this_ptr: &mut ReplyChannelRange, mut val: bool) {
4298 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sync_complete = val;
4300 /// The short_channel_ids in the channel range
4302 /// Returns a copy of the field.
4304 pub extern "C" fn ReplyChannelRange_get_short_channel_ids(this_ptr: &ReplyChannelRange) -> crate::c_types::derived::CVec_u64Z {
4305 let mut inner_val = this_ptr.get_native_mut_ref().short_channel_ids.clone();
4306 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
4307 local_inner_val.into()
4309 /// The short_channel_ids in the channel range
4311 pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::derived::CVec_u64Z) {
4312 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
4313 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
4315 /// Constructs a new ReplyChannelRange given each field
4318 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 {
4319 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 }); };
4320 ReplyChannelRange { inner: ObjOps::heap_alloc(nativeReplyChannelRange {
4321 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4322 first_blocknum: first_blocknum_arg,
4323 number_of_blocks: number_of_blocks_arg,
4324 sync_complete: sync_complete_arg,
4325 short_channel_ids: local_short_channel_ids_arg,
4326 }), is_owned: true }
4328 impl Clone for ReplyChannelRange {
4329 fn clone(&self) -> Self {
4331 inner: if <*mut nativeReplyChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
4332 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4338 /// Used only if an object of this type is returned as a trait impl by a method
4339 pub(crate) extern "C" fn ReplyChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
4340 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyChannelRange)).clone() })) as *mut c_void
4343 /// Creates a copy of the ReplyChannelRange
4344 pub extern "C" fn ReplyChannelRange_clone(orig: &ReplyChannelRange) -> ReplyChannelRange {
4348 use lightning::ln::msgs::QueryShortChannelIds as nativeQueryShortChannelIdsImport;
4349 pub(crate) type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport;
4351 /// A query_short_channel_ids message is used to query a peer for
4352 /// routing gossip messages related to one or more short_channel_ids.
4353 /// The query recipient will reply with the latest, if available,
4354 /// channel_announcement, channel_update and node_announcement messages
4355 /// it maintains for the requested short_channel_ids followed by a
4356 /// reply_short_channel_ids_end message. The short_channel_ids sent in
4357 /// this query are encoded. We only support encoding_type=0 uncompressed
4358 /// serialization and do not support encoding_type=1 zlib serialization.
4361 pub struct QueryShortChannelIds {
4362 /// A pointer to the opaque Rust object.
4364 /// Nearly everywhere, inner must be non-null, however in places where
4365 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4366 pub inner: *mut nativeQueryShortChannelIds,
4367 /// Indicates that this is the only struct which contains the same pointer.
4369 /// Rust functions which take ownership of an object provided via an argument require
4370 /// this to be true and invalidate the object pointed to by inner.
4374 impl Drop for QueryShortChannelIds {
4375 fn drop(&mut self) {
4376 if self.is_owned && !<*mut nativeQueryShortChannelIds>::is_null(self.inner) {
4377 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4381 /// Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL.
4383 pub extern "C" fn QueryShortChannelIds_free(this_obj: QueryShortChannelIds) { }
4385 /// Used only if an object of this type is returned as a trait impl by a method
4386 pub(crate) extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) {
4387 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryShortChannelIds); }
4390 impl QueryShortChannelIds {
4391 pub(crate) fn get_native_ref(&self) -> &'static nativeQueryShortChannelIds {
4392 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4394 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryShortChannelIds {
4395 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4397 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4398 pub(crate) fn take_inner(mut self) -> *mut nativeQueryShortChannelIds {
4399 assert!(self.is_owned);
4400 let ret = ObjOps::untweak_ptr(self.inner);
4401 self.inner = core::ptr::null_mut();
4405 /// The genesis hash of the blockchain being queried
4407 pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *const [u8; 32] {
4408 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4409 inner_val.as_inner()
4411 /// The genesis hash of the blockchain being queried
4413 pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::ThirtyTwoBytes) {
4414 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4416 /// The short_channel_ids that are being queried
4418 /// Returns a copy of the field.
4420 pub extern "C" fn QueryShortChannelIds_get_short_channel_ids(this_ptr: &QueryShortChannelIds) -> crate::c_types::derived::CVec_u64Z {
4421 let mut inner_val = this_ptr.get_native_mut_ref().short_channel_ids.clone();
4422 let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
4423 local_inner_val.into()
4425 /// The short_channel_ids that are being queried
4427 pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::derived::CVec_u64Z) {
4428 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
4429 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
4431 /// Constructs a new QueryShortChannelIds given each field
4434 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 {
4435 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 }); };
4436 QueryShortChannelIds { inner: ObjOps::heap_alloc(nativeQueryShortChannelIds {
4437 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4438 short_channel_ids: local_short_channel_ids_arg,
4439 }), is_owned: true }
4441 impl Clone for QueryShortChannelIds {
4442 fn clone(&self) -> Self {
4444 inner: if <*mut nativeQueryShortChannelIds>::is_null(self.inner) { core::ptr::null_mut() } else {
4445 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4451 /// Used only if an object of this type is returned as a trait impl by a method
4452 pub(crate) extern "C" fn QueryShortChannelIds_clone_void(this_ptr: *const c_void) -> *mut c_void {
4453 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryShortChannelIds)).clone() })) as *mut c_void
4456 /// Creates a copy of the QueryShortChannelIds
4457 pub extern "C" fn QueryShortChannelIds_clone(orig: &QueryShortChannelIds) -> QueryShortChannelIds {
4461 use lightning::ln::msgs::ReplyShortChannelIdsEnd as nativeReplyShortChannelIdsEndImport;
4462 pub(crate) type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport;
4464 /// A reply_short_channel_ids_end message is sent as a reply to a
4465 /// query_short_channel_ids message. The query recipient makes a best
4466 /// effort to respond based on their local network view which may not be
4467 /// a perfect view of the network.
4470 pub struct ReplyShortChannelIdsEnd {
4471 /// A pointer to the opaque Rust object.
4473 /// Nearly everywhere, inner must be non-null, however in places where
4474 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4475 pub inner: *mut nativeReplyShortChannelIdsEnd,
4476 /// Indicates that this is the only struct which contains the same pointer.
4478 /// Rust functions which take ownership of an object provided via an argument require
4479 /// this to be true and invalidate the object pointed to by inner.
4483 impl Drop for ReplyShortChannelIdsEnd {
4484 fn drop(&mut self) {
4485 if self.is_owned && !<*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) {
4486 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4490 /// Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL.
4492 pub extern "C" fn ReplyShortChannelIdsEnd_free(this_obj: ReplyShortChannelIdsEnd) { }
4494 /// Used only if an object of this type is returned as a trait impl by a method
4495 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) {
4496 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyShortChannelIdsEnd); }
4499 impl ReplyShortChannelIdsEnd {
4500 pub(crate) fn get_native_ref(&self) -> &'static nativeReplyShortChannelIdsEnd {
4501 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4503 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyShortChannelIdsEnd {
4504 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4506 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4507 pub(crate) fn take_inner(mut self) -> *mut nativeReplyShortChannelIdsEnd {
4508 assert!(self.is_owned);
4509 let ret = ObjOps::untweak_ptr(self.inner);
4510 self.inner = core::ptr::null_mut();
4514 /// The genesis hash of the blockchain that was queried
4516 pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *const [u8; 32] {
4517 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4518 inner_val.as_inner()
4520 /// The genesis hash of the blockchain that was queried
4522 pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) {
4523 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4525 /// Indicates if the query recipient maintains up-to-date channel
4526 /// information for the chain_hash
4528 pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool {
4529 let mut inner_val = &mut this_ptr.get_native_mut_ref().full_information;
4532 /// Indicates if the query recipient maintains up-to-date channel
4533 /// information for the chain_hash
4535 pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: bool) {
4536 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.full_information = val;
4538 /// Constructs a new ReplyShortChannelIdsEnd given each field
4541 pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd {
4542 ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(nativeReplyShortChannelIdsEnd {
4543 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4544 full_information: full_information_arg,
4545 }), is_owned: true }
4547 impl Clone for ReplyShortChannelIdsEnd {
4548 fn clone(&self) -> Self {
4550 inner: if <*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) { core::ptr::null_mut() } else {
4551 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4557 /// Used only if an object of this type is returned as a trait impl by a method
4558 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_void) -> *mut c_void {
4559 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyShortChannelIdsEnd)).clone() })) as *mut c_void
4562 /// Creates a copy of the ReplyShortChannelIdsEnd
4563 pub extern "C" fn ReplyShortChannelIdsEnd_clone(orig: &ReplyShortChannelIdsEnd) -> ReplyShortChannelIdsEnd {
4567 use lightning::ln::msgs::GossipTimestampFilter as nativeGossipTimestampFilterImport;
4568 pub(crate) type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport;
4570 /// A gossip_timestamp_filter message is used by a node to request
4571 /// gossip relay for messages in the requested time range when the
4572 /// gossip_queries feature has been negotiated.
4575 pub struct GossipTimestampFilter {
4576 /// A pointer to the opaque Rust object.
4578 /// Nearly everywhere, inner must be non-null, however in places where
4579 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4580 pub inner: *mut nativeGossipTimestampFilter,
4581 /// Indicates that this is the only struct which contains the same pointer.
4583 /// Rust functions which take ownership of an object provided via an argument require
4584 /// this to be true and invalidate the object pointed to by inner.
4588 impl Drop for GossipTimestampFilter {
4589 fn drop(&mut self) {
4590 if self.is_owned && !<*mut nativeGossipTimestampFilter>::is_null(self.inner) {
4591 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4595 /// Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL.
4597 pub extern "C" fn GossipTimestampFilter_free(this_obj: GossipTimestampFilter) { }
4599 /// Used only if an object of this type is returned as a trait impl by a method
4600 pub(crate) extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) {
4601 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeGossipTimestampFilter); }
4604 impl GossipTimestampFilter {
4605 pub(crate) fn get_native_ref(&self) -> &'static nativeGossipTimestampFilter {
4606 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4608 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeGossipTimestampFilter {
4609 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4611 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4612 pub(crate) fn take_inner(mut self) -> *mut nativeGossipTimestampFilter {
4613 assert!(self.is_owned);
4614 let ret = ObjOps::untweak_ptr(self.inner);
4615 self.inner = core::ptr::null_mut();
4619 /// The genesis hash of the blockchain for channel and node information
4621 pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *const [u8; 32] {
4622 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4623 inner_val.as_inner()
4625 /// The genesis hash of the blockchain for channel and node information
4627 pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) {
4628 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4630 /// The starting unix timestamp
4632 pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 {
4633 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_timestamp;
4636 /// The starting unix timestamp
4638 pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
4639 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_timestamp = val;
4641 /// The range of information in seconds
4643 pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 {
4644 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp_range;
4647 /// The range of information in seconds
4649 pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
4650 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp_range = val;
4652 /// Constructs a new GossipTimestampFilter given each field
4655 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 {
4656 GossipTimestampFilter { inner: ObjOps::heap_alloc(nativeGossipTimestampFilter {
4657 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4658 first_timestamp: first_timestamp_arg,
4659 timestamp_range: timestamp_range_arg,
4660 }), is_owned: true }
4662 impl Clone for GossipTimestampFilter {
4663 fn clone(&self) -> Self {
4665 inner: if <*mut nativeGossipTimestampFilter>::is_null(self.inner) { core::ptr::null_mut() } else {
4666 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4672 /// Used only if an object of this type is returned as a trait impl by a method
4673 pub(crate) extern "C" fn GossipTimestampFilter_clone_void(this_ptr: *const c_void) -> *mut c_void {
4674 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeGossipTimestampFilter)).clone() })) as *mut c_void
4677 /// Creates a copy of the GossipTimestampFilter
4678 pub extern "C" fn GossipTimestampFilter_clone(orig: &GossipTimestampFilter) -> GossipTimestampFilter {
4681 /// Used to put an error message in a LightningError
4685 pub enum ErrorAction {
4686 /// The peer took some action which made us think they were useless. Disconnect them.
4688 /// An error message which we should make an effort to send before we disconnect.
4690 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
4691 msg: crate::lightning::ln::msgs::ErrorMessage,
4693 /// The peer did something harmless that we weren't able to process, just log and ignore
4695 /// The peer did something harmless that we weren't able to meaningfully process.
4696 /// If the error is logged, log it at the given level.
4698 crate::lightning::util::logger::Level),
4699 /// The peer provided us with a gossip message which we'd already seen. In most cases this
4700 /// should be ignored, but it may result in the message being forwarded if it is a duplicate of
4701 /// our own channel announcements.
4702 IgnoreDuplicateGossip,
4703 /// The peer did something incorrect. Tell them.
4705 /// The message to send.
4706 msg: crate::lightning::ln::msgs::ErrorMessage,
4708 /// The peer did something incorrect. Tell them without closing any channels.
4709 SendWarningMessage {
4710 /// The message to send.
4711 msg: crate::lightning::ln::msgs::WarningMessage,
4712 /// The peer may have done something harmless that we weren't able to meaningfully process,
4713 /// though we should still tell them about it.
4714 /// If this event is logged, log it at the given level.
4715 log_level: crate::lightning::util::logger::Level,
4718 use lightning::ln::msgs::ErrorAction as ErrorActionImport;
4719 pub(crate) type nativeErrorAction = ErrorActionImport;
4723 pub(crate) fn to_native(&self) -> nativeErrorAction {
4725 ErrorAction::DisconnectPeer {ref msg, } => {
4726 let mut msg_nonref = (*msg).clone();
4727 let mut local_msg_nonref = if msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg_nonref.take_inner()) } }) };
4728 nativeErrorAction::DisconnectPeer {
4729 msg: local_msg_nonref,
4732 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
4733 ErrorAction::IgnoreAndLog (ref a, ) => {
4734 let mut a_nonref = (*a).clone();
4735 nativeErrorAction::IgnoreAndLog (
4736 a_nonref.into_native(),
4739 ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
4740 ErrorAction::SendErrorMessage {ref msg, } => {
4741 let mut msg_nonref = (*msg).clone();
4742 nativeErrorAction::SendErrorMessage {
4743 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
4746 ErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
4747 let mut msg_nonref = (*msg).clone();
4748 let mut log_level_nonref = (*log_level).clone();
4749 nativeErrorAction::SendWarningMessage {
4750 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
4751 log_level: log_level_nonref.into_native(),
4757 pub(crate) fn into_native(self) -> nativeErrorAction {
4759 ErrorAction::DisconnectPeer {mut msg, } => {
4760 let mut local_msg = if msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg.take_inner()) } }) };
4761 nativeErrorAction::DisconnectPeer {
4765 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
4766 ErrorAction::IgnoreAndLog (mut a, ) => {
4767 nativeErrorAction::IgnoreAndLog (
4771 ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
4772 ErrorAction::SendErrorMessage {mut msg, } => {
4773 nativeErrorAction::SendErrorMessage {
4774 msg: *unsafe { Box::from_raw(msg.take_inner()) },
4777 ErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
4778 nativeErrorAction::SendWarningMessage {
4779 msg: *unsafe { Box::from_raw(msg.take_inner()) },
4780 log_level: log_level.into_native(),
4786 pub(crate) fn from_native(native: &nativeErrorAction) -> Self {
4788 nativeErrorAction::DisconnectPeer {ref msg, } => {
4789 let mut msg_nonref = (*msg).clone();
4790 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 };
4791 ErrorAction::DisconnectPeer {
4792 msg: local_msg_nonref,
4795 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
4796 nativeErrorAction::IgnoreAndLog (ref a, ) => {
4797 let mut a_nonref = (*a).clone();
4798 ErrorAction::IgnoreAndLog (
4799 crate::lightning::util::logger::Level::native_into(a_nonref),
4802 nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
4803 nativeErrorAction::SendErrorMessage {ref msg, } => {
4804 let mut msg_nonref = (*msg).clone();
4805 ErrorAction::SendErrorMessage {
4806 msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
4809 nativeErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
4810 let mut msg_nonref = (*msg).clone();
4811 let mut log_level_nonref = (*log_level).clone();
4812 ErrorAction::SendWarningMessage {
4813 msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
4814 log_level: crate::lightning::util::logger::Level::native_into(log_level_nonref),
4820 pub(crate) fn native_into(native: nativeErrorAction) -> Self {
4822 nativeErrorAction::DisconnectPeer {mut msg, } => {
4823 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 };
4824 ErrorAction::DisconnectPeer {
4828 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
4829 nativeErrorAction::IgnoreAndLog (mut a, ) => {
4830 ErrorAction::IgnoreAndLog (
4831 crate::lightning::util::logger::Level::native_into(a),
4834 nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
4835 nativeErrorAction::SendErrorMessage {mut msg, } => {
4836 ErrorAction::SendErrorMessage {
4837 msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
4840 nativeErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
4841 ErrorAction::SendWarningMessage {
4842 msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
4843 log_level: crate::lightning::util::logger::Level::native_into(log_level),
4849 /// Frees any resources used by the ErrorAction
4851 pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { }
4852 /// Creates a copy of the ErrorAction
4854 pub extern "C" fn ErrorAction_clone(orig: &ErrorAction) -> ErrorAction {
4858 /// Utility method to constructs a new DisconnectPeer-variant ErrorAction
4859 pub extern "C" fn ErrorAction_disconnect_peer(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
4860 ErrorAction::DisconnectPeer {
4865 /// Utility method to constructs a new IgnoreError-variant ErrorAction
4866 pub extern "C" fn ErrorAction_ignore_error() -> ErrorAction {
4867 ErrorAction::IgnoreError}
4869 /// Utility method to constructs a new IgnoreAndLog-variant ErrorAction
4870 pub extern "C" fn ErrorAction_ignore_and_log(a: crate::lightning::util::logger::Level) -> ErrorAction {
4871 ErrorAction::IgnoreAndLog(a, )
4874 /// Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction
4875 pub extern "C" fn ErrorAction_ignore_duplicate_gossip() -> ErrorAction {
4876 ErrorAction::IgnoreDuplicateGossip}
4878 /// Utility method to constructs a new SendErrorMessage-variant ErrorAction
4879 pub extern "C" fn ErrorAction_send_error_message(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
4880 ErrorAction::SendErrorMessage {
4885 /// Utility method to constructs a new SendWarningMessage-variant ErrorAction
4886 pub extern "C" fn ErrorAction_send_warning_message(msg: crate::lightning::ln::msgs::WarningMessage, log_level: crate::lightning::util::logger::Level) -> ErrorAction {
4887 ErrorAction::SendWarningMessage {
4893 use lightning::ln::msgs::LightningError as nativeLightningErrorImport;
4894 pub(crate) type nativeLightningError = nativeLightningErrorImport;
4896 /// An Err type for failure to process messages.
4899 pub struct LightningError {
4900 /// A pointer to the opaque Rust object.
4902 /// Nearly everywhere, inner must be non-null, however in places where
4903 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4904 pub inner: *mut nativeLightningError,
4905 /// Indicates that this is the only struct which contains the same pointer.
4907 /// Rust functions which take ownership of an object provided via an argument require
4908 /// this to be true and invalidate the object pointed to by inner.
4912 impl Drop for LightningError {
4913 fn drop(&mut self) {
4914 if self.is_owned && !<*mut nativeLightningError>::is_null(self.inner) {
4915 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4919 /// Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL.
4921 pub extern "C" fn LightningError_free(this_obj: LightningError) { }
4923 /// Used only if an object of this type is returned as a trait impl by a method
4924 pub(crate) extern "C" fn LightningError_free_void(this_ptr: *mut c_void) {
4925 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeLightningError); }
4928 impl LightningError {
4929 pub(crate) fn get_native_ref(&self) -> &'static nativeLightningError {
4930 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4932 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLightningError {
4933 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4935 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4936 pub(crate) fn take_inner(mut self) -> *mut nativeLightningError {
4937 assert!(self.is_owned);
4938 let ret = ObjOps::untweak_ptr(self.inner);
4939 self.inner = core::ptr::null_mut();
4943 /// A human-readable message describing the error
4945 pub extern "C" fn LightningError_get_err(this_ptr: &LightningError) -> crate::c_types::Str {
4946 let mut inner_val = &mut this_ptr.get_native_mut_ref().err;
4947 inner_val.as_str().into()
4949 /// A human-readable message describing the error
4951 pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: crate::c_types::Str) {
4952 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.err = val.into_string();
4954 /// The action which should be taken against the offending peer.
4956 pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate::lightning::ln::msgs::ErrorAction {
4957 let mut inner_val = &mut this_ptr.get_native_mut_ref().action;
4958 crate::lightning::ln::msgs::ErrorAction::from_native(inner_val)
4960 /// The action which should be taken against the offending peer.
4962 pub extern "C" fn LightningError_set_action(this_ptr: &mut LightningError, mut val: crate::lightning::ln::msgs::ErrorAction) {
4963 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.action = val.into_native();
4965 /// Constructs a new LightningError given each field
4968 pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::Str, mut action_arg: crate::lightning::ln::msgs::ErrorAction) -> LightningError {
4969 LightningError { inner: ObjOps::heap_alloc(nativeLightningError {
4970 err: err_arg.into_string(),
4971 action: action_arg.into_native(),
4972 }), is_owned: true }
4974 impl Clone for LightningError {
4975 fn clone(&self) -> Self {
4977 inner: if <*mut nativeLightningError>::is_null(self.inner) { core::ptr::null_mut() } else {
4978 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4984 /// Used only if an object of this type is returned as a trait impl by a method
4985 pub(crate) extern "C" fn LightningError_clone_void(this_ptr: *const c_void) -> *mut c_void {
4986 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeLightningError)).clone() })) as *mut c_void
4989 /// Creates a copy of the LightningError
4990 pub extern "C" fn LightningError_clone(orig: &LightningError) -> LightningError {
4994 use lightning::ln::msgs::CommitmentUpdate as nativeCommitmentUpdateImport;
4995 pub(crate) type nativeCommitmentUpdate = nativeCommitmentUpdateImport;
4997 /// Struct used to return values from revoke_and_ack messages, containing a bunch of commitment
4998 /// transaction updates if they were pending.
5001 pub struct CommitmentUpdate {
5002 /// A pointer to the opaque Rust object.
5004 /// Nearly everywhere, inner must be non-null, however in places where
5005 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
5006 pub inner: *mut nativeCommitmentUpdate,
5007 /// Indicates that this is the only struct which contains the same pointer.
5009 /// Rust functions which take ownership of an object provided via an argument require
5010 /// this to be true and invalidate the object pointed to by inner.
5014 impl Drop for CommitmentUpdate {
5015 fn drop(&mut self) {
5016 if self.is_owned && !<*mut nativeCommitmentUpdate>::is_null(self.inner) {
5017 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
5021 /// Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL.
5023 pub extern "C" fn CommitmentUpdate_free(this_obj: CommitmentUpdate) { }
5025 /// Used only if an object of this type is returned as a trait impl by a method
5026 pub(crate) extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) {
5027 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentUpdate); }
5030 impl CommitmentUpdate {
5031 pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentUpdate {
5032 unsafe { &*ObjOps::untweak_ptr(self.inner) }
5034 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentUpdate {
5035 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
5037 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
5038 pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentUpdate {
5039 assert!(self.is_owned);
5040 let ret = ObjOps::untweak_ptr(self.inner);
5041 self.inner = core::ptr::null_mut();
5045 /// update_add_htlc messages which should be sent
5047 pub extern "C" fn CommitmentUpdate_get_update_add_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateAddHTLCZ {
5048 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_add_htlcs;
5049 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 } }); };
5050 local_inner_val.into()
5052 /// update_add_htlc messages which should be sent
5054 pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) {
5055 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
5056 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_add_htlcs = local_val;
5058 /// update_fulfill_htlc messages which should be sent
5060 pub extern "C" fn CommitmentUpdate_get_update_fulfill_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFulfillHTLCZ {
5061 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fulfill_htlcs;
5062 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 } }); };
5063 local_inner_val.into()
5065 /// update_fulfill_htlc messages which should be sent
5067 pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) {
5068 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
5069 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fulfill_htlcs = local_val;
5071 /// update_fail_htlc messages which should be sent
5073 pub extern "C" fn CommitmentUpdate_get_update_fail_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailHTLCZ {
5074 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_htlcs;
5075 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 } }); };
5076 local_inner_val.into()
5078 /// update_fail_htlc messages which should be sent
5080 pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) {
5081 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
5082 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_htlcs = local_val;
5084 /// update_fail_malformed_htlc messages which should be sent
5086 pub extern "C" fn CommitmentUpdate_get_update_fail_malformed_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ {
5087 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_malformed_htlcs;
5088 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 } }); };
5089 local_inner_val.into()
5091 /// update_fail_malformed_htlc messages which should be sent
5093 pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) {
5094 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
5095 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_malformed_htlcs = local_val;
5097 /// An update_fee message which should be sent
5099 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
5101 pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::UpdateFee {
5102 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fee;
5103 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 };
5106 /// An update_fee message which should be sent
5108 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
5110 pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::UpdateFee) {
5111 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
5112 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fee = local_val;
5114 /// Finally, the commitment_signed message which should be sent
5116 pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::CommitmentSigned {
5117 let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_signed;
5118 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 }
5120 /// Finally, the commitment_signed message which should be sent
5122 pub extern "C" fn CommitmentUpdate_set_commitment_signed(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::CommitmentSigned) {
5123 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_signed = *unsafe { Box::from_raw(val.take_inner()) };
5125 /// Constructs a new CommitmentUpdate given each field
5128 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 {
5129 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()) } }); };
5130 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()) } }); };
5131 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()) } }); };
5132 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()) } }); };
5133 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()) } }) };
5134 CommitmentUpdate { inner: ObjOps::heap_alloc(nativeCommitmentUpdate {
5135 update_add_htlcs: local_update_add_htlcs_arg,
5136 update_fulfill_htlcs: local_update_fulfill_htlcs_arg,
5137 update_fail_htlcs: local_update_fail_htlcs_arg,
5138 update_fail_malformed_htlcs: local_update_fail_malformed_htlcs_arg,
5139 update_fee: local_update_fee_arg,
5140 commitment_signed: *unsafe { Box::from_raw(commitment_signed_arg.take_inner()) },
5141 }), is_owned: true }
5143 impl Clone for CommitmentUpdate {
5144 fn clone(&self) -> Self {
5146 inner: if <*mut nativeCommitmentUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
5147 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
5153 /// Used only if an object of this type is returned as a trait impl by a method
5154 pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
5155 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentUpdate)).clone() })) as *mut c_void
5158 /// Creates a copy of the CommitmentUpdate
5159 pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentUpdate {
5162 /// A trait to describe an object which can receive channel messages.
5164 /// Messages MAY be called in parallel when they originate from different their_node_ids, however
5165 /// they MUST NOT be called in parallel when the two calls have the same their_node_id.
5167 pub struct ChannelMessageHandler {
5168 /// An opaque pointer which is passed to your function implementations as an argument.
5169 /// This has no meaning in the LDK, and can be NULL or any other value.
5170 pub this_arg: *mut c_void,
5171 /// Handle an incoming open_channel message from the given peer.
5172 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),
5173 /// Handle an incoming accept_channel message from the given peer.
5174 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),
5175 /// Handle an incoming funding_created message from the given peer.
5176 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),
5177 /// Handle an incoming funding_signed message from the given peer.
5178 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),
5179 /// Handle an incoming channel_ready message from the given peer.
5180 pub handle_channel_ready: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelReady),
5181 /// Handle an incoming shutdown message from the given peer.
5182 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),
5183 /// Handle an incoming closing_signed message from the given peer.
5184 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),
5185 /// Handle an incoming update_add_htlc message from the given peer.
5186 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),
5187 /// Handle an incoming update_fulfill_htlc message from the given peer.
5188 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),
5189 /// Handle an incoming update_fail_htlc message from the given peer.
5190 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),
5191 /// Handle an incoming update_fail_malformed_htlc message from the given peer.
5192 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),
5193 /// Handle an incoming commitment_signed message from the given peer.
5194 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),
5195 /// Handle an incoming revoke_and_ack message from the given peer.
5196 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),
5197 /// Handle an incoming update_fee message from the given peer.
5198 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),
5199 /// Handle an incoming announcement_signatures message from the given peer.
5200 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),
5201 /// Indicates a connection to the peer failed/an existing connection was lost. If no connection
5202 /// is believed to be possible in the future (eg they're sending us messages we don't
5203 /// understand or indicate they require unknown feature bits), no_connection_possible is set
5204 /// and any outstanding channels should be failed.
5205 pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, no_connection_possible: bool),
5206 /// Handle a peer reconnecting, possibly generating channel_reestablish message(s).
5207 pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Init),
5208 /// Handle an incoming channel_reestablish message from the given peer.
5209 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),
5210 /// Handle an incoming channel update from the given peer.
5211 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),
5212 /// Handle an incoming error message from the given peer.
5213 pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ErrorMessage),
5214 /// Implementation of MessageSendEventsProvider for this object.
5215 pub MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider,
5216 /// Frees any resources associated with this object given its this_arg pointer.
5217 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
5218 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
5220 unsafe impl Send for ChannelMessageHandler {}
5221 unsafe impl Sync for ChannelMessageHandler {}
5223 pub(crate) extern "C" fn ChannelMessageHandler_clone_fields(orig: &ChannelMessageHandler) -> ChannelMessageHandler {
5224 ChannelMessageHandler {
5225 this_arg: orig.this_arg,
5226 handle_open_channel: Clone::clone(&orig.handle_open_channel),
5227 handle_accept_channel: Clone::clone(&orig.handle_accept_channel),
5228 handle_funding_created: Clone::clone(&orig.handle_funding_created),
5229 handle_funding_signed: Clone::clone(&orig.handle_funding_signed),
5230 handle_channel_ready: Clone::clone(&orig.handle_channel_ready),
5231 handle_shutdown: Clone::clone(&orig.handle_shutdown),
5232 handle_closing_signed: Clone::clone(&orig.handle_closing_signed),
5233 handle_update_add_htlc: Clone::clone(&orig.handle_update_add_htlc),
5234 handle_update_fulfill_htlc: Clone::clone(&orig.handle_update_fulfill_htlc),
5235 handle_update_fail_htlc: Clone::clone(&orig.handle_update_fail_htlc),
5236 handle_update_fail_malformed_htlc: Clone::clone(&orig.handle_update_fail_malformed_htlc),
5237 handle_commitment_signed: Clone::clone(&orig.handle_commitment_signed),
5238 handle_revoke_and_ack: Clone::clone(&orig.handle_revoke_and_ack),
5239 handle_update_fee: Clone::clone(&orig.handle_update_fee),
5240 handle_announcement_signatures: Clone::clone(&orig.handle_announcement_signatures),
5241 peer_disconnected: Clone::clone(&orig.peer_disconnected),
5242 peer_connected: Clone::clone(&orig.peer_connected),
5243 handle_channel_reestablish: Clone::clone(&orig.handle_channel_reestablish),
5244 handle_channel_update: Clone::clone(&orig.handle_channel_update),
5245 handle_error: Clone::clone(&orig.handle_error),
5246 MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
5247 free: Clone::clone(&orig.free),
5250 impl lightning::util::events::MessageSendEventsProvider for ChannelMessageHandler {
5251 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
5252 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
5253 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
5258 use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler;
5259 impl rustChannelMessageHandler for ChannelMessageHandler {
5260 fn handle_open_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut their_features: lightning::ln::features::InitFeatures, mut msg: &lightning::ln::msgs::OpenChannel) {
5261 (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 })
5263 fn handle_accept_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut their_features: lightning::ln::features::InitFeatures, mut msg: &lightning::ln::msgs::AcceptChannel) {
5264 (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 })
5266 fn handle_funding_created(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingCreated) {
5267 (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 })
5269 fn handle_funding_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingSigned) {
5270 (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 })
5272 fn handle_channel_ready(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReady) {
5273 (self.handle_channel_ready)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ChannelReady { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelReady<>) as *mut _) }, is_owned: false })
5275 fn handle_shutdown(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut their_features: &lightning::ln::features::InitFeatures, mut msg: &lightning::ln::msgs::Shutdown) {
5276 (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 })
5278 fn handle_closing_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ClosingSigned) {
5279 (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 })
5281 fn handle_update_add_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateAddHTLC) {
5282 (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 })
5284 fn handle_update_fulfill_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFulfillHTLC) {
5285 (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 })
5287 fn handle_update_fail_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailHTLC) {
5288 (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 })
5290 fn handle_update_fail_malformed_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) {
5291 (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 })
5293 fn handle_commitment_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::CommitmentSigned) {
5294 (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 })
5296 fn handle_revoke_and_ack(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::RevokeAndACK) {
5297 (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 })
5299 fn handle_update_fee(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFee) {
5300 (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 })
5302 fn handle_announcement_signatures(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AnnouncementSignatures) {
5303 (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 })
5305 fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut no_connection_possible: bool) {
5306 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), no_connection_possible)
5308 fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Init) {
5309 (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 })
5311 fn handle_channel_reestablish(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReestablish) {
5312 (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 })
5314 fn handle_channel_update(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelUpdate) {
5315 (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 })
5317 fn handle_error(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ErrorMessage) {
5318 (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 })
5322 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
5323 // directly as a Deref trait in higher-level structs:
5324 impl core::ops::Deref for ChannelMessageHandler {
5326 fn deref(&self) -> &Self {
5330 /// Calls the free function if one is set
5332 pub extern "C" fn ChannelMessageHandler_free(this_ptr: ChannelMessageHandler) { }
5333 impl Drop for ChannelMessageHandler {
5334 fn drop(&mut self) {
5335 if let Some(f) = self.free {
5340 /// A trait to describe an object which can receive routing messages.
5342 /// # Implementor DoS Warnings
5344 /// For `gossip_queries` messages there are potential DoS vectors when handling
5345 /// inbound queries. Implementors using an on-disk network graph should be aware of
5346 /// repeated disk I/O for queries accessing different parts of the network graph.
5348 pub struct RoutingMessageHandler {
5349 /// An opaque pointer which is passed to your function implementations as an argument.
5350 /// This has no meaning in the LDK, and can be NULL or any other value.
5351 pub this_arg: *mut c_void,
5352 /// Handle an incoming node_announcement message, returning true if it should be forwarded on,
5353 /// false or returning an Err otherwise.
5355 pub handle_node_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
5356 /// Handle a channel_announcement message, returning true if it should be forwarded on, false
5357 /// or returning an Err otherwise.
5359 pub handle_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
5360 /// Handle an incoming channel_update message, returning true if it should be forwarded on,
5361 /// false or returning an Err otherwise.
5363 pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ,
5364 /// Gets a subset of the channel announcements and updates required to dump our routing table
5365 /// to a remote node, starting at the short_channel_id indicated by starting_point and
5366 /// including the batch_amount entries immediately higher in numerical value than starting_point.
5368 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,
5369 /// Gets a subset of the node announcements required to dump our routing table to a remote node,
5370 /// starting at the node *after* the provided publickey and including batch_amount entries
5371 /// immediately higher (as defined by <PublicKey as Ord>::cmp) than starting_point.
5372 /// If None is provided for starting_point, we start at the first node.
5374 /// Note that starting_point (or a relevant inner pointer) may be NULL or all-0s to represent None
5376 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,
5377 /// Called when a connection is established with a peer. This can be used to
5378 /// perform routing table synchronization using a strategy defined by the
5380 pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, init: &crate::lightning::ln::msgs::Init),
5381 /// Handles the reply of a query we initiated to learn about channels
5382 /// for a given range of blocks. We can expect to receive one or more
5383 /// replies to a single query.
5385 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,
5386 /// Handles the reply of a query we initiated asking for routing gossip
5387 /// messages for a list of channels. We should receive this message when
5388 /// a node has completed its best effort to send us the pertaining routing
5389 /// gossip messages.
5391 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,
5392 /// Handles when a peer asks us to send a list of short_channel_ids
5393 /// for the requested range of blocks.
5395 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,
5396 /// Handles when a peer asks us to send routing gossip messages for a
5397 /// list of short_channel_ids.
5399 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,
5400 /// Implementation of MessageSendEventsProvider for this object.
5401 pub MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider,
5402 /// Frees any resources associated with this object given its this_arg pointer.
5403 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
5404 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
5406 unsafe impl Send for RoutingMessageHandler {}
5407 unsafe impl Sync for RoutingMessageHandler {}
5409 pub(crate) extern "C" fn RoutingMessageHandler_clone_fields(orig: &RoutingMessageHandler) -> RoutingMessageHandler {
5410 RoutingMessageHandler {
5411 this_arg: orig.this_arg,
5412 handle_node_announcement: Clone::clone(&orig.handle_node_announcement),
5413 handle_channel_announcement: Clone::clone(&orig.handle_channel_announcement),
5414 handle_channel_update: Clone::clone(&orig.handle_channel_update),
5415 get_next_channel_announcements: Clone::clone(&orig.get_next_channel_announcements),
5416 get_next_node_announcements: Clone::clone(&orig.get_next_node_announcements),
5417 peer_connected: Clone::clone(&orig.peer_connected),
5418 handle_reply_channel_range: Clone::clone(&orig.handle_reply_channel_range),
5419 handle_reply_short_channel_ids_end: Clone::clone(&orig.handle_reply_short_channel_ids_end),
5420 handle_query_channel_range: Clone::clone(&orig.handle_query_channel_range),
5421 handle_query_short_channel_ids: Clone::clone(&orig.handle_query_short_channel_ids),
5422 MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
5423 free: Clone::clone(&orig.free),
5426 impl lightning::util::events::MessageSendEventsProvider for RoutingMessageHandler {
5427 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
5428 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
5429 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
5434 use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler;
5435 impl rustRoutingMessageHandler for RoutingMessageHandler {
5436 fn handle_node_announcement(&self, mut msg: &lightning::ln::msgs::NodeAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
5437 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 });
5438 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()) } })};
5441 fn handle_channel_announcement(&self, mut msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
5442 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 });
5443 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()) } })};
5446 fn handle_channel_update(&self, mut msg: &lightning::ln::msgs::ChannelUpdate) -> Result<bool, lightning::ln::msgs::LightningError> {
5447 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 });
5448 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()) } })};
5451 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>)> {
5452 let mut ret = (self.get_next_channel_announcements)(self.this_arg, starting_point, batch_amount);
5453 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 }); };
5456 fn get_next_node_announcements(&self, mut starting_point: Option<&bitcoin::secp256k1::PublicKey>, mut batch_amount: u8) -> Vec<lightning::ln::msgs::NodeAnnouncement> {
5457 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())) } };
5458 let mut ret = (self.get_next_node_announcements)(self.this_arg, local_starting_point, batch_amount);
5459 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
5462 fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init) {
5463 (self.peer_connected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { ObjOps::nonnull_ptr_to_inner((init as *const lightning::ln::msgs::Init<>) as *mut _) }, is_owned: false })
5465 fn handle_reply_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::ReplyChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
5466 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 });
5467 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()) } })};
5470 fn handle_reply_short_channel_ids_end(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::ReplyShortChannelIdsEnd) -> Result<(), lightning::ln::msgs::LightningError> {
5471 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 });
5472 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()) } })};
5475 fn handle_query_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::QueryChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
5476 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 });
5477 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()) } })};
5480 fn handle_query_short_channel_ids(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::QueryShortChannelIds) -> Result<(), lightning::ln::msgs::LightningError> {
5481 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 });
5482 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()) } })};
5487 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
5488 // directly as a Deref trait in higher-level structs:
5489 impl core::ops::Deref for RoutingMessageHandler {
5491 fn deref(&self) -> &Self {
5495 /// Calls the free function if one is set
5497 pub extern "C" fn RoutingMessageHandler_free(this_ptr: RoutingMessageHandler) { }
5498 impl Drop for RoutingMessageHandler {
5499 fn drop(&mut self) {
5500 if let Some(f) = self.free {
5505 mod fuzzy_internal_msgs {
5507 use alloc::str::FromStr;
5508 use core::ffi::c_void;
5509 use core::convert::Infallible;
5510 use bitcoin::hashes::Hash;
5511 use crate::c_types::*;
5512 #[cfg(feature="no-std")]
5513 use alloc::{vec::Vec, boxed::Box};
5517 /// Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read
5518 pub extern "C" fn AcceptChannel_write(obj: &crate::lightning::ln::msgs::AcceptChannel) -> crate::c_types::derived::CVec_u8Z {
5519 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5522 pub(crate) extern "C" fn AcceptChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5523 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannel) })
5526 /// Read a AcceptChannel from a byte array, created by AcceptChannel_write
5527 pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelDecodeErrorZ {
5528 let res: Result<lightning::ln::msgs::AcceptChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5529 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() };
5533 /// Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read
5534 pub extern "C" fn AnnouncementSignatures_write(obj: &crate::lightning::ln::msgs::AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z {
5535 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5538 pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5539 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAnnouncementSignatures) })
5542 /// Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write
5543 pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AnnouncementSignaturesDecodeErrorZ {
5544 let res: Result<lightning::ln::msgs::AnnouncementSignatures, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5545 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() };
5549 /// Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read
5550 pub extern "C" fn ChannelReestablish_write(obj: &crate::lightning::ln::msgs::ChannelReestablish) -> crate::c_types::derived::CVec_u8Z {
5551 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5554 pub(crate) extern "C" fn ChannelReestablish_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5555 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReestablish) })
5558 /// Read a ChannelReestablish from a byte array, created by ChannelReestablish_write
5559 pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReestablishDecodeErrorZ {
5560 let res: Result<lightning::ln::msgs::ChannelReestablish, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5561 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() };
5565 /// Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read
5566 pub extern "C" fn ClosingSigned_write(obj: &crate::lightning::ln::msgs::ClosingSigned) -> crate::c_types::derived::CVec_u8Z {
5567 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5570 pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5571 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSigned) })
5574 /// Read a ClosingSigned from a byte array, created by ClosingSigned_write
5575 pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedDecodeErrorZ {
5576 let res: Result<lightning::ln::msgs::ClosingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5577 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() };
5581 /// Serialize the ClosingSignedFeeRange object into a byte array which can be read by ClosingSignedFeeRange_read
5582 pub extern "C" fn ClosingSignedFeeRange_write(obj: &crate::lightning::ln::msgs::ClosingSignedFeeRange) -> crate::c_types::derived::CVec_u8Z {
5583 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5586 pub(crate) extern "C" fn ClosingSignedFeeRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5587 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSignedFeeRange) })
5590 /// Read a ClosingSignedFeeRange from a byte array, created by ClosingSignedFeeRange_write
5591 pub extern "C" fn ClosingSignedFeeRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedFeeRangeDecodeErrorZ {
5592 let res: Result<lightning::ln::msgs::ClosingSignedFeeRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5593 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::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() };
5597 /// Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read
5598 pub extern "C" fn CommitmentSigned_write(obj: &crate::lightning::ln::msgs::CommitmentSigned) -> crate::c_types::derived::CVec_u8Z {
5599 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5602 pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5603 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentSigned) })
5606 /// Read a CommitmentSigned from a byte array, created by CommitmentSigned_write
5607 pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CommitmentSignedDecodeErrorZ {
5608 let res: Result<lightning::ln::msgs::CommitmentSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5609 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() };
5613 /// Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read
5614 pub extern "C" fn FundingCreated_write(obj: &crate::lightning::ln::msgs::FundingCreated) -> crate::c_types::derived::CVec_u8Z {
5615 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5618 pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5619 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingCreated) })
5622 /// Read a FundingCreated from a byte array, created by FundingCreated_write
5623 pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingCreatedDecodeErrorZ {
5624 let res: Result<lightning::ln::msgs::FundingCreated, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5625 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() };
5629 /// Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read
5630 pub extern "C" fn FundingSigned_write(obj: &crate::lightning::ln::msgs::FundingSigned) -> crate::c_types::derived::CVec_u8Z {
5631 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5634 pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5635 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingSigned) })
5638 /// Read a FundingSigned from a byte array, created by FundingSigned_write
5639 pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingSignedDecodeErrorZ {
5640 let res: Result<lightning::ln::msgs::FundingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5641 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() };
5645 /// Serialize the ChannelReady object into a byte array which can be read by ChannelReady_read
5646 pub extern "C" fn ChannelReady_write(obj: &crate::lightning::ln::msgs::ChannelReady) -> crate::c_types::derived::CVec_u8Z {
5647 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5650 pub(crate) extern "C" fn ChannelReady_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5651 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReady) })
5654 /// Read a ChannelReady from a byte array, created by ChannelReady_write
5655 pub extern "C" fn ChannelReady_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReadyDecodeErrorZ {
5656 let res: Result<lightning::ln::msgs::ChannelReady, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5657 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ChannelReady { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
5661 /// Serialize the Init object into a byte array which can be read by Init_read
5662 pub extern "C" fn Init_write(obj: &crate::lightning::ln::msgs::Init) -> crate::c_types::derived::CVec_u8Z {
5663 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5666 pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5667 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInit) })
5670 /// Read a Init from a byte array, created by Init_write
5671 pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitDecodeErrorZ {
5672 let res: Result<lightning::ln::msgs::Init, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5673 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() };
5677 /// Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read
5678 pub extern "C" fn OpenChannel_write(obj: &crate::lightning::ln::msgs::OpenChannel) -> crate::c_types::derived::CVec_u8Z {
5679 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5682 pub(crate) extern "C" fn OpenChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5683 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannel) })
5686 /// Read a OpenChannel from a byte array, created by OpenChannel_write
5687 pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelDecodeErrorZ {
5688 let res: Result<lightning::ln::msgs::OpenChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5689 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() };
5693 /// Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read
5694 pub extern "C" fn RevokeAndACK_write(obj: &crate::lightning::ln::msgs::RevokeAndACK) -> crate::c_types::derived::CVec_u8Z {
5695 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5698 pub(crate) extern "C" fn RevokeAndACK_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5699 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevokeAndACK) })
5702 /// Read a RevokeAndACK from a byte array, created by RevokeAndACK_write
5703 pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RevokeAndACKDecodeErrorZ {
5704 let res: Result<lightning::ln::msgs::RevokeAndACK, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5705 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() };
5709 /// Serialize the Shutdown object into a byte array which can be read by Shutdown_read
5710 pub extern "C" fn Shutdown_write(obj: &crate::lightning::ln::msgs::Shutdown) -> crate::c_types::derived::CVec_u8Z {
5711 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5714 pub(crate) extern "C" fn Shutdown_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5715 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeShutdown) })
5718 /// Read a Shutdown from a byte array, created by Shutdown_write
5719 pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ShutdownDecodeErrorZ {
5720 let res: Result<lightning::ln::msgs::Shutdown, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5721 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() };
5725 /// Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read
5726 pub extern "C" fn UpdateFailHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFailHTLC) -> crate::c_types::derived::CVec_u8Z {
5727 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5730 pub(crate) extern "C" fn UpdateFailHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5731 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailHTLC) })
5734 /// Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write
5735 pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailHTLCDecodeErrorZ {
5736 let res: Result<lightning::ln::msgs::UpdateFailHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5737 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() };
5741 /// Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read
5742 pub extern "C" fn UpdateFailMalformedHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFailMalformedHTLC) -> crate::c_types::derived::CVec_u8Z {
5743 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5746 pub(crate) extern "C" fn UpdateFailMalformedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5747 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailMalformedHTLC) })
5750 /// Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write
5751 pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailMalformedHTLCDecodeErrorZ {
5752 let res: Result<lightning::ln::msgs::UpdateFailMalformedHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5753 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() };
5757 /// Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read
5758 pub extern "C" fn UpdateFee_write(obj: &crate::lightning::ln::msgs::UpdateFee) -> crate::c_types::derived::CVec_u8Z {
5759 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5762 pub(crate) extern "C" fn UpdateFee_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5763 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFee) })
5766 /// Read a UpdateFee from a byte array, created by UpdateFee_write
5767 pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFeeDecodeErrorZ {
5768 let res: Result<lightning::ln::msgs::UpdateFee, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5769 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() };
5773 /// Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read
5774 pub extern "C" fn UpdateFulfillHTLC_write(obj: &crate::lightning::ln::msgs::UpdateFulfillHTLC) -> crate::c_types::derived::CVec_u8Z {
5775 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5778 pub(crate) extern "C" fn UpdateFulfillHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5779 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFulfillHTLC) })
5782 /// Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write
5783 pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFulfillHTLCDecodeErrorZ {
5784 let res: Result<lightning::ln::msgs::UpdateFulfillHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5785 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() };
5789 /// Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read
5790 pub extern "C" fn UpdateAddHTLC_write(obj: &crate::lightning::ln::msgs::UpdateAddHTLC) -> crate::c_types::derived::CVec_u8Z {
5791 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5794 pub(crate) extern "C" fn UpdateAddHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5795 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateAddHTLC) })
5798 /// Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write
5799 pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateAddHTLCDecodeErrorZ {
5800 let res: Result<lightning::ln::msgs::UpdateAddHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5801 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() };
5805 /// Serialize the Ping object into a byte array which can be read by Ping_read
5806 pub extern "C" fn Ping_write(obj: &crate::lightning::ln::msgs::Ping) -> crate::c_types::derived::CVec_u8Z {
5807 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5810 pub(crate) extern "C" fn Ping_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5811 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePing) })
5814 /// Read a Ping from a byte array, created by Ping_write
5815 pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PingDecodeErrorZ {
5816 let res: Result<lightning::ln::msgs::Ping, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5817 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() };
5821 /// Serialize the Pong object into a byte array which can be read by Pong_read
5822 pub extern "C" fn Pong_write(obj: &crate::lightning::ln::msgs::Pong) -> crate::c_types::derived::CVec_u8Z {
5823 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5826 pub(crate) extern "C" fn Pong_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5827 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePong) })
5830 /// Read a Pong from a byte array, created by Pong_write
5831 pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PongDecodeErrorZ {
5832 let res: Result<lightning::ln::msgs::Pong, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5833 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() };
5837 /// Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read
5838 pub extern "C" fn UnsignedChannelAnnouncement_write(obj: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
5839 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5842 pub(crate) extern "C" fn UnsignedChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5843 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelAnnouncement) })
5846 /// Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write
5847 pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelAnnouncementDecodeErrorZ {
5848 let res: Result<lightning::ln::msgs::UnsignedChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5849 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() };
5853 /// Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read
5854 pub extern "C" fn ChannelAnnouncement_write(obj: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
5855 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5858 pub(crate) extern "C" fn ChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5859 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelAnnouncement) })
5862 /// Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write
5863 pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelAnnouncementDecodeErrorZ {
5864 let res: Result<lightning::ln::msgs::ChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5865 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() };
5869 /// Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read
5870 pub extern "C" fn UnsignedChannelUpdate_write(obj: &crate::lightning::ln::msgs::UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
5871 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5874 pub(crate) extern "C" fn UnsignedChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5875 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelUpdate) })
5878 /// Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write
5879 pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelUpdateDecodeErrorZ {
5880 let res: Result<lightning::ln::msgs::UnsignedChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5881 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() };
5885 /// Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read
5886 pub extern "C" fn ChannelUpdate_write(obj: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
5887 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5890 pub(crate) extern "C" fn ChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5891 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdate) })
5894 /// Read a ChannelUpdate from a byte array, created by ChannelUpdate_write
5895 pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelUpdateDecodeErrorZ {
5896 let res: Result<lightning::ln::msgs::ChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5897 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() };
5901 /// Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read
5902 pub extern "C" fn ErrorMessage_write(obj: &crate::lightning::ln::msgs::ErrorMessage) -> crate::c_types::derived::CVec_u8Z {
5903 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5906 pub(crate) extern "C" fn ErrorMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5907 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeErrorMessage) })
5910 /// Read a ErrorMessage from a byte array, created by ErrorMessage_write
5911 pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ErrorMessageDecodeErrorZ {
5912 let res: Result<lightning::ln::msgs::ErrorMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5913 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() };
5917 /// Serialize the WarningMessage object into a byte array which can be read by WarningMessage_read
5918 pub extern "C" fn WarningMessage_write(obj: &crate::lightning::ln::msgs::WarningMessage) -> crate::c_types::derived::CVec_u8Z {
5919 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5922 pub(crate) extern "C" fn WarningMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5923 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeWarningMessage) })
5926 /// Read a WarningMessage from a byte array, created by WarningMessage_write
5927 pub extern "C" fn WarningMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_WarningMessageDecodeErrorZ {
5928 let res: Result<lightning::ln::msgs::WarningMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5929 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() };
5933 /// Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read
5934 pub extern "C" fn UnsignedNodeAnnouncement_write(obj: &crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
5935 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5938 pub(crate) extern "C" fn UnsignedNodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5939 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedNodeAnnouncement) })
5942 /// Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write
5943 pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedNodeAnnouncementDecodeErrorZ {
5944 let res: Result<lightning::ln::msgs::UnsignedNodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5945 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() };
5949 /// Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read
5950 pub extern "C" fn NodeAnnouncement_write(obj: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
5951 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5954 pub(crate) extern "C" fn NodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5955 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncement) })
5958 /// Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write
5959 pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementDecodeErrorZ {
5960 let res: Result<lightning::ln::msgs::NodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5961 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() };
5965 /// Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write
5966 pub extern "C" fn QueryShortChannelIds_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryShortChannelIdsDecodeErrorZ {
5967 let res: Result<lightning::ln::msgs::QueryShortChannelIds, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5968 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() };
5972 /// Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read
5973 pub extern "C" fn QueryShortChannelIds_write(obj: &crate::lightning::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CVec_u8Z {
5974 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5977 pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5978 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) })
5981 /// Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read
5982 pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z {
5983 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5986 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5987 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) })
5990 /// Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write
5991 pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyShortChannelIdsEndDecodeErrorZ {
5992 let res: Result<lightning::ln::msgs::ReplyShortChannelIdsEnd, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5993 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() };
5996 ///\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
5999 pub extern "C" fn QueryChannelRange_end_blocknum(this_arg: &crate::lightning::ln::msgs::QueryChannelRange) -> u32 {
6000 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.end_blocknum();
6005 /// Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read
6006 pub extern "C" fn QueryChannelRange_write(obj: &crate::lightning::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CVec_u8Z {
6007 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6010 pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6011 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) })
6014 /// Read a QueryChannelRange from a byte array, created by QueryChannelRange_write
6015 pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ {
6016 let res: Result<lightning::ln::msgs::QueryChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6017 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() };
6021 /// Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write
6022 pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyChannelRangeDecodeErrorZ {
6023 let res: Result<lightning::ln::msgs::ReplyChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6024 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() };
6028 /// Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read
6029 pub extern "C" fn ReplyChannelRange_write(obj: &crate::lightning::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CVec_u8Z {
6030 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6033 pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6034 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) })
6037 /// Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read
6038 pub extern "C" fn GossipTimestampFilter_write(obj: &crate::lightning::ln::msgs::GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z {
6039 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
6042 pub(crate) extern "C" fn GossipTimestampFilter_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
6043 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeGossipTimestampFilter) })
6046 /// Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write
6047 pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_GossipTimestampFilterDecodeErrorZ {
6048 let res: Result<lightning::ln::msgs::GossipTimestampFilter, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
6049 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() };