1 // This file is Copyright its original authors, visible in version control
2 // history and in the source files from which this was generated.
4 // This file is licensed under the license available in the LICENSE or LICENSE.md
5 // file in the root of this repository or, if no such file exists, the same
6 // license as that which applies to the original source files from which this
7 // source was automatically generated.
9 //! Wire messages, traits representing wire message handlers, and a few error types live here.
11 //! For a normal node you probably don't need to use anything here, however, if you wish to split a
12 //! node into an internet-facing route/message socket handling daemon and a separate daemon (or
13 //! server entirely) which handles only channel-related messages you may wish to implement
14 //! ChannelMessageHandler yourself and use it to re-serialize messages and pass them across
17 //! Note that if you go with such an architecture (instead of passing raw socket events to a
18 //! non-internet-facing system) you trust the frontend internet-facing system to not lie about the
19 //! source node_id of the message, however this does allow you to significantly reduce bandwidth
20 //! between the systems as routing messages can represent a significant chunk of bandwidth usage
21 //! (especially for non-channel-publicly-announcing nodes). As an alternate design which avoids
22 //! this issue, if you have sufficient bidirectional bandwidth between your systems, you may send
23 //! raw socket events into your non-internet-facing system and then send routing events back to
24 //! track the network on the less-secure system.
26 use alloc::str::FromStr;
27 use core::ffi::c_void;
28 use core::convert::Infallible;
29 use bitcoin::hashes::Hash;
30 use crate::c_types::*;
31 #[cfg(feature="no-std")]
32 use alloc::{vec::Vec, boxed::Box};
35 use lightning::ln::msgs::DecodeError as nativeDecodeErrorImport;
36 pub(crate) type nativeDecodeError = nativeDecodeErrorImport;
38 /// An error in decoding a message or struct.
41 pub struct DecodeError {
42 /// A pointer to the opaque Rust object.
44 /// Nearly everywhere, inner must be non-null, however in places where
45 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
46 pub inner: *mut nativeDecodeError,
47 /// Indicates that this is the only struct which contains the same pointer.
49 /// Rust functions which take ownership of an object provided via an argument require
50 /// this to be true and invalidate the object pointed to by inner.
54 impl Drop for DecodeError {
56 if self.is_owned && !<*mut nativeDecodeError>::is_null(self.inner) {
57 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
61 /// Frees any resources used by the DecodeError, if is_owned is set and inner is non-NULL.
63 pub extern "C" fn DecodeError_free(this_obj: DecodeError) { }
65 /// Used only if an object of this type is returned as a trait impl by a method
66 pub(crate) extern "C" fn DecodeError_free_void(this_ptr: *mut c_void) {
67 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDecodeError); }
71 pub(crate) fn get_native_ref(&self) -> &'static nativeDecodeError {
72 unsafe { &*ObjOps::untweak_ptr(self.inner) }
74 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeDecodeError {
75 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
77 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
78 pub(crate) fn take_inner(mut self) -> *mut nativeDecodeError {
79 assert!(self.is_owned);
80 let ret = ObjOps::untweak_ptr(self.inner);
81 self.inner = core::ptr::null_mut();
85 impl Clone for DecodeError {
86 fn clone(&self) -> Self {
88 inner: if <*mut nativeDecodeError>::is_null(self.inner) { core::ptr::null_mut() } else {
89 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
95 /// Used only if an object of this type is returned as a trait impl by a method
96 pub(crate) extern "C" fn DecodeError_clone_void(this_ptr: *const c_void) -> *mut c_void {
97 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDecodeError)).clone() })) as *mut c_void
100 /// Creates a copy of the DecodeError
101 pub extern "C" fn DecodeError_clone(orig: &DecodeError) -> DecodeError {
105 use lightning::ln::msgs::Init as nativeInitImport;
106 pub(crate) type nativeInit = nativeInitImport;
108 /// An init message to be sent or received from a peer
112 /// A pointer to the opaque Rust object.
114 /// Nearly everywhere, inner must be non-null, however in places where
115 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
116 pub inner: *mut nativeInit,
117 /// Indicates that this is the only struct which contains the same pointer.
119 /// Rust functions which take ownership of an object provided via an argument require
120 /// this to be true and invalidate the object pointed to by inner.
126 if self.is_owned && !<*mut nativeInit>::is_null(self.inner) {
127 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
131 /// Frees any resources used by the Init, if is_owned is set and inner is non-NULL.
133 pub extern "C" fn Init_free(this_obj: Init) { }
135 /// Used only if an object of this type is returned as a trait impl by a method
136 pub(crate) extern "C" fn Init_free_void(this_ptr: *mut c_void) {
137 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeInit); }
141 pub(crate) fn get_native_ref(&self) -> &'static nativeInit {
142 unsafe { &*ObjOps::untweak_ptr(self.inner) }
144 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInit {
145 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
147 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
148 pub(crate) fn take_inner(mut self) -> *mut nativeInit {
149 assert!(self.is_owned);
150 let ret = ObjOps::untweak_ptr(self.inner);
151 self.inner = core::ptr::null_mut();
155 /// The relevant features which the sender supports
157 pub extern "C" fn Init_get_features(this_ptr: &Init) -> crate::lightning::ln::features::InitFeatures {
158 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
159 crate::lightning::ln::features::InitFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::InitFeatures<>) as *mut _) }, is_owned: false }
161 /// The relevant features which the sender supports
163 pub extern "C" fn Init_set_features(this_ptr: &mut Init, mut val: crate::lightning::ln::features::InitFeatures) {
164 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
166 /// Constructs a new Init given each field
169 pub extern "C" fn Init_new(mut features_arg: crate::lightning::ln::features::InitFeatures) -> Init {
170 Init { inner: ObjOps::heap_alloc(nativeInit {
171 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
174 impl Clone for Init {
175 fn clone(&self) -> Self {
177 inner: if <*mut nativeInit>::is_null(self.inner) { core::ptr::null_mut() } else {
178 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
184 /// Used only if an object of this type is returned as a trait impl by a method
185 pub(crate) extern "C" fn Init_clone_void(this_ptr: *const c_void) -> *mut c_void {
186 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInit)).clone() })) as *mut c_void
189 /// Creates a copy of the Init
190 pub extern "C" fn Init_clone(orig: &Init) -> Init {
194 use lightning::ln::msgs::ErrorMessage as nativeErrorMessageImport;
195 pub(crate) type nativeErrorMessage = nativeErrorMessageImport;
197 /// An error message to be sent or received from a peer
200 pub struct ErrorMessage {
201 /// A pointer to the opaque Rust object.
203 /// Nearly everywhere, inner must be non-null, however in places where
204 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
205 pub inner: *mut nativeErrorMessage,
206 /// Indicates that this is the only struct which contains the same pointer.
208 /// Rust functions which take ownership of an object provided via an argument require
209 /// this to be true and invalidate the object pointed to by inner.
213 impl Drop for ErrorMessage {
215 if self.is_owned && !<*mut nativeErrorMessage>::is_null(self.inner) {
216 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
220 /// Frees any resources used by the ErrorMessage, if is_owned is set and inner is non-NULL.
222 pub extern "C" fn ErrorMessage_free(this_obj: ErrorMessage) { }
224 /// Used only if an object of this type is returned as a trait impl by a method
225 pub(crate) extern "C" fn ErrorMessage_free_void(this_ptr: *mut c_void) {
226 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeErrorMessage); }
230 pub(crate) fn get_native_ref(&self) -> &'static nativeErrorMessage {
231 unsafe { &*ObjOps::untweak_ptr(self.inner) }
233 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeErrorMessage {
234 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
236 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
237 pub(crate) fn take_inner(mut self) -> *mut nativeErrorMessage {
238 assert!(self.is_owned);
239 let ret = ObjOps::untweak_ptr(self.inner);
240 self.inner = core::ptr::null_mut();
244 /// The channel ID involved in the error
246 pub extern "C" fn ErrorMessage_get_channel_id(this_ptr: &ErrorMessage) -> *const [u8; 32] {
247 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
250 /// The channel ID involved in the error
252 pub extern "C" fn ErrorMessage_set_channel_id(this_ptr: &mut ErrorMessage, mut val: crate::c_types::ThirtyTwoBytes) {
253 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
255 /// A possibly human-readable error description.
256 /// The string should be sanitized before it is used (e.g. emitted to logs
257 /// or printed to stdout). Otherwise, a well crafted error message may trigger a security
258 /// vulnerability in the terminal emulator or the logging subsystem.
260 pub extern "C" fn ErrorMessage_get_data(this_ptr: &ErrorMessage) -> crate::c_types::Str {
261 let mut inner_val = &mut this_ptr.get_native_mut_ref().data;
262 inner_val.as_str().into()
264 /// A possibly human-readable error description.
265 /// The string should be sanitized before it is used (e.g. emitted to logs
266 /// or printed to stdout). Otherwise, a well crafted error message may trigger a security
267 /// vulnerability in the terminal emulator or the logging subsystem.
269 pub extern "C" fn ErrorMessage_set_data(this_ptr: &mut ErrorMessage, mut val: crate::c_types::Str) {
270 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string();
272 /// Constructs a new ErrorMessage given each field
275 pub extern "C" fn ErrorMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::Str) -> ErrorMessage {
276 ErrorMessage { inner: ObjOps::heap_alloc(nativeErrorMessage {
277 channel_id: channel_id_arg.data,
278 data: data_arg.into_string(),
281 impl Clone for ErrorMessage {
282 fn clone(&self) -> Self {
284 inner: if <*mut nativeErrorMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
285 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
291 /// Used only if an object of this type is returned as a trait impl by a method
292 pub(crate) extern "C" fn ErrorMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
293 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeErrorMessage)).clone() })) as *mut c_void
296 /// Creates a copy of the ErrorMessage
297 pub extern "C" fn ErrorMessage_clone(orig: &ErrorMessage) -> ErrorMessage {
301 use lightning::ln::msgs::Ping as nativePingImport;
302 pub(crate) type nativePing = nativePingImport;
304 /// A ping message to be sent or received from a peer
308 /// A pointer to the opaque Rust object.
310 /// Nearly everywhere, inner must be non-null, however in places where
311 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
312 pub inner: *mut nativePing,
313 /// Indicates that this is the only struct which contains the same pointer.
315 /// Rust functions which take ownership of an object provided via an argument require
316 /// this to be true and invalidate the object pointed to by inner.
322 if self.is_owned && !<*mut nativePing>::is_null(self.inner) {
323 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
327 /// Frees any resources used by the Ping, if is_owned is set and inner is non-NULL.
329 pub extern "C" fn Ping_free(this_obj: Ping) { }
331 /// Used only if an object of this type is returned as a trait impl by a method
332 pub(crate) extern "C" fn Ping_free_void(this_ptr: *mut c_void) {
333 unsafe { let _ = Box::from_raw(this_ptr as *mut nativePing); }
337 pub(crate) fn get_native_ref(&self) -> &'static nativePing {
338 unsafe { &*ObjOps::untweak_ptr(self.inner) }
340 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePing {
341 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
343 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
344 pub(crate) fn take_inner(mut self) -> *mut nativePing {
345 assert!(self.is_owned);
346 let ret = ObjOps::untweak_ptr(self.inner);
347 self.inner = core::ptr::null_mut();
351 /// The desired response length
353 pub extern "C" fn Ping_get_ponglen(this_ptr: &Ping) -> u16 {
354 let mut inner_val = &mut this_ptr.get_native_mut_ref().ponglen;
357 /// The desired response length
359 pub extern "C" fn Ping_set_ponglen(this_ptr: &mut Ping, mut val: u16) {
360 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.ponglen = val;
362 /// The ping packet size.
363 /// This field is not sent on the wire. byteslen zeros are sent.
365 pub extern "C" fn Ping_get_byteslen(this_ptr: &Ping) -> u16 {
366 let mut inner_val = &mut this_ptr.get_native_mut_ref().byteslen;
369 /// The ping packet size.
370 /// This field is not sent on the wire. byteslen zeros are sent.
372 pub extern "C" fn Ping_set_byteslen(this_ptr: &mut Ping, mut val: u16) {
373 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.byteslen = val;
375 /// Constructs a new Ping given each field
378 pub extern "C" fn Ping_new(mut ponglen_arg: u16, mut byteslen_arg: u16) -> Ping {
379 Ping { inner: ObjOps::heap_alloc(nativePing {
380 ponglen: ponglen_arg,
381 byteslen: byteslen_arg,
384 impl Clone for Ping {
385 fn clone(&self) -> Self {
387 inner: if <*mut nativePing>::is_null(self.inner) { core::ptr::null_mut() } else {
388 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
394 /// Used only if an object of this type is returned as a trait impl by a method
395 pub(crate) extern "C" fn Ping_clone_void(this_ptr: *const c_void) -> *mut c_void {
396 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePing)).clone() })) as *mut c_void
399 /// Creates a copy of the Ping
400 pub extern "C" fn Ping_clone(orig: &Ping) -> Ping {
404 use lightning::ln::msgs::Pong as nativePongImport;
405 pub(crate) type nativePong = nativePongImport;
407 /// A pong message to be sent or received from a peer
411 /// A pointer to the opaque Rust object.
413 /// Nearly everywhere, inner must be non-null, however in places where
414 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
415 pub inner: *mut nativePong,
416 /// Indicates that this is the only struct which contains the same pointer.
418 /// Rust functions which take ownership of an object provided via an argument require
419 /// this to be true and invalidate the object pointed to by inner.
425 if self.is_owned && !<*mut nativePong>::is_null(self.inner) {
426 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
430 /// Frees any resources used by the Pong, if is_owned is set and inner is non-NULL.
432 pub extern "C" fn Pong_free(this_obj: Pong) { }
434 /// Used only if an object of this type is returned as a trait impl by a method
435 pub(crate) extern "C" fn Pong_free_void(this_ptr: *mut c_void) {
436 unsafe { let _ = Box::from_raw(this_ptr as *mut nativePong); }
440 pub(crate) fn get_native_ref(&self) -> &'static nativePong {
441 unsafe { &*ObjOps::untweak_ptr(self.inner) }
443 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePong {
444 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
446 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
447 pub(crate) fn take_inner(mut self) -> *mut nativePong {
448 assert!(self.is_owned);
449 let ret = ObjOps::untweak_ptr(self.inner);
450 self.inner = core::ptr::null_mut();
454 /// The pong packet size.
455 /// This field is not sent on the wire. byteslen zeros are sent.
457 pub extern "C" fn Pong_get_byteslen(this_ptr: &Pong) -> u16 {
458 let mut inner_val = &mut this_ptr.get_native_mut_ref().byteslen;
461 /// The pong packet size.
462 /// This field is not sent on the wire. byteslen zeros are sent.
464 pub extern "C" fn Pong_set_byteslen(this_ptr: &mut Pong, mut val: u16) {
465 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.byteslen = val;
467 /// Constructs a new Pong given each field
470 pub extern "C" fn Pong_new(mut byteslen_arg: u16) -> Pong {
471 Pong { inner: ObjOps::heap_alloc(nativePong {
472 byteslen: byteslen_arg,
475 impl Clone for Pong {
476 fn clone(&self) -> Self {
478 inner: if <*mut nativePong>::is_null(self.inner) { core::ptr::null_mut() } else {
479 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
485 /// Used only if an object of this type is returned as a trait impl by a method
486 pub(crate) extern "C" fn Pong_clone_void(this_ptr: *const c_void) -> *mut c_void {
487 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePong)).clone() })) as *mut c_void
490 /// Creates a copy of the Pong
491 pub extern "C" fn Pong_clone(orig: &Pong) -> Pong {
495 use lightning::ln::msgs::OpenChannel as nativeOpenChannelImport;
496 pub(crate) type nativeOpenChannel = nativeOpenChannelImport;
498 /// An open_channel message to be sent or received from a peer
501 pub struct OpenChannel {
502 /// A pointer to the opaque Rust object.
504 /// Nearly everywhere, inner must be non-null, however in places where
505 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
506 pub inner: *mut nativeOpenChannel,
507 /// Indicates that this is the only struct which contains the same pointer.
509 /// Rust functions which take ownership of an object provided via an argument require
510 /// this to be true and invalidate the object pointed to by inner.
514 impl Drop for OpenChannel {
516 if self.is_owned && !<*mut nativeOpenChannel>::is_null(self.inner) {
517 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
521 /// Frees any resources used by the OpenChannel, if is_owned is set and inner is non-NULL.
523 pub extern "C" fn OpenChannel_free(this_obj: OpenChannel) { }
525 /// Used only if an object of this type is returned as a trait impl by a method
526 pub(crate) extern "C" fn OpenChannel_free_void(this_ptr: *mut c_void) {
527 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeOpenChannel); }
531 pub(crate) fn get_native_ref(&self) -> &'static nativeOpenChannel {
532 unsafe { &*ObjOps::untweak_ptr(self.inner) }
534 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOpenChannel {
535 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
537 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
538 pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannel {
539 assert!(self.is_owned);
540 let ret = ObjOps::untweak_ptr(self.inner);
541 self.inner = core::ptr::null_mut();
545 /// The genesis hash of the blockchain where the channel is to be opened
547 pub extern "C" fn OpenChannel_get_chain_hash(this_ptr: &OpenChannel) -> *const [u8; 32] {
548 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
551 /// The genesis hash of the blockchain where the channel is to be opened
553 pub extern "C" fn OpenChannel_set_chain_hash(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
554 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
556 /// A temporary channel ID, until the funding outpoint is announced
558 pub extern "C" fn OpenChannel_get_temporary_channel_id(this_ptr: &OpenChannel) -> *const [u8; 32] {
559 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
562 /// A temporary channel ID, until the funding outpoint is announced
564 pub extern "C" fn OpenChannel_set_temporary_channel_id(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
565 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
567 /// The channel value
569 pub extern "C" fn OpenChannel_get_funding_satoshis(this_ptr: &OpenChannel) -> u64 {
570 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
573 /// The channel value
575 pub extern "C" fn OpenChannel_set_funding_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
576 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
578 /// The amount to push to the counterparty as part of the open, in milli-satoshi
580 pub extern "C" fn OpenChannel_get_push_msat(this_ptr: &OpenChannel) -> u64 {
581 let mut inner_val = &mut this_ptr.get_native_mut_ref().push_msat;
584 /// The amount to push to the counterparty as part of the open, in milli-satoshi
586 pub extern "C" fn OpenChannel_set_push_msat(this_ptr: &mut OpenChannel, mut val: u64) {
587 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.push_msat = val;
589 /// The threshold below which outputs on transactions broadcast by sender will be omitted
591 pub extern "C" fn OpenChannel_get_dust_limit_satoshis(this_ptr: &OpenChannel) -> u64 {
592 let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
595 /// The threshold below which outputs on transactions broadcast by sender will be omitted
597 pub extern "C" fn OpenChannel_set_dust_limit_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
598 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
600 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
602 pub extern "C" fn OpenChannel_get_max_htlc_value_in_flight_msat(this_ptr: &OpenChannel) -> u64 {
603 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
606 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
608 pub extern "C" fn OpenChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut OpenChannel, mut val: u64) {
609 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
611 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
613 pub extern "C" fn OpenChannel_get_channel_reserve_satoshis(this_ptr: &OpenChannel) -> u64 {
614 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
617 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
619 pub extern "C" fn OpenChannel_set_channel_reserve_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
620 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
622 /// The minimum HTLC size incoming to sender, in milli-satoshi
624 pub extern "C" fn OpenChannel_get_htlc_minimum_msat(this_ptr: &OpenChannel) -> u64 {
625 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
628 /// The minimum HTLC size incoming to sender, in milli-satoshi
630 pub extern "C" fn OpenChannel_set_htlc_minimum_msat(this_ptr: &mut OpenChannel, mut val: u64) {
631 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
633 /// The feerate per 1000-weight of sender generated transactions, until updated by update_fee
635 pub extern "C" fn OpenChannel_get_feerate_per_kw(this_ptr: &OpenChannel) -> u32 {
636 let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
639 /// The feerate per 1000-weight of sender generated transactions, until updated by update_fee
641 pub extern "C" fn OpenChannel_set_feerate_per_kw(this_ptr: &mut OpenChannel, mut val: u32) {
642 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
644 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
646 pub extern "C" fn OpenChannel_get_to_self_delay(this_ptr: &OpenChannel) -> u16 {
647 let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
650 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
652 pub extern "C" fn OpenChannel_set_to_self_delay(this_ptr: &mut OpenChannel, mut val: u16) {
653 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
655 /// The maximum number of inbound HTLCs towards sender
657 pub extern "C" fn OpenChannel_get_max_accepted_htlcs(this_ptr: &OpenChannel) -> u16 {
658 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
661 /// The maximum number of inbound HTLCs towards sender
663 pub extern "C" fn OpenChannel_set_max_accepted_htlcs(this_ptr: &mut OpenChannel, mut val: u16) {
664 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
666 /// The sender's key controlling the funding transaction
668 pub extern "C" fn OpenChannel_get_funding_pubkey(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
669 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
670 crate::c_types::PublicKey::from_rust(&inner_val)
672 /// The sender's key controlling the funding transaction
674 pub extern "C" fn OpenChannel_set_funding_pubkey(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
675 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
677 /// Used to derive a revocation key for transactions broadcast by counterparty
679 pub extern "C" fn OpenChannel_get_revocation_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
680 let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
681 crate::c_types::PublicKey::from_rust(&inner_val)
683 /// Used to derive a revocation key for transactions broadcast by counterparty
685 pub extern "C" fn OpenChannel_set_revocation_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
686 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
688 /// A payment key to sender for transactions broadcast by counterparty
690 pub extern "C" fn OpenChannel_get_payment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
691 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_point;
692 crate::c_types::PublicKey::from_rust(&inner_val)
694 /// A payment key to sender for transactions broadcast by counterparty
696 pub extern "C" fn OpenChannel_set_payment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
697 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_point = val.into_rust();
699 /// Used to derive a payment key to sender for transactions broadcast by sender
701 pub extern "C" fn OpenChannel_get_delayed_payment_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
702 let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
703 crate::c_types::PublicKey::from_rust(&inner_val)
705 /// Used to derive a payment key to sender for transactions broadcast by sender
707 pub extern "C" fn OpenChannel_set_delayed_payment_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
708 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
710 /// Used to derive an HTLC payment key to sender
712 pub extern "C" fn OpenChannel_get_htlc_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
713 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
714 crate::c_types::PublicKey::from_rust(&inner_val)
716 /// Used to derive an HTLC payment key to sender
718 pub extern "C" fn OpenChannel_set_htlc_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
719 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
721 /// The first to-be-broadcast-by-sender transaction's per commitment point
723 pub extern "C" fn OpenChannel_get_first_per_commitment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
724 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
725 crate::c_types::PublicKey::from_rust(&inner_val)
727 /// The first to-be-broadcast-by-sender transaction's per commitment point
729 pub extern "C" fn OpenChannel_set_first_per_commitment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
730 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
734 pub extern "C" fn OpenChannel_get_channel_flags(this_ptr: &OpenChannel) -> u8 {
735 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_flags;
740 pub extern "C" fn OpenChannel_set_channel_flags(this_ptr: &mut OpenChannel, mut val: u8) {
741 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_flags = val;
743 /// The channel type that this channel will represent. If none is set, we derive the channel
744 /// type from the intersection of our feature bits with our counterparty's feature bits from
745 /// the Init message.
747 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
749 pub extern "C" fn OpenChannel_get_channel_type(this_ptr: &OpenChannel) -> crate::lightning::ln::features::ChannelTypeFeatures {
750 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
751 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 };
754 /// The channel type that this channel will represent. If none is set, we derive the channel
755 /// type from the intersection of our feature bits with our counterparty's feature bits from
756 /// the Init message.
758 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
760 pub extern "C" fn OpenChannel_set_channel_type(this_ptr: &mut OpenChannel, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
761 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
762 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
764 impl Clone for OpenChannel {
765 fn clone(&self) -> Self {
767 inner: if <*mut nativeOpenChannel>::is_null(self.inner) { core::ptr::null_mut() } else {
768 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
774 /// Used only if an object of this type is returned as a trait impl by a method
775 pub(crate) extern "C" fn OpenChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
776 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOpenChannel)).clone() })) as *mut c_void
779 /// Creates a copy of the OpenChannel
780 pub extern "C" fn OpenChannel_clone(orig: &OpenChannel) -> OpenChannel {
784 use lightning::ln::msgs::AcceptChannel as nativeAcceptChannelImport;
785 pub(crate) type nativeAcceptChannel = nativeAcceptChannelImport;
787 /// An accept_channel message to be sent or received from a peer
790 pub struct AcceptChannel {
791 /// A pointer to the opaque Rust object.
793 /// Nearly everywhere, inner must be non-null, however in places where
794 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
795 pub inner: *mut nativeAcceptChannel,
796 /// Indicates that this is the only struct which contains the same pointer.
798 /// Rust functions which take ownership of an object provided via an argument require
799 /// this to be true and invalidate the object pointed to by inner.
803 impl Drop for AcceptChannel {
805 if self.is_owned && !<*mut nativeAcceptChannel>::is_null(self.inner) {
806 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
810 /// Frees any resources used by the AcceptChannel, if is_owned is set and inner is non-NULL.
812 pub extern "C" fn AcceptChannel_free(this_obj: AcceptChannel) { }
814 /// Used only if an object of this type is returned as a trait impl by a method
815 pub(crate) extern "C" fn AcceptChannel_free_void(this_ptr: *mut c_void) {
816 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeAcceptChannel); }
820 pub(crate) fn get_native_ref(&self) -> &'static nativeAcceptChannel {
821 unsafe { &*ObjOps::untweak_ptr(self.inner) }
823 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAcceptChannel {
824 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
826 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
827 pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannel {
828 assert!(self.is_owned);
829 let ret = ObjOps::untweak_ptr(self.inner);
830 self.inner = core::ptr::null_mut();
834 /// A temporary channel ID, until the funding outpoint is announced
836 pub extern "C" fn AcceptChannel_get_temporary_channel_id(this_ptr: &AcceptChannel) -> *const [u8; 32] {
837 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
840 /// A temporary channel ID, until the funding outpoint is announced
842 pub extern "C" fn AcceptChannel_set_temporary_channel_id(this_ptr: &mut AcceptChannel, mut val: crate::c_types::ThirtyTwoBytes) {
843 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
845 /// The threshold below which outputs on transactions broadcast by sender will be omitted
847 pub extern "C" fn AcceptChannel_get_dust_limit_satoshis(this_ptr: &AcceptChannel) -> u64 {
848 let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
851 /// The threshold below which outputs on transactions broadcast by sender will be omitted
853 pub extern "C" fn AcceptChannel_set_dust_limit_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
854 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
856 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
858 pub extern "C" fn AcceptChannel_get_max_htlc_value_in_flight_msat(this_ptr: &AcceptChannel) -> u64 {
859 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
862 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
864 pub extern "C" fn AcceptChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
865 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
867 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
869 pub extern "C" fn AcceptChannel_get_channel_reserve_satoshis(this_ptr: &AcceptChannel) -> u64 {
870 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
873 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
875 pub extern "C" fn AcceptChannel_set_channel_reserve_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
876 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
878 /// The minimum HTLC size incoming to sender, in milli-satoshi
880 pub extern "C" fn AcceptChannel_get_htlc_minimum_msat(this_ptr: &AcceptChannel) -> u64 {
881 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
884 /// The minimum HTLC size incoming to sender, in milli-satoshi
886 pub extern "C" fn AcceptChannel_set_htlc_minimum_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
887 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
889 /// Minimum depth of the funding transaction before the channel is considered open
891 pub extern "C" fn AcceptChannel_get_minimum_depth(this_ptr: &AcceptChannel) -> u32 {
892 let mut inner_val = &mut this_ptr.get_native_mut_ref().minimum_depth;
895 /// Minimum depth of the funding transaction before the channel is considered open
897 pub extern "C" fn AcceptChannel_set_minimum_depth(this_ptr: &mut AcceptChannel, mut val: u32) {
898 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.minimum_depth = val;
900 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
902 pub extern "C" fn AcceptChannel_get_to_self_delay(this_ptr: &AcceptChannel) -> u16 {
903 let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
906 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
908 pub extern "C" fn AcceptChannel_set_to_self_delay(this_ptr: &mut AcceptChannel, mut val: u16) {
909 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
911 /// The maximum number of inbound HTLCs towards sender
913 pub extern "C" fn AcceptChannel_get_max_accepted_htlcs(this_ptr: &AcceptChannel) -> u16 {
914 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
917 /// The maximum number of inbound HTLCs towards sender
919 pub extern "C" fn AcceptChannel_set_max_accepted_htlcs(this_ptr: &mut AcceptChannel, mut val: u16) {
920 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
922 /// The sender's key controlling the funding transaction
924 pub extern "C" fn AcceptChannel_get_funding_pubkey(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
925 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
926 crate::c_types::PublicKey::from_rust(&inner_val)
928 /// The sender's key controlling the funding transaction
930 pub extern "C" fn AcceptChannel_set_funding_pubkey(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
931 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
933 /// Used to derive a revocation key for transactions broadcast by counterparty
935 pub extern "C" fn AcceptChannel_get_revocation_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
936 let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
937 crate::c_types::PublicKey::from_rust(&inner_val)
939 /// Used to derive a revocation key for transactions broadcast by counterparty
941 pub extern "C" fn AcceptChannel_set_revocation_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
942 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
944 /// A payment key to sender for transactions broadcast by counterparty
946 pub extern "C" fn AcceptChannel_get_payment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
947 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_point;
948 crate::c_types::PublicKey::from_rust(&inner_val)
950 /// A payment key to sender for transactions broadcast by counterparty
952 pub extern "C" fn AcceptChannel_set_payment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
953 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_point = val.into_rust();
955 /// Used to derive a payment key to sender for transactions broadcast by sender
957 pub extern "C" fn AcceptChannel_get_delayed_payment_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
958 let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
959 crate::c_types::PublicKey::from_rust(&inner_val)
961 /// Used to derive a payment key to sender for transactions broadcast by sender
963 pub extern "C" fn AcceptChannel_set_delayed_payment_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
964 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
966 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
968 pub extern "C" fn AcceptChannel_get_htlc_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
969 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
970 crate::c_types::PublicKey::from_rust(&inner_val)
972 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
974 pub extern "C" fn AcceptChannel_set_htlc_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
975 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
977 /// The first to-be-broadcast-by-sender transaction's per commitment point
979 pub extern "C" fn AcceptChannel_get_first_per_commitment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
980 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
981 crate::c_types::PublicKey::from_rust(&inner_val)
983 /// The first to-be-broadcast-by-sender transaction's per commitment point
985 pub extern "C" fn AcceptChannel_set_first_per_commitment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
986 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
988 impl Clone for AcceptChannel {
989 fn clone(&self) -> Self {
991 inner: if <*mut nativeAcceptChannel>::is_null(self.inner) { core::ptr::null_mut() } else {
992 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
998 /// Used only if an object of this type is returned as a trait impl by a method
999 pub(crate) extern "C" fn AcceptChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
1000 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAcceptChannel)).clone() })) as *mut c_void
1003 /// Creates a copy of the AcceptChannel
1004 pub extern "C" fn AcceptChannel_clone(orig: &AcceptChannel) -> AcceptChannel {
1008 use lightning::ln::msgs::FundingCreated as nativeFundingCreatedImport;
1009 pub(crate) type nativeFundingCreated = nativeFundingCreatedImport;
1011 /// A funding_created message to be sent or received from a peer
1014 pub struct FundingCreated {
1015 /// A pointer to the opaque Rust object.
1017 /// Nearly everywhere, inner must be non-null, however in places where
1018 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1019 pub inner: *mut nativeFundingCreated,
1020 /// Indicates that this is the only struct which contains the same pointer.
1022 /// Rust functions which take ownership of an object provided via an argument require
1023 /// this to be true and invalidate the object pointed to by inner.
1027 impl Drop for FundingCreated {
1028 fn drop(&mut self) {
1029 if self.is_owned && !<*mut nativeFundingCreated>::is_null(self.inner) {
1030 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1034 /// Frees any resources used by the FundingCreated, if is_owned is set and inner is non-NULL.
1036 pub extern "C" fn FundingCreated_free(this_obj: FundingCreated) { }
1038 /// Used only if an object of this type is returned as a trait impl by a method
1039 pub(crate) extern "C" fn FundingCreated_free_void(this_ptr: *mut c_void) {
1040 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingCreated); }
1043 impl FundingCreated {
1044 pub(crate) fn get_native_ref(&self) -> &'static nativeFundingCreated {
1045 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1047 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingCreated {
1048 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1050 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1051 pub(crate) fn take_inner(mut self) -> *mut nativeFundingCreated {
1052 assert!(self.is_owned);
1053 let ret = ObjOps::untweak_ptr(self.inner);
1054 self.inner = core::ptr::null_mut();
1058 /// A temporary channel ID, until the funding is established
1060 pub extern "C" fn FundingCreated_get_temporary_channel_id(this_ptr: &FundingCreated) -> *const [u8; 32] {
1061 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
1064 /// A temporary channel ID, until the funding is established
1066 pub extern "C" fn FundingCreated_set_temporary_channel_id(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
1067 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
1069 /// The funding transaction ID
1071 pub extern "C" fn FundingCreated_get_funding_txid(this_ptr: &FundingCreated) -> *const [u8; 32] {
1072 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_txid;
1073 inner_val.as_inner()
1075 /// The funding transaction ID
1077 pub extern "C" fn FundingCreated_set_funding_txid(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
1078 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_txid = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
1080 /// The specific output index funding this channel
1082 pub extern "C" fn FundingCreated_get_funding_output_index(this_ptr: &FundingCreated) -> u16 {
1083 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_index;
1086 /// The specific output index funding this channel
1088 pub extern "C" fn FundingCreated_set_funding_output_index(this_ptr: &mut FundingCreated, mut val: u16) {
1089 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_index = val;
1091 /// The signature of the channel initiator (funder) on the initial commitment transaction
1093 pub extern "C" fn FundingCreated_get_signature(this_ptr: &FundingCreated) -> crate::c_types::Signature {
1094 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
1095 crate::c_types::Signature::from_rust(&inner_val)
1097 /// The signature of the channel initiator (funder) on the initial commitment transaction
1099 pub extern "C" fn FundingCreated_set_signature(this_ptr: &mut FundingCreated, mut val: crate::c_types::Signature) {
1100 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
1102 /// Constructs a new FundingCreated given each field
1105 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 {
1106 FundingCreated { inner: ObjOps::heap_alloc(nativeFundingCreated {
1107 temporary_channel_id: temporary_channel_id_arg.data,
1108 funding_txid: ::bitcoin::hash_types::Txid::from_slice(&funding_txid_arg.data[..]).unwrap(),
1109 funding_output_index: funding_output_index_arg,
1110 signature: signature_arg.into_rust(),
1111 }), is_owned: true }
1113 impl Clone for FundingCreated {
1114 fn clone(&self) -> Self {
1116 inner: if <*mut nativeFundingCreated>::is_null(self.inner) { core::ptr::null_mut() } else {
1117 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1123 /// Used only if an object of this type is returned as a trait impl by a method
1124 pub(crate) extern "C" fn FundingCreated_clone_void(this_ptr: *const c_void) -> *mut c_void {
1125 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingCreated)).clone() })) as *mut c_void
1128 /// Creates a copy of the FundingCreated
1129 pub extern "C" fn FundingCreated_clone(orig: &FundingCreated) -> FundingCreated {
1133 use lightning::ln::msgs::FundingSigned as nativeFundingSignedImport;
1134 pub(crate) type nativeFundingSigned = nativeFundingSignedImport;
1136 /// A funding_signed message to be sent or received from a peer
1139 pub struct FundingSigned {
1140 /// A pointer to the opaque Rust object.
1142 /// Nearly everywhere, inner must be non-null, however in places where
1143 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1144 pub inner: *mut nativeFundingSigned,
1145 /// Indicates that this is the only struct which contains the same pointer.
1147 /// Rust functions which take ownership of an object provided via an argument require
1148 /// this to be true and invalidate the object pointed to by inner.
1152 impl Drop for FundingSigned {
1153 fn drop(&mut self) {
1154 if self.is_owned && !<*mut nativeFundingSigned>::is_null(self.inner) {
1155 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1159 /// Frees any resources used by the FundingSigned, if is_owned is set and inner is non-NULL.
1161 pub extern "C" fn FundingSigned_free(this_obj: FundingSigned) { }
1163 /// Used only if an object of this type is returned as a trait impl by a method
1164 pub(crate) extern "C" fn FundingSigned_free_void(this_ptr: *mut c_void) {
1165 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingSigned); }
1168 impl FundingSigned {
1169 pub(crate) fn get_native_ref(&self) -> &'static nativeFundingSigned {
1170 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1172 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingSigned {
1173 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1175 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1176 pub(crate) fn take_inner(mut self) -> *mut nativeFundingSigned {
1177 assert!(self.is_owned);
1178 let ret = ObjOps::untweak_ptr(self.inner);
1179 self.inner = core::ptr::null_mut();
1185 pub extern "C" fn FundingSigned_get_channel_id(this_ptr: &FundingSigned) -> *const [u8; 32] {
1186 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1191 pub extern "C" fn FundingSigned_set_channel_id(this_ptr: &mut FundingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
1192 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1194 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
1196 pub extern "C" fn FundingSigned_get_signature(this_ptr: &FundingSigned) -> crate::c_types::Signature {
1197 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
1198 crate::c_types::Signature::from_rust(&inner_val)
1200 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
1202 pub extern "C" fn FundingSigned_set_signature(this_ptr: &mut FundingSigned, mut val: crate::c_types::Signature) {
1203 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
1205 /// Constructs a new FundingSigned given each field
1208 pub extern "C" fn FundingSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut signature_arg: crate::c_types::Signature) -> FundingSigned {
1209 FundingSigned { inner: ObjOps::heap_alloc(nativeFundingSigned {
1210 channel_id: channel_id_arg.data,
1211 signature: signature_arg.into_rust(),
1212 }), is_owned: true }
1214 impl Clone for FundingSigned {
1215 fn clone(&self) -> Self {
1217 inner: if <*mut nativeFundingSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
1218 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1224 /// Used only if an object of this type is returned as a trait impl by a method
1225 pub(crate) extern "C" fn FundingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
1226 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingSigned)).clone() })) as *mut c_void
1229 /// Creates a copy of the FundingSigned
1230 pub extern "C" fn FundingSigned_clone(orig: &FundingSigned) -> FundingSigned {
1234 use lightning::ln::msgs::FundingLocked as nativeFundingLockedImport;
1235 pub(crate) type nativeFundingLocked = nativeFundingLockedImport;
1237 /// A funding_locked message to be sent or received from a peer
1240 pub struct FundingLocked {
1241 /// A pointer to the opaque Rust object.
1243 /// Nearly everywhere, inner must be non-null, however in places where
1244 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1245 pub inner: *mut nativeFundingLocked,
1246 /// Indicates that this is the only struct which contains the same pointer.
1248 /// Rust functions which take ownership of an object provided via an argument require
1249 /// this to be true and invalidate the object pointed to by inner.
1253 impl Drop for FundingLocked {
1254 fn drop(&mut self) {
1255 if self.is_owned && !<*mut nativeFundingLocked>::is_null(self.inner) {
1256 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1260 /// Frees any resources used by the FundingLocked, if is_owned is set and inner is non-NULL.
1262 pub extern "C" fn FundingLocked_free(this_obj: FundingLocked) { }
1264 /// Used only if an object of this type is returned as a trait impl by a method
1265 pub(crate) extern "C" fn FundingLocked_free_void(this_ptr: *mut c_void) {
1266 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingLocked); }
1269 impl FundingLocked {
1270 pub(crate) fn get_native_ref(&self) -> &'static nativeFundingLocked {
1271 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1273 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingLocked {
1274 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1276 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1277 pub(crate) fn take_inner(mut self) -> *mut nativeFundingLocked {
1278 assert!(self.is_owned);
1279 let ret = ObjOps::untweak_ptr(self.inner);
1280 self.inner = core::ptr::null_mut();
1286 pub extern "C" fn FundingLocked_get_channel_id(this_ptr: &FundingLocked) -> *const [u8; 32] {
1287 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1292 pub extern "C" fn FundingLocked_set_channel_id(this_ptr: &mut FundingLocked, mut val: crate::c_types::ThirtyTwoBytes) {
1293 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1295 /// The per-commitment point of the second commitment transaction
1297 pub extern "C" fn FundingLocked_get_next_per_commitment_point(this_ptr: &FundingLocked) -> crate::c_types::PublicKey {
1298 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
1299 crate::c_types::PublicKey::from_rust(&inner_val)
1301 /// The per-commitment point of the second commitment transaction
1303 pub extern "C" fn FundingLocked_set_next_per_commitment_point(this_ptr: &mut FundingLocked, mut val: crate::c_types::PublicKey) {
1304 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
1306 /// Constructs a new FundingLocked given each field
1309 pub extern "C" fn FundingLocked_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut next_per_commitment_point_arg: crate::c_types::PublicKey) -> FundingLocked {
1310 FundingLocked { inner: ObjOps::heap_alloc(nativeFundingLocked {
1311 channel_id: channel_id_arg.data,
1312 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
1313 }), is_owned: true }
1315 impl Clone for FundingLocked {
1316 fn clone(&self) -> Self {
1318 inner: if <*mut nativeFundingLocked>::is_null(self.inner) { core::ptr::null_mut() } else {
1319 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1325 /// Used only if an object of this type is returned as a trait impl by a method
1326 pub(crate) extern "C" fn FundingLocked_clone_void(this_ptr: *const c_void) -> *mut c_void {
1327 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingLocked)).clone() })) as *mut c_void
1330 /// Creates a copy of the FundingLocked
1331 pub extern "C" fn FundingLocked_clone(orig: &FundingLocked) -> FundingLocked {
1335 use lightning::ln::msgs::Shutdown as nativeShutdownImport;
1336 pub(crate) type nativeShutdown = nativeShutdownImport;
1338 /// A shutdown message to be sent or received from a peer
1341 pub struct Shutdown {
1342 /// A pointer to the opaque Rust object.
1344 /// Nearly everywhere, inner must be non-null, however in places where
1345 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1346 pub inner: *mut nativeShutdown,
1347 /// Indicates that this is the only struct which contains the same pointer.
1349 /// Rust functions which take ownership of an object provided via an argument require
1350 /// this to be true and invalidate the object pointed to by inner.
1354 impl Drop for Shutdown {
1355 fn drop(&mut self) {
1356 if self.is_owned && !<*mut nativeShutdown>::is_null(self.inner) {
1357 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1361 /// Frees any resources used by the Shutdown, if is_owned is set and inner is non-NULL.
1363 pub extern "C" fn Shutdown_free(this_obj: Shutdown) { }
1365 /// Used only if an object of this type is returned as a trait impl by a method
1366 pub(crate) extern "C" fn Shutdown_free_void(this_ptr: *mut c_void) {
1367 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeShutdown); }
1371 pub(crate) fn get_native_ref(&self) -> &'static nativeShutdown {
1372 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1374 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeShutdown {
1375 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1377 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1378 pub(crate) fn take_inner(mut self) -> *mut nativeShutdown {
1379 assert!(self.is_owned);
1380 let ret = ObjOps::untweak_ptr(self.inner);
1381 self.inner = core::ptr::null_mut();
1387 pub extern "C" fn Shutdown_get_channel_id(this_ptr: &Shutdown) -> *const [u8; 32] {
1388 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1393 pub extern "C" fn Shutdown_set_channel_id(this_ptr: &mut Shutdown, mut val: crate::c_types::ThirtyTwoBytes) {
1394 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1396 /// The destination of this peer's funds on closing.
1397 /// Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
1399 pub extern "C" fn Shutdown_get_scriptpubkey(this_ptr: &Shutdown) -> crate::c_types::u8slice {
1400 let mut inner_val = &mut this_ptr.get_native_mut_ref().scriptpubkey;
1401 crate::c_types::u8slice::from_slice(&inner_val[..])
1403 /// The destination of this peer's funds on closing.
1404 /// Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
1406 pub extern "C" fn Shutdown_set_scriptpubkey(this_ptr: &mut Shutdown, mut val: crate::c_types::derived::CVec_u8Z) {
1407 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.scriptpubkey = ::bitcoin::blockdata::script::Script::from(val.into_rust());
1409 /// Constructs a new Shutdown given each field
1412 pub extern "C" fn Shutdown_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut scriptpubkey_arg: crate::c_types::derived::CVec_u8Z) -> Shutdown {
1413 Shutdown { inner: ObjOps::heap_alloc(nativeShutdown {
1414 channel_id: channel_id_arg.data,
1415 scriptpubkey: ::bitcoin::blockdata::script::Script::from(scriptpubkey_arg.into_rust()),
1416 }), is_owned: true }
1418 impl Clone for Shutdown {
1419 fn clone(&self) -> Self {
1421 inner: if <*mut nativeShutdown>::is_null(self.inner) { core::ptr::null_mut() } else {
1422 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1428 /// Used only if an object of this type is returned as a trait impl by a method
1429 pub(crate) extern "C" fn Shutdown_clone_void(this_ptr: *const c_void) -> *mut c_void {
1430 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeShutdown)).clone() })) as *mut c_void
1433 /// Creates a copy of the Shutdown
1434 pub extern "C" fn Shutdown_clone(orig: &Shutdown) -> Shutdown {
1438 use lightning::ln::msgs::ClosingSignedFeeRange as nativeClosingSignedFeeRangeImport;
1439 pub(crate) type nativeClosingSignedFeeRange = nativeClosingSignedFeeRangeImport;
1441 /// The minimum and maximum fees which the sender is willing to place on the closing transaction.
1442 /// This is provided in [`ClosingSigned`] by both sides to indicate the fee range they are willing
1446 pub struct ClosingSignedFeeRange {
1447 /// A pointer to the opaque Rust object.
1449 /// Nearly everywhere, inner must be non-null, however in places where
1450 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1451 pub inner: *mut nativeClosingSignedFeeRange,
1452 /// Indicates that this is the only struct which contains the same pointer.
1454 /// Rust functions which take ownership of an object provided via an argument require
1455 /// this to be true and invalidate the object pointed to by inner.
1459 impl Drop for ClosingSignedFeeRange {
1460 fn drop(&mut self) {
1461 if self.is_owned && !<*mut nativeClosingSignedFeeRange>::is_null(self.inner) {
1462 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1466 /// Frees any resources used by the ClosingSignedFeeRange, if is_owned is set and inner is non-NULL.
1468 pub extern "C" fn ClosingSignedFeeRange_free(this_obj: ClosingSignedFeeRange) { }
1470 /// Used only if an object of this type is returned as a trait impl by a method
1471 pub(crate) extern "C" fn ClosingSignedFeeRange_free_void(this_ptr: *mut c_void) {
1472 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeClosingSignedFeeRange); }
1475 impl ClosingSignedFeeRange {
1476 pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSignedFeeRange {
1477 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1479 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSignedFeeRange {
1480 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1482 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1483 pub(crate) fn take_inner(mut self) -> *mut nativeClosingSignedFeeRange {
1484 assert!(self.is_owned);
1485 let ret = ObjOps::untweak_ptr(self.inner);
1486 self.inner = core::ptr::null_mut();
1490 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
1493 pub extern "C" fn ClosingSignedFeeRange_get_min_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
1494 let mut inner_val = &mut this_ptr.get_native_mut_ref().min_fee_satoshis;
1497 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
1500 pub extern "C" fn ClosingSignedFeeRange_set_min_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
1501 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_fee_satoshis = val;
1503 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
1506 pub extern "C" fn ClosingSignedFeeRange_get_max_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
1507 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_fee_satoshis;
1510 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
1513 pub extern "C" fn ClosingSignedFeeRange_set_max_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
1514 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_fee_satoshis = val;
1516 /// Constructs a new ClosingSignedFeeRange given each field
1519 pub extern "C" fn ClosingSignedFeeRange_new(mut min_fee_satoshis_arg: u64, mut max_fee_satoshis_arg: u64) -> ClosingSignedFeeRange {
1520 ClosingSignedFeeRange { inner: ObjOps::heap_alloc(nativeClosingSignedFeeRange {
1521 min_fee_satoshis: min_fee_satoshis_arg,
1522 max_fee_satoshis: max_fee_satoshis_arg,
1523 }), is_owned: true }
1525 impl Clone for ClosingSignedFeeRange {
1526 fn clone(&self) -> Self {
1528 inner: if <*mut nativeClosingSignedFeeRange>::is_null(self.inner) { core::ptr::null_mut() } else {
1529 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1535 /// Used only if an object of this type is returned as a trait impl by a method
1536 pub(crate) extern "C" fn ClosingSignedFeeRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
1537 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClosingSignedFeeRange)).clone() })) as *mut c_void
1540 /// Creates a copy of the ClosingSignedFeeRange
1541 pub extern "C" fn ClosingSignedFeeRange_clone(orig: &ClosingSignedFeeRange) -> ClosingSignedFeeRange {
1545 use lightning::ln::msgs::ClosingSigned as nativeClosingSignedImport;
1546 pub(crate) type nativeClosingSigned = nativeClosingSignedImport;
1548 /// A closing_signed message to be sent or received from a peer
1551 pub struct ClosingSigned {
1552 /// A pointer to the opaque Rust object.
1554 /// Nearly everywhere, inner must be non-null, however in places where
1555 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1556 pub inner: *mut nativeClosingSigned,
1557 /// Indicates that this is the only struct which contains the same pointer.
1559 /// Rust functions which take ownership of an object provided via an argument require
1560 /// this to be true and invalidate the object pointed to by inner.
1564 impl Drop for ClosingSigned {
1565 fn drop(&mut self) {
1566 if self.is_owned && !<*mut nativeClosingSigned>::is_null(self.inner) {
1567 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1571 /// Frees any resources used by the ClosingSigned, if is_owned is set and inner is non-NULL.
1573 pub extern "C" fn ClosingSigned_free(this_obj: ClosingSigned) { }
1575 /// Used only if an object of this type is returned as a trait impl by a method
1576 pub(crate) extern "C" fn ClosingSigned_free_void(this_ptr: *mut c_void) {
1577 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeClosingSigned); }
1580 impl ClosingSigned {
1581 pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSigned {
1582 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1584 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSigned {
1585 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1587 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1588 pub(crate) fn take_inner(mut self) -> *mut nativeClosingSigned {
1589 assert!(self.is_owned);
1590 let ret = ObjOps::untweak_ptr(self.inner);
1591 self.inner = core::ptr::null_mut();
1597 pub extern "C" fn ClosingSigned_get_channel_id(this_ptr: &ClosingSigned) -> *const [u8; 32] {
1598 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1603 pub extern "C" fn ClosingSigned_set_channel_id(this_ptr: &mut ClosingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
1604 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1606 /// The proposed total fee for the closing transaction
1608 pub extern "C" fn ClosingSigned_get_fee_satoshis(this_ptr: &ClosingSigned) -> u64 {
1609 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_satoshis;
1612 /// The proposed total fee for the closing transaction
1614 pub extern "C" fn ClosingSigned_set_fee_satoshis(this_ptr: &mut ClosingSigned, mut val: u64) {
1615 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_satoshis = val;
1617 /// A signature on the closing transaction
1619 pub extern "C" fn ClosingSigned_get_signature(this_ptr: &ClosingSigned) -> crate::c_types::Signature {
1620 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
1621 crate::c_types::Signature::from_rust(&inner_val)
1623 /// A signature on the closing transaction
1625 pub extern "C" fn ClosingSigned_set_signature(this_ptr: &mut ClosingSigned, mut val: crate::c_types::Signature) {
1626 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
1628 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
1631 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1633 pub extern "C" fn ClosingSigned_get_fee_range(this_ptr: &ClosingSigned) -> crate::lightning::ln::msgs::ClosingSignedFeeRange {
1634 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_range;
1635 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 };
1638 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
1641 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1643 pub extern "C" fn ClosingSigned_set_fee_range(this_ptr: &mut ClosingSigned, mut val: crate::lightning::ln::msgs::ClosingSignedFeeRange) {
1644 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1645 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_range = local_val;
1647 /// Constructs a new ClosingSigned given each field
1650 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 {
1651 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()) } }) };
1652 ClosingSigned { inner: ObjOps::heap_alloc(nativeClosingSigned {
1653 channel_id: channel_id_arg.data,
1654 fee_satoshis: fee_satoshis_arg,
1655 signature: signature_arg.into_rust(),
1656 fee_range: local_fee_range_arg,
1657 }), is_owned: true }
1659 impl Clone for ClosingSigned {
1660 fn clone(&self) -> Self {
1662 inner: if <*mut nativeClosingSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
1663 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1669 /// Used only if an object of this type is returned as a trait impl by a method
1670 pub(crate) extern "C" fn ClosingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
1671 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClosingSigned)).clone() })) as *mut c_void
1674 /// Creates a copy of the ClosingSigned
1675 pub extern "C" fn ClosingSigned_clone(orig: &ClosingSigned) -> ClosingSigned {
1679 use lightning::ln::msgs::UpdateAddHTLC as nativeUpdateAddHTLCImport;
1680 pub(crate) type nativeUpdateAddHTLC = nativeUpdateAddHTLCImport;
1682 /// An update_add_htlc message to be sent or received from a peer
1685 pub struct UpdateAddHTLC {
1686 /// A pointer to the opaque Rust object.
1688 /// Nearly everywhere, inner must be non-null, however in places where
1689 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1690 pub inner: *mut nativeUpdateAddHTLC,
1691 /// Indicates that this is the only struct which contains the same pointer.
1693 /// Rust functions which take ownership of an object provided via an argument require
1694 /// this to be true and invalidate the object pointed to by inner.
1698 impl Drop for UpdateAddHTLC {
1699 fn drop(&mut self) {
1700 if self.is_owned && !<*mut nativeUpdateAddHTLC>::is_null(self.inner) {
1701 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1705 /// Frees any resources used by the UpdateAddHTLC, if is_owned is set and inner is non-NULL.
1707 pub extern "C" fn UpdateAddHTLC_free(this_obj: UpdateAddHTLC) { }
1709 /// Used only if an object of this type is returned as a trait impl by a method
1710 pub(crate) extern "C" fn UpdateAddHTLC_free_void(this_ptr: *mut c_void) {
1711 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateAddHTLC); }
1714 impl UpdateAddHTLC {
1715 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateAddHTLC {
1716 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1718 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateAddHTLC {
1719 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1721 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1722 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateAddHTLC {
1723 assert!(self.is_owned);
1724 let ret = ObjOps::untweak_ptr(self.inner);
1725 self.inner = core::ptr::null_mut();
1731 pub extern "C" fn UpdateAddHTLC_get_channel_id(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
1732 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1737 pub extern "C" fn UpdateAddHTLC_set_channel_id(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1738 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1742 pub extern "C" fn UpdateAddHTLC_get_htlc_id(this_ptr: &UpdateAddHTLC) -> u64 {
1743 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
1748 pub extern "C" fn UpdateAddHTLC_set_htlc_id(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
1749 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
1751 /// The HTLC value in milli-satoshi
1753 pub extern "C" fn UpdateAddHTLC_get_amount_msat(this_ptr: &UpdateAddHTLC) -> u64 {
1754 let mut inner_val = &mut this_ptr.get_native_mut_ref().amount_msat;
1757 /// The HTLC value in milli-satoshi
1759 pub extern "C" fn UpdateAddHTLC_set_amount_msat(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
1760 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.amount_msat = val;
1762 /// The payment hash, the pre-image of which controls HTLC redemption
1764 pub extern "C" fn UpdateAddHTLC_get_payment_hash(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
1765 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_hash;
1768 /// The payment hash, the pre-image of which controls HTLC redemption
1770 pub extern "C" fn UpdateAddHTLC_set_payment_hash(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1771 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_hash = ::lightning::ln::PaymentHash(val.data);
1773 /// The expiry height of the HTLC
1775 pub extern "C" fn UpdateAddHTLC_get_cltv_expiry(this_ptr: &UpdateAddHTLC) -> u32 {
1776 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry;
1779 /// The expiry height of the HTLC
1781 pub extern "C" fn UpdateAddHTLC_set_cltv_expiry(this_ptr: &mut UpdateAddHTLC, mut val: u32) {
1782 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry = val;
1784 impl Clone for UpdateAddHTLC {
1785 fn clone(&self) -> Self {
1787 inner: if <*mut nativeUpdateAddHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
1788 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1794 /// Used only if an object of this type is returned as a trait impl by a method
1795 pub(crate) extern "C" fn UpdateAddHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1796 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateAddHTLC)).clone() })) as *mut c_void
1799 /// Creates a copy of the UpdateAddHTLC
1800 pub extern "C" fn UpdateAddHTLC_clone(orig: &UpdateAddHTLC) -> UpdateAddHTLC {
1804 use lightning::ln::msgs::UpdateFulfillHTLC as nativeUpdateFulfillHTLCImport;
1805 pub(crate) type nativeUpdateFulfillHTLC = nativeUpdateFulfillHTLCImport;
1807 /// An update_fulfill_htlc message to be sent or received from a peer
1810 pub struct UpdateFulfillHTLC {
1811 /// A pointer to the opaque Rust object.
1813 /// Nearly everywhere, inner must be non-null, however in places where
1814 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1815 pub inner: *mut nativeUpdateFulfillHTLC,
1816 /// Indicates that this is the only struct which contains the same pointer.
1818 /// Rust functions which take ownership of an object provided via an argument require
1819 /// this to be true and invalidate the object pointed to by inner.
1823 impl Drop for UpdateFulfillHTLC {
1824 fn drop(&mut self) {
1825 if self.is_owned && !<*mut nativeUpdateFulfillHTLC>::is_null(self.inner) {
1826 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1830 /// Frees any resources used by the UpdateFulfillHTLC, if is_owned is set and inner is non-NULL.
1832 pub extern "C" fn UpdateFulfillHTLC_free(this_obj: UpdateFulfillHTLC) { }
1834 /// Used only if an object of this type is returned as a trait impl by a method
1835 pub(crate) extern "C" fn UpdateFulfillHTLC_free_void(this_ptr: *mut c_void) {
1836 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFulfillHTLC); }
1839 impl UpdateFulfillHTLC {
1840 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFulfillHTLC {
1841 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1843 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFulfillHTLC {
1844 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1846 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1847 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFulfillHTLC {
1848 assert!(self.is_owned);
1849 let ret = ObjOps::untweak_ptr(self.inner);
1850 self.inner = core::ptr::null_mut();
1856 pub extern "C" fn UpdateFulfillHTLC_get_channel_id(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
1857 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1862 pub extern "C" fn UpdateFulfillHTLC_set_channel_id(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1863 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1867 pub extern "C" fn UpdateFulfillHTLC_get_htlc_id(this_ptr: &UpdateFulfillHTLC) -> u64 {
1868 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
1873 pub extern "C" fn UpdateFulfillHTLC_set_htlc_id(this_ptr: &mut UpdateFulfillHTLC, mut val: u64) {
1874 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
1876 /// The pre-image of the payment hash, allowing HTLC redemption
1878 pub extern "C" fn UpdateFulfillHTLC_get_payment_preimage(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
1879 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_preimage;
1882 /// The pre-image of the payment hash, allowing HTLC redemption
1884 pub extern "C" fn UpdateFulfillHTLC_set_payment_preimage(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1885 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_preimage = ::lightning::ln::PaymentPreimage(val.data);
1887 /// Constructs a new UpdateFulfillHTLC given each field
1890 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 {
1891 UpdateFulfillHTLC { inner: ObjOps::heap_alloc(nativeUpdateFulfillHTLC {
1892 channel_id: channel_id_arg.data,
1893 htlc_id: htlc_id_arg,
1894 payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_arg.data),
1895 }), is_owned: true }
1897 impl Clone for UpdateFulfillHTLC {
1898 fn clone(&self) -> Self {
1900 inner: if <*mut nativeUpdateFulfillHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
1901 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1907 /// Used only if an object of this type is returned as a trait impl by a method
1908 pub(crate) extern "C" fn UpdateFulfillHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1909 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFulfillHTLC)).clone() })) as *mut c_void
1912 /// Creates a copy of the UpdateFulfillHTLC
1913 pub extern "C" fn UpdateFulfillHTLC_clone(orig: &UpdateFulfillHTLC) -> UpdateFulfillHTLC {
1917 use lightning::ln::msgs::UpdateFailHTLC as nativeUpdateFailHTLCImport;
1918 pub(crate) type nativeUpdateFailHTLC = nativeUpdateFailHTLCImport;
1920 /// An update_fail_htlc message to be sent or received from a peer
1923 pub struct UpdateFailHTLC {
1924 /// A pointer to the opaque Rust object.
1926 /// Nearly everywhere, inner must be non-null, however in places where
1927 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1928 pub inner: *mut nativeUpdateFailHTLC,
1929 /// Indicates that this is the only struct which contains the same pointer.
1931 /// Rust functions which take ownership of an object provided via an argument require
1932 /// this to be true and invalidate the object pointed to by inner.
1936 impl Drop for UpdateFailHTLC {
1937 fn drop(&mut self) {
1938 if self.is_owned && !<*mut nativeUpdateFailHTLC>::is_null(self.inner) {
1939 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1943 /// Frees any resources used by the UpdateFailHTLC, if is_owned is set and inner is non-NULL.
1945 pub extern "C" fn UpdateFailHTLC_free(this_obj: UpdateFailHTLC) { }
1947 /// Used only if an object of this type is returned as a trait impl by a method
1948 pub(crate) extern "C" fn UpdateFailHTLC_free_void(this_ptr: *mut c_void) {
1949 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFailHTLC); }
1952 impl UpdateFailHTLC {
1953 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailHTLC {
1954 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1956 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailHTLC {
1957 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1959 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1960 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailHTLC {
1961 assert!(self.is_owned);
1962 let ret = ObjOps::untweak_ptr(self.inner);
1963 self.inner = core::ptr::null_mut();
1969 pub extern "C" fn UpdateFailHTLC_get_channel_id(this_ptr: &UpdateFailHTLC) -> *const [u8; 32] {
1970 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1975 pub extern "C" fn UpdateFailHTLC_set_channel_id(this_ptr: &mut UpdateFailHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1976 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1980 pub extern "C" fn UpdateFailHTLC_get_htlc_id(this_ptr: &UpdateFailHTLC) -> u64 {
1981 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
1986 pub extern "C" fn UpdateFailHTLC_set_htlc_id(this_ptr: &mut UpdateFailHTLC, mut val: u64) {
1987 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
1989 impl Clone for UpdateFailHTLC {
1990 fn clone(&self) -> Self {
1992 inner: if <*mut nativeUpdateFailHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
1993 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1999 /// Used only if an object of this type is returned as a trait impl by a method
2000 pub(crate) extern "C" fn UpdateFailHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
2001 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailHTLC)).clone() })) as *mut c_void
2004 /// Creates a copy of the UpdateFailHTLC
2005 pub extern "C" fn UpdateFailHTLC_clone(orig: &UpdateFailHTLC) -> UpdateFailHTLC {
2009 use lightning::ln::msgs::UpdateFailMalformedHTLC as nativeUpdateFailMalformedHTLCImport;
2010 pub(crate) type nativeUpdateFailMalformedHTLC = nativeUpdateFailMalformedHTLCImport;
2012 /// An update_fail_malformed_htlc message to be sent or received from a peer
2015 pub struct UpdateFailMalformedHTLC {
2016 /// A pointer to the opaque Rust object.
2018 /// Nearly everywhere, inner must be non-null, however in places where
2019 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2020 pub inner: *mut nativeUpdateFailMalformedHTLC,
2021 /// Indicates that this is the only struct which contains the same pointer.
2023 /// Rust functions which take ownership of an object provided via an argument require
2024 /// this to be true and invalidate the object pointed to by inner.
2028 impl Drop for UpdateFailMalformedHTLC {
2029 fn drop(&mut self) {
2030 if self.is_owned && !<*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) {
2031 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2035 /// Frees any resources used by the UpdateFailMalformedHTLC, if is_owned is set and inner is non-NULL.
2037 pub extern "C" fn UpdateFailMalformedHTLC_free(this_obj: UpdateFailMalformedHTLC) { }
2039 /// Used only if an object of this type is returned as a trait impl by a method
2040 pub(crate) extern "C" fn UpdateFailMalformedHTLC_free_void(this_ptr: *mut c_void) {
2041 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFailMalformedHTLC); }
2044 impl UpdateFailMalformedHTLC {
2045 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailMalformedHTLC {
2046 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2048 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailMalformedHTLC {
2049 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2051 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2052 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailMalformedHTLC {
2053 assert!(self.is_owned);
2054 let ret = ObjOps::untweak_ptr(self.inner);
2055 self.inner = core::ptr::null_mut();
2061 pub extern "C" fn UpdateFailMalformedHTLC_get_channel_id(this_ptr: &UpdateFailMalformedHTLC) -> *const [u8; 32] {
2062 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2067 pub extern "C" fn UpdateFailMalformedHTLC_set_channel_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
2068 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2072 pub extern "C" fn UpdateFailMalformedHTLC_get_htlc_id(this_ptr: &UpdateFailMalformedHTLC) -> u64 {
2073 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
2078 pub extern "C" fn UpdateFailMalformedHTLC_set_htlc_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u64) {
2079 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
2081 /// The failure code
2083 pub extern "C" fn UpdateFailMalformedHTLC_get_failure_code(this_ptr: &UpdateFailMalformedHTLC) -> u16 {
2084 let mut inner_val = &mut this_ptr.get_native_mut_ref().failure_code;
2087 /// The failure code
2089 pub extern "C" fn UpdateFailMalformedHTLC_set_failure_code(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u16) {
2090 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.failure_code = val;
2092 impl Clone for UpdateFailMalformedHTLC {
2093 fn clone(&self) -> Self {
2095 inner: if <*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
2096 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2102 /// Used only if an object of this type is returned as a trait impl by a method
2103 pub(crate) extern "C" fn UpdateFailMalformedHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
2104 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailMalformedHTLC)).clone() })) as *mut c_void
2107 /// Creates a copy of the UpdateFailMalformedHTLC
2108 pub extern "C" fn UpdateFailMalformedHTLC_clone(orig: &UpdateFailMalformedHTLC) -> UpdateFailMalformedHTLC {
2112 use lightning::ln::msgs::CommitmentSigned as nativeCommitmentSignedImport;
2113 pub(crate) type nativeCommitmentSigned = nativeCommitmentSignedImport;
2115 /// A commitment_signed message to be sent or received from a peer
2118 pub struct CommitmentSigned {
2119 /// A pointer to the opaque Rust object.
2121 /// Nearly everywhere, inner must be non-null, however in places where
2122 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2123 pub inner: *mut nativeCommitmentSigned,
2124 /// Indicates that this is the only struct which contains the same pointer.
2126 /// Rust functions which take ownership of an object provided via an argument require
2127 /// this to be true and invalidate the object pointed to by inner.
2131 impl Drop for CommitmentSigned {
2132 fn drop(&mut self) {
2133 if self.is_owned && !<*mut nativeCommitmentSigned>::is_null(self.inner) {
2134 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2138 /// Frees any resources used by the CommitmentSigned, if is_owned is set and inner is non-NULL.
2140 pub extern "C" fn CommitmentSigned_free(this_obj: CommitmentSigned) { }
2142 /// Used only if an object of this type is returned as a trait impl by a method
2143 pub(crate) extern "C" fn CommitmentSigned_free_void(this_ptr: *mut c_void) {
2144 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentSigned); }
2147 impl CommitmentSigned {
2148 pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentSigned {
2149 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2151 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentSigned {
2152 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2154 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2155 pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentSigned {
2156 assert!(self.is_owned);
2157 let ret = ObjOps::untweak_ptr(self.inner);
2158 self.inner = core::ptr::null_mut();
2164 pub extern "C" fn CommitmentSigned_get_channel_id(this_ptr: &CommitmentSigned) -> *const [u8; 32] {
2165 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2170 pub extern "C" fn CommitmentSigned_set_channel_id(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::ThirtyTwoBytes) {
2171 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2173 /// A signature on the commitment transaction
2175 pub extern "C" fn CommitmentSigned_get_signature(this_ptr: &CommitmentSigned) -> crate::c_types::Signature {
2176 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
2177 crate::c_types::Signature::from_rust(&inner_val)
2179 /// A signature on the commitment transaction
2181 pub extern "C" fn CommitmentSigned_set_signature(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::Signature) {
2182 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
2184 /// Signatures on the HTLC transactions
2186 pub extern "C" fn CommitmentSigned_set_htlc_signatures(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::derived::CVec_SignatureZ) {
2187 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_rust() }); };
2188 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_signatures = local_val;
2190 /// Constructs a new CommitmentSigned given each field
2193 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 {
2194 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() }); };
2195 CommitmentSigned { inner: ObjOps::heap_alloc(nativeCommitmentSigned {
2196 channel_id: channel_id_arg.data,
2197 signature: signature_arg.into_rust(),
2198 htlc_signatures: local_htlc_signatures_arg,
2199 }), is_owned: true }
2201 impl Clone for CommitmentSigned {
2202 fn clone(&self) -> Self {
2204 inner: if <*mut nativeCommitmentSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
2205 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2211 /// Used only if an object of this type is returned as a trait impl by a method
2212 pub(crate) extern "C" fn CommitmentSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
2213 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentSigned)).clone() })) as *mut c_void
2216 /// Creates a copy of the CommitmentSigned
2217 pub extern "C" fn CommitmentSigned_clone(orig: &CommitmentSigned) -> CommitmentSigned {
2221 use lightning::ln::msgs::RevokeAndACK as nativeRevokeAndACKImport;
2222 pub(crate) type nativeRevokeAndACK = nativeRevokeAndACKImport;
2224 /// A revoke_and_ack message to be sent or received from a peer
2227 pub struct RevokeAndACK {
2228 /// A pointer to the opaque Rust object.
2230 /// Nearly everywhere, inner must be non-null, however in places where
2231 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2232 pub inner: *mut nativeRevokeAndACK,
2233 /// Indicates that this is the only struct which contains the same pointer.
2235 /// Rust functions which take ownership of an object provided via an argument require
2236 /// this to be true and invalidate the object pointed to by inner.
2240 impl Drop for RevokeAndACK {
2241 fn drop(&mut self) {
2242 if self.is_owned && !<*mut nativeRevokeAndACK>::is_null(self.inner) {
2243 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2247 /// Frees any resources used by the RevokeAndACK, if is_owned is set and inner is non-NULL.
2249 pub extern "C" fn RevokeAndACK_free(this_obj: RevokeAndACK) { }
2251 /// Used only if an object of this type is returned as a trait impl by a method
2252 pub(crate) extern "C" fn RevokeAndACK_free_void(this_ptr: *mut c_void) {
2253 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRevokeAndACK); }
2257 pub(crate) fn get_native_ref(&self) -> &'static nativeRevokeAndACK {
2258 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2260 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRevokeAndACK {
2261 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2263 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2264 pub(crate) fn take_inner(mut self) -> *mut nativeRevokeAndACK {
2265 assert!(self.is_owned);
2266 let ret = ObjOps::untweak_ptr(self.inner);
2267 self.inner = core::ptr::null_mut();
2273 pub extern "C" fn RevokeAndACK_get_channel_id(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
2274 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2279 pub extern "C" fn RevokeAndACK_set_channel_id(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
2280 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2282 /// The secret corresponding to the per-commitment point
2284 pub extern "C" fn RevokeAndACK_get_per_commitment_secret(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
2285 let mut inner_val = &mut this_ptr.get_native_mut_ref().per_commitment_secret;
2288 /// The secret corresponding to the per-commitment point
2290 pub extern "C" fn RevokeAndACK_set_per_commitment_secret(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
2291 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.per_commitment_secret = val.data;
2293 /// The next sender-broadcast commitment transaction's per-commitment point
2295 pub extern "C" fn RevokeAndACK_get_next_per_commitment_point(this_ptr: &RevokeAndACK) -> crate::c_types::PublicKey {
2296 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
2297 crate::c_types::PublicKey::from_rust(&inner_val)
2299 /// The next sender-broadcast commitment transaction's per-commitment point
2301 pub extern "C" fn RevokeAndACK_set_next_per_commitment_point(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::PublicKey) {
2302 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
2304 /// Constructs a new RevokeAndACK given each field
2307 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 {
2308 RevokeAndACK { inner: ObjOps::heap_alloc(nativeRevokeAndACK {
2309 channel_id: channel_id_arg.data,
2310 per_commitment_secret: per_commitment_secret_arg.data,
2311 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
2312 }), is_owned: true }
2314 impl Clone for RevokeAndACK {
2315 fn clone(&self) -> Self {
2317 inner: if <*mut nativeRevokeAndACK>::is_null(self.inner) { core::ptr::null_mut() } else {
2318 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2324 /// Used only if an object of this type is returned as a trait impl by a method
2325 pub(crate) extern "C" fn RevokeAndACK_clone_void(this_ptr: *const c_void) -> *mut c_void {
2326 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRevokeAndACK)).clone() })) as *mut c_void
2329 /// Creates a copy of the RevokeAndACK
2330 pub extern "C" fn RevokeAndACK_clone(orig: &RevokeAndACK) -> RevokeAndACK {
2334 use lightning::ln::msgs::UpdateFee as nativeUpdateFeeImport;
2335 pub(crate) type nativeUpdateFee = nativeUpdateFeeImport;
2337 /// An update_fee message to be sent or received from a peer
2340 pub struct UpdateFee {
2341 /// A pointer to the opaque Rust object.
2343 /// Nearly everywhere, inner must be non-null, however in places where
2344 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2345 pub inner: *mut nativeUpdateFee,
2346 /// Indicates that this is the only struct which contains the same pointer.
2348 /// Rust functions which take ownership of an object provided via an argument require
2349 /// this to be true and invalidate the object pointed to by inner.
2353 impl Drop for UpdateFee {
2354 fn drop(&mut self) {
2355 if self.is_owned && !<*mut nativeUpdateFee>::is_null(self.inner) {
2356 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2360 /// Frees any resources used by the UpdateFee, if is_owned is set and inner is non-NULL.
2362 pub extern "C" fn UpdateFee_free(this_obj: UpdateFee) { }
2364 /// Used only if an object of this type is returned as a trait impl by a method
2365 pub(crate) extern "C" fn UpdateFee_free_void(this_ptr: *mut c_void) {
2366 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFee); }
2370 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFee {
2371 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2373 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFee {
2374 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2376 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2377 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFee {
2378 assert!(self.is_owned);
2379 let ret = ObjOps::untweak_ptr(self.inner);
2380 self.inner = core::ptr::null_mut();
2386 pub extern "C" fn UpdateFee_get_channel_id(this_ptr: &UpdateFee) -> *const [u8; 32] {
2387 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2392 pub extern "C" fn UpdateFee_set_channel_id(this_ptr: &mut UpdateFee, mut val: crate::c_types::ThirtyTwoBytes) {
2393 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2395 /// Fee rate per 1000-weight of the transaction
2397 pub extern "C" fn UpdateFee_get_feerate_per_kw(this_ptr: &UpdateFee) -> u32 {
2398 let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
2401 /// Fee rate per 1000-weight of the transaction
2403 pub extern "C" fn UpdateFee_set_feerate_per_kw(this_ptr: &mut UpdateFee, mut val: u32) {
2404 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
2406 /// Constructs a new UpdateFee given each field
2409 pub extern "C" fn UpdateFee_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut feerate_per_kw_arg: u32) -> UpdateFee {
2410 UpdateFee { inner: ObjOps::heap_alloc(nativeUpdateFee {
2411 channel_id: channel_id_arg.data,
2412 feerate_per_kw: feerate_per_kw_arg,
2413 }), is_owned: true }
2415 impl Clone for UpdateFee {
2416 fn clone(&self) -> Self {
2418 inner: if <*mut nativeUpdateFee>::is_null(self.inner) { core::ptr::null_mut() } else {
2419 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2425 /// Used only if an object of this type is returned as a trait impl by a method
2426 pub(crate) extern "C" fn UpdateFee_clone_void(this_ptr: *const c_void) -> *mut c_void {
2427 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFee)).clone() })) as *mut c_void
2430 /// Creates a copy of the UpdateFee
2431 pub extern "C" fn UpdateFee_clone(orig: &UpdateFee) -> UpdateFee {
2435 use lightning::ln::msgs::DataLossProtect as nativeDataLossProtectImport;
2436 pub(crate) type nativeDataLossProtect = nativeDataLossProtectImport;
2438 /// Proof that the sender knows the per-commitment secret of the previous commitment transaction.
2439 /// This is used to convince the recipient that the channel is at a certain commitment
2440 /// number even if they lost that data due to a local failure. Of course, the peer may lie
2441 /// and even later commitments may have been revoked.
2444 pub struct DataLossProtect {
2445 /// A pointer to the opaque Rust object.
2447 /// Nearly everywhere, inner must be non-null, however in places where
2448 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2449 pub inner: *mut nativeDataLossProtect,
2450 /// Indicates that this is the only struct which contains the same pointer.
2452 /// Rust functions which take ownership of an object provided via an argument require
2453 /// this to be true and invalidate the object pointed to by inner.
2457 impl Drop for DataLossProtect {
2458 fn drop(&mut self) {
2459 if self.is_owned && !<*mut nativeDataLossProtect>::is_null(self.inner) {
2460 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2464 /// Frees any resources used by the DataLossProtect, if is_owned is set and inner is non-NULL.
2466 pub extern "C" fn DataLossProtect_free(this_obj: DataLossProtect) { }
2468 /// Used only if an object of this type is returned as a trait impl by a method
2469 pub(crate) extern "C" fn DataLossProtect_free_void(this_ptr: *mut c_void) {
2470 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDataLossProtect); }
2473 impl DataLossProtect {
2474 pub(crate) fn get_native_ref(&self) -> &'static nativeDataLossProtect {
2475 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2477 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeDataLossProtect {
2478 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2480 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2481 pub(crate) fn take_inner(mut self) -> *mut nativeDataLossProtect {
2482 assert!(self.is_owned);
2483 let ret = ObjOps::untweak_ptr(self.inner);
2484 self.inner = core::ptr::null_mut();
2488 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
2489 /// belonging to the recipient
2491 pub extern "C" fn DataLossProtect_get_your_last_per_commitment_secret(this_ptr: &DataLossProtect) -> *const [u8; 32] {
2492 let mut inner_val = &mut this_ptr.get_native_mut_ref().your_last_per_commitment_secret;
2495 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
2496 /// belonging to the recipient
2498 pub extern "C" fn DataLossProtect_set_your_last_per_commitment_secret(this_ptr: &mut DataLossProtect, mut val: crate::c_types::ThirtyTwoBytes) {
2499 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.your_last_per_commitment_secret = val.data;
2501 /// The sender's per-commitment point for their current commitment transaction
2503 pub extern "C" fn DataLossProtect_get_my_current_per_commitment_point(this_ptr: &DataLossProtect) -> crate::c_types::PublicKey {
2504 let mut inner_val = &mut this_ptr.get_native_mut_ref().my_current_per_commitment_point;
2505 crate::c_types::PublicKey::from_rust(&inner_val)
2507 /// The sender's per-commitment point for their current commitment transaction
2509 pub extern "C" fn DataLossProtect_set_my_current_per_commitment_point(this_ptr: &mut DataLossProtect, mut val: crate::c_types::PublicKey) {
2510 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.my_current_per_commitment_point = val.into_rust();
2512 /// Constructs a new DataLossProtect given each field
2515 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 {
2516 DataLossProtect { inner: ObjOps::heap_alloc(nativeDataLossProtect {
2517 your_last_per_commitment_secret: your_last_per_commitment_secret_arg.data,
2518 my_current_per_commitment_point: my_current_per_commitment_point_arg.into_rust(),
2519 }), is_owned: true }
2521 impl Clone for DataLossProtect {
2522 fn clone(&self) -> Self {
2524 inner: if <*mut nativeDataLossProtect>::is_null(self.inner) { core::ptr::null_mut() } else {
2525 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2531 /// Used only if an object of this type is returned as a trait impl by a method
2532 pub(crate) extern "C" fn DataLossProtect_clone_void(this_ptr: *const c_void) -> *mut c_void {
2533 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDataLossProtect)).clone() })) as *mut c_void
2536 /// Creates a copy of the DataLossProtect
2537 pub extern "C" fn DataLossProtect_clone(orig: &DataLossProtect) -> DataLossProtect {
2541 use lightning::ln::msgs::ChannelReestablish as nativeChannelReestablishImport;
2542 pub(crate) type nativeChannelReestablish = nativeChannelReestablishImport;
2544 /// A channel_reestablish message to be sent or received from a peer
2547 pub struct ChannelReestablish {
2548 /// A pointer to the opaque Rust object.
2550 /// Nearly everywhere, inner must be non-null, however in places where
2551 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2552 pub inner: *mut nativeChannelReestablish,
2553 /// Indicates that this is the only struct which contains the same pointer.
2555 /// Rust functions which take ownership of an object provided via an argument require
2556 /// this to be true and invalidate the object pointed to by inner.
2560 impl Drop for ChannelReestablish {
2561 fn drop(&mut self) {
2562 if self.is_owned && !<*mut nativeChannelReestablish>::is_null(self.inner) {
2563 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2567 /// Frees any resources used by the ChannelReestablish, if is_owned is set and inner is non-NULL.
2569 pub extern "C" fn ChannelReestablish_free(this_obj: ChannelReestablish) { }
2571 /// Used only if an object of this type is returned as a trait impl by a method
2572 pub(crate) extern "C" fn ChannelReestablish_free_void(this_ptr: *mut c_void) {
2573 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelReestablish); }
2576 impl ChannelReestablish {
2577 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelReestablish {
2578 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2580 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelReestablish {
2581 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2583 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2584 pub(crate) fn take_inner(mut self) -> *mut nativeChannelReestablish {
2585 assert!(self.is_owned);
2586 let ret = ObjOps::untweak_ptr(self.inner);
2587 self.inner = core::ptr::null_mut();
2593 pub extern "C" fn ChannelReestablish_get_channel_id(this_ptr: &ChannelReestablish) -> *const [u8; 32] {
2594 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2599 pub extern "C" fn ChannelReestablish_set_channel_id(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) {
2600 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2602 /// The next commitment number for the sender
2604 pub extern "C" fn ChannelReestablish_get_next_local_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
2605 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_local_commitment_number;
2608 /// The next commitment number for the sender
2610 pub extern "C" fn ChannelReestablish_set_next_local_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
2611 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_local_commitment_number = val;
2613 /// The next commitment number for the recipient
2615 pub extern "C" fn ChannelReestablish_get_next_remote_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
2616 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_remote_commitment_number;
2619 /// The next commitment number for the recipient
2621 pub extern "C" fn ChannelReestablish_set_next_remote_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
2622 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_remote_commitment_number = val;
2624 impl Clone for ChannelReestablish {
2625 fn clone(&self) -> Self {
2627 inner: if <*mut nativeChannelReestablish>::is_null(self.inner) { core::ptr::null_mut() } else {
2628 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2634 /// Used only if an object of this type is returned as a trait impl by a method
2635 pub(crate) extern "C" fn ChannelReestablish_clone_void(this_ptr: *const c_void) -> *mut c_void {
2636 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelReestablish)).clone() })) as *mut c_void
2639 /// Creates a copy of the ChannelReestablish
2640 pub extern "C" fn ChannelReestablish_clone(orig: &ChannelReestablish) -> ChannelReestablish {
2644 use lightning::ln::msgs::AnnouncementSignatures as nativeAnnouncementSignaturesImport;
2645 pub(crate) type nativeAnnouncementSignatures = nativeAnnouncementSignaturesImport;
2647 /// An announcement_signatures message to be sent or received from a peer
2650 pub struct AnnouncementSignatures {
2651 /// A pointer to the opaque Rust object.
2653 /// Nearly everywhere, inner must be non-null, however in places where
2654 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2655 pub inner: *mut nativeAnnouncementSignatures,
2656 /// Indicates that this is the only struct which contains the same pointer.
2658 /// Rust functions which take ownership of an object provided via an argument require
2659 /// this to be true and invalidate the object pointed to by inner.
2663 impl Drop for AnnouncementSignatures {
2664 fn drop(&mut self) {
2665 if self.is_owned && !<*mut nativeAnnouncementSignatures>::is_null(self.inner) {
2666 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2670 /// Frees any resources used by the AnnouncementSignatures, if is_owned is set and inner is non-NULL.
2672 pub extern "C" fn AnnouncementSignatures_free(this_obj: AnnouncementSignatures) { }
2674 /// Used only if an object of this type is returned as a trait impl by a method
2675 pub(crate) extern "C" fn AnnouncementSignatures_free_void(this_ptr: *mut c_void) {
2676 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeAnnouncementSignatures); }
2679 impl AnnouncementSignatures {
2680 pub(crate) fn get_native_ref(&self) -> &'static nativeAnnouncementSignatures {
2681 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2683 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAnnouncementSignatures {
2684 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2686 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2687 pub(crate) fn take_inner(mut self) -> *mut nativeAnnouncementSignatures {
2688 assert!(self.is_owned);
2689 let ret = ObjOps::untweak_ptr(self.inner);
2690 self.inner = core::ptr::null_mut();
2696 pub extern "C" fn AnnouncementSignatures_get_channel_id(this_ptr: &AnnouncementSignatures) -> *const [u8; 32] {
2697 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2702 pub extern "C" fn AnnouncementSignatures_set_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
2703 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2705 /// The short channel ID
2707 pub extern "C" fn AnnouncementSignatures_get_short_channel_id(this_ptr: &AnnouncementSignatures) -> u64 {
2708 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
2711 /// The short channel ID
2713 pub extern "C" fn AnnouncementSignatures_set_short_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: u64) {
2714 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
2716 /// A signature by the node key
2718 pub extern "C" fn AnnouncementSignatures_get_node_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
2719 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature;
2720 crate::c_types::Signature::from_rust(&inner_val)
2722 /// A signature by the node key
2724 pub extern "C" fn AnnouncementSignatures_set_node_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
2725 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature = val.into_rust();
2727 /// A signature by the funding key
2729 pub extern "C" fn AnnouncementSignatures_get_bitcoin_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
2730 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature;
2731 crate::c_types::Signature::from_rust(&inner_val)
2733 /// A signature by the funding key
2735 pub extern "C" fn AnnouncementSignatures_set_bitcoin_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
2736 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature = val.into_rust();
2738 /// Constructs a new AnnouncementSignatures given each field
2741 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 {
2742 AnnouncementSignatures { inner: ObjOps::heap_alloc(nativeAnnouncementSignatures {
2743 channel_id: channel_id_arg.data,
2744 short_channel_id: short_channel_id_arg,
2745 node_signature: node_signature_arg.into_rust(),
2746 bitcoin_signature: bitcoin_signature_arg.into_rust(),
2747 }), is_owned: true }
2749 impl Clone for AnnouncementSignatures {
2750 fn clone(&self) -> Self {
2752 inner: if <*mut nativeAnnouncementSignatures>::is_null(self.inner) { core::ptr::null_mut() } else {
2753 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2759 /// Used only if an object of this type is returned as a trait impl by a method
2760 pub(crate) extern "C" fn AnnouncementSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
2761 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAnnouncementSignatures)).clone() })) as *mut c_void
2764 /// Creates a copy of the AnnouncementSignatures
2765 pub extern "C" fn AnnouncementSignatures_clone(orig: &AnnouncementSignatures) -> AnnouncementSignatures {
2768 /// An address which can be used to connect to a remote peer
2772 pub enum NetAddress {
2773 /// An IPv4 address/port on which the peer is listening.
2775 /// The 4-byte IPv4 address
2776 addr: crate::c_types::FourBytes,
2777 /// The port on which the node is listening
2780 /// An IPv6 address/port on which the peer is listening.
2782 /// The 16-byte IPv6 address
2783 addr: crate::c_types::SixteenBytes,
2784 /// The port on which the node is listening
2787 /// An old-style Tor onion address/port on which the peer is listening.
2789 /// This field is deprecated and the Tor network generally no longer supports V2 Onion
2790 /// addresses. Thus, the details are not parsed here.
2791 OnionV2(crate::c_types::TwelveBytes),
2792 /// A new-style Tor onion address/port on which the peer is listening.
2793 /// To create the human-readable \"hostname\", concatenate ed25519_pubkey, checksum, and version,
2794 /// wrap as base32 and append \".onion\".
2796 /// The ed25519 long-term public key of the peer
2797 ed25519_pubkey: crate::c_types::ThirtyTwoBytes,
2798 /// The checksum of the pubkey and version, as included in the onion address
2800 /// The version byte, as defined by the Tor Onion v3 spec.
2802 /// The port on which the node is listening
2806 use lightning::ln::msgs::NetAddress as nativeNetAddress;
2809 pub(crate) fn to_native(&self) -> nativeNetAddress {
2811 NetAddress::IPv4 {ref addr, ref port, } => {
2812 let mut addr_nonref = (*addr).clone();
2813 let mut port_nonref = (*port).clone();
2814 nativeNetAddress::IPv4 {
2815 addr: addr_nonref.data,
2819 NetAddress::IPv6 {ref addr, ref port, } => {
2820 let mut addr_nonref = (*addr).clone();
2821 let mut port_nonref = (*port).clone();
2822 nativeNetAddress::IPv6 {
2823 addr: addr_nonref.data,
2827 NetAddress::OnionV2 (ref a, ) => {
2828 let mut a_nonref = (*a).clone();
2829 nativeNetAddress::OnionV2 (
2833 NetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
2834 let mut ed25519_pubkey_nonref = (*ed25519_pubkey).clone();
2835 let mut checksum_nonref = (*checksum).clone();
2836 let mut version_nonref = (*version).clone();
2837 let mut port_nonref = (*port).clone();
2838 nativeNetAddress::OnionV3 {
2839 ed25519_pubkey: ed25519_pubkey_nonref.data,
2840 checksum: checksum_nonref,
2841 version: version_nonref,
2848 pub(crate) fn into_native(self) -> nativeNetAddress {
2850 NetAddress::IPv4 {mut addr, mut port, } => {
2851 nativeNetAddress::IPv4 {
2856 NetAddress::IPv6 {mut addr, mut port, } => {
2857 nativeNetAddress::IPv6 {
2862 NetAddress::OnionV2 (mut a, ) => {
2863 nativeNetAddress::OnionV2 (
2867 NetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
2868 nativeNetAddress::OnionV3 {
2869 ed25519_pubkey: ed25519_pubkey.data,
2878 pub(crate) fn from_native(native: &nativeNetAddress) -> Self {
2880 nativeNetAddress::IPv4 {ref addr, ref port, } => {
2881 let mut addr_nonref = (*addr).clone();
2882 let mut port_nonref = (*port).clone();
2884 addr: crate::c_types::FourBytes { data: addr_nonref },
2888 nativeNetAddress::IPv6 {ref addr, ref port, } => {
2889 let mut addr_nonref = (*addr).clone();
2890 let mut port_nonref = (*port).clone();
2892 addr: crate::c_types::SixteenBytes { data: addr_nonref },
2896 nativeNetAddress::OnionV2 (ref a, ) => {
2897 let mut a_nonref = (*a).clone();
2898 NetAddress::OnionV2 (
2899 crate::c_types::TwelveBytes { data: a_nonref },
2902 nativeNetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
2903 let mut ed25519_pubkey_nonref = (*ed25519_pubkey).clone();
2904 let mut checksum_nonref = (*checksum).clone();
2905 let mut version_nonref = (*version).clone();
2906 let mut port_nonref = (*port).clone();
2907 NetAddress::OnionV3 {
2908 ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey_nonref },
2909 checksum: checksum_nonref,
2910 version: version_nonref,
2917 pub(crate) fn native_into(native: nativeNetAddress) -> Self {
2919 nativeNetAddress::IPv4 {mut addr, mut port, } => {
2921 addr: crate::c_types::FourBytes { data: addr },
2925 nativeNetAddress::IPv6 {mut addr, mut port, } => {
2927 addr: crate::c_types::SixteenBytes { data: addr },
2931 nativeNetAddress::OnionV2 (mut a, ) => {
2932 NetAddress::OnionV2 (
2933 crate::c_types::TwelveBytes { data: a },
2936 nativeNetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
2937 NetAddress::OnionV3 {
2938 ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey },
2947 /// Frees any resources used by the NetAddress
2949 pub extern "C" fn NetAddress_free(this_ptr: NetAddress) { }
2950 /// Creates a copy of the NetAddress
2952 pub extern "C" fn NetAddress_clone(orig: &NetAddress) -> NetAddress {
2956 /// Utility method to constructs a new IPv4-variant NetAddress
2957 pub extern "C" fn NetAddress_ipv4(addr: crate::c_types::FourBytes, port: u16) -> NetAddress {
2964 /// Utility method to constructs a new IPv6-variant NetAddress
2965 pub extern "C" fn NetAddress_ipv6(addr: crate::c_types::SixteenBytes, port: u16) -> NetAddress {
2972 /// Utility method to constructs a new OnionV2-variant NetAddress
2973 pub extern "C" fn NetAddress_onion_v2(a: crate::c_types::TwelveBytes) -> NetAddress {
2974 NetAddress::OnionV2(a, )
2977 /// Utility method to constructs a new OnionV3-variant NetAddress
2978 pub extern "C" fn NetAddress_onion_v3(ed25519_pubkey: crate::c_types::ThirtyTwoBytes, checksum: u16, version: u8, port: u16) -> NetAddress {
2979 NetAddress::OnionV3 {
2987 /// Serialize the NetAddress object into a byte array which can be read by NetAddress_read
2988 pub extern "C" fn NetAddress_write(obj: &NetAddress) -> crate::c_types::derived::CVec_u8Z {
2989 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
2992 /// Read a NetAddress from a byte array, created by NetAddress_write
2993 pub extern "C" fn NetAddress_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NetAddressDecodeErrorZ {
2994 let res: Result<lightning::ln::msgs::NetAddress, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
2995 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() };
2999 use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport;
3000 pub(crate) type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport;
3002 /// The unsigned part of a node_announcement
3005 pub struct UnsignedNodeAnnouncement {
3006 /// A pointer to the opaque Rust object.
3008 /// Nearly everywhere, inner must be non-null, however in places where
3009 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3010 pub inner: *mut nativeUnsignedNodeAnnouncement,
3011 /// Indicates that this is the only struct which contains the same pointer.
3013 /// Rust functions which take ownership of an object provided via an argument require
3014 /// this to be true and invalidate the object pointed to by inner.
3018 impl Drop for UnsignedNodeAnnouncement {
3019 fn drop(&mut self) {
3020 if self.is_owned && !<*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) {
3021 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3025 /// Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL.
3027 pub extern "C" fn UnsignedNodeAnnouncement_free(this_obj: UnsignedNodeAnnouncement) { }
3029 /// Used only if an object of this type is returned as a trait impl by a method
3030 pub(crate) extern "C" fn UnsignedNodeAnnouncement_free_void(this_ptr: *mut c_void) {
3031 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedNodeAnnouncement); }
3034 impl UnsignedNodeAnnouncement {
3035 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedNodeAnnouncement {
3036 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3038 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedNodeAnnouncement {
3039 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3041 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3042 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedNodeAnnouncement {
3043 assert!(self.is_owned);
3044 let ret = ObjOps::untweak_ptr(self.inner);
3045 self.inner = core::ptr::null_mut();
3049 /// The advertised features
3051 pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::ln::features::NodeFeatures {
3052 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
3053 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 }
3055 /// The advertised features
3057 pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::ln::features::NodeFeatures) {
3058 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
3060 /// A strictly monotonic announcement counter, with gaps allowed
3062 pub extern "C" fn UnsignedNodeAnnouncement_get_timestamp(this_ptr: &UnsignedNodeAnnouncement) -> u32 {
3063 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
3066 /// A strictly monotonic announcement counter, with gaps allowed
3068 pub extern "C" fn UnsignedNodeAnnouncement_set_timestamp(this_ptr: &mut UnsignedNodeAnnouncement, mut val: u32) {
3069 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
3071 /// The node_id this announcement originated from (don't rebroadcast the node_announcement back
3074 pub extern "C" fn UnsignedNodeAnnouncement_get_node_id(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::PublicKey {
3075 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id;
3076 crate::c_types::PublicKey::from_rust(&inner_val)
3078 /// The node_id this announcement originated from (don't rebroadcast the node_announcement back
3081 pub extern "C" fn UnsignedNodeAnnouncement_set_node_id(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::PublicKey) {
3082 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id = val.into_rust();
3084 /// An RGB color for UI purposes
3086 pub extern "C" fn UnsignedNodeAnnouncement_get_rgb(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 3] {
3087 let mut inner_val = &mut this_ptr.get_native_mut_ref().rgb;
3090 /// An RGB color for UI purposes
3092 pub extern "C" fn UnsignedNodeAnnouncement_set_rgb(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThreeBytes) {
3093 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.rgb = val.data;
3095 /// An alias, for UI purposes. This should be sanitized before use. There is no guarantee
3098 pub extern "C" fn UnsignedNodeAnnouncement_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 32] {
3099 let mut inner_val = &mut this_ptr.get_native_mut_ref().alias;
3102 /// An alias, for UI purposes. This should be sanitized before use. There is no guarantee
3105 pub extern "C" fn UnsignedNodeAnnouncement_set_alias(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
3106 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.alias = val.data;
3108 /// List of addresses on which this node is reachable
3110 pub extern "C" fn UnsignedNodeAnnouncement_set_addresses(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_NetAddressZ) {
3111 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
3112 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.addresses = local_val;
3114 impl Clone for UnsignedNodeAnnouncement {
3115 fn clone(&self) -> Self {
3117 inner: if <*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
3118 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3124 /// Used only if an object of this type is returned as a trait impl by a method
3125 pub(crate) extern "C" fn UnsignedNodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3126 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedNodeAnnouncement)).clone() })) as *mut c_void
3129 /// Creates a copy of the UnsignedNodeAnnouncement
3130 pub extern "C" fn UnsignedNodeAnnouncement_clone(orig: &UnsignedNodeAnnouncement) -> UnsignedNodeAnnouncement {
3134 use lightning::ln::msgs::NodeAnnouncement as nativeNodeAnnouncementImport;
3135 pub(crate) type nativeNodeAnnouncement = nativeNodeAnnouncementImport;
3137 /// A node_announcement message to be sent or received from a peer
3140 pub struct NodeAnnouncement {
3141 /// A pointer to the opaque Rust object.
3143 /// Nearly everywhere, inner must be non-null, however in places where
3144 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3145 pub inner: *mut nativeNodeAnnouncement,
3146 /// Indicates that this is the only struct which contains the same pointer.
3148 /// Rust functions which take ownership of an object provided via an argument require
3149 /// this to be true and invalidate the object pointed to by inner.
3153 impl Drop for NodeAnnouncement {
3154 fn drop(&mut self) {
3155 if self.is_owned && !<*mut nativeNodeAnnouncement>::is_null(self.inner) {
3156 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3160 /// Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL.
3162 pub extern "C" fn NodeAnnouncement_free(this_obj: NodeAnnouncement) { }
3164 /// Used only if an object of this type is returned as a trait impl by a method
3165 pub(crate) extern "C" fn NodeAnnouncement_free_void(this_ptr: *mut c_void) {
3166 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeAnnouncement); }
3169 impl NodeAnnouncement {
3170 pub(crate) fn get_native_ref(&self) -> &'static nativeNodeAnnouncement {
3171 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3173 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeAnnouncement {
3174 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3176 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3177 pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncement {
3178 assert!(self.is_owned);
3179 let ret = ObjOps::untweak_ptr(self.inner);
3180 self.inner = core::ptr::null_mut();
3184 /// The signature by the node key
3186 pub extern "C" fn NodeAnnouncement_get_signature(this_ptr: &NodeAnnouncement) -> crate::c_types::Signature {
3187 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
3188 crate::c_types::Signature::from_rust(&inner_val)
3190 /// The signature by the node key
3192 pub extern "C" fn NodeAnnouncement_set_signature(this_ptr: &mut NodeAnnouncement, mut val: crate::c_types::Signature) {
3193 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
3195 /// The actual content of the announcement
3197 pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> crate::lightning::ln::msgs::UnsignedNodeAnnouncement {
3198 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
3199 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 }
3201 /// The actual content of the announcement
3203 pub extern "C" fn NodeAnnouncement_set_contents(this_ptr: &mut NodeAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) {
3204 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
3206 /// Constructs a new NodeAnnouncement given each field
3209 pub extern "C" fn NodeAnnouncement_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> NodeAnnouncement {
3210 NodeAnnouncement { inner: ObjOps::heap_alloc(nativeNodeAnnouncement {
3211 signature: signature_arg.into_rust(),
3212 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
3213 }), is_owned: true }
3215 impl Clone for NodeAnnouncement {
3216 fn clone(&self) -> Self {
3218 inner: if <*mut nativeNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
3219 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3225 /// Used only if an object of this type is returned as a trait impl by a method
3226 pub(crate) extern "C" fn NodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3227 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeAnnouncement)).clone() })) as *mut c_void
3230 /// Creates a copy of the NodeAnnouncement
3231 pub extern "C" fn NodeAnnouncement_clone(orig: &NodeAnnouncement) -> NodeAnnouncement {
3235 use lightning::ln::msgs::UnsignedChannelAnnouncement as nativeUnsignedChannelAnnouncementImport;
3236 pub(crate) type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport;
3238 /// The unsigned part of a channel_announcement
3241 pub struct UnsignedChannelAnnouncement {
3242 /// A pointer to the opaque Rust object.
3244 /// Nearly everywhere, inner must be non-null, however in places where
3245 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3246 pub inner: *mut nativeUnsignedChannelAnnouncement,
3247 /// Indicates that this is the only struct which contains the same pointer.
3249 /// Rust functions which take ownership of an object provided via an argument require
3250 /// this to be true and invalidate the object pointed to by inner.
3254 impl Drop for UnsignedChannelAnnouncement {
3255 fn drop(&mut self) {
3256 if self.is_owned && !<*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) {
3257 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3261 /// Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL.
3263 pub extern "C" fn UnsignedChannelAnnouncement_free(this_obj: UnsignedChannelAnnouncement) { }
3265 /// Used only if an object of this type is returned as a trait impl by a method
3266 pub(crate) extern "C" fn UnsignedChannelAnnouncement_free_void(this_ptr: *mut c_void) {
3267 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelAnnouncement); }
3270 impl UnsignedChannelAnnouncement {
3271 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelAnnouncement {
3272 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3274 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelAnnouncement {
3275 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3277 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3278 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelAnnouncement {
3279 assert!(self.is_owned);
3280 let ret = ObjOps::untweak_ptr(self.inner);
3281 self.inner = core::ptr::null_mut();
3285 /// The advertised channel features
3287 pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::ln::features::ChannelFeatures {
3288 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
3289 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 }
3291 /// The advertised channel features
3293 pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::ln::features::ChannelFeatures) {
3294 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
3296 /// The genesis hash of the blockchain where the channel is to be opened
3298 pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &UnsignedChannelAnnouncement) -> *const [u8; 32] {
3299 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
3300 inner_val.as_inner()
3302 /// The genesis hash of the blockchain where the channel is to be opened
3304 pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
3305 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3307 /// The short channel ID
3309 pub extern "C" fn UnsignedChannelAnnouncement_get_short_channel_id(this_ptr: &UnsignedChannelAnnouncement) -> u64 {
3310 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
3313 /// The short channel ID
3315 pub extern "C" fn UnsignedChannelAnnouncement_set_short_channel_id(this_ptr: &mut UnsignedChannelAnnouncement, mut val: u64) {
3316 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
3318 /// One of the two node_ids which are endpoints of this channel
3320 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3321 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_1;
3322 crate::c_types::PublicKey::from_rust(&inner_val)
3324 /// One of the two node_ids which are endpoints of this channel
3326 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3327 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_1 = val.into_rust();
3329 /// The other of the two node_ids which are endpoints of this channel
3331 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3332 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_2;
3333 crate::c_types::PublicKey::from_rust(&inner_val)
3335 /// The other of the two node_ids which are endpoints of this channel
3337 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3338 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_2 = val.into_rust();
3340 /// The funding key for the first node
3342 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3343 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_1;
3344 crate::c_types::PublicKey::from_rust(&inner_val)
3346 /// The funding key for the first node
3348 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3349 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_1 = val.into_rust();
3351 /// The funding key for the second node
3353 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3354 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_2;
3355 crate::c_types::PublicKey::from_rust(&inner_val)
3357 /// The funding key for the second node
3359 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3360 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_2 = val.into_rust();
3362 impl Clone for UnsignedChannelAnnouncement {
3363 fn clone(&self) -> Self {
3365 inner: if <*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
3366 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3372 /// Used only if an object of this type is returned as a trait impl by a method
3373 pub(crate) extern "C" fn UnsignedChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3374 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelAnnouncement)).clone() })) as *mut c_void
3377 /// Creates a copy of the UnsignedChannelAnnouncement
3378 pub extern "C" fn UnsignedChannelAnnouncement_clone(orig: &UnsignedChannelAnnouncement) -> UnsignedChannelAnnouncement {
3382 use lightning::ln::msgs::ChannelAnnouncement as nativeChannelAnnouncementImport;
3383 pub(crate) type nativeChannelAnnouncement = nativeChannelAnnouncementImport;
3385 /// A channel_announcement message to be sent or received from a peer
3388 pub struct ChannelAnnouncement {
3389 /// A pointer to the opaque Rust object.
3391 /// Nearly everywhere, inner must be non-null, however in places where
3392 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3393 pub inner: *mut nativeChannelAnnouncement,
3394 /// Indicates that this is the only struct which contains the same pointer.
3396 /// Rust functions which take ownership of an object provided via an argument require
3397 /// this to be true and invalidate the object pointed to by inner.
3401 impl Drop for ChannelAnnouncement {
3402 fn drop(&mut self) {
3403 if self.is_owned && !<*mut nativeChannelAnnouncement>::is_null(self.inner) {
3404 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3408 /// Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL.
3410 pub extern "C" fn ChannelAnnouncement_free(this_obj: ChannelAnnouncement) { }
3412 /// Used only if an object of this type is returned as a trait impl by a method
3413 pub(crate) extern "C" fn ChannelAnnouncement_free_void(this_ptr: *mut c_void) {
3414 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelAnnouncement); }
3417 impl ChannelAnnouncement {
3418 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelAnnouncement {
3419 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3421 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelAnnouncement {
3422 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3424 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3425 pub(crate) fn take_inner(mut self) -> *mut nativeChannelAnnouncement {
3426 assert!(self.is_owned);
3427 let ret = ObjOps::untweak_ptr(self.inner);
3428 self.inner = core::ptr::null_mut();
3432 /// Authentication of the announcement by the first public node
3434 pub extern "C" fn ChannelAnnouncement_get_node_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3435 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_1;
3436 crate::c_types::Signature::from_rust(&inner_val)
3438 /// Authentication of the announcement by the first public node
3440 pub extern "C" fn ChannelAnnouncement_set_node_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3441 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_1 = val.into_rust();
3443 /// Authentication of the announcement by the second public node
3445 pub extern "C" fn ChannelAnnouncement_get_node_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3446 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_2;
3447 crate::c_types::Signature::from_rust(&inner_val)
3449 /// Authentication of the announcement by the second public node
3451 pub extern "C" fn ChannelAnnouncement_set_node_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3452 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_2 = val.into_rust();
3454 /// Proof of funding UTXO ownership by the first public node
3456 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3457 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_1;
3458 crate::c_types::Signature::from_rust(&inner_val)
3460 /// Proof of funding UTXO ownership by the first public node
3462 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3463 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_1 = val.into_rust();
3465 /// Proof of funding UTXO ownership by the second public node
3467 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3468 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_2;
3469 crate::c_types::Signature::from_rust(&inner_val)
3471 /// Proof of funding UTXO ownership by the second public node
3473 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3474 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_2 = val.into_rust();
3476 /// The actual announcement
3478 pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncement) -> crate::lightning::ln::msgs::UnsignedChannelAnnouncement {
3479 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
3480 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 }
3482 /// The actual announcement
3484 pub extern "C" fn ChannelAnnouncement_set_contents(this_ptr: &mut ChannelAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) {
3485 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
3487 /// Constructs a new ChannelAnnouncement given each field
3490 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 {
3491 ChannelAnnouncement { inner: ObjOps::heap_alloc(nativeChannelAnnouncement {
3492 node_signature_1: node_signature_1_arg.into_rust(),
3493 node_signature_2: node_signature_2_arg.into_rust(),
3494 bitcoin_signature_1: bitcoin_signature_1_arg.into_rust(),
3495 bitcoin_signature_2: bitcoin_signature_2_arg.into_rust(),
3496 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
3497 }), is_owned: true }
3499 impl Clone for ChannelAnnouncement {
3500 fn clone(&self) -> Self {
3502 inner: if <*mut nativeChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
3503 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3509 /// Used only if an object of this type is returned as a trait impl by a method
3510 pub(crate) extern "C" fn ChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3511 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelAnnouncement)).clone() })) as *mut c_void
3514 /// Creates a copy of the ChannelAnnouncement
3515 pub extern "C" fn ChannelAnnouncement_clone(orig: &ChannelAnnouncement) -> ChannelAnnouncement {
3519 use lightning::ln::msgs::UnsignedChannelUpdate as nativeUnsignedChannelUpdateImport;
3520 pub(crate) type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport;
3522 /// The unsigned part of a channel_update
3525 pub struct UnsignedChannelUpdate {
3526 /// A pointer to the opaque Rust object.
3528 /// Nearly everywhere, inner must be non-null, however in places where
3529 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3530 pub inner: *mut nativeUnsignedChannelUpdate,
3531 /// Indicates that this is the only struct which contains the same pointer.
3533 /// Rust functions which take ownership of an object provided via an argument require
3534 /// this to be true and invalidate the object pointed to by inner.
3538 impl Drop for UnsignedChannelUpdate {
3539 fn drop(&mut self) {
3540 if self.is_owned && !<*mut nativeUnsignedChannelUpdate>::is_null(self.inner) {
3541 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3545 /// Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL.
3547 pub extern "C" fn UnsignedChannelUpdate_free(this_obj: UnsignedChannelUpdate) { }
3549 /// Used only if an object of this type is returned as a trait impl by a method
3550 pub(crate) extern "C" fn UnsignedChannelUpdate_free_void(this_ptr: *mut c_void) {
3551 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelUpdate); }
3554 impl UnsignedChannelUpdate {
3555 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelUpdate {
3556 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3558 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelUpdate {
3559 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3561 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3562 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelUpdate {
3563 assert!(self.is_owned);
3564 let ret = ObjOps::untweak_ptr(self.inner);
3565 self.inner = core::ptr::null_mut();
3569 /// The genesis hash of the blockchain where the channel is to be opened
3571 pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChannelUpdate) -> *const [u8; 32] {
3572 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
3573 inner_val.as_inner()
3575 /// The genesis hash of the blockchain where the channel is to be opened
3577 pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::ThirtyTwoBytes) {
3578 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3580 /// The short channel ID
3582 pub extern "C" fn UnsignedChannelUpdate_get_short_channel_id(this_ptr: &UnsignedChannelUpdate) -> u64 {
3583 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
3586 /// The short channel ID
3588 pub extern "C" fn UnsignedChannelUpdate_set_short_channel_id(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
3589 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
3591 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
3593 pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannelUpdate) -> u32 {
3594 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
3597 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
3599 pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3600 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
3604 pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 {
3605 let mut inner_val = &mut this_ptr.get_native_mut_ref().flags;
3610 pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) {
3611 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.flags = val;
3613 /// The number of blocks such that if:
3614 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
3615 /// then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines
3616 /// the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a
3617 /// cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10,
3618 /// then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before
3619 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
3620 /// constructing the route.
3622 pub extern "C" fn UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr: &UnsignedChannelUpdate) -> u16 {
3623 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
3626 /// The number of blocks such that if:
3627 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
3628 /// then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines
3629 /// the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a
3630 /// cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10,
3631 /// then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before
3632 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
3633 /// constructing the route.
3635 pub extern "C" fn UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr: &mut UnsignedChannelUpdate, mut val: u16) {
3636 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
3638 /// The minimum HTLC size incoming to sender, in milli-satoshi
3640 pub extern "C" fn UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
3641 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
3644 /// The minimum HTLC size incoming to sender, in milli-satoshi
3646 pub extern "C" fn UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
3647 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
3649 /// The base HTLC fee charged by sender, in milli-satoshi
3651 pub extern "C" fn UnsignedChannelUpdate_get_fee_base_msat(this_ptr: &UnsignedChannelUpdate) -> u32 {
3652 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat;
3655 /// The base HTLC fee charged by sender, in milli-satoshi
3657 pub extern "C" fn UnsignedChannelUpdate_set_fee_base_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3658 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val;
3660 /// The amount to fee multiplier, in micro-satoshi
3662 pub extern "C" fn UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr: &UnsignedChannelUpdate) -> u32 {
3663 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths;
3666 /// The amount to fee multiplier, in micro-satoshi
3668 pub extern "C" fn UnsignedChannelUpdate_set_fee_proportional_millionths(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3669 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val;
3671 impl Clone for UnsignedChannelUpdate {
3672 fn clone(&self) -> Self {
3674 inner: if <*mut nativeUnsignedChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
3675 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3681 /// Used only if an object of this type is returned as a trait impl by a method
3682 pub(crate) extern "C" fn UnsignedChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
3683 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelUpdate)).clone() })) as *mut c_void
3686 /// Creates a copy of the UnsignedChannelUpdate
3687 pub extern "C" fn UnsignedChannelUpdate_clone(orig: &UnsignedChannelUpdate) -> UnsignedChannelUpdate {
3691 use lightning::ln::msgs::ChannelUpdate as nativeChannelUpdateImport;
3692 pub(crate) type nativeChannelUpdate = nativeChannelUpdateImport;
3694 /// A channel_update message to be sent or received from a peer
3697 pub struct ChannelUpdate {
3698 /// A pointer to the opaque Rust object.
3700 /// Nearly everywhere, inner must be non-null, however in places where
3701 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3702 pub inner: *mut nativeChannelUpdate,
3703 /// Indicates that this is the only struct which contains the same pointer.
3705 /// Rust functions which take ownership of an object provided via an argument require
3706 /// this to be true and invalidate the object pointed to by inner.
3710 impl Drop for ChannelUpdate {
3711 fn drop(&mut self) {
3712 if self.is_owned && !<*mut nativeChannelUpdate>::is_null(self.inner) {
3713 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3717 /// Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL.
3719 pub extern "C" fn ChannelUpdate_free(this_obj: ChannelUpdate) { }
3721 /// Used only if an object of this type is returned as a trait impl by a method
3722 pub(crate) extern "C" fn ChannelUpdate_free_void(this_ptr: *mut c_void) {
3723 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelUpdate); }
3726 impl ChannelUpdate {
3727 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelUpdate {
3728 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3730 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelUpdate {
3731 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3733 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3734 pub(crate) fn take_inner(mut self) -> *mut nativeChannelUpdate {
3735 assert!(self.is_owned);
3736 let ret = ObjOps::untweak_ptr(self.inner);
3737 self.inner = core::ptr::null_mut();
3741 /// A signature of the channel update
3743 pub extern "C" fn ChannelUpdate_get_signature(this_ptr: &ChannelUpdate) -> crate::c_types::Signature {
3744 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
3745 crate::c_types::Signature::from_rust(&inner_val)
3747 /// A signature of the channel update
3749 pub extern "C" fn ChannelUpdate_set_signature(this_ptr: &mut ChannelUpdate, mut val: crate::c_types::Signature) {
3750 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
3752 /// The actual channel update
3754 pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate::lightning::ln::msgs::UnsignedChannelUpdate {
3755 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
3756 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 }
3758 /// The actual channel update
3760 pub extern "C" fn ChannelUpdate_set_contents(this_ptr: &mut ChannelUpdate, mut val: crate::lightning::ln::msgs::UnsignedChannelUpdate) {
3761 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
3763 /// Constructs a new ChannelUpdate given each field
3766 pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> ChannelUpdate {
3767 ChannelUpdate { inner: ObjOps::heap_alloc(nativeChannelUpdate {
3768 signature: signature_arg.into_rust(),
3769 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
3770 }), is_owned: true }
3772 impl Clone for ChannelUpdate {
3773 fn clone(&self) -> Self {
3775 inner: if <*mut nativeChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
3776 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3782 /// Used only if an object of this type is returned as a trait impl by a method
3783 pub(crate) extern "C" fn ChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
3784 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelUpdate)).clone() })) as *mut c_void
3787 /// Creates a copy of the ChannelUpdate
3788 pub extern "C" fn ChannelUpdate_clone(orig: &ChannelUpdate) -> ChannelUpdate {
3792 use lightning::ln::msgs::QueryChannelRange as nativeQueryChannelRangeImport;
3793 pub(crate) type nativeQueryChannelRange = nativeQueryChannelRangeImport;
3795 /// A query_channel_range message is used to query a peer for channel
3796 /// UTXOs in a range of blocks. The recipient of a query makes a best
3797 /// effort to reply to the query using one or more reply_channel_range
3801 pub struct QueryChannelRange {
3802 /// A pointer to the opaque Rust object.
3804 /// Nearly everywhere, inner must be non-null, however in places where
3805 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3806 pub inner: *mut nativeQueryChannelRange,
3807 /// Indicates that this is the only struct which contains the same pointer.
3809 /// Rust functions which take ownership of an object provided via an argument require
3810 /// this to be true and invalidate the object pointed to by inner.
3814 impl Drop for QueryChannelRange {
3815 fn drop(&mut self) {
3816 if self.is_owned && !<*mut nativeQueryChannelRange>::is_null(self.inner) {
3817 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3821 /// Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL.
3823 pub extern "C" fn QueryChannelRange_free(this_obj: QueryChannelRange) { }
3825 /// Used only if an object of this type is returned as a trait impl by a method
3826 pub(crate) extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) {
3827 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryChannelRange); }
3830 impl QueryChannelRange {
3831 pub(crate) fn get_native_ref(&self) -> &'static nativeQueryChannelRange {
3832 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3834 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryChannelRange {
3835 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3837 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3838 pub(crate) fn take_inner(mut self) -> *mut nativeQueryChannelRange {
3839 assert!(self.is_owned);
3840 let ret = ObjOps::untweak_ptr(self.inner);
3841 self.inner = core::ptr::null_mut();
3845 /// The genesis hash of the blockchain being queried
3847 pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *const [u8; 32] {
3848 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
3849 inner_val.as_inner()
3851 /// The genesis hash of the blockchain being queried
3853 pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
3854 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3856 /// The height of the first block for the channel UTXOs being queried
3858 pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 {
3859 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
3862 /// The height of the first block for the channel UTXOs being queried
3864 pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChannelRange, mut val: u32) {
3865 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
3867 /// The number of blocks to include in the query results
3869 pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 {
3870 let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
3873 /// The number of blocks to include in the query results
3875 pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryChannelRange, mut val: u32) {
3876 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
3878 /// Constructs a new QueryChannelRange given each field
3881 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 {
3882 QueryChannelRange { inner: ObjOps::heap_alloc(nativeQueryChannelRange {
3883 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3884 first_blocknum: first_blocknum_arg,
3885 number_of_blocks: number_of_blocks_arg,
3886 }), is_owned: true }
3888 impl Clone for QueryChannelRange {
3889 fn clone(&self) -> Self {
3891 inner: if <*mut nativeQueryChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
3892 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3898 /// Used only if an object of this type is returned as a trait impl by a method
3899 pub(crate) extern "C" fn QueryChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
3900 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryChannelRange)).clone() })) as *mut c_void
3903 /// Creates a copy of the QueryChannelRange
3904 pub extern "C" fn QueryChannelRange_clone(orig: &QueryChannelRange) -> QueryChannelRange {
3908 use lightning::ln::msgs::ReplyChannelRange as nativeReplyChannelRangeImport;
3909 pub(crate) type nativeReplyChannelRange = nativeReplyChannelRangeImport;
3911 /// A reply_channel_range message is a reply to a query_channel_range
3912 /// message. Multiple reply_channel_range messages can be sent in reply
3913 /// to a single query_channel_range message. The query recipient makes a
3914 /// best effort to respond based on their local network view which may
3915 /// not be a perfect view of the network. The short_channel_ids in the
3916 /// reply are encoded. We only support encoding_type=0 uncompressed
3917 /// serialization and do not support encoding_type=1 zlib serialization.
3920 pub struct ReplyChannelRange {
3921 /// A pointer to the opaque Rust object.
3923 /// Nearly everywhere, inner must be non-null, however in places where
3924 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3925 pub inner: *mut nativeReplyChannelRange,
3926 /// Indicates that this is the only struct which contains the same pointer.
3928 /// Rust functions which take ownership of an object provided via an argument require
3929 /// this to be true and invalidate the object pointed to by inner.
3933 impl Drop for ReplyChannelRange {
3934 fn drop(&mut self) {
3935 if self.is_owned && !<*mut nativeReplyChannelRange>::is_null(self.inner) {
3936 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3940 /// Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL.
3942 pub extern "C" fn ReplyChannelRange_free(this_obj: ReplyChannelRange) { }
3944 /// Used only if an object of this type is returned as a trait impl by a method
3945 pub(crate) extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) {
3946 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyChannelRange); }
3949 impl ReplyChannelRange {
3950 pub(crate) fn get_native_ref(&self) -> &'static nativeReplyChannelRange {
3951 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3953 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyChannelRange {
3954 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3956 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3957 pub(crate) fn take_inner(mut self) -> *mut nativeReplyChannelRange {
3958 assert!(self.is_owned);
3959 let ret = ObjOps::untweak_ptr(self.inner);
3960 self.inner = core::ptr::null_mut();
3964 /// The genesis hash of the blockchain being queried
3966 pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *const [u8; 32] {
3967 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
3968 inner_val.as_inner()
3970 /// The genesis hash of the blockchain being queried
3972 pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
3973 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3975 /// The height of the first block in the range of the reply
3977 pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 {
3978 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
3981 /// The height of the first block in the range of the reply
3983 pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChannelRange, mut val: u32) {
3984 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
3986 /// The number of blocks included in the range of the reply
3988 pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 {
3989 let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
3992 /// The number of blocks included in the range of the reply
3994 pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyChannelRange, mut val: u32) {
3995 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
3997 /// True when this is the final reply for a query
3999 pub extern "C" fn ReplyChannelRange_get_sync_complete(this_ptr: &ReplyChannelRange) -> bool {
4000 let mut inner_val = &mut this_ptr.get_native_mut_ref().sync_complete;
4003 /// True when this is the final reply for a query
4005 pub extern "C" fn ReplyChannelRange_set_sync_complete(this_ptr: &mut ReplyChannelRange, mut val: bool) {
4006 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sync_complete = val;
4008 /// The short_channel_ids in the channel range
4010 pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::derived::CVec_u64Z) {
4011 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
4012 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
4014 /// Constructs a new ReplyChannelRange given each field
4017 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 {
4018 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 }); };
4019 ReplyChannelRange { inner: ObjOps::heap_alloc(nativeReplyChannelRange {
4020 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4021 first_blocknum: first_blocknum_arg,
4022 number_of_blocks: number_of_blocks_arg,
4023 sync_complete: sync_complete_arg,
4024 short_channel_ids: local_short_channel_ids_arg,
4025 }), is_owned: true }
4027 impl Clone for ReplyChannelRange {
4028 fn clone(&self) -> Self {
4030 inner: if <*mut nativeReplyChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
4031 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4037 /// Used only if an object of this type is returned as a trait impl by a method
4038 pub(crate) extern "C" fn ReplyChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
4039 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyChannelRange)).clone() })) as *mut c_void
4042 /// Creates a copy of the ReplyChannelRange
4043 pub extern "C" fn ReplyChannelRange_clone(orig: &ReplyChannelRange) -> ReplyChannelRange {
4047 use lightning::ln::msgs::QueryShortChannelIds as nativeQueryShortChannelIdsImport;
4048 pub(crate) type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport;
4050 /// A query_short_channel_ids message is used to query a peer for
4051 /// routing gossip messages related to one or more short_channel_ids.
4052 /// The query recipient will reply with the latest, if available,
4053 /// channel_announcement, channel_update and node_announcement messages
4054 /// it maintains for the requested short_channel_ids followed by a
4055 /// reply_short_channel_ids_end message. The short_channel_ids sent in
4056 /// this query are encoded. We only support encoding_type=0 uncompressed
4057 /// serialization and do not support encoding_type=1 zlib serialization.
4060 pub struct QueryShortChannelIds {
4061 /// A pointer to the opaque Rust object.
4063 /// Nearly everywhere, inner must be non-null, however in places where
4064 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4065 pub inner: *mut nativeQueryShortChannelIds,
4066 /// Indicates that this is the only struct which contains the same pointer.
4068 /// Rust functions which take ownership of an object provided via an argument require
4069 /// this to be true and invalidate the object pointed to by inner.
4073 impl Drop for QueryShortChannelIds {
4074 fn drop(&mut self) {
4075 if self.is_owned && !<*mut nativeQueryShortChannelIds>::is_null(self.inner) {
4076 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4080 /// Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL.
4082 pub extern "C" fn QueryShortChannelIds_free(this_obj: QueryShortChannelIds) { }
4084 /// Used only if an object of this type is returned as a trait impl by a method
4085 pub(crate) extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) {
4086 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryShortChannelIds); }
4089 impl QueryShortChannelIds {
4090 pub(crate) fn get_native_ref(&self) -> &'static nativeQueryShortChannelIds {
4091 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4093 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryShortChannelIds {
4094 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4096 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4097 pub(crate) fn take_inner(mut self) -> *mut nativeQueryShortChannelIds {
4098 assert!(self.is_owned);
4099 let ret = ObjOps::untweak_ptr(self.inner);
4100 self.inner = core::ptr::null_mut();
4104 /// The genesis hash of the blockchain being queried
4106 pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *const [u8; 32] {
4107 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4108 inner_val.as_inner()
4110 /// The genesis hash of the blockchain being queried
4112 pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::ThirtyTwoBytes) {
4113 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4115 /// The short_channel_ids that are being queried
4117 pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::derived::CVec_u64Z) {
4118 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
4119 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
4121 /// Constructs a new QueryShortChannelIds given each field
4124 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 {
4125 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 }); };
4126 QueryShortChannelIds { inner: ObjOps::heap_alloc(nativeQueryShortChannelIds {
4127 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4128 short_channel_ids: local_short_channel_ids_arg,
4129 }), is_owned: true }
4131 impl Clone for QueryShortChannelIds {
4132 fn clone(&self) -> Self {
4134 inner: if <*mut nativeQueryShortChannelIds>::is_null(self.inner) { core::ptr::null_mut() } else {
4135 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4141 /// Used only if an object of this type is returned as a trait impl by a method
4142 pub(crate) extern "C" fn QueryShortChannelIds_clone_void(this_ptr: *const c_void) -> *mut c_void {
4143 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryShortChannelIds)).clone() })) as *mut c_void
4146 /// Creates a copy of the QueryShortChannelIds
4147 pub extern "C" fn QueryShortChannelIds_clone(orig: &QueryShortChannelIds) -> QueryShortChannelIds {
4151 use lightning::ln::msgs::ReplyShortChannelIdsEnd as nativeReplyShortChannelIdsEndImport;
4152 pub(crate) type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport;
4154 /// A reply_short_channel_ids_end message is sent as a reply to a
4155 /// query_short_channel_ids message. The query recipient makes a best
4156 /// effort to respond based on their local network view which may not be
4157 /// a perfect view of the network.
4160 pub struct ReplyShortChannelIdsEnd {
4161 /// A pointer to the opaque Rust object.
4163 /// Nearly everywhere, inner must be non-null, however in places where
4164 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4165 pub inner: *mut nativeReplyShortChannelIdsEnd,
4166 /// Indicates that this is the only struct which contains the same pointer.
4168 /// Rust functions which take ownership of an object provided via an argument require
4169 /// this to be true and invalidate the object pointed to by inner.
4173 impl Drop for ReplyShortChannelIdsEnd {
4174 fn drop(&mut self) {
4175 if self.is_owned && !<*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) {
4176 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4180 /// Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL.
4182 pub extern "C" fn ReplyShortChannelIdsEnd_free(this_obj: ReplyShortChannelIdsEnd) { }
4184 /// Used only if an object of this type is returned as a trait impl by a method
4185 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) {
4186 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyShortChannelIdsEnd); }
4189 impl ReplyShortChannelIdsEnd {
4190 pub(crate) fn get_native_ref(&self) -> &'static nativeReplyShortChannelIdsEnd {
4191 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4193 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyShortChannelIdsEnd {
4194 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4196 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4197 pub(crate) fn take_inner(mut self) -> *mut nativeReplyShortChannelIdsEnd {
4198 assert!(self.is_owned);
4199 let ret = ObjOps::untweak_ptr(self.inner);
4200 self.inner = core::ptr::null_mut();
4204 /// The genesis hash of the blockchain that was queried
4206 pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *const [u8; 32] {
4207 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4208 inner_val.as_inner()
4210 /// The genesis hash of the blockchain that was queried
4212 pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) {
4213 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4215 /// Indicates if the query recipient maintains up-to-date channel
4216 /// information for the chain_hash
4218 pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool {
4219 let mut inner_val = &mut this_ptr.get_native_mut_ref().full_information;
4222 /// Indicates if the query recipient maintains up-to-date channel
4223 /// information for the chain_hash
4225 pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: bool) {
4226 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.full_information = val;
4228 /// Constructs a new ReplyShortChannelIdsEnd given each field
4231 pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd {
4232 ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(nativeReplyShortChannelIdsEnd {
4233 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4234 full_information: full_information_arg,
4235 }), is_owned: true }
4237 impl Clone for ReplyShortChannelIdsEnd {
4238 fn clone(&self) -> Self {
4240 inner: if <*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) { core::ptr::null_mut() } else {
4241 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4247 /// Used only if an object of this type is returned as a trait impl by a method
4248 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_void) -> *mut c_void {
4249 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyShortChannelIdsEnd)).clone() })) as *mut c_void
4252 /// Creates a copy of the ReplyShortChannelIdsEnd
4253 pub extern "C" fn ReplyShortChannelIdsEnd_clone(orig: &ReplyShortChannelIdsEnd) -> ReplyShortChannelIdsEnd {
4257 use lightning::ln::msgs::GossipTimestampFilter as nativeGossipTimestampFilterImport;
4258 pub(crate) type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport;
4260 /// A gossip_timestamp_filter message is used by a node to request
4261 /// gossip relay for messages in the requested time range when the
4262 /// gossip_queries feature has been negotiated.
4265 pub struct GossipTimestampFilter {
4266 /// A pointer to the opaque Rust object.
4268 /// Nearly everywhere, inner must be non-null, however in places where
4269 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4270 pub inner: *mut nativeGossipTimestampFilter,
4271 /// Indicates that this is the only struct which contains the same pointer.
4273 /// Rust functions which take ownership of an object provided via an argument require
4274 /// this to be true and invalidate the object pointed to by inner.
4278 impl Drop for GossipTimestampFilter {
4279 fn drop(&mut self) {
4280 if self.is_owned && !<*mut nativeGossipTimestampFilter>::is_null(self.inner) {
4281 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4285 /// Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL.
4287 pub extern "C" fn GossipTimestampFilter_free(this_obj: GossipTimestampFilter) { }
4289 /// Used only if an object of this type is returned as a trait impl by a method
4290 pub(crate) extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) {
4291 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeGossipTimestampFilter); }
4294 impl GossipTimestampFilter {
4295 pub(crate) fn get_native_ref(&self) -> &'static nativeGossipTimestampFilter {
4296 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4298 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeGossipTimestampFilter {
4299 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4301 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4302 pub(crate) fn take_inner(mut self) -> *mut nativeGossipTimestampFilter {
4303 assert!(self.is_owned);
4304 let ret = ObjOps::untweak_ptr(self.inner);
4305 self.inner = core::ptr::null_mut();
4309 /// The genesis hash of the blockchain for channel and node information
4311 pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *const [u8; 32] {
4312 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4313 inner_val.as_inner()
4315 /// The genesis hash of the blockchain for channel and node information
4317 pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) {
4318 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4320 /// The starting unix timestamp
4322 pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 {
4323 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_timestamp;
4326 /// The starting unix timestamp
4328 pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
4329 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_timestamp = val;
4331 /// The range of information in seconds
4333 pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 {
4334 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp_range;
4337 /// The range of information in seconds
4339 pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
4340 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp_range = val;
4342 /// Constructs a new GossipTimestampFilter given each field
4345 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 {
4346 GossipTimestampFilter { inner: ObjOps::heap_alloc(nativeGossipTimestampFilter {
4347 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4348 first_timestamp: first_timestamp_arg,
4349 timestamp_range: timestamp_range_arg,
4350 }), is_owned: true }
4352 impl Clone for GossipTimestampFilter {
4353 fn clone(&self) -> Self {
4355 inner: if <*mut nativeGossipTimestampFilter>::is_null(self.inner) { core::ptr::null_mut() } else {
4356 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4362 /// Used only if an object of this type is returned as a trait impl by a method
4363 pub(crate) extern "C" fn GossipTimestampFilter_clone_void(this_ptr: *const c_void) -> *mut c_void {
4364 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeGossipTimestampFilter)).clone() })) as *mut c_void
4367 /// Creates a copy of the GossipTimestampFilter
4368 pub extern "C" fn GossipTimestampFilter_clone(orig: &GossipTimestampFilter) -> GossipTimestampFilter {
4371 /// Used to put an error message in a LightningError
4375 pub enum ErrorAction {
4376 /// The peer took some action which made us think they were useless. Disconnect them.
4378 /// An error message which we should make an effort to send before we disconnect.
4380 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
4381 msg: crate::lightning::ln::msgs::ErrorMessage,
4383 /// The peer did something harmless that we weren't able to process, just log and ignore
4385 /// The peer did something harmless that we weren't able to meaningfully process.
4386 /// If the error is logged, log it at the given level.
4387 IgnoreAndLog(crate::lightning::util::logger::Level),
4388 /// The peer provided us with a gossip message which we'd already seen. In most cases this
4389 /// should be ignored, but it may result in the message being forwarded if it is a duplicate of
4390 /// our own channel announcements.
4391 IgnoreDuplicateGossip,
4392 /// The peer did something incorrect. Tell them.
4394 /// The message to send.
4395 msg: crate::lightning::ln::msgs::ErrorMessage,
4398 use lightning::ln::msgs::ErrorAction as nativeErrorAction;
4401 pub(crate) fn to_native(&self) -> nativeErrorAction {
4403 ErrorAction::DisconnectPeer {ref msg, } => {
4404 let mut msg_nonref = (*msg).clone();
4405 let mut local_msg_nonref = if msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg_nonref.take_inner()) } }) };
4406 nativeErrorAction::DisconnectPeer {
4407 msg: local_msg_nonref,
4410 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
4411 ErrorAction::IgnoreAndLog (ref a, ) => {
4412 let mut a_nonref = (*a).clone();
4413 nativeErrorAction::IgnoreAndLog (
4414 a_nonref.into_native(),
4417 ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
4418 ErrorAction::SendErrorMessage {ref msg, } => {
4419 let mut msg_nonref = (*msg).clone();
4420 nativeErrorAction::SendErrorMessage {
4421 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
4427 pub(crate) fn into_native(self) -> nativeErrorAction {
4429 ErrorAction::DisconnectPeer {mut msg, } => {
4430 let mut local_msg = if msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg.take_inner()) } }) };
4431 nativeErrorAction::DisconnectPeer {
4435 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
4436 ErrorAction::IgnoreAndLog (mut a, ) => {
4437 nativeErrorAction::IgnoreAndLog (
4441 ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
4442 ErrorAction::SendErrorMessage {mut msg, } => {
4443 nativeErrorAction::SendErrorMessage {
4444 msg: *unsafe { Box::from_raw(msg.take_inner()) },
4450 pub(crate) fn from_native(native: &nativeErrorAction) -> Self {
4452 nativeErrorAction::DisconnectPeer {ref msg, } => {
4453 let mut msg_nonref = (*msg).clone();
4454 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 };
4455 ErrorAction::DisconnectPeer {
4456 msg: local_msg_nonref,
4459 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
4460 nativeErrorAction::IgnoreAndLog (ref a, ) => {
4461 let mut a_nonref = (*a).clone();
4462 ErrorAction::IgnoreAndLog (
4463 crate::lightning::util::logger::Level::native_into(a_nonref),
4466 nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
4467 nativeErrorAction::SendErrorMessage {ref msg, } => {
4468 let mut msg_nonref = (*msg).clone();
4469 ErrorAction::SendErrorMessage {
4470 msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
4476 pub(crate) fn native_into(native: nativeErrorAction) -> Self {
4478 nativeErrorAction::DisconnectPeer {mut msg, } => {
4479 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 };
4480 ErrorAction::DisconnectPeer {
4484 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
4485 nativeErrorAction::IgnoreAndLog (mut a, ) => {
4486 ErrorAction::IgnoreAndLog (
4487 crate::lightning::util::logger::Level::native_into(a),
4490 nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
4491 nativeErrorAction::SendErrorMessage {mut msg, } => {
4492 ErrorAction::SendErrorMessage {
4493 msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
4499 /// Frees any resources used by the ErrorAction
4501 pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { }
4502 /// Creates a copy of the ErrorAction
4504 pub extern "C" fn ErrorAction_clone(orig: &ErrorAction) -> ErrorAction {
4508 /// Utility method to constructs a new DisconnectPeer-variant ErrorAction
4509 pub extern "C" fn ErrorAction_disconnect_peer(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
4510 ErrorAction::DisconnectPeer {
4515 /// Utility method to constructs a new IgnoreError-variant ErrorAction
4516 pub extern "C" fn ErrorAction_ignore_error() -> ErrorAction {
4517 ErrorAction::IgnoreError}
4519 /// Utility method to constructs a new IgnoreAndLog-variant ErrorAction
4520 pub extern "C" fn ErrorAction_ignore_and_log(a: crate::lightning::util::logger::Level) -> ErrorAction {
4521 ErrorAction::IgnoreAndLog(a, )
4524 /// Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction
4525 pub extern "C" fn ErrorAction_ignore_duplicate_gossip() -> ErrorAction {
4526 ErrorAction::IgnoreDuplicateGossip}
4528 /// Utility method to constructs a new SendErrorMessage-variant ErrorAction
4529 pub extern "C" fn ErrorAction_send_error_message(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
4530 ErrorAction::SendErrorMessage {
4535 use lightning::ln::msgs::LightningError as nativeLightningErrorImport;
4536 pub(crate) type nativeLightningError = nativeLightningErrorImport;
4538 /// An Err type for failure to process messages.
4541 pub struct LightningError {
4542 /// A pointer to the opaque Rust object.
4544 /// Nearly everywhere, inner must be non-null, however in places where
4545 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4546 pub inner: *mut nativeLightningError,
4547 /// Indicates that this is the only struct which contains the same pointer.
4549 /// Rust functions which take ownership of an object provided via an argument require
4550 /// this to be true and invalidate the object pointed to by inner.
4554 impl Drop for LightningError {
4555 fn drop(&mut self) {
4556 if self.is_owned && !<*mut nativeLightningError>::is_null(self.inner) {
4557 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4561 /// Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL.
4563 pub extern "C" fn LightningError_free(this_obj: LightningError) { }
4565 /// Used only if an object of this type is returned as a trait impl by a method
4566 pub(crate) extern "C" fn LightningError_free_void(this_ptr: *mut c_void) {
4567 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeLightningError); }
4570 impl LightningError {
4571 pub(crate) fn get_native_ref(&self) -> &'static nativeLightningError {
4572 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4574 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLightningError {
4575 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4577 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4578 pub(crate) fn take_inner(mut self) -> *mut nativeLightningError {
4579 assert!(self.is_owned);
4580 let ret = ObjOps::untweak_ptr(self.inner);
4581 self.inner = core::ptr::null_mut();
4585 /// A human-readable message describing the error
4587 pub extern "C" fn LightningError_get_err(this_ptr: &LightningError) -> crate::c_types::Str {
4588 let mut inner_val = &mut this_ptr.get_native_mut_ref().err;
4589 inner_val.as_str().into()
4591 /// A human-readable message describing the error
4593 pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: crate::c_types::Str) {
4594 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.err = val.into_string();
4596 /// The action which should be taken against the offending peer.
4598 pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate::lightning::ln::msgs::ErrorAction {
4599 let mut inner_val = &mut this_ptr.get_native_mut_ref().action;
4600 crate::lightning::ln::msgs::ErrorAction::from_native(inner_val)
4602 /// The action which should be taken against the offending peer.
4604 pub extern "C" fn LightningError_set_action(this_ptr: &mut LightningError, mut val: crate::lightning::ln::msgs::ErrorAction) {
4605 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.action = val.into_native();
4607 /// Constructs a new LightningError given each field
4610 pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::Str, mut action_arg: crate::lightning::ln::msgs::ErrorAction) -> LightningError {
4611 LightningError { inner: ObjOps::heap_alloc(nativeLightningError {
4612 err: err_arg.into_string(),
4613 action: action_arg.into_native(),
4614 }), is_owned: true }
4616 impl Clone for LightningError {
4617 fn clone(&self) -> Self {
4619 inner: if <*mut nativeLightningError>::is_null(self.inner) { core::ptr::null_mut() } else {
4620 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4626 /// Used only if an object of this type is returned as a trait impl by a method
4627 pub(crate) extern "C" fn LightningError_clone_void(this_ptr: *const c_void) -> *mut c_void {
4628 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeLightningError)).clone() })) as *mut c_void
4631 /// Creates a copy of the LightningError
4632 pub extern "C" fn LightningError_clone(orig: &LightningError) -> LightningError {
4636 use lightning::ln::msgs::CommitmentUpdate as nativeCommitmentUpdateImport;
4637 pub(crate) type nativeCommitmentUpdate = nativeCommitmentUpdateImport;
4639 /// Struct used to return values from revoke_and_ack messages, containing a bunch of commitment
4640 /// transaction updates if they were pending.
4643 pub struct CommitmentUpdate {
4644 /// A pointer to the opaque Rust object.
4646 /// Nearly everywhere, inner must be non-null, however in places where
4647 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4648 pub inner: *mut nativeCommitmentUpdate,
4649 /// Indicates that this is the only struct which contains the same pointer.
4651 /// Rust functions which take ownership of an object provided via an argument require
4652 /// this to be true and invalidate the object pointed to by inner.
4656 impl Drop for CommitmentUpdate {
4657 fn drop(&mut self) {
4658 if self.is_owned && !<*mut nativeCommitmentUpdate>::is_null(self.inner) {
4659 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4663 /// Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL.
4665 pub extern "C" fn CommitmentUpdate_free(this_obj: CommitmentUpdate) { }
4667 /// Used only if an object of this type is returned as a trait impl by a method
4668 pub(crate) extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) {
4669 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentUpdate); }
4672 impl CommitmentUpdate {
4673 pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentUpdate {
4674 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4676 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentUpdate {
4677 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4679 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4680 pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentUpdate {
4681 assert!(self.is_owned);
4682 let ret = ObjOps::untweak_ptr(self.inner);
4683 self.inner = core::ptr::null_mut();
4687 /// update_add_htlc messages which should be sent
4689 pub extern "C" fn CommitmentUpdate_get_update_add_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateAddHTLCZ {
4690 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_add_htlcs;
4691 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 } }); };
4692 local_inner_val.into()
4694 /// update_add_htlc messages which should be sent
4696 pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) {
4697 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4698 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_add_htlcs = local_val;
4700 /// update_fulfill_htlc messages which should be sent
4702 pub extern "C" fn CommitmentUpdate_get_update_fulfill_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFulfillHTLCZ {
4703 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fulfill_htlcs;
4704 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 } }); };
4705 local_inner_val.into()
4707 /// update_fulfill_htlc messages which should be sent
4709 pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) {
4710 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4711 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fulfill_htlcs = local_val;
4713 /// update_fail_htlc messages which should be sent
4715 pub extern "C" fn CommitmentUpdate_get_update_fail_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailHTLCZ {
4716 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_htlcs;
4717 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 } }); };
4718 local_inner_val.into()
4720 /// update_fail_htlc messages which should be sent
4722 pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) {
4723 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4724 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_htlcs = local_val;
4726 /// update_fail_malformed_htlc messages which should be sent
4728 pub extern "C" fn CommitmentUpdate_get_update_fail_malformed_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ {
4729 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_malformed_htlcs;
4730 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 } }); };
4731 local_inner_val.into()
4733 /// update_fail_malformed_htlc messages which should be sent
4735 pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) {
4736 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4737 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_malformed_htlcs = local_val;
4739 /// An update_fee message which should be sent
4741 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
4743 pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::UpdateFee {
4744 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fee;
4745 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 };
4748 /// An update_fee message which should be sent
4750 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
4752 pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::UpdateFee) {
4753 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
4754 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fee = local_val;
4756 /// Finally, the commitment_signed message which should be sent
4758 pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::CommitmentSigned {
4759 let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_signed;
4760 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 }
4762 /// Finally, the commitment_signed message which should be sent
4764 pub extern "C" fn CommitmentUpdate_set_commitment_signed(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::CommitmentSigned) {
4765 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_signed = *unsafe { Box::from_raw(val.take_inner()) };
4767 /// Constructs a new CommitmentUpdate given each field
4770 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 {
4771 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()) } }); };
4772 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()) } }); };
4773 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()) } }); };
4774 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()) } }); };
4775 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()) } }) };
4776 CommitmentUpdate { inner: ObjOps::heap_alloc(nativeCommitmentUpdate {
4777 update_add_htlcs: local_update_add_htlcs_arg,
4778 update_fulfill_htlcs: local_update_fulfill_htlcs_arg,
4779 update_fail_htlcs: local_update_fail_htlcs_arg,
4780 update_fail_malformed_htlcs: local_update_fail_malformed_htlcs_arg,
4781 update_fee: local_update_fee_arg,
4782 commitment_signed: *unsafe { Box::from_raw(commitment_signed_arg.take_inner()) },
4783 }), is_owned: true }
4785 impl Clone for CommitmentUpdate {
4786 fn clone(&self) -> Self {
4788 inner: if <*mut nativeCommitmentUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
4789 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4795 /// Used only if an object of this type is returned as a trait impl by a method
4796 pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
4797 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentUpdate)).clone() })) as *mut c_void
4800 /// Creates a copy of the CommitmentUpdate
4801 pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentUpdate {
4804 /// A trait to describe an object which can receive channel messages.
4806 /// Messages MAY be called in parallel when they originate from different their_node_ids, however
4807 /// they MUST NOT be called in parallel when the two calls have the same their_node_id.
4809 pub struct ChannelMessageHandler {
4810 /// An opaque pointer which is passed to your function implementations as an argument.
4811 /// This has no meaning in the LDK, and can be NULL or any other value.
4812 pub this_arg: *mut c_void,
4813 /// Handle an incoming open_channel message from the given peer.
4814 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),
4815 /// Handle an incoming accept_channel message from the given peer.
4816 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),
4817 /// Handle an incoming funding_created message from the given peer.
4818 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),
4819 /// Handle an incoming funding_signed message from the given peer.
4820 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),
4821 /// Handle an incoming funding_locked message from the given peer.
4822 pub handle_funding_locked: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::FundingLocked),
4823 /// Handle an incoming shutdown message from the given peer.
4824 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),
4825 /// Handle an incoming closing_signed message from the given peer.
4826 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),
4827 /// Handle an incoming update_add_htlc message from the given peer.
4828 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),
4829 /// Handle an incoming update_fulfill_htlc message from the given peer.
4830 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),
4831 /// Handle an incoming update_fail_htlc message from the given peer.
4832 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),
4833 /// Handle an incoming update_fail_malformed_htlc message from the given peer.
4834 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),
4835 /// Handle an incoming commitment_signed message from the given peer.
4836 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),
4837 /// Handle an incoming revoke_and_ack message from the given peer.
4838 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),
4839 /// Handle an incoming update_fee message from the given peer.
4840 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),
4841 /// Handle an incoming announcement_signatures message from the given peer.
4842 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),
4843 /// Indicates a connection to the peer failed/an existing connection was lost. If no connection
4844 /// is believed to be possible in the future (eg they're sending us messages we don't
4845 /// understand or indicate they require unknown feature bits), no_connection_possible is set
4846 /// and any outstanding channels should be failed.
4847 pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, no_connection_possible: bool),
4848 /// Handle a peer reconnecting, possibly generating channel_reestablish message(s).
4849 pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Init),
4850 /// Handle an incoming channel_reestablish message from the given peer.
4851 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),
4852 /// Handle an incoming channel update from the given peer.
4853 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),
4854 /// Handle an incoming error message from the given peer.
4855 pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ErrorMessage),
4856 /// Implementation of MessageSendEventsProvider for this object.
4857 pub MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider,
4858 /// Frees any resources associated with this object given its this_arg pointer.
4859 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
4860 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
4862 unsafe impl Send for ChannelMessageHandler {}
4863 unsafe impl Sync for ChannelMessageHandler {}
4865 pub(crate) extern "C" fn ChannelMessageHandler_clone_fields(orig: &ChannelMessageHandler) -> ChannelMessageHandler {
4866 ChannelMessageHandler {
4867 this_arg: orig.this_arg,
4868 handle_open_channel: Clone::clone(&orig.handle_open_channel),
4869 handle_accept_channel: Clone::clone(&orig.handle_accept_channel),
4870 handle_funding_created: Clone::clone(&orig.handle_funding_created),
4871 handle_funding_signed: Clone::clone(&orig.handle_funding_signed),
4872 handle_funding_locked: Clone::clone(&orig.handle_funding_locked),
4873 handle_shutdown: Clone::clone(&orig.handle_shutdown),
4874 handle_closing_signed: Clone::clone(&orig.handle_closing_signed),
4875 handle_update_add_htlc: Clone::clone(&orig.handle_update_add_htlc),
4876 handle_update_fulfill_htlc: Clone::clone(&orig.handle_update_fulfill_htlc),
4877 handle_update_fail_htlc: Clone::clone(&orig.handle_update_fail_htlc),
4878 handle_update_fail_malformed_htlc: Clone::clone(&orig.handle_update_fail_malformed_htlc),
4879 handle_commitment_signed: Clone::clone(&orig.handle_commitment_signed),
4880 handle_revoke_and_ack: Clone::clone(&orig.handle_revoke_and_ack),
4881 handle_update_fee: Clone::clone(&orig.handle_update_fee),
4882 handle_announcement_signatures: Clone::clone(&orig.handle_announcement_signatures),
4883 peer_disconnected: Clone::clone(&orig.peer_disconnected),
4884 peer_connected: Clone::clone(&orig.peer_connected),
4885 handle_channel_reestablish: Clone::clone(&orig.handle_channel_reestablish),
4886 handle_channel_update: Clone::clone(&orig.handle_channel_update),
4887 handle_error: Clone::clone(&orig.handle_error),
4888 MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
4889 free: Clone::clone(&orig.free),
4892 impl lightning::util::events::MessageSendEventsProvider for ChannelMessageHandler {
4893 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
4894 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
4895 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
4900 use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler;
4901 impl rustChannelMessageHandler for ChannelMessageHandler {
4902 fn handle_open_channel(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut their_features: lightning::ln::features::InitFeatures, mut msg: &lightning::ln::msgs::OpenChannel) {
4903 (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 })
4905 fn handle_accept_channel(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut their_features: lightning::ln::features::InitFeatures, mut msg: &lightning::ln::msgs::AcceptChannel) {
4906 (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 })
4908 fn handle_funding_created(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::FundingCreated) {
4909 (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 })
4911 fn handle_funding_signed(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::FundingSigned) {
4912 (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 })
4914 fn handle_funding_locked(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::FundingLocked) {
4915 (self.handle_funding_locked)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::FundingLocked { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::FundingLocked<>) as *mut _) }, is_owned: false })
4917 fn handle_shutdown(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut their_features: &lightning::ln::features::InitFeatures, mut msg: &lightning::ln::msgs::Shutdown) {
4918 (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 })
4920 fn handle_closing_signed(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ClosingSigned) {
4921 (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 })
4923 fn handle_update_add_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateAddHTLC) {
4924 (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 })
4926 fn handle_update_fulfill_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFulfillHTLC) {
4927 (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 })
4929 fn handle_update_fail_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailHTLC) {
4930 (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 })
4932 fn handle_update_fail_malformed_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) {
4933 (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 })
4935 fn handle_commitment_signed(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::CommitmentSigned) {
4936 (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 })
4938 fn handle_revoke_and_ack(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::RevokeAndACK) {
4939 (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 })
4941 fn handle_update_fee(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFee) {
4942 (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 })
4944 fn handle_announcement_signatures(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::AnnouncementSignatures) {
4945 (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 })
4947 fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut no_connection_possible: bool) {
4948 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), no_connection_possible)
4950 fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::Init) {
4951 (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 })
4953 fn handle_channel_reestablish(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ChannelReestablish) {
4954 (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 })
4956 fn handle_channel_update(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ChannelUpdate) {
4957 (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 })
4959 fn handle_error(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ErrorMessage) {
4960 (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 })
4964 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
4965 // directly as a Deref trait in higher-level structs:
4966 impl core::ops::Deref for ChannelMessageHandler {
4968 fn deref(&self) -> &Self {
4972 /// Calls the free function if one is set
4974 pub extern "C" fn ChannelMessageHandler_free(this_ptr: ChannelMessageHandler) { }
4975 impl Drop for ChannelMessageHandler {
4976 fn drop(&mut self) {
4977 if let Some(f) = self.free {
4982 /// A trait to describe an object which can receive routing messages.
4984 /// # Implementor DoS Warnings
4986 /// For `gossip_queries` messages there are potential DoS vectors when handling
4987 /// inbound queries. Implementors using an on-disk network graph should be aware of
4988 /// repeated disk I/O for queries accessing different parts of the network graph.
4990 pub struct RoutingMessageHandler {
4991 /// An opaque pointer which is passed to your function implementations as an argument.
4992 /// This has no meaning in the LDK, and can be NULL or any other value.
4993 pub this_arg: *mut c_void,
4994 /// Handle an incoming node_announcement message, returning true if it should be forwarded on,
4995 /// false or returning an Err otherwise.
4997 pub handle_node_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
4998 /// Handle a channel_announcement message, returning true if it should be forwarded on, false
4999 /// or returning an Err otherwise.
5001 pub handle_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
5002 /// Handle an incoming channel_update message, returning true if it should be forwarded on,
5003 /// false or returning an Err otherwise.
5005 pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ,
5006 /// Gets a subset of the channel announcements and updates required to dump our routing table
5007 /// to a remote node, starting at the short_channel_id indicated by starting_point and
5008 /// including the batch_amount entries immediately higher in numerical value than starting_point.
5010 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,
5011 /// Gets a subset of the node announcements required to dump our routing table to a remote node,
5012 /// starting at the node *after* the provided publickey and including batch_amount entries
5013 /// immediately higher (as defined by <PublicKey as Ord>::cmp) than starting_point.
5014 /// If None is provided for starting_point, we start at the first node.
5016 /// Note that starting_point (or a relevant inner pointer) may be NULL or all-0s to represent None
5018 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,
5019 /// Called when a connection is established with a peer. This can be used to
5020 /// perform routing table synchronization using a strategy defined by the
5022 pub sync_routing_table: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, init: &crate::lightning::ln::msgs::Init),
5023 /// Handles the reply of a query we initiated to learn about channels
5024 /// for a given range of blocks. We can expect to receive one or more
5025 /// replies to a single query.
5027 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,
5028 /// Handles the reply of a query we initiated asking for routing gossip
5029 /// messages for a list of channels. We should receive this message when
5030 /// a node has completed its best effort to send us the pertaining routing
5031 /// gossip messages.
5033 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,
5034 /// Handles when a peer asks us to send a list of short_channel_ids
5035 /// for the requested range of blocks.
5037 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,
5038 /// Handles when a peer asks us to send routing gossip messages for a
5039 /// list of short_channel_ids.
5041 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,
5042 /// Implementation of MessageSendEventsProvider for this object.
5043 pub MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider,
5044 /// Frees any resources associated with this object given its this_arg pointer.
5045 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
5046 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
5048 unsafe impl Send for RoutingMessageHandler {}
5049 unsafe impl Sync for RoutingMessageHandler {}
5051 pub(crate) extern "C" fn RoutingMessageHandler_clone_fields(orig: &RoutingMessageHandler) -> RoutingMessageHandler {
5052 RoutingMessageHandler {
5053 this_arg: orig.this_arg,
5054 handle_node_announcement: Clone::clone(&orig.handle_node_announcement),
5055 handle_channel_announcement: Clone::clone(&orig.handle_channel_announcement),
5056 handle_channel_update: Clone::clone(&orig.handle_channel_update),
5057 get_next_channel_announcements: Clone::clone(&orig.get_next_channel_announcements),
5058 get_next_node_announcements: Clone::clone(&orig.get_next_node_announcements),
5059 sync_routing_table: Clone::clone(&orig.sync_routing_table),
5060 handle_reply_channel_range: Clone::clone(&orig.handle_reply_channel_range),
5061 handle_reply_short_channel_ids_end: Clone::clone(&orig.handle_reply_short_channel_ids_end),
5062 handle_query_channel_range: Clone::clone(&orig.handle_query_channel_range),
5063 handle_query_short_channel_ids: Clone::clone(&orig.handle_query_short_channel_ids),
5064 MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
5065 free: Clone::clone(&orig.free),
5068 impl lightning::util::events::MessageSendEventsProvider for RoutingMessageHandler {
5069 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
5070 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
5071 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
5076 use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler;
5077 impl rustRoutingMessageHandler for RoutingMessageHandler {
5078 fn handle_node_announcement(&self, mut msg: &lightning::ln::msgs::NodeAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
5079 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 });
5080 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()) } })};
5083 fn handle_channel_announcement(&self, mut msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
5084 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 });
5085 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()) } })};
5088 fn handle_channel_update(&self, mut msg: &lightning::ln::msgs::ChannelUpdate) -> Result<bool, lightning::ln::msgs::LightningError> {
5089 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 });
5090 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()) } })};
5093 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>)> {
5094 let mut ret = (self.get_next_channel_announcements)(self.this_arg, starting_point, batch_amount);
5095 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 }); };
5098 fn get_next_node_announcements(&self, mut starting_point: Option<&bitcoin::secp256k1::key::PublicKey>, mut batch_amount: u8) -> Vec<lightning::ln::msgs::NodeAnnouncement> {
5099 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())) } };
5100 let mut ret = (self.get_next_node_announcements)(self.this_arg, local_starting_point, batch_amount);
5101 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
5104 fn sync_routing_table(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut init: &lightning::ln::msgs::Init) {
5105 (self.sync_routing_table)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { ObjOps::nonnull_ptr_to_inner((init as *const lightning::ln::msgs::Init<>) as *mut _) }, is_owned: false })
5107 fn handle_reply_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: lightning::ln::msgs::ReplyChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
5108 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 });
5109 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()) } })};
5112 fn handle_reply_short_channel_ids_end(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: lightning::ln::msgs::ReplyShortChannelIdsEnd) -> Result<(), lightning::ln::msgs::LightningError> {
5113 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 });
5114 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()) } })};
5117 fn handle_query_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: lightning::ln::msgs::QueryChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
5118 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 });
5119 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()) } })};
5122 fn handle_query_short_channel_ids(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: lightning::ln::msgs::QueryShortChannelIds) -> Result<(), lightning::ln::msgs::LightningError> {
5123 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 });
5124 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()) } })};
5129 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
5130 // directly as a Deref trait in higher-level structs:
5131 impl core::ops::Deref for RoutingMessageHandler {
5133 fn deref(&self) -> &Self {
5137 /// Calls the free function if one is set
5139 pub extern "C" fn RoutingMessageHandler_free(this_ptr: RoutingMessageHandler) { }
5140 impl Drop for RoutingMessageHandler {
5141 fn drop(&mut self) {
5142 if let Some(f) = self.free {
5147 mod fuzzy_internal_msgs {
5149 use alloc::str::FromStr;
5150 use core::ffi::c_void;
5151 use core::convert::Infallible;
5152 use bitcoin::hashes::Hash;
5153 use crate::c_types::*;
5154 #[cfg(feature="no-std")]
5155 use alloc::{vec::Vec, boxed::Box};
5159 /// Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read
5160 pub extern "C" fn AcceptChannel_write(obj: &AcceptChannel) -> crate::c_types::derived::CVec_u8Z {
5161 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5164 pub(crate) extern "C" fn AcceptChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5165 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannel) })
5168 /// Read a AcceptChannel from a byte array, created by AcceptChannel_write
5169 pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelDecodeErrorZ {
5170 let res: Result<lightning::ln::msgs::AcceptChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5171 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() };
5175 /// Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read
5176 pub extern "C" fn AnnouncementSignatures_write(obj: &AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z {
5177 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5180 pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5181 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAnnouncementSignatures) })
5184 /// Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write
5185 pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AnnouncementSignaturesDecodeErrorZ {
5186 let res: Result<lightning::ln::msgs::AnnouncementSignatures, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5187 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() };
5191 /// Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read
5192 pub extern "C" fn ChannelReestablish_write(obj: &ChannelReestablish) -> crate::c_types::derived::CVec_u8Z {
5193 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5196 pub(crate) extern "C" fn ChannelReestablish_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5197 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReestablish) })
5200 /// Read a ChannelReestablish from a byte array, created by ChannelReestablish_write
5201 pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReestablishDecodeErrorZ {
5202 let res: Result<lightning::ln::msgs::ChannelReestablish, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5203 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() };
5207 /// Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read
5208 pub extern "C" fn ClosingSigned_write(obj: &ClosingSigned) -> crate::c_types::derived::CVec_u8Z {
5209 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5212 pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5213 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSigned) })
5216 /// Read a ClosingSigned from a byte array, created by ClosingSigned_write
5217 pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedDecodeErrorZ {
5218 let res: Result<lightning::ln::msgs::ClosingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5219 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() };
5223 /// Serialize the ClosingSignedFeeRange object into a byte array which can be read by ClosingSignedFeeRange_read
5224 pub extern "C" fn ClosingSignedFeeRange_write(obj: &ClosingSignedFeeRange) -> crate::c_types::derived::CVec_u8Z {
5225 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5228 pub(crate) extern "C" fn ClosingSignedFeeRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5229 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSignedFeeRange) })
5232 /// Read a ClosingSignedFeeRange from a byte array, created by ClosingSignedFeeRange_write
5233 pub extern "C" fn ClosingSignedFeeRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedFeeRangeDecodeErrorZ {
5234 let res: Result<lightning::ln::msgs::ClosingSignedFeeRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5235 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() };
5239 /// Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read
5240 pub extern "C" fn CommitmentSigned_write(obj: &CommitmentSigned) -> crate::c_types::derived::CVec_u8Z {
5241 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5244 pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5245 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentSigned) })
5248 /// Read a CommitmentSigned from a byte array, created by CommitmentSigned_write
5249 pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CommitmentSignedDecodeErrorZ {
5250 let res: Result<lightning::ln::msgs::CommitmentSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5251 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() };
5255 /// Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read
5256 pub extern "C" fn FundingCreated_write(obj: &FundingCreated) -> crate::c_types::derived::CVec_u8Z {
5257 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5260 pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5261 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingCreated) })
5264 /// Read a FundingCreated from a byte array, created by FundingCreated_write
5265 pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingCreatedDecodeErrorZ {
5266 let res: Result<lightning::ln::msgs::FundingCreated, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5267 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() };
5271 /// Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read
5272 pub extern "C" fn FundingSigned_write(obj: &FundingSigned) -> crate::c_types::derived::CVec_u8Z {
5273 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5276 pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5277 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingSigned) })
5280 /// Read a FundingSigned from a byte array, created by FundingSigned_write
5281 pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingSignedDecodeErrorZ {
5282 let res: Result<lightning::ln::msgs::FundingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5283 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() };
5287 /// Serialize the FundingLocked object into a byte array which can be read by FundingLocked_read
5288 pub extern "C" fn FundingLocked_write(obj: &FundingLocked) -> crate::c_types::derived::CVec_u8Z {
5289 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5292 pub(crate) extern "C" fn FundingLocked_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5293 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingLocked) })
5296 /// Read a FundingLocked from a byte array, created by FundingLocked_write
5297 pub extern "C" fn FundingLocked_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingLockedDecodeErrorZ {
5298 let res: Result<lightning::ln::msgs::FundingLocked, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5299 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::FundingLocked { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
5303 /// Serialize the Init object into a byte array which can be read by Init_read
5304 pub extern "C" fn Init_write(obj: &Init) -> crate::c_types::derived::CVec_u8Z {
5305 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5308 pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5309 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInit) })
5312 /// Read a Init from a byte array, created by Init_write
5313 pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitDecodeErrorZ {
5314 let res: Result<lightning::ln::msgs::Init, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5315 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() };
5319 /// Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read
5320 pub extern "C" fn OpenChannel_write(obj: &OpenChannel) -> crate::c_types::derived::CVec_u8Z {
5321 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5324 pub(crate) extern "C" fn OpenChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5325 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannel) })
5328 /// Read a OpenChannel from a byte array, created by OpenChannel_write
5329 pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelDecodeErrorZ {
5330 let res: Result<lightning::ln::msgs::OpenChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5331 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() };
5335 /// Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read
5336 pub extern "C" fn RevokeAndACK_write(obj: &RevokeAndACK) -> crate::c_types::derived::CVec_u8Z {
5337 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5340 pub(crate) extern "C" fn RevokeAndACK_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5341 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevokeAndACK) })
5344 /// Read a RevokeAndACK from a byte array, created by RevokeAndACK_write
5345 pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RevokeAndACKDecodeErrorZ {
5346 let res: Result<lightning::ln::msgs::RevokeAndACK, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5347 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() };
5351 /// Serialize the Shutdown object into a byte array which can be read by Shutdown_read
5352 pub extern "C" fn Shutdown_write(obj: &Shutdown) -> crate::c_types::derived::CVec_u8Z {
5353 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5356 pub(crate) extern "C" fn Shutdown_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5357 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeShutdown) })
5360 /// Read a Shutdown from a byte array, created by Shutdown_write
5361 pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ShutdownDecodeErrorZ {
5362 let res: Result<lightning::ln::msgs::Shutdown, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5363 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() };
5367 /// Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read
5368 pub extern "C" fn UpdateFailHTLC_write(obj: &UpdateFailHTLC) -> crate::c_types::derived::CVec_u8Z {
5369 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5372 pub(crate) extern "C" fn UpdateFailHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5373 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailHTLC) })
5376 /// Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write
5377 pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailHTLCDecodeErrorZ {
5378 let res: Result<lightning::ln::msgs::UpdateFailHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5379 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() };
5383 /// Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read
5384 pub extern "C" fn UpdateFailMalformedHTLC_write(obj: &UpdateFailMalformedHTLC) -> crate::c_types::derived::CVec_u8Z {
5385 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5388 pub(crate) extern "C" fn UpdateFailMalformedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5389 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailMalformedHTLC) })
5392 /// Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write
5393 pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailMalformedHTLCDecodeErrorZ {
5394 let res: Result<lightning::ln::msgs::UpdateFailMalformedHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5395 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() };
5399 /// Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read
5400 pub extern "C" fn UpdateFee_write(obj: &UpdateFee) -> crate::c_types::derived::CVec_u8Z {
5401 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5404 pub(crate) extern "C" fn UpdateFee_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5405 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFee) })
5408 /// Read a UpdateFee from a byte array, created by UpdateFee_write
5409 pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFeeDecodeErrorZ {
5410 let res: Result<lightning::ln::msgs::UpdateFee, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5411 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() };
5415 /// Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read
5416 pub extern "C" fn UpdateFulfillHTLC_write(obj: &UpdateFulfillHTLC) -> crate::c_types::derived::CVec_u8Z {
5417 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5420 pub(crate) extern "C" fn UpdateFulfillHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5421 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFulfillHTLC) })
5424 /// Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write
5425 pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFulfillHTLCDecodeErrorZ {
5426 let res: Result<lightning::ln::msgs::UpdateFulfillHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5427 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() };
5431 /// Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read
5432 pub extern "C" fn UpdateAddHTLC_write(obj: &UpdateAddHTLC) -> crate::c_types::derived::CVec_u8Z {
5433 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5436 pub(crate) extern "C" fn UpdateAddHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5437 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateAddHTLC) })
5440 /// Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write
5441 pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateAddHTLCDecodeErrorZ {
5442 let res: Result<lightning::ln::msgs::UpdateAddHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5443 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() };
5447 /// Serialize the Ping object into a byte array which can be read by Ping_read
5448 pub extern "C" fn Ping_write(obj: &Ping) -> crate::c_types::derived::CVec_u8Z {
5449 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5452 pub(crate) extern "C" fn Ping_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5453 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePing) })
5456 /// Read a Ping from a byte array, created by Ping_write
5457 pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PingDecodeErrorZ {
5458 let res: Result<lightning::ln::msgs::Ping, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5459 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() };
5463 /// Serialize the Pong object into a byte array which can be read by Pong_read
5464 pub extern "C" fn Pong_write(obj: &Pong) -> crate::c_types::derived::CVec_u8Z {
5465 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5468 pub(crate) extern "C" fn Pong_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5469 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePong) })
5472 /// Read a Pong from a byte array, created by Pong_write
5473 pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PongDecodeErrorZ {
5474 let res: Result<lightning::ln::msgs::Pong, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5475 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() };
5479 /// Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read
5480 pub extern "C" fn UnsignedChannelAnnouncement_write(obj: &UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
5481 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5484 pub(crate) extern "C" fn UnsignedChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5485 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelAnnouncement) })
5488 /// Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write
5489 pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelAnnouncementDecodeErrorZ {
5490 let res: Result<lightning::ln::msgs::UnsignedChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5491 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() };
5495 /// Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read
5496 pub extern "C" fn ChannelAnnouncement_write(obj: &ChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
5497 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5500 pub(crate) extern "C" fn ChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5501 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelAnnouncement) })
5504 /// Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write
5505 pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelAnnouncementDecodeErrorZ {
5506 let res: Result<lightning::ln::msgs::ChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5507 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() };
5511 /// Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read
5512 pub extern "C" fn UnsignedChannelUpdate_write(obj: &UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
5513 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5516 pub(crate) extern "C" fn UnsignedChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5517 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelUpdate) })
5520 /// Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write
5521 pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelUpdateDecodeErrorZ {
5522 let res: Result<lightning::ln::msgs::UnsignedChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5523 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() };
5527 /// Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read
5528 pub extern "C" fn ChannelUpdate_write(obj: &ChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
5529 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5532 pub(crate) extern "C" fn ChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5533 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdate) })
5536 /// Read a ChannelUpdate from a byte array, created by ChannelUpdate_write
5537 pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelUpdateDecodeErrorZ {
5538 let res: Result<lightning::ln::msgs::ChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5539 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() };
5543 /// Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read
5544 pub extern "C" fn ErrorMessage_write(obj: &ErrorMessage) -> crate::c_types::derived::CVec_u8Z {
5545 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5548 pub(crate) extern "C" fn ErrorMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5549 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeErrorMessage) })
5552 /// Read a ErrorMessage from a byte array, created by ErrorMessage_write
5553 pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ErrorMessageDecodeErrorZ {
5554 let res: Result<lightning::ln::msgs::ErrorMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5555 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() };
5559 /// Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read
5560 pub extern "C" fn UnsignedNodeAnnouncement_write(obj: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
5561 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5564 pub(crate) extern "C" fn UnsignedNodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5565 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedNodeAnnouncement) })
5568 /// Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write
5569 pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedNodeAnnouncementDecodeErrorZ {
5570 let res: Result<lightning::ln::msgs::UnsignedNodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5571 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() };
5575 /// Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read
5576 pub extern "C" fn NodeAnnouncement_write(obj: &NodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
5577 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5580 pub(crate) extern "C" fn NodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5581 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncement) })
5584 /// Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write
5585 pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementDecodeErrorZ {
5586 let res: Result<lightning::ln::msgs::NodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5587 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() };
5591 /// Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write
5592 pub extern "C" fn QueryShortChannelIds_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryShortChannelIdsDecodeErrorZ {
5593 let res: Result<lightning::ln::msgs::QueryShortChannelIds, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5594 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() };
5598 /// Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read
5599 pub extern "C" fn QueryShortChannelIds_write(obj: &QueryShortChannelIds) -> crate::c_types::derived::CVec_u8Z {
5600 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5603 pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5604 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) })
5607 /// Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read
5608 pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z {
5609 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5612 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5613 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) })
5616 /// Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write
5617 pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyShortChannelIdsEndDecodeErrorZ {
5618 let res: Result<lightning::ln::msgs::ReplyShortChannelIdsEnd, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5619 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() };
5622 ///\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
5625 pub extern "C" fn QueryChannelRange_end_blocknum(this_arg: &QueryChannelRange) -> u32 {
5626 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.end_blocknum();
5631 /// Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read
5632 pub extern "C" fn QueryChannelRange_write(obj: &QueryChannelRange) -> crate::c_types::derived::CVec_u8Z {
5633 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5636 pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5637 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) })
5640 /// Read a QueryChannelRange from a byte array, created by QueryChannelRange_write
5641 pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ {
5642 let res: Result<lightning::ln::msgs::QueryChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5643 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() };
5647 /// Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write
5648 pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyChannelRangeDecodeErrorZ {
5649 let res: Result<lightning::ln::msgs::ReplyChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5650 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() };
5654 /// Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read
5655 pub extern "C" fn ReplyChannelRange_write(obj: &ReplyChannelRange) -> crate::c_types::derived::CVec_u8Z {
5656 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5659 pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5660 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) })
5663 /// Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read
5664 pub extern "C" fn GossipTimestampFilter_write(obj: &GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z {
5665 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5668 pub(crate) extern "C" fn GossipTimestampFilter_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5669 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeGossipTimestampFilter) })
5672 /// Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write
5673 pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_GossipTimestampFilterDecodeErrorZ {
5674 let res: Result<lightning::ln::msgs::GossipTimestampFilter, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5675 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() };