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 std::str::FromStr;
28 use core::convert::Infallible;
29 use bitcoin::hashes::Hash;
30 use crate::c_types::*;
33 use lightning::ln::msgs::DecodeError as nativeDecodeErrorImport;
34 pub(crate) type nativeDecodeError = nativeDecodeErrorImport;
36 /// An error in decoding a message or struct.
39 pub struct DecodeError {
40 /// A pointer to the opaque Rust object.
42 /// Nearly everywhere, inner must be non-null, however in places where
43 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
44 pub inner: *mut nativeDecodeError,
45 /// Indicates that this is the only struct which contains the same pointer.
47 /// Rust functions which take ownership of an object provided via an argument require
48 /// this to be true and invalidate the object pointed to by inner.
52 impl Drop for DecodeError {
54 if self.is_owned && !<*mut nativeDecodeError>::is_null(self.inner) {
55 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
59 /// Frees any resources used by the DecodeError, if is_owned is set and inner is non-NULL.
61 pub extern "C" fn DecodeError_free(this_obj: DecodeError) { }
63 /// Used only if an object of this type is returned as a trait impl by a method
64 pub(crate) extern "C" fn DecodeError_free_void(this_ptr: *mut c_void) {
65 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDecodeError); }
69 pub(crate) fn get_native_ref(&self) -> &'static nativeDecodeError {
70 unsafe { &*ObjOps::untweak_ptr(self.inner) }
72 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeDecodeError {
73 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
75 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
76 pub(crate) fn take_inner(mut self) -> *mut nativeDecodeError {
77 assert!(self.is_owned);
78 let ret = ObjOps::untweak_ptr(self.inner);
79 self.inner = std::ptr::null_mut();
83 impl Clone for DecodeError {
84 fn clone(&self) -> Self {
86 inner: if <*mut nativeDecodeError>::is_null(self.inner) { std::ptr::null_mut() } else {
87 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
93 /// Used only if an object of this type is returned as a trait impl by a method
94 pub(crate) extern "C" fn DecodeError_clone_void(this_ptr: *const c_void) -> *mut c_void {
95 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDecodeError)).clone() })) as *mut c_void
98 /// Creates a copy of the DecodeError
99 pub extern "C" fn DecodeError_clone(orig: &DecodeError) -> DecodeError {
103 use lightning::ln::msgs::Init as nativeInitImport;
104 pub(crate) type nativeInit = nativeInitImport;
106 /// An init message to be sent or received from a peer
110 /// A pointer to the opaque Rust object.
112 /// Nearly everywhere, inner must be non-null, however in places where
113 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
114 pub inner: *mut nativeInit,
115 /// Indicates that this is the only struct which contains the same pointer.
117 /// Rust functions which take ownership of an object provided via an argument require
118 /// this to be true and invalidate the object pointed to by inner.
124 if self.is_owned && !<*mut nativeInit>::is_null(self.inner) {
125 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
129 /// Frees any resources used by the Init, if is_owned is set and inner is non-NULL.
131 pub extern "C" fn Init_free(this_obj: Init) { }
133 /// Used only if an object of this type is returned as a trait impl by a method
134 pub(crate) extern "C" fn Init_free_void(this_ptr: *mut c_void) {
135 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeInit); }
139 pub(crate) fn get_native_ref(&self) -> &'static nativeInit {
140 unsafe { &*ObjOps::untweak_ptr(self.inner) }
142 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInit {
143 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
145 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
146 pub(crate) fn take_inner(mut self) -> *mut nativeInit {
147 assert!(self.is_owned);
148 let ret = ObjOps::untweak_ptr(self.inner);
149 self.inner = std::ptr::null_mut();
153 /// The relevant features which the sender supports
155 pub extern "C" fn Init_get_features(this_ptr: &Init) -> crate::lightning::ln::features::InitFeatures {
156 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
157 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 }
159 /// The relevant features which the sender supports
161 pub extern "C" fn Init_set_features(this_ptr: &mut Init, mut val: crate::lightning::ln::features::InitFeatures) {
162 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
164 /// Constructs a new Init given each field
167 pub extern "C" fn Init_new(mut features_arg: crate::lightning::ln::features::InitFeatures) -> Init {
168 Init { inner: ObjOps::heap_alloc(nativeInit {
169 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
172 impl Clone for Init {
173 fn clone(&self) -> Self {
175 inner: if <*mut nativeInit>::is_null(self.inner) { std::ptr::null_mut() } else {
176 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
182 /// Used only if an object of this type is returned as a trait impl by a method
183 pub(crate) extern "C" fn Init_clone_void(this_ptr: *const c_void) -> *mut c_void {
184 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInit)).clone() })) as *mut c_void
187 /// Creates a copy of the Init
188 pub extern "C" fn Init_clone(orig: &Init) -> Init {
192 use lightning::ln::msgs::ErrorMessage as nativeErrorMessageImport;
193 pub(crate) type nativeErrorMessage = nativeErrorMessageImport;
195 /// An error message to be sent or received from a peer
198 pub struct ErrorMessage {
199 /// A pointer to the opaque Rust object.
201 /// Nearly everywhere, inner must be non-null, however in places where
202 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
203 pub inner: *mut nativeErrorMessage,
204 /// Indicates that this is the only struct which contains the same pointer.
206 /// Rust functions which take ownership of an object provided via an argument require
207 /// this to be true and invalidate the object pointed to by inner.
211 impl Drop for ErrorMessage {
213 if self.is_owned && !<*mut nativeErrorMessage>::is_null(self.inner) {
214 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
218 /// Frees any resources used by the ErrorMessage, if is_owned is set and inner is non-NULL.
220 pub extern "C" fn ErrorMessage_free(this_obj: ErrorMessage) { }
222 /// Used only if an object of this type is returned as a trait impl by a method
223 pub(crate) extern "C" fn ErrorMessage_free_void(this_ptr: *mut c_void) {
224 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeErrorMessage); }
228 pub(crate) fn get_native_ref(&self) -> &'static nativeErrorMessage {
229 unsafe { &*ObjOps::untweak_ptr(self.inner) }
231 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeErrorMessage {
232 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
234 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
235 pub(crate) fn take_inner(mut self) -> *mut nativeErrorMessage {
236 assert!(self.is_owned);
237 let ret = ObjOps::untweak_ptr(self.inner);
238 self.inner = std::ptr::null_mut();
242 /// The channel ID involved in the error
244 pub extern "C" fn ErrorMessage_get_channel_id(this_ptr: &ErrorMessage) -> *const [u8; 32] {
245 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
248 /// The channel ID involved in the error
250 pub extern "C" fn ErrorMessage_set_channel_id(this_ptr: &mut ErrorMessage, mut val: crate::c_types::ThirtyTwoBytes) {
251 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
253 /// A possibly human-readable error description.
254 /// The string should be sanitized before it is used (e.g. emitted to logs
255 /// or printed to stdout). Otherwise, a well crafted error message may trigger a security
256 /// vulnerability in the terminal emulator or the logging subsystem.
258 pub extern "C" fn ErrorMessage_get_data(this_ptr: &ErrorMessage) -> crate::c_types::Str {
259 let mut inner_val = &mut this_ptr.get_native_mut_ref().data;
260 inner_val.as_str().into()
262 /// A possibly human-readable error description.
263 /// The string should be sanitized before it is used (e.g. emitted to logs
264 /// or printed to stdout). Otherwise, a well crafted error message may trigger a security
265 /// vulnerability in the terminal emulator or the logging subsystem.
267 pub extern "C" fn ErrorMessage_set_data(this_ptr: &mut ErrorMessage, mut val: crate::c_types::Str) {
268 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string();
270 /// Constructs a new ErrorMessage given each field
273 pub extern "C" fn ErrorMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::Str) -> ErrorMessage {
274 ErrorMessage { inner: ObjOps::heap_alloc(nativeErrorMessage {
275 channel_id: channel_id_arg.data,
276 data: data_arg.into_string(),
279 impl Clone for ErrorMessage {
280 fn clone(&self) -> Self {
282 inner: if <*mut nativeErrorMessage>::is_null(self.inner) { std::ptr::null_mut() } else {
283 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
289 /// Used only if an object of this type is returned as a trait impl by a method
290 pub(crate) extern "C" fn ErrorMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
291 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeErrorMessage)).clone() })) as *mut c_void
294 /// Creates a copy of the ErrorMessage
295 pub extern "C" fn ErrorMessage_clone(orig: &ErrorMessage) -> ErrorMessage {
299 use lightning::ln::msgs::Ping as nativePingImport;
300 pub(crate) type nativePing = nativePingImport;
302 /// A ping message to be sent or received from a peer
306 /// A pointer to the opaque Rust object.
308 /// Nearly everywhere, inner must be non-null, however in places where
309 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
310 pub inner: *mut nativePing,
311 /// Indicates that this is the only struct which contains the same pointer.
313 /// Rust functions which take ownership of an object provided via an argument require
314 /// this to be true and invalidate the object pointed to by inner.
320 if self.is_owned && !<*mut nativePing>::is_null(self.inner) {
321 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
325 /// Frees any resources used by the Ping, if is_owned is set and inner is non-NULL.
327 pub extern "C" fn Ping_free(this_obj: Ping) { }
329 /// Used only if an object of this type is returned as a trait impl by a method
330 pub(crate) extern "C" fn Ping_free_void(this_ptr: *mut c_void) {
331 unsafe { let _ = Box::from_raw(this_ptr as *mut nativePing); }
335 pub(crate) fn get_native_ref(&self) -> &'static nativePing {
336 unsafe { &*ObjOps::untweak_ptr(self.inner) }
338 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePing {
339 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
341 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
342 pub(crate) fn take_inner(mut self) -> *mut nativePing {
343 assert!(self.is_owned);
344 let ret = ObjOps::untweak_ptr(self.inner);
345 self.inner = std::ptr::null_mut();
349 /// The desired response length
351 pub extern "C" fn Ping_get_ponglen(this_ptr: &Ping) -> u16 {
352 let mut inner_val = &mut this_ptr.get_native_mut_ref().ponglen;
355 /// The desired response length
357 pub extern "C" fn Ping_set_ponglen(this_ptr: &mut Ping, mut val: u16) {
358 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.ponglen = val;
360 /// The ping packet size.
361 /// This field is not sent on the wire. byteslen zeros are sent.
363 pub extern "C" fn Ping_get_byteslen(this_ptr: &Ping) -> u16 {
364 let mut inner_val = &mut this_ptr.get_native_mut_ref().byteslen;
367 /// The ping packet size.
368 /// This field is not sent on the wire. byteslen zeros are sent.
370 pub extern "C" fn Ping_set_byteslen(this_ptr: &mut Ping, mut val: u16) {
371 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.byteslen = val;
373 /// Constructs a new Ping given each field
376 pub extern "C" fn Ping_new(mut ponglen_arg: u16, mut byteslen_arg: u16) -> Ping {
377 Ping { inner: ObjOps::heap_alloc(nativePing {
378 ponglen: ponglen_arg,
379 byteslen: byteslen_arg,
382 impl Clone for Ping {
383 fn clone(&self) -> Self {
385 inner: if <*mut nativePing>::is_null(self.inner) { std::ptr::null_mut() } else {
386 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
392 /// Used only if an object of this type is returned as a trait impl by a method
393 pub(crate) extern "C" fn Ping_clone_void(this_ptr: *const c_void) -> *mut c_void {
394 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePing)).clone() })) as *mut c_void
397 /// Creates a copy of the Ping
398 pub extern "C" fn Ping_clone(orig: &Ping) -> Ping {
402 use lightning::ln::msgs::Pong as nativePongImport;
403 pub(crate) type nativePong = nativePongImport;
405 /// A pong message to be sent or received from a peer
409 /// A pointer to the opaque Rust object.
411 /// Nearly everywhere, inner must be non-null, however in places where
412 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
413 pub inner: *mut nativePong,
414 /// Indicates that this is the only struct which contains the same pointer.
416 /// Rust functions which take ownership of an object provided via an argument require
417 /// this to be true and invalidate the object pointed to by inner.
423 if self.is_owned && !<*mut nativePong>::is_null(self.inner) {
424 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
428 /// Frees any resources used by the Pong, if is_owned is set and inner is non-NULL.
430 pub extern "C" fn Pong_free(this_obj: Pong) { }
432 /// Used only if an object of this type is returned as a trait impl by a method
433 pub(crate) extern "C" fn Pong_free_void(this_ptr: *mut c_void) {
434 unsafe { let _ = Box::from_raw(this_ptr as *mut nativePong); }
438 pub(crate) fn get_native_ref(&self) -> &'static nativePong {
439 unsafe { &*ObjOps::untweak_ptr(self.inner) }
441 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePong {
442 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
444 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
445 pub(crate) fn take_inner(mut self) -> *mut nativePong {
446 assert!(self.is_owned);
447 let ret = ObjOps::untweak_ptr(self.inner);
448 self.inner = std::ptr::null_mut();
452 /// The pong packet size.
453 /// This field is not sent on the wire. byteslen zeros are sent.
455 pub extern "C" fn Pong_get_byteslen(this_ptr: &Pong) -> u16 {
456 let mut inner_val = &mut this_ptr.get_native_mut_ref().byteslen;
459 /// The pong packet size.
460 /// This field is not sent on the wire. byteslen zeros are sent.
462 pub extern "C" fn Pong_set_byteslen(this_ptr: &mut Pong, mut val: u16) {
463 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.byteslen = val;
465 /// Constructs a new Pong given each field
468 pub extern "C" fn Pong_new(mut byteslen_arg: u16) -> Pong {
469 Pong { inner: ObjOps::heap_alloc(nativePong {
470 byteslen: byteslen_arg,
473 impl Clone for Pong {
474 fn clone(&self) -> Self {
476 inner: if <*mut nativePong>::is_null(self.inner) { std::ptr::null_mut() } else {
477 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
483 /// Used only if an object of this type is returned as a trait impl by a method
484 pub(crate) extern "C" fn Pong_clone_void(this_ptr: *const c_void) -> *mut c_void {
485 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePong)).clone() })) as *mut c_void
488 /// Creates a copy of the Pong
489 pub extern "C" fn Pong_clone(orig: &Pong) -> Pong {
493 use lightning::ln::msgs::OpenChannel as nativeOpenChannelImport;
494 pub(crate) type nativeOpenChannel = nativeOpenChannelImport;
496 /// An open_channel message to be sent or received from a peer
499 pub struct OpenChannel {
500 /// A pointer to the opaque Rust object.
502 /// Nearly everywhere, inner must be non-null, however in places where
503 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
504 pub inner: *mut nativeOpenChannel,
505 /// Indicates that this is the only struct which contains the same pointer.
507 /// Rust functions which take ownership of an object provided via an argument require
508 /// this to be true and invalidate the object pointed to by inner.
512 impl Drop for OpenChannel {
514 if self.is_owned && !<*mut nativeOpenChannel>::is_null(self.inner) {
515 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
519 /// Frees any resources used by the OpenChannel, if is_owned is set and inner is non-NULL.
521 pub extern "C" fn OpenChannel_free(this_obj: OpenChannel) { }
523 /// Used only if an object of this type is returned as a trait impl by a method
524 pub(crate) extern "C" fn OpenChannel_free_void(this_ptr: *mut c_void) {
525 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeOpenChannel); }
529 pub(crate) fn get_native_ref(&self) -> &'static nativeOpenChannel {
530 unsafe { &*ObjOps::untweak_ptr(self.inner) }
532 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOpenChannel {
533 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
535 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
536 pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannel {
537 assert!(self.is_owned);
538 let ret = ObjOps::untweak_ptr(self.inner);
539 self.inner = std::ptr::null_mut();
543 /// The genesis hash of the blockchain where the channel is to be opened
545 pub extern "C" fn OpenChannel_get_chain_hash(this_ptr: &OpenChannel) -> *const [u8; 32] {
546 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
549 /// The genesis hash of the blockchain where the channel is to be opened
551 pub extern "C" fn OpenChannel_set_chain_hash(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
552 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
554 /// A temporary channel ID, until the funding outpoint is announced
556 pub extern "C" fn OpenChannel_get_temporary_channel_id(this_ptr: &OpenChannel) -> *const [u8; 32] {
557 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
560 /// A temporary channel ID, until the funding outpoint is announced
562 pub extern "C" fn OpenChannel_set_temporary_channel_id(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
563 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
565 /// The channel value
567 pub extern "C" fn OpenChannel_get_funding_satoshis(this_ptr: &OpenChannel) -> u64 {
568 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
571 /// The channel value
573 pub extern "C" fn OpenChannel_set_funding_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
574 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
576 /// The amount to push to the counterparty as part of the open, in milli-satoshi
578 pub extern "C" fn OpenChannel_get_push_msat(this_ptr: &OpenChannel) -> u64 {
579 let mut inner_val = &mut this_ptr.get_native_mut_ref().push_msat;
582 /// The amount to push to the counterparty as part of the open, in milli-satoshi
584 pub extern "C" fn OpenChannel_set_push_msat(this_ptr: &mut OpenChannel, mut val: u64) {
585 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.push_msat = val;
587 /// The threshold below which outputs on transactions broadcast by sender will be omitted
589 pub extern "C" fn OpenChannel_get_dust_limit_satoshis(this_ptr: &OpenChannel) -> u64 {
590 let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
593 /// The threshold below which outputs on transactions broadcast by sender will be omitted
595 pub extern "C" fn OpenChannel_set_dust_limit_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
596 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
598 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
600 pub extern "C" fn OpenChannel_get_max_htlc_value_in_flight_msat(this_ptr: &OpenChannel) -> u64 {
601 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
604 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
606 pub extern "C" fn OpenChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut OpenChannel, mut val: u64) {
607 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
609 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
611 pub extern "C" fn OpenChannel_get_channel_reserve_satoshis(this_ptr: &OpenChannel) -> u64 {
612 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
615 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
617 pub extern "C" fn OpenChannel_set_channel_reserve_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
618 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
620 /// The minimum HTLC size incoming to sender, in milli-satoshi
622 pub extern "C" fn OpenChannel_get_htlc_minimum_msat(this_ptr: &OpenChannel) -> u64 {
623 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
626 /// The minimum HTLC size incoming to sender, in milli-satoshi
628 pub extern "C" fn OpenChannel_set_htlc_minimum_msat(this_ptr: &mut OpenChannel, mut val: u64) {
629 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
631 /// The feerate per 1000-weight of sender generated transactions, until updated by update_fee
633 pub extern "C" fn OpenChannel_get_feerate_per_kw(this_ptr: &OpenChannel) -> u32 {
634 let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
637 /// The feerate per 1000-weight of sender generated transactions, until updated by update_fee
639 pub extern "C" fn OpenChannel_set_feerate_per_kw(this_ptr: &mut OpenChannel, mut val: u32) {
640 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
642 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
644 pub extern "C" fn OpenChannel_get_to_self_delay(this_ptr: &OpenChannel) -> u16 {
645 let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
648 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
650 pub extern "C" fn OpenChannel_set_to_self_delay(this_ptr: &mut OpenChannel, mut val: u16) {
651 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
653 /// The maximum number of inbound HTLCs towards sender
655 pub extern "C" fn OpenChannel_get_max_accepted_htlcs(this_ptr: &OpenChannel) -> u16 {
656 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
659 /// The maximum number of inbound HTLCs towards sender
661 pub extern "C" fn OpenChannel_set_max_accepted_htlcs(this_ptr: &mut OpenChannel, mut val: u16) {
662 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
664 /// The sender's key controlling the funding transaction
666 pub extern "C" fn OpenChannel_get_funding_pubkey(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
667 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
668 crate::c_types::PublicKey::from_rust(&inner_val)
670 /// The sender's key controlling the funding transaction
672 pub extern "C" fn OpenChannel_set_funding_pubkey(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
673 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
675 /// Used to derive a revocation key for transactions broadcast by counterparty
677 pub extern "C" fn OpenChannel_get_revocation_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
678 let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
679 crate::c_types::PublicKey::from_rust(&inner_val)
681 /// Used to derive a revocation key for transactions broadcast by counterparty
683 pub extern "C" fn OpenChannel_set_revocation_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
684 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
686 /// A payment key to sender for transactions broadcast by counterparty
688 pub extern "C" fn OpenChannel_get_payment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
689 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_point;
690 crate::c_types::PublicKey::from_rust(&inner_val)
692 /// A payment key to sender for transactions broadcast by counterparty
694 pub extern "C" fn OpenChannel_set_payment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
695 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_point = val.into_rust();
697 /// Used to derive a payment key to sender for transactions broadcast by sender
699 pub extern "C" fn OpenChannel_get_delayed_payment_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
700 let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
701 crate::c_types::PublicKey::from_rust(&inner_val)
703 /// Used to derive a payment key to sender for transactions broadcast by sender
705 pub extern "C" fn OpenChannel_set_delayed_payment_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
706 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
708 /// Used to derive an HTLC payment key to sender
710 pub extern "C" fn OpenChannel_get_htlc_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
711 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
712 crate::c_types::PublicKey::from_rust(&inner_val)
714 /// Used to derive an HTLC payment key to sender
716 pub extern "C" fn OpenChannel_set_htlc_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
717 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
719 /// The first to-be-broadcast-by-sender transaction's per commitment point
721 pub extern "C" fn OpenChannel_get_first_per_commitment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
722 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
723 crate::c_types::PublicKey::from_rust(&inner_val)
725 /// The first to-be-broadcast-by-sender transaction's per commitment point
727 pub extern "C" fn OpenChannel_set_first_per_commitment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
728 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
732 pub extern "C" fn OpenChannel_get_channel_flags(this_ptr: &OpenChannel) -> u8 {
733 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_flags;
738 pub extern "C" fn OpenChannel_set_channel_flags(this_ptr: &mut OpenChannel, mut val: u8) {
739 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_flags = val;
741 impl Clone for OpenChannel {
742 fn clone(&self) -> Self {
744 inner: if <*mut nativeOpenChannel>::is_null(self.inner) { std::ptr::null_mut() } else {
745 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
751 /// Used only if an object of this type is returned as a trait impl by a method
752 pub(crate) extern "C" fn OpenChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
753 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOpenChannel)).clone() })) as *mut c_void
756 /// Creates a copy of the OpenChannel
757 pub extern "C" fn OpenChannel_clone(orig: &OpenChannel) -> OpenChannel {
761 use lightning::ln::msgs::AcceptChannel as nativeAcceptChannelImport;
762 pub(crate) type nativeAcceptChannel = nativeAcceptChannelImport;
764 /// An accept_channel message to be sent or received from a peer
767 pub struct AcceptChannel {
768 /// A pointer to the opaque Rust object.
770 /// Nearly everywhere, inner must be non-null, however in places where
771 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
772 pub inner: *mut nativeAcceptChannel,
773 /// Indicates that this is the only struct which contains the same pointer.
775 /// Rust functions which take ownership of an object provided via an argument require
776 /// this to be true and invalidate the object pointed to by inner.
780 impl Drop for AcceptChannel {
782 if self.is_owned && !<*mut nativeAcceptChannel>::is_null(self.inner) {
783 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
787 /// Frees any resources used by the AcceptChannel, if is_owned is set and inner is non-NULL.
789 pub extern "C" fn AcceptChannel_free(this_obj: AcceptChannel) { }
791 /// Used only if an object of this type is returned as a trait impl by a method
792 pub(crate) extern "C" fn AcceptChannel_free_void(this_ptr: *mut c_void) {
793 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeAcceptChannel); }
797 pub(crate) fn get_native_ref(&self) -> &'static nativeAcceptChannel {
798 unsafe { &*ObjOps::untweak_ptr(self.inner) }
800 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAcceptChannel {
801 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
803 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
804 pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannel {
805 assert!(self.is_owned);
806 let ret = ObjOps::untweak_ptr(self.inner);
807 self.inner = std::ptr::null_mut();
811 /// A temporary channel ID, until the funding outpoint is announced
813 pub extern "C" fn AcceptChannel_get_temporary_channel_id(this_ptr: &AcceptChannel) -> *const [u8; 32] {
814 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
817 /// A temporary channel ID, until the funding outpoint is announced
819 pub extern "C" fn AcceptChannel_set_temporary_channel_id(this_ptr: &mut AcceptChannel, mut val: crate::c_types::ThirtyTwoBytes) {
820 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
822 /// The threshold below which outputs on transactions broadcast by sender will be omitted
824 pub extern "C" fn AcceptChannel_get_dust_limit_satoshis(this_ptr: &AcceptChannel) -> u64 {
825 let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
828 /// The threshold below which outputs on transactions broadcast by sender will be omitted
830 pub extern "C" fn AcceptChannel_set_dust_limit_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
831 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
833 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
835 pub extern "C" fn AcceptChannel_get_max_htlc_value_in_flight_msat(this_ptr: &AcceptChannel) -> u64 {
836 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
839 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
841 pub extern "C" fn AcceptChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
842 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
844 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
846 pub extern "C" fn AcceptChannel_get_channel_reserve_satoshis(this_ptr: &AcceptChannel) -> u64 {
847 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
850 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
852 pub extern "C" fn AcceptChannel_set_channel_reserve_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
853 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
855 /// The minimum HTLC size incoming to sender, in milli-satoshi
857 pub extern "C" fn AcceptChannel_get_htlc_minimum_msat(this_ptr: &AcceptChannel) -> u64 {
858 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
861 /// The minimum HTLC size incoming to sender, in milli-satoshi
863 pub extern "C" fn AcceptChannel_set_htlc_minimum_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
864 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
866 /// Minimum depth of the funding transaction before the channel is considered open
868 pub extern "C" fn AcceptChannel_get_minimum_depth(this_ptr: &AcceptChannel) -> u32 {
869 let mut inner_val = &mut this_ptr.get_native_mut_ref().minimum_depth;
872 /// Minimum depth of the funding transaction before the channel is considered open
874 pub extern "C" fn AcceptChannel_set_minimum_depth(this_ptr: &mut AcceptChannel, mut val: u32) {
875 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.minimum_depth = val;
877 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
879 pub extern "C" fn AcceptChannel_get_to_self_delay(this_ptr: &AcceptChannel) -> u16 {
880 let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
883 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
885 pub extern "C" fn AcceptChannel_set_to_self_delay(this_ptr: &mut AcceptChannel, mut val: u16) {
886 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
888 /// The maximum number of inbound HTLCs towards sender
890 pub extern "C" fn AcceptChannel_get_max_accepted_htlcs(this_ptr: &AcceptChannel) -> u16 {
891 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
894 /// The maximum number of inbound HTLCs towards sender
896 pub extern "C" fn AcceptChannel_set_max_accepted_htlcs(this_ptr: &mut AcceptChannel, mut val: u16) {
897 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
899 /// The sender's key controlling the funding transaction
901 pub extern "C" fn AcceptChannel_get_funding_pubkey(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
902 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
903 crate::c_types::PublicKey::from_rust(&inner_val)
905 /// The sender's key controlling the funding transaction
907 pub extern "C" fn AcceptChannel_set_funding_pubkey(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
908 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
910 /// Used to derive a revocation key for transactions broadcast by counterparty
912 pub extern "C" fn AcceptChannel_get_revocation_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
913 let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
914 crate::c_types::PublicKey::from_rust(&inner_val)
916 /// Used to derive a revocation key for transactions broadcast by counterparty
918 pub extern "C" fn AcceptChannel_set_revocation_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
919 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
921 /// A payment key to sender for transactions broadcast by counterparty
923 pub extern "C" fn AcceptChannel_get_payment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
924 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_point;
925 crate::c_types::PublicKey::from_rust(&inner_val)
927 /// A payment key to sender for transactions broadcast by counterparty
929 pub extern "C" fn AcceptChannel_set_payment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
930 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_point = val.into_rust();
932 /// Used to derive a payment key to sender for transactions broadcast by sender
934 pub extern "C" fn AcceptChannel_get_delayed_payment_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
935 let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
936 crate::c_types::PublicKey::from_rust(&inner_val)
938 /// Used to derive a payment key to sender for transactions broadcast by sender
940 pub extern "C" fn AcceptChannel_set_delayed_payment_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
941 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
943 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
945 pub extern "C" fn AcceptChannel_get_htlc_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
946 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
947 crate::c_types::PublicKey::from_rust(&inner_val)
949 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
951 pub extern "C" fn AcceptChannel_set_htlc_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
952 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
954 /// The first to-be-broadcast-by-sender transaction's per commitment point
956 pub extern "C" fn AcceptChannel_get_first_per_commitment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
957 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
958 crate::c_types::PublicKey::from_rust(&inner_val)
960 /// The first to-be-broadcast-by-sender transaction's per commitment point
962 pub extern "C" fn AcceptChannel_set_first_per_commitment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
963 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
965 impl Clone for AcceptChannel {
966 fn clone(&self) -> Self {
968 inner: if <*mut nativeAcceptChannel>::is_null(self.inner) { std::ptr::null_mut() } else {
969 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
975 /// Used only if an object of this type is returned as a trait impl by a method
976 pub(crate) extern "C" fn AcceptChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
977 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAcceptChannel)).clone() })) as *mut c_void
980 /// Creates a copy of the AcceptChannel
981 pub extern "C" fn AcceptChannel_clone(orig: &AcceptChannel) -> AcceptChannel {
985 use lightning::ln::msgs::FundingCreated as nativeFundingCreatedImport;
986 pub(crate) type nativeFundingCreated = nativeFundingCreatedImport;
988 /// A funding_created message to be sent or received from a peer
991 pub struct FundingCreated {
992 /// A pointer to the opaque Rust object.
994 /// Nearly everywhere, inner must be non-null, however in places where
995 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
996 pub inner: *mut nativeFundingCreated,
997 /// Indicates that this is the only struct which contains the same pointer.
999 /// Rust functions which take ownership of an object provided via an argument require
1000 /// this to be true and invalidate the object pointed to by inner.
1004 impl Drop for FundingCreated {
1005 fn drop(&mut self) {
1006 if self.is_owned && !<*mut nativeFundingCreated>::is_null(self.inner) {
1007 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1011 /// Frees any resources used by the FundingCreated, if is_owned is set and inner is non-NULL.
1013 pub extern "C" fn FundingCreated_free(this_obj: FundingCreated) { }
1015 /// Used only if an object of this type is returned as a trait impl by a method
1016 pub(crate) extern "C" fn FundingCreated_free_void(this_ptr: *mut c_void) {
1017 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingCreated); }
1020 impl FundingCreated {
1021 pub(crate) fn get_native_ref(&self) -> &'static nativeFundingCreated {
1022 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1024 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingCreated {
1025 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1027 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1028 pub(crate) fn take_inner(mut self) -> *mut nativeFundingCreated {
1029 assert!(self.is_owned);
1030 let ret = ObjOps::untweak_ptr(self.inner);
1031 self.inner = std::ptr::null_mut();
1035 /// A temporary channel ID, until the funding is established
1037 pub extern "C" fn FundingCreated_get_temporary_channel_id(this_ptr: &FundingCreated) -> *const [u8; 32] {
1038 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
1041 /// A temporary channel ID, until the funding is established
1043 pub extern "C" fn FundingCreated_set_temporary_channel_id(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
1044 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
1046 /// The funding transaction ID
1048 pub extern "C" fn FundingCreated_get_funding_txid(this_ptr: &FundingCreated) -> *const [u8; 32] {
1049 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_txid;
1050 inner_val.as_inner()
1052 /// The funding transaction ID
1054 pub extern "C" fn FundingCreated_set_funding_txid(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
1055 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_txid = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
1057 /// The specific output index funding this channel
1059 pub extern "C" fn FundingCreated_get_funding_output_index(this_ptr: &FundingCreated) -> u16 {
1060 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_index;
1063 /// The specific output index funding this channel
1065 pub extern "C" fn FundingCreated_set_funding_output_index(this_ptr: &mut FundingCreated, mut val: u16) {
1066 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_index = val;
1068 /// The signature of the channel initiator (funder) on the initial commitment transaction
1070 pub extern "C" fn FundingCreated_get_signature(this_ptr: &FundingCreated) -> crate::c_types::Signature {
1071 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
1072 crate::c_types::Signature::from_rust(&inner_val)
1074 /// The signature of the channel initiator (funder) on the initial commitment transaction
1076 pub extern "C" fn FundingCreated_set_signature(this_ptr: &mut FundingCreated, mut val: crate::c_types::Signature) {
1077 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
1079 /// Constructs a new FundingCreated given each field
1082 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 {
1083 FundingCreated { inner: ObjOps::heap_alloc(nativeFundingCreated {
1084 temporary_channel_id: temporary_channel_id_arg.data,
1085 funding_txid: ::bitcoin::hash_types::Txid::from_slice(&funding_txid_arg.data[..]).unwrap(),
1086 funding_output_index: funding_output_index_arg,
1087 signature: signature_arg.into_rust(),
1088 }), is_owned: true }
1090 impl Clone for FundingCreated {
1091 fn clone(&self) -> Self {
1093 inner: if <*mut nativeFundingCreated>::is_null(self.inner) { std::ptr::null_mut() } else {
1094 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1100 /// Used only if an object of this type is returned as a trait impl by a method
1101 pub(crate) extern "C" fn FundingCreated_clone_void(this_ptr: *const c_void) -> *mut c_void {
1102 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingCreated)).clone() })) as *mut c_void
1105 /// Creates a copy of the FundingCreated
1106 pub extern "C" fn FundingCreated_clone(orig: &FundingCreated) -> FundingCreated {
1110 use lightning::ln::msgs::FundingSigned as nativeFundingSignedImport;
1111 pub(crate) type nativeFundingSigned = nativeFundingSignedImport;
1113 /// A funding_signed message to be sent or received from a peer
1116 pub struct FundingSigned {
1117 /// A pointer to the opaque Rust object.
1119 /// Nearly everywhere, inner must be non-null, however in places where
1120 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1121 pub inner: *mut nativeFundingSigned,
1122 /// Indicates that this is the only struct which contains the same pointer.
1124 /// Rust functions which take ownership of an object provided via an argument require
1125 /// this to be true and invalidate the object pointed to by inner.
1129 impl Drop for FundingSigned {
1130 fn drop(&mut self) {
1131 if self.is_owned && !<*mut nativeFundingSigned>::is_null(self.inner) {
1132 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1136 /// Frees any resources used by the FundingSigned, if is_owned is set and inner is non-NULL.
1138 pub extern "C" fn FundingSigned_free(this_obj: FundingSigned) { }
1140 /// Used only if an object of this type is returned as a trait impl by a method
1141 pub(crate) extern "C" fn FundingSigned_free_void(this_ptr: *mut c_void) {
1142 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingSigned); }
1145 impl FundingSigned {
1146 pub(crate) fn get_native_ref(&self) -> &'static nativeFundingSigned {
1147 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1149 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingSigned {
1150 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1152 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1153 pub(crate) fn take_inner(mut self) -> *mut nativeFundingSigned {
1154 assert!(self.is_owned);
1155 let ret = ObjOps::untweak_ptr(self.inner);
1156 self.inner = std::ptr::null_mut();
1162 pub extern "C" fn FundingSigned_get_channel_id(this_ptr: &FundingSigned) -> *const [u8; 32] {
1163 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1168 pub extern "C" fn FundingSigned_set_channel_id(this_ptr: &mut FundingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
1169 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1171 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
1173 pub extern "C" fn FundingSigned_get_signature(this_ptr: &FundingSigned) -> crate::c_types::Signature {
1174 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
1175 crate::c_types::Signature::from_rust(&inner_val)
1177 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
1179 pub extern "C" fn FundingSigned_set_signature(this_ptr: &mut FundingSigned, mut val: crate::c_types::Signature) {
1180 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
1182 /// Constructs a new FundingSigned given each field
1185 pub extern "C" fn FundingSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut signature_arg: crate::c_types::Signature) -> FundingSigned {
1186 FundingSigned { inner: ObjOps::heap_alloc(nativeFundingSigned {
1187 channel_id: channel_id_arg.data,
1188 signature: signature_arg.into_rust(),
1189 }), is_owned: true }
1191 impl Clone for FundingSigned {
1192 fn clone(&self) -> Self {
1194 inner: if <*mut nativeFundingSigned>::is_null(self.inner) { std::ptr::null_mut() } else {
1195 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1201 /// Used only if an object of this type is returned as a trait impl by a method
1202 pub(crate) extern "C" fn FundingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
1203 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingSigned)).clone() })) as *mut c_void
1206 /// Creates a copy of the FundingSigned
1207 pub extern "C" fn FundingSigned_clone(orig: &FundingSigned) -> FundingSigned {
1211 use lightning::ln::msgs::FundingLocked as nativeFundingLockedImport;
1212 pub(crate) type nativeFundingLocked = nativeFundingLockedImport;
1214 /// A funding_locked message to be sent or received from a peer
1217 pub struct FundingLocked {
1218 /// A pointer to the opaque Rust object.
1220 /// Nearly everywhere, inner must be non-null, however in places where
1221 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1222 pub inner: *mut nativeFundingLocked,
1223 /// Indicates that this is the only struct which contains the same pointer.
1225 /// Rust functions which take ownership of an object provided via an argument require
1226 /// this to be true and invalidate the object pointed to by inner.
1230 impl Drop for FundingLocked {
1231 fn drop(&mut self) {
1232 if self.is_owned && !<*mut nativeFundingLocked>::is_null(self.inner) {
1233 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1237 /// Frees any resources used by the FundingLocked, if is_owned is set and inner is non-NULL.
1239 pub extern "C" fn FundingLocked_free(this_obj: FundingLocked) { }
1241 /// Used only if an object of this type is returned as a trait impl by a method
1242 pub(crate) extern "C" fn FundingLocked_free_void(this_ptr: *mut c_void) {
1243 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingLocked); }
1246 impl FundingLocked {
1247 pub(crate) fn get_native_ref(&self) -> &'static nativeFundingLocked {
1248 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1250 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingLocked {
1251 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1253 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1254 pub(crate) fn take_inner(mut self) -> *mut nativeFundingLocked {
1255 assert!(self.is_owned);
1256 let ret = ObjOps::untweak_ptr(self.inner);
1257 self.inner = std::ptr::null_mut();
1263 pub extern "C" fn FundingLocked_get_channel_id(this_ptr: &FundingLocked) -> *const [u8; 32] {
1264 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1269 pub extern "C" fn FundingLocked_set_channel_id(this_ptr: &mut FundingLocked, mut val: crate::c_types::ThirtyTwoBytes) {
1270 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1272 /// The per-commitment point of the second commitment transaction
1274 pub extern "C" fn FundingLocked_get_next_per_commitment_point(this_ptr: &FundingLocked) -> crate::c_types::PublicKey {
1275 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
1276 crate::c_types::PublicKey::from_rust(&inner_val)
1278 /// The per-commitment point of the second commitment transaction
1280 pub extern "C" fn FundingLocked_set_next_per_commitment_point(this_ptr: &mut FundingLocked, mut val: crate::c_types::PublicKey) {
1281 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
1283 /// Constructs a new FundingLocked given each field
1286 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 {
1287 FundingLocked { inner: ObjOps::heap_alloc(nativeFundingLocked {
1288 channel_id: channel_id_arg.data,
1289 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
1290 }), is_owned: true }
1292 impl Clone for FundingLocked {
1293 fn clone(&self) -> Self {
1295 inner: if <*mut nativeFundingLocked>::is_null(self.inner) { std::ptr::null_mut() } else {
1296 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1302 /// Used only if an object of this type is returned as a trait impl by a method
1303 pub(crate) extern "C" fn FundingLocked_clone_void(this_ptr: *const c_void) -> *mut c_void {
1304 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingLocked)).clone() })) as *mut c_void
1307 /// Creates a copy of the FundingLocked
1308 pub extern "C" fn FundingLocked_clone(orig: &FundingLocked) -> FundingLocked {
1312 use lightning::ln::msgs::Shutdown as nativeShutdownImport;
1313 pub(crate) type nativeShutdown = nativeShutdownImport;
1315 /// A shutdown message to be sent or received from a peer
1318 pub struct Shutdown {
1319 /// A pointer to the opaque Rust object.
1321 /// Nearly everywhere, inner must be non-null, however in places where
1322 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1323 pub inner: *mut nativeShutdown,
1324 /// Indicates that this is the only struct which contains the same pointer.
1326 /// Rust functions which take ownership of an object provided via an argument require
1327 /// this to be true and invalidate the object pointed to by inner.
1331 impl Drop for Shutdown {
1332 fn drop(&mut self) {
1333 if self.is_owned && !<*mut nativeShutdown>::is_null(self.inner) {
1334 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1338 /// Frees any resources used by the Shutdown, if is_owned is set and inner is non-NULL.
1340 pub extern "C" fn Shutdown_free(this_obj: Shutdown) { }
1342 /// Used only if an object of this type is returned as a trait impl by a method
1343 pub(crate) extern "C" fn Shutdown_free_void(this_ptr: *mut c_void) {
1344 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeShutdown); }
1348 pub(crate) fn get_native_ref(&self) -> &'static nativeShutdown {
1349 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1351 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeShutdown {
1352 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1354 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1355 pub(crate) fn take_inner(mut self) -> *mut nativeShutdown {
1356 assert!(self.is_owned);
1357 let ret = ObjOps::untweak_ptr(self.inner);
1358 self.inner = std::ptr::null_mut();
1364 pub extern "C" fn Shutdown_get_channel_id(this_ptr: &Shutdown) -> *const [u8; 32] {
1365 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1370 pub extern "C" fn Shutdown_set_channel_id(this_ptr: &mut Shutdown, mut val: crate::c_types::ThirtyTwoBytes) {
1371 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1373 /// The destination of this peer's funds on closing.
1374 /// Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
1376 pub extern "C" fn Shutdown_get_scriptpubkey(this_ptr: &Shutdown) -> crate::c_types::u8slice {
1377 let mut inner_val = &mut this_ptr.get_native_mut_ref().scriptpubkey;
1378 crate::c_types::u8slice::from_slice(&inner_val[..])
1380 /// The destination of this peer's funds on closing.
1381 /// Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
1383 pub extern "C" fn Shutdown_set_scriptpubkey(this_ptr: &mut Shutdown, mut val: crate::c_types::derived::CVec_u8Z) {
1384 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.scriptpubkey = ::bitcoin::blockdata::script::Script::from(val.into_rust());
1386 /// Constructs a new Shutdown given each field
1389 pub extern "C" fn Shutdown_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut scriptpubkey_arg: crate::c_types::derived::CVec_u8Z) -> Shutdown {
1390 Shutdown { inner: ObjOps::heap_alloc(nativeShutdown {
1391 channel_id: channel_id_arg.data,
1392 scriptpubkey: ::bitcoin::blockdata::script::Script::from(scriptpubkey_arg.into_rust()),
1393 }), is_owned: true }
1395 impl Clone for Shutdown {
1396 fn clone(&self) -> Self {
1398 inner: if <*mut nativeShutdown>::is_null(self.inner) { std::ptr::null_mut() } else {
1399 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1405 /// Used only if an object of this type is returned as a trait impl by a method
1406 pub(crate) extern "C" fn Shutdown_clone_void(this_ptr: *const c_void) -> *mut c_void {
1407 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeShutdown)).clone() })) as *mut c_void
1410 /// Creates a copy of the Shutdown
1411 pub extern "C" fn Shutdown_clone(orig: &Shutdown) -> Shutdown {
1415 use lightning::ln::msgs::ClosingSignedFeeRange as nativeClosingSignedFeeRangeImport;
1416 pub(crate) type nativeClosingSignedFeeRange = nativeClosingSignedFeeRangeImport;
1418 /// The minimum and maximum fees which the sender is willing to place on the closing transaction.
1419 /// This is provided in [`ClosingSigned`] by both sides to indicate the fee range they are willing
1423 pub struct ClosingSignedFeeRange {
1424 /// A pointer to the opaque Rust object.
1426 /// Nearly everywhere, inner must be non-null, however in places where
1427 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1428 pub inner: *mut nativeClosingSignedFeeRange,
1429 /// Indicates that this is the only struct which contains the same pointer.
1431 /// Rust functions which take ownership of an object provided via an argument require
1432 /// this to be true and invalidate the object pointed to by inner.
1436 impl Drop for ClosingSignedFeeRange {
1437 fn drop(&mut self) {
1438 if self.is_owned && !<*mut nativeClosingSignedFeeRange>::is_null(self.inner) {
1439 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1443 /// Frees any resources used by the ClosingSignedFeeRange, if is_owned is set and inner is non-NULL.
1445 pub extern "C" fn ClosingSignedFeeRange_free(this_obj: ClosingSignedFeeRange) { }
1447 /// Used only if an object of this type is returned as a trait impl by a method
1448 pub(crate) extern "C" fn ClosingSignedFeeRange_free_void(this_ptr: *mut c_void) {
1449 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeClosingSignedFeeRange); }
1452 impl ClosingSignedFeeRange {
1453 pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSignedFeeRange {
1454 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1456 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSignedFeeRange {
1457 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1459 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1460 pub(crate) fn take_inner(mut self) -> *mut nativeClosingSignedFeeRange {
1461 assert!(self.is_owned);
1462 let ret = ObjOps::untweak_ptr(self.inner);
1463 self.inner = std::ptr::null_mut();
1467 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
1470 pub extern "C" fn ClosingSignedFeeRange_get_min_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
1471 let mut inner_val = &mut this_ptr.get_native_mut_ref().min_fee_satoshis;
1474 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
1477 pub extern "C" fn ClosingSignedFeeRange_set_min_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
1478 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_fee_satoshis = val;
1480 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
1483 pub extern "C" fn ClosingSignedFeeRange_get_max_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
1484 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_fee_satoshis;
1487 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
1490 pub extern "C" fn ClosingSignedFeeRange_set_max_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
1491 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_fee_satoshis = val;
1493 /// Constructs a new ClosingSignedFeeRange given each field
1496 pub extern "C" fn ClosingSignedFeeRange_new(mut min_fee_satoshis_arg: u64, mut max_fee_satoshis_arg: u64) -> ClosingSignedFeeRange {
1497 ClosingSignedFeeRange { inner: ObjOps::heap_alloc(nativeClosingSignedFeeRange {
1498 min_fee_satoshis: min_fee_satoshis_arg,
1499 max_fee_satoshis: max_fee_satoshis_arg,
1500 }), is_owned: true }
1502 impl Clone for ClosingSignedFeeRange {
1503 fn clone(&self) -> Self {
1505 inner: if <*mut nativeClosingSignedFeeRange>::is_null(self.inner) { std::ptr::null_mut() } else {
1506 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1512 /// Used only if an object of this type is returned as a trait impl by a method
1513 pub(crate) extern "C" fn ClosingSignedFeeRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
1514 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClosingSignedFeeRange)).clone() })) as *mut c_void
1517 /// Creates a copy of the ClosingSignedFeeRange
1518 pub extern "C" fn ClosingSignedFeeRange_clone(orig: &ClosingSignedFeeRange) -> ClosingSignedFeeRange {
1522 use lightning::ln::msgs::ClosingSigned as nativeClosingSignedImport;
1523 pub(crate) type nativeClosingSigned = nativeClosingSignedImport;
1525 /// A closing_signed message to be sent or received from a peer
1528 pub struct ClosingSigned {
1529 /// A pointer to the opaque Rust object.
1531 /// Nearly everywhere, inner must be non-null, however in places where
1532 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1533 pub inner: *mut nativeClosingSigned,
1534 /// Indicates that this is the only struct which contains the same pointer.
1536 /// Rust functions which take ownership of an object provided via an argument require
1537 /// this to be true and invalidate the object pointed to by inner.
1541 impl Drop for ClosingSigned {
1542 fn drop(&mut self) {
1543 if self.is_owned && !<*mut nativeClosingSigned>::is_null(self.inner) {
1544 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1548 /// Frees any resources used by the ClosingSigned, if is_owned is set and inner is non-NULL.
1550 pub extern "C" fn ClosingSigned_free(this_obj: ClosingSigned) { }
1552 /// Used only if an object of this type is returned as a trait impl by a method
1553 pub(crate) extern "C" fn ClosingSigned_free_void(this_ptr: *mut c_void) {
1554 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeClosingSigned); }
1557 impl ClosingSigned {
1558 pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSigned {
1559 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1561 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSigned {
1562 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1564 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1565 pub(crate) fn take_inner(mut self) -> *mut nativeClosingSigned {
1566 assert!(self.is_owned);
1567 let ret = ObjOps::untweak_ptr(self.inner);
1568 self.inner = std::ptr::null_mut();
1574 pub extern "C" fn ClosingSigned_get_channel_id(this_ptr: &ClosingSigned) -> *const [u8; 32] {
1575 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1580 pub extern "C" fn ClosingSigned_set_channel_id(this_ptr: &mut ClosingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
1581 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1583 /// The proposed total fee for the closing transaction
1585 pub extern "C" fn ClosingSigned_get_fee_satoshis(this_ptr: &ClosingSigned) -> u64 {
1586 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_satoshis;
1589 /// The proposed total fee for the closing transaction
1591 pub extern "C" fn ClosingSigned_set_fee_satoshis(this_ptr: &mut ClosingSigned, mut val: u64) {
1592 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_satoshis = val;
1594 /// A signature on the closing transaction
1596 pub extern "C" fn ClosingSigned_get_signature(this_ptr: &ClosingSigned) -> crate::c_types::Signature {
1597 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
1598 crate::c_types::Signature::from_rust(&inner_val)
1600 /// A signature on the closing transaction
1602 pub extern "C" fn ClosingSigned_set_signature(this_ptr: &mut ClosingSigned, mut val: crate::c_types::Signature) {
1603 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
1605 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
1608 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1610 pub extern "C" fn ClosingSigned_get_fee_range(this_ptr: &ClosingSigned) -> crate::lightning::ln::msgs::ClosingSignedFeeRange {
1611 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_range;
1612 let mut local_inner_val = crate::lightning::ln::msgs::ClosingSignedFeeRange { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::msgs::ClosingSignedFeeRange<>) as *mut _ }, is_owned: false };
1615 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
1618 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1620 pub extern "C" fn ClosingSigned_set_fee_range(this_ptr: &mut ClosingSigned, mut val: crate::lightning::ln::msgs::ClosingSignedFeeRange) {
1621 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1622 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_range = local_val;
1624 /// Constructs a new ClosingSigned given each field
1627 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 {
1628 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()) } }) };
1629 ClosingSigned { inner: ObjOps::heap_alloc(nativeClosingSigned {
1630 channel_id: channel_id_arg.data,
1631 fee_satoshis: fee_satoshis_arg,
1632 signature: signature_arg.into_rust(),
1633 fee_range: local_fee_range_arg,
1634 }), is_owned: true }
1636 impl Clone for ClosingSigned {
1637 fn clone(&self) -> Self {
1639 inner: if <*mut nativeClosingSigned>::is_null(self.inner) { std::ptr::null_mut() } else {
1640 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1646 /// Used only if an object of this type is returned as a trait impl by a method
1647 pub(crate) extern "C" fn ClosingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
1648 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClosingSigned)).clone() })) as *mut c_void
1651 /// Creates a copy of the ClosingSigned
1652 pub extern "C" fn ClosingSigned_clone(orig: &ClosingSigned) -> ClosingSigned {
1656 use lightning::ln::msgs::UpdateAddHTLC as nativeUpdateAddHTLCImport;
1657 pub(crate) type nativeUpdateAddHTLC = nativeUpdateAddHTLCImport;
1659 /// An update_add_htlc message to be sent or received from a peer
1662 pub struct UpdateAddHTLC {
1663 /// A pointer to the opaque Rust object.
1665 /// Nearly everywhere, inner must be non-null, however in places where
1666 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1667 pub inner: *mut nativeUpdateAddHTLC,
1668 /// Indicates that this is the only struct which contains the same pointer.
1670 /// Rust functions which take ownership of an object provided via an argument require
1671 /// this to be true and invalidate the object pointed to by inner.
1675 impl Drop for UpdateAddHTLC {
1676 fn drop(&mut self) {
1677 if self.is_owned && !<*mut nativeUpdateAddHTLC>::is_null(self.inner) {
1678 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1682 /// Frees any resources used by the UpdateAddHTLC, if is_owned is set and inner is non-NULL.
1684 pub extern "C" fn UpdateAddHTLC_free(this_obj: UpdateAddHTLC) { }
1686 /// Used only if an object of this type is returned as a trait impl by a method
1687 pub(crate) extern "C" fn UpdateAddHTLC_free_void(this_ptr: *mut c_void) {
1688 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateAddHTLC); }
1691 impl UpdateAddHTLC {
1692 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateAddHTLC {
1693 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1695 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateAddHTLC {
1696 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1698 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1699 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateAddHTLC {
1700 assert!(self.is_owned);
1701 let ret = ObjOps::untweak_ptr(self.inner);
1702 self.inner = std::ptr::null_mut();
1708 pub extern "C" fn UpdateAddHTLC_get_channel_id(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
1709 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1714 pub extern "C" fn UpdateAddHTLC_set_channel_id(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1715 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1719 pub extern "C" fn UpdateAddHTLC_get_htlc_id(this_ptr: &UpdateAddHTLC) -> u64 {
1720 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
1725 pub extern "C" fn UpdateAddHTLC_set_htlc_id(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
1726 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
1728 /// The HTLC value in milli-satoshi
1730 pub extern "C" fn UpdateAddHTLC_get_amount_msat(this_ptr: &UpdateAddHTLC) -> u64 {
1731 let mut inner_val = &mut this_ptr.get_native_mut_ref().amount_msat;
1734 /// The HTLC value in milli-satoshi
1736 pub extern "C" fn UpdateAddHTLC_set_amount_msat(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
1737 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.amount_msat = val;
1739 /// The payment hash, the pre-image of which controls HTLC redemption
1741 pub extern "C" fn UpdateAddHTLC_get_payment_hash(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
1742 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_hash;
1745 /// The payment hash, the pre-image of which controls HTLC redemption
1747 pub extern "C" fn UpdateAddHTLC_set_payment_hash(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1748 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_hash = ::lightning::ln::PaymentHash(val.data);
1750 /// The expiry height of the HTLC
1752 pub extern "C" fn UpdateAddHTLC_get_cltv_expiry(this_ptr: &UpdateAddHTLC) -> u32 {
1753 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry;
1756 /// The expiry height of the HTLC
1758 pub extern "C" fn UpdateAddHTLC_set_cltv_expiry(this_ptr: &mut UpdateAddHTLC, mut val: u32) {
1759 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry = val;
1761 impl Clone for UpdateAddHTLC {
1762 fn clone(&self) -> Self {
1764 inner: if <*mut nativeUpdateAddHTLC>::is_null(self.inner) { std::ptr::null_mut() } else {
1765 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1771 /// Used only if an object of this type is returned as a trait impl by a method
1772 pub(crate) extern "C" fn UpdateAddHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1773 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateAddHTLC)).clone() })) as *mut c_void
1776 /// Creates a copy of the UpdateAddHTLC
1777 pub extern "C" fn UpdateAddHTLC_clone(orig: &UpdateAddHTLC) -> UpdateAddHTLC {
1781 use lightning::ln::msgs::UpdateFulfillHTLC as nativeUpdateFulfillHTLCImport;
1782 pub(crate) type nativeUpdateFulfillHTLC = nativeUpdateFulfillHTLCImport;
1784 /// An update_fulfill_htlc message to be sent or received from a peer
1787 pub struct UpdateFulfillHTLC {
1788 /// A pointer to the opaque Rust object.
1790 /// Nearly everywhere, inner must be non-null, however in places where
1791 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1792 pub inner: *mut nativeUpdateFulfillHTLC,
1793 /// Indicates that this is the only struct which contains the same pointer.
1795 /// Rust functions which take ownership of an object provided via an argument require
1796 /// this to be true and invalidate the object pointed to by inner.
1800 impl Drop for UpdateFulfillHTLC {
1801 fn drop(&mut self) {
1802 if self.is_owned && !<*mut nativeUpdateFulfillHTLC>::is_null(self.inner) {
1803 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1807 /// Frees any resources used by the UpdateFulfillHTLC, if is_owned is set and inner is non-NULL.
1809 pub extern "C" fn UpdateFulfillHTLC_free(this_obj: UpdateFulfillHTLC) { }
1811 /// Used only if an object of this type is returned as a trait impl by a method
1812 pub(crate) extern "C" fn UpdateFulfillHTLC_free_void(this_ptr: *mut c_void) {
1813 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFulfillHTLC); }
1816 impl UpdateFulfillHTLC {
1817 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFulfillHTLC {
1818 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1820 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFulfillHTLC {
1821 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1823 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1824 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFulfillHTLC {
1825 assert!(self.is_owned);
1826 let ret = ObjOps::untweak_ptr(self.inner);
1827 self.inner = std::ptr::null_mut();
1833 pub extern "C" fn UpdateFulfillHTLC_get_channel_id(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
1834 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1839 pub extern "C" fn UpdateFulfillHTLC_set_channel_id(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1840 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1844 pub extern "C" fn UpdateFulfillHTLC_get_htlc_id(this_ptr: &UpdateFulfillHTLC) -> u64 {
1845 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
1850 pub extern "C" fn UpdateFulfillHTLC_set_htlc_id(this_ptr: &mut UpdateFulfillHTLC, mut val: u64) {
1851 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
1853 /// The pre-image of the payment hash, allowing HTLC redemption
1855 pub extern "C" fn UpdateFulfillHTLC_get_payment_preimage(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
1856 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_preimage;
1859 /// The pre-image of the payment hash, allowing HTLC redemption
1861 pub extern "C" fn UpdateFulfillHTLC_set_payment_preimage(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1862 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_preimage = ::lightning::ln::PaymentPreimage(val.data);
1864 /// Constructs a new UpdateFulfillHTLC given each field
1867 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 {
1868 UpdateFulfillHTLC { inner: ObjOps::heap_alloc(nativeUpdateFulfillHTLC {
1869 channel_id: channel_id_arg.data,
1870 htlc_id: htlc_id_arg,
1871 payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_arg.data),
1872 }), is_owned: true }
1874 impl Clone for UpdateFulfillHTLC {
1875 fn clone(&self) -> Self {
1877 inner: if <*mut nativeUpdateFulfillHTLC>::is_null(self.inner) { std::ptr::null_mut() } else {
1878 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1884 /// Used only if an object of this type is returned as a trait impl by a method
1885 pub(crate) extern "C" fn UpdateFulfillHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1886 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFulfillHTLC)).clone() })) as *mut c_void
1889 /// Creates a copy of the UpdateFulfillHTLC
1890 pub extern "C" fn UpdateFulfillHTLC_clone(orig: &UpdateFulfillHTLC) -> UpdateFulfillHTLC {
1894 use lightning::ln::msgs::UpdateFailHTLC as nativeUpdateFailHTLCImport;
1895 pub(crate) type nativeUpdateFailHTLC = nativeUpdateFailHTLCImport;
1897 /// An update_fail_htlc message to be sent or received from a peer
1900 pub struct UpdateFailHTLC {
1901 /// A pointer to the opaque Rust object.
1903 /// Nearly everywhere, inner must be non-null, however in places where
1904 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1905 pub inner: *mut nativeUpdateFailHTLC,
1906 /// Indicates that this is the only struct which contains the same pointer.
1908 /// Rust functions which take ownership of an object provided via an argument require
1909 /// this to be true and invalidate the object pointed to by inner.
1913 impl Drop for UpdateFailHTLC {
1914 fn drop(&mut self) {
1915 if self.is_owned && !<*mut nativeUpdateFailHTLC>::is_null(self.inner) {
1916 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1920 /// Frees any resources used by the UpdateFailHTLC, if is_owned is set and inner is non-NULL.
1922 pub extern "C" fn UpdateFailHTLC_free(this_obj: UpdateFailHTLC) { }
1924 /// Used only if an object of this type is returned as a trait impl by a method
1925 pub(crate) extern "C" fn UpdateFailHTLC_free_void(this_ptr: *mut c_void) {
1926 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFailHTLC); }
1929 impl UpdateFailHTLC {
1930 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailHTLC {
1931 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1933 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailHTLC {
1934 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1936 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1937 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailHTLC {
1938 assert!(self.is_owned);
1939 let ret = ObjOps::untweak_ptr(self.inner);
1940 self.inner = std::ptr::null_mut();
1946 pub extern "C" fn UpdateFailHTLC_get_channel_id(this_ptr: &UpdateFailHTLC) -> *const [u8; 32] {
1947 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1952 pub extern "C" fn UpdateFailHTLC_set_channel_id(this_ptr: &mut UpdateFailHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1953 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1957 pub extern "C" fn UpdateFailHTLC_get_htlc_id(this_ptr: &UpdateFailHTLC) -> u64 {
1958 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
1963 pub extern "C" fn UpdateFailHTLC_set_htlc_id(this_ptr: &mut UpdateFailHTLC, mut val: u64) {
1964 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
1966 impl Clone for UpdateFailHTLC {
1967 fn clone(&self) -> Self {
1969 inner: if <*mut nativeUpdateFailHTLC>::is_null(self.inner) { std::ptr::null_mut() } else {
1970 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1976 /// Used only if an object of this type is returned as a trait impl by a method
1977 pub(crate) extern "C" fn UpdateFailHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1978 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailHTLC)).clone() })) as *mut c_void
1981 /// Creates a copy of the UpdateFailHTLC
1982 pub extern "C" fn UpdateFailHTLC_clone(orig: &UpdateFailHTLC) -> UpdateFailHTLC {
1986 use lightning::ln::msgs::UpdateFailMalformedHTLC as nativeUpdateFailMalformedHTLCImport;
1987 pub(crate) type nativeUpdateFailMalformedHTLC = nativeUpdateFailMalformedHTLCImport;
1989 /// An update_fail_malformed_htlc message to be sent or received from a peer
1992 pub struct UpdateFailMalformedHTLC {
1993 /// A pointer to the opaque Rust object.
1995 /// Nearly everywhere, inner must be non-null, however in places where
1996 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1997 pub inner: *mut nativeUpdateFailMalformedHTLC,
1998 /// Indicates that this is the only struct which contains the same pointer.
2000 /// Rust functions which take ownership of an object provided via an argument require
2001 /// this to be true and invalidate the object pointed to by inner.
2005 impl Drop for UpdateFailMalformedHTLC {
2006 fn drop(&mut self) {
2007 if self.is_owned && !<*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) {
2008 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2012 /// Frees any resources used by the UpdateFailMalformedHTLC, if is_owned is set and inner is non-NULL.
2014 pub extern "C" fn UpdateFailMalformedHTLC_free(this_obj: UpdateFailMalformedHTLC) { }
2016 /// Used only if an object of this type is returned as a trait impl by a method
2017 pub(crate) extern "C" fn UpdateFailMalformedHTLC_free_void(this_ptr: *mut c_void) {
2018 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFailMalformedHTLC); }
2021 impl UpdateFailMalformedHTLC {
2022 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailMalformedHTLC {
2023 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2025 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailMalformedHTLC {
2026 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2028 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2029 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailMalformedHTLC {
2030 assert!(self.is_owned);
2031 let ret = ObjOps::untweak_ptr(self.inner);
2032 self.inner = std::ptr::null_mut();
2038 pub extern "C" fn UpdateFailMalformedHTLC_get_channel_id(this_ptr: &UpdateFailMalformedHTLC) -> *const [u8; 32] {
2039 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2044 pub extern "C" fn UpdateFailMalformedHTLC_set_channel_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
2045 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2049 pub extern "C" fn UpdateFailMalformedHTLC_get_htlc_id(this_ptr: &UpdateFailMalformedHTLC) -> u64 {
2050 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
2055 pub extern "C" fn UpdateFailMalformedHTLC_set_htlc_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u64) {
2056 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
2058 /// The failure code
2060 pub extern "C" fn UpdateFailMalformedHTLC_get_failure_code(this_ptr: &UpdateFailMalformedHTLC) -> u16 {
2061 let mut inner_val = &mut this_ptr.get_native_mut_ref().failure_code;
2064 /// The failure code
2066 pub extern "C" fn UpdateFailMalformedHTLC_set_failure_code(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u16) {
2067 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.failure_code = val;
2069 impl Clone for UpdateFailMalformedHTLC {
2070 fn clone(&self) -> Self {
2072 inner: if <*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) { std::ptr::null_mut() } else {
2073 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2079 /// Used only if an object of this type is returned as a trait impl by a method
2080 pub(crate) extern "C" fn UpdateFailMalformedHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
2081 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailMalformedHTLC)).clone() })) as *mut c_void
2084 /// Creates a copy of the UpdateFailMalformedHTLC
2085 pub extern "C" fn UpdateFailMalformedHTLC_clone(orig: &UpdateFailMalformedHTLC) -> UpdateFailMalformedHTLC {
2089 use lightning::ln::msgs::CommitmentSigned as nativeCommitmentSignedImport;
2090 pub(crate) type nativeCommitmentSigned = nativeCommitmentSignedImport;
2092 /// A commitment_signed message to be sent or received from a peer
2095 pub struct CommitmentSigned {
2096 /// A pointer to the opaque Rust object.
2098 /// Nearly everywhere, inner must be non-null, however in places where
2099 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2100 pub inner: *mut nativeCommitmentSigned,
2101 /// Indicates that this is the only struct which contains the same pointer.
2103 /// Rust functions which take ownership of an object provided via an argument require
2104 /// this to be true and invalidate the object pointed to by inner.
2108 impl Drop for CommitmentSigned {
2109 fn drop(&mut self) {
2110 if self.is_owned && !<*mut nativeCommitmentSigned>::is_null(self.inner) {
2111 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2115 /// Frees any resources used by the CommitmentSigned, if is_owned is set and inner is non-NULL.
2117 pub extern "C" fn CommitmentSigned_free(this_obj: CommitmentSigned) { }
2119 /// Used only if an object of this type is returned as a trait impl by a method
2120 pub(crate) extern "C" fn CommitmentSigned_free_void(this_ptr: *mut c_void) {
2121 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentSigned); }
2124 impl CommitmentSigned {
2125 pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentSigned {
2126 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2128 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentSigned {
2129 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2131 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2132 pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentSigned {
2133 assert!(self.is_owned);
2134 let ret = ObjOps::untweak_ptr(self.inner);
2135 self.inner = std::ptr::null_mut();
2141 pub extern "C" fn CommitmentSigned_get_channel_id(this_ptr: &CommitmentSigned) -> *const [u8; 32] {
2142 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2147 pub extern "C" fn CommitmentSigned_set_channel_id(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::ThirtyTwoBytes) {
2148 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2150 /// A signature on the commitment transaction
2152 pub extern "C" fn CommitmentSigned_get_signature(this_ptr: &CommitmentSigned) -> crate::c_types::Signature {
2153 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
2154 crate::c_types::Signature::from_rust(&inner_val)
2156 /// A signature on the commitment transaction
2158 pub extern "C" fn CommitmentSigned_set_signature(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::Signature) {
2159 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
2161 /// Signatures on the HTLC transactions
2163 pub extern "C" fn CommitmentSigned_set_htlc_signatures(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::derived::CVec_SignatureZ) {
2164 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_rust() }); };
2165 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_signatures = local_val;
2167 /// Constructs a new CommitmentSigned given each field
2170 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 {
2171 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() }); };
2172 CommitmentSigned { inner: ObjOps::heap_alloc(nativeCommitmentSigned {
2173 channel_id: channel_id_arg.data,
2174 signature: signature_arg.into_rust(),
2175 htlc_signatures: local_htlc_signatures_arg,
2176 }), is_owned: true }
2178 impl Clone for CommitmentSigned {
2179 fn clone(&self) -> Self {
2181 inner: if <*mut nativeCommitmentSigned>::is_null(self.inner) { std::ptr::null_mut() } else {
2182 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2188 /// Used only if an object of this type is returned as a trait impl by a method
2189 pub(crate) extern "C" fn CommitmentSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
2190 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentSigned)).clone() })) as *mut c_void
2193 /// Creates a copy of the CommitmentSigned
2194 pub extern "C" fn CommitmentSigned_clone(orig: &CommitmentSigned) -> CommitmentSigned {
2198 use lightning::ln::msgs::RevokeAndACK as nativeRevokeAndACKImport;
2199 pub(crate) type nativeRevokeAndACK = nativeRevokeAndACKImport;
2201 /// A revoke_and_ack message to be sent or received from a peer
2204 pub struct RevokeAndACK {
2205 /// A pointer to the opaque Rust object.
2207 /// Nearly everywhere, inner must be non-null, however in places where
2208 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2209 pub inner: *mut nativeRevokeAndACK,
2210 /// Indicates that this is the only struct which contains the same pointer.
2212 /// Rust functions which take ownership of an object provided via an argument require
2213 /// this to be true and invalidate the object pointed to by inner.
2217 impl Drop for RevokeAndACK {
2218 fn drop(&mut self) {
2219 if self.is_owned && !<*mut nativeRevokeAndACK>::is_null(self.inner) {
2220 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2224 /// Frees any resources used by the RevokeAndACK, if is_owned is set and inner is non-NULL.
2226 pub extern "C" fn RevokeAndACK_free(this_obj: RevokeAndACK) { }
2228 /// Used only if an object of this type is returned as a trait impl by a method
2229 pub(crate) extern "C" fn RevokeAndACK_free_void(this_ptr: *mut c_void) {
2230 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRevokeAndACK); }
2234 pub(crate) fn get_native_ref(&self) -> &'static nativeRevokeAndACK {
2235 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2237 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRevokeAndACK {
2238 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2240 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2241 pub(crate) fn take_inner(mut self) -> *mut nativeRevokeAndACK {
2242 assert!(self.is_owned);
2243 let ret = ObjOps::untweak_ptr(self.inner);
2244 self.inner = std::ptr::null_mut();
2250 pub extern "C" fn RevokeAndACK_get_channel_id(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
2251 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2256 pub extern "C" fn RevokeAndACK_set_channel_id(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
2257 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2259 /// The secret corresponding to the per-commitment point
2261 pub extern "C" fn RevokeAndACK_get_per_commitment_secret(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
2262 let mut inner_val = &mut this_ptr.get_native_mut_ref().per_commitment_secret;
2265 /// The secret corresponding to the per-commitment point
2267 pub extern "C" fn RevokeAndACK_set_per_commitment_secret(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
2268 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.per_commitment_secret = val.data;
2270 /// The next sender-broadcast commitment transaction's per-commitment point
2272 pub extern "C" fn RevokeAndACK_get_next_per_commitment_point(this_ptr: &RevokeAndACK) -> crate::c_types::PublicKey {
2273 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
2274 crate::c_types::PublicKey::from_rust(&inner_val)
2276 /// The next sender-broadcast commitment transaction's per-commitment point
2278 pub extern "C" fn RevokeAndACK_set_next_per_commitment_point(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::PublicKey) {
2279 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
2281 /// Constructs a new RevokeAndACK given each field
2284 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 {
2285 RevokeAndACK { inner: ObjOps::heap_alloc(nativeRevokeAndACK {
2286 channel_id: channel_id_arg.data,
2287 per_commitment_secret: per_commitment_secret_arg.data,
2288 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
2289 }), is_owned: true }
2291 impl Clone for RevokeAndACK {
2292 fn clone(&self) -> Self {
2294 inner: if <*mut nativeRevokeAndACK>::is_null(self.inner) { std::ptr::null_mut() } else {
2295 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2301 /// Used only if an object of this type is returned as a trait impl by a method
2302 pub(crate) extern "C" fn RevokeAndACK_clone_void(this_ptr: *const c_void) -> *mut c_void {
2303 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRevokeAndACK)).clone() })) as *mut c_void
2306 /// Creates a copy of the RevokeAndACK
2307 pub extern "C" fn RevokeAndACK_clone(orig: &RevokeAndACK) -> RevokeAndACK {
2311 use lightning::ln::msgs::UpdateFee as nativeUpdateFeeImport;
2312 pub(crate) type nativeUpdateFee = nativeUpdateFeeImport;
2314 /// An update_fee message to be sent or received from a peer
2317 pub struct UpdateFee {
2318 /// A pointer to the opaque Rust object.
2320 /// Nearly everywhere, inner must be non-null, however in places where
2321 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2322 pub inner: *mut nativeUpdateFee,
2323 /// Indicates that this is the only struct which contains the same pointer.
2325 /// Rust functions which take ownership of an object provided via an argument require
2326 /// this to be true and invalidate the object pointed to by inner.
2330 impl Drop for UpdateFee {
2331 fn drop(&mut self) {
2332 if self.is_owned && !<*mut nativeUpdateFee>::is_null(self.inner) {
2333 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2337 /// Frees any resources used by the UpdateFee, if is_owned is set and inner is non-NULL.
2339 pub extern "C" fn UpdateFee_free(this_obj: UpdateFee) { }
2341 /// Used only if an object of this type is returned as a trait impl by a method
2342 pub(crate) extern "C" fn UpdateFee_free_void(this_ptr: *mut c_void) {
2343 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFee); }
2347 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFee {
2348 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2350 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFee {
2351 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2353 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2354 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFee {
2355 assert!(self.is_owned);
2356 let ret = ObjOps::untweak_ptr(self.inner);
2357 self.inner = std::ptr::null_mut();
2363 pub extern "C" fn UpdateFee_get_channel_id(this_ptr: &UpdateFee) -> *const [u8; 32] {
2364 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2369 pub extern "C" fn UpdateFee_set_channel_id(this_ptr: &mut UpdateFee, mut val: crate::c_types::ThirtyTwoBytes) {
2370 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2372 /// Fee rate per 1000-weight of the transaction
2374 pub extern "C" fn UpdateFee_get_feerate_per_kw(this_ptr: &UpdateFee) -> u32 {
2375 let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
2378 /// Fee rate per 1000-weight of the transaction
2380 pub extern "C" fn UpdateFee_set_feerate_per_kw(this_ptr: &mut UpdateFee, mut val: u32) {
2381 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
2383 /// Constructs a new UpdateFee given each field
2386 pub extern "C" fn UpdateFee_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut feerate_per_kw_arg: u32) -> UpdateFee {
2387 UpdateFee { inner: ObjOps::heap_alloc(nativeUpdateFee {
2388 channel_id: channel_id_arg.data,
2389 feerate_per_kw: feerate_per_kw_arg,
2390 }), is_owned: true }
2392 impl Clone for UpdateFee {
2393 fn clone(&self) -> Self {
2395 inner: if <*mut nativeUpdateFee>::is_null(self.inner) { std::ptr::null_mut() } else {
2396 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2402 /// Used only if an object of this type is returned as a trait impl by a method
2403 pub(crate) extern "C" fn UpdateFee_clone_void(this_ptr: *const c_void) -> *mut c_void {
2404 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFee)).clone() })) as *mut c_void
2407 /// Creates a copy of the UpdateFee
2408 pub extern "C" fn UpdateFee_clone(orig: &UpdateFee) -> UpdateFee {
2412 use lightning::ln::msgs::DataLossProtect as nativeDataLossProtectImport;
2413 pub(crate) type nativeDataLossProtect = nativeDataLossProtectImport;
2415 /// Proof that the sender knows the per-commitment secret of the previous commitment transaction.
2416 /// This is used to convince the recipient that the channel is at a certain commitment
2417 /// number even if they lost that data due to a local failure. Of course, the peer may lie
2418 /// and even later commitments may have been revoked.
2421 pub struct DataLossProtect {
2422 /// A pointer to the opaque Rust object.
2424 /// Nearly everywhere, inner must be non-null, however in places where
2425 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2426 pub inner: *mut nativeDataLossProtect,
2427 /// Indicates that this is the only struct which contains the same pointer.
2429 /// Rust functions which take ownership of an object provided via an argument require
2430 /// this to be true and invalidate the object pointed to by inner.
2434 impl Drop for DataLossProtect {
2435 fn drop(&mut self) {
2436 if self.is_owned && !<*mut nativeDataLossProtect>::is_null(self.inner) {
2437 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2441 /// Frees any resources used by the DataLossProtect, if is_owned is set and inner is non-NULL.
2443 pub extern "C" fn DataLossProtect_free(this_obj: DataLossProtect) { }
2445 /// Used only if an object of this type is returned as a trait impl by a method
2446 pub(crate) extern "C" fn DataLossProtect_free_void(this_ptr: *mut c_void) {
2447 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDataLossProtect); }
2450 impl DataLossProtect {
2451 pub(crate) fn get_native_ref(&self) -> &'static nativeDataLossProtect {
2452 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2454 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeDataLossProtect {
2455 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2457 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2458 pub(crate) fn take_inner(mut self) -> *mut nativeDataLossProtect {
2459 assert!(self.is_owned);
2460 let ret = ObjOps::untweak_ptr(self.inner);
2461 self.inner = std::ptr::null_mut();
2465 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
2466 /// belonging to the recipient
2468 pub extern "C" fn DataLossProtect_get_your_last_per_commitment_secret(this_ptr: &DataLossProtect) -> *const [u8; 32] {
2469 let mut inner_val = &mut this_ptr.get_native_mut_ref().your_last_per_commitment_secret;
2472 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
2473 /// belonging to the recipient
2475 pub extern "C" fn DataLossProtect_set_your_last_per_commitment_secret(this_ptr: &mut DataLossProtect, mut val: crate::c_types::ThirtyTwoBytes) {
2476 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.your_last_per_commitment_secret = val.data;
2478 /// The sender's per-commitment point for their current commitment transaction
2480 pub extern "C" fn DataLossProtect_get_my_current_per_commitment_point(this_ptr: &DataLossProtect) -> crate::c_types::PublicKey {
2481 let mut inner_val = &mut this_ptr.get_native_mut_ref().my_current_per_commitment_point;
2482 crate::c_types::PublicKey::from_rust(&inner_val)
2484 /// The sender's per-commitment point for their current commitment transaction
2486 pub extern "C" fn DataLossProtect_set_my_current_per_commitment_point(this_ptr: &mut DataLossProtect, mut val: crate::c_types::PublicKey) {
2487 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.my_current_per_commitment_point = val.into_rust();
2489 /// Constructs a new DataLossProtect given each field
2492 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 {
2493 DataLossProtect { inner: ObjOps::heap_alloc(nativeDataLossProtect {
2494 your_last_per_commitment_secret: your_last_per_commitment_secret_arg.data,
2495 my_current_per_commitment_point: my_current_per_commitment_point_arg.into_rust(),
2496 }), is_owned: true }
2498 impl Clone for DataLossProtect {
2499 fn clone(&self) -> Self {
2501 inner: if <*mut nativeDataLossProtect>::is_null(self.inner) { std::ptr::null_mut() } else {
2502 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2508 /// Used only if an object of this type is returned as a trait impl by a method
2509 pub(crate) extern "C" fn DataLossProtect_clone_void(this_ptr: *const c_void) -> *mut c_void {
2510 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDataLossProtect)).clone() })) as *mut c_void
2513 /// Creates a copy of the DataLossProtect
2514 pub extern "C" fn DataLossProtect_clone(orig: &DataLossProtect) -> DataLossProtect {
2518 use lightning::ln::msgs::ChannelReestablish as nativeChannelReestablishImport;
2519 pub(crate) type nativeChannelReestablish = nativeChannelReestablishImport;
2521 /// A channel_reestablish message to be sent or received from a peer
2524 pub struct ChannelReestablish {
2525 /// A pointer to the opaque Rust object.
2527 /// Nearly everywhere, inner must be non-null, however in places where
2528 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2529 pub inner: *mut nativeChannelReestablish,
2530 /// Indicates that this is the only struct which contains the same pointer.
2532 /// Rust functions which take ownership of an object provided via an argument require
2533 /// this to be true and invalidate the object pointed to by inner.
2537 impl Drop for ChannelReestablish {
2538 fn drop(&mut self) {
2539 if self.is_owned && !<*mut nativeChannelReestablish>::is_null(self.inner) {
2540 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2544 /// Frees any resources used by the ChannelReestablish, if is_owned is set and inner is non-NULL.
2546 pub extern "C" fn ChannelReestablish_free(this_obj: ChannelReestablish) { }
2548 /// Used only if an object of this type is returned as a trait impl by a method
2549 pub(crate) extern "C" fn ChannelReestablish_free_void(this_ptr: *mut c_void) {
2550 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelReestablish); }
2553 impl ChannelReestablish {
2554 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelReestablish {
2555 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2557 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelReestablish {
2558 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2560 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2561 pub(crate) fn take_inner(mut self) -> *mut nativeChannelReestablish {
2562 assert!(self.is_owned);
2563 let ret = ObjOps::untweak_ptr(self.inner);
2564 self.inner = std::ptr::null_mut();
2570 pub extern "C" fn ChannelReestablish_get_channel_id(this_ptr: &ChannelReestablish) -> *const [u8; 32] {
2571 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2576 pub extern "C" fn ChannelReestablish_set_channel_id(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) {
2577 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2579 /// The next commitment number for the sender
2581 pub extern "C" fn ChannelReestablish_get_next_local_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
2582 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_local_commitment_number;
2585 /// The next commitment number for the sender
2587 pub extern "C" fn ChannelReestablish_set_next_local_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
2588 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_local_commitment_number = val;
2590 /// The next commitment number for the recipient
2592 pub extern "C" fn ChannelReestablish_get_next_remote_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
2593 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_remote_commitment_number;
2596 /// The next commitment number for the recipient
2598 pub extern "C" fn ChannelReestablish_set_next_remote_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
2599 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_remote_commitment_number = val;
2601 impl Clone for ChannelReestablish {
2602 fn clone(&self) -> Self {
2604 inner: if <*mut nativeChannelReestablish>::is_null(self.inner) { std::ptr::null_mut() } else {
2605 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2611 /// Used only if an object of this type is returned as a trait impl by a method
2612 pub(crate) extern "C" fn ChannelReestablish_clone_void(this_ptr: *const c_void) -> *mut c_void {
2613 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelReestablish)).clone() })) as *mut c_void
2616 /// Creates a copy of the ChannelReestablish
2617 pub extern "C" fn ChannelReestablish_clone(orig: &ChannelReestablish) -> ChannelReestablish {
2621 use lightning::ln::msgs::AnnouncementSignatures as nativeAnnouncementSignaturesImport;
2622 pub(crate) type nativeAnnouncementSignatures = nativeAnnouncementSignaturesImport;
2624 /// An announcement_signatures message to be sent or received from a peer
2627 pub struct AnnouncementSignatures {
2628 /// A pointer to the opaque Rust object.
2630 /// Nearly everywhere, inner must be non-null, however in places where
2631 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2632 pub inner: *mut nativeAnnouncementSignatures,
2633 /// Indicates that this is the only struct which contains the same pointer.
2635 /// Rust functions which take ownership of an object provided via an argument require
2636 /// this to be true and invalidate the object pointed to by inner.
2640 impl Drop for AnnouncementSignatures {
2641 fn drop(&mut self) {
2642 if self.is_owned && !<*mut nativeAnnouncementSignatures>::is_null(self.inner) {
2643 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2647 /// Frees any resources used by the AnnouncementSignatures, if is_owned is set and inner is non-NULL.
2649 pub extern "C" fn AnnouncementSignatures_free(this_obj: AnnouncementSignatures) { }
2651 /// Used only if an object of this type is returned as a trait impl by a method
2652 pub(crate) extern "C" fn AnnouncementSignatures_free_void(this_ptr: *mut c_void) {
2653 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeAnnouncementSignatures); }
2656 impl AnnouncementSignatures {
2657 pub(crate) fn get_native_ref(&self) -> &'static nativeAnnouncementSignatures {
2658 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2660 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAnnouncementSignatures {
2661 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2663 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2664 pub(crate) fn take_inner(mut self) -> *mut nativeAnnouncementSignatures {
2665 assert!(self.is_owned);
2666 let ret = ObjOps::untweak_ptr(self.inner);
2667 self.inner = std::ptr::null_mut();
2673 pub extern "C" fn AnnouncementSignatures_get_channel_id(this_ptr: &AnnouncementSignatures) -> *const [u8; 32] {
2674 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2679 pub extern "C" fn AnnouncementSignatures_set_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
2680 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2682 /// The short channel ID
2684 pub extern "C" fn AnnouncementSignatures_get_short_channel_id(this_ptr: &AnnouncementSignatures) -> u64 {
2685 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
2688 /// The short channel ID
2690 pub extern "C" fn AnnouncementSignatures_set_short_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: u64) {
2691 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
2693 /// A signature by the node key
2695 pub extern "C" fn AnnouncementSignatures_get_node_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
2696 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature;
2697 crate::c_types::Signature::from_rust(&inner_val)
2699 /// A signature by the node key
2701 pub extern "C" fn AnnouncementSignatures_set_node_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
2702 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature = val.into_rust();
2704 /// A signature by the funding key
2706 pub extern "C" fn AnnouncementSignatures_get_bitcoin_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
2707 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature;
2708 crate::c_types::Signature::from_rust(&inner_val)
2710 /// A signature by the funding key
2712 pub extern "C" fn AnnouncementSignatures_set_bitcoin_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
2713 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature = val.into_rust();
2715 /// Constructs a new AnnouncementSignatures given each field
2718 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 {
2719 AnnouncementSignatures { inner: ObjOps::heap_alloc(nativeAnnouncementSignatures {
2720 channel_id: channel_id_arg.data,
2721 short_channel_id: short_channel_id_arg,
2722 node_signature: node_signature_arg.into_rust(),
2723 bitcoin_signature: bitcoin_signature_arg.into_rust(),
2724 }), is_owned: true }
2726 impl Clone for AnnouncementSignatures {
2727 fn clone(&self) -> Self {
2729 inner: if <*mut nativeAnnouncementSignatures>::is_null(self.inner) { std::ptr::null_mut() } else {
2730 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2736 /// Used only if an object of this type is returned as a trait impl by a method
2737 pub(crate) extern "C" fn AnnouncementSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
2738 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAnnouncementSignatures)).clone() })) as *mut c_void
2741 /// Creates a copy of the AnnouncementSignatures
2742 pub extern "C" fn AnnouncementSignatures_clone(orig: &AnnouncementSignatures) -> AnnouncementSignatures {
2745 /// An address which can be used to connect to a remote peer
2749 pub enum NetAddress {
2750 /// An IPv4 address/port on which the peer is listening.
2752 /// The 4-byte IPv4 address
2753 addr: crate::c_types::FourBytes,
2754 /// The port on which the node is listening
2757 /// An IPv6 address/port on which the peer is listening.
2759 /// The 16-byte IPv6 address
2760 addr: crate::c_types::SixteenBytes,
2761 /// The port on which the node is listening
2764 /// An old-style Tor onion address/port on which the peer is listening.
2766 /// The bytes (usually encoded in base32 with \".onion\" appended)
2767 addr: crate::c_types::TenBytes,
2768 /// The port on which the node is listening
2771 /// A new-style Tor onion address/port on which the peer is listening.
2772 /// To create the human-readable \"hostname\", concatenate ed25519_pubkey, checksum, and version,
2773 /// wrap as base32 and append \".onion\".
2775 /// The ed25519 long-term public key of the peer
2776 ed25519_pubkey: crate::c_types::ThirtyTwoBytes,
2777 /// The checksum of the pubkey and version, as included in the onion address
2779 /// The version byte, as defined by the Tor Onion v3 spec.
2781 /// The port on which the node is listening
2785 use lightning::ln::msgs::NetAddress as nativeNetAddress;
2788 pub(crate) fn to_native(&self) -> nativeNetAddress {
2790 NetAddress::IPv4 {ref addr, ref port, } => {
2791 let mut addr_nonref = (*addr).clone();
2792 let mut port_nonref = (*port).clone();
2793 nativeNetAddress::IPv4 {
2794 addr: addr_nonref.data,
2798 NetAddress::IPv6 {ref addr, ref port, } => {
2799 let mut addr_nonref = (*addr).clone();
2800 let mut port_nonref = (*port).clone();
2801 nativeNetAddress::IPv6 {
2802 addr: addr_nonref.data,
2806 NetAddress::OnionV2 {ref addr, ref port, } => {
2807 let mut addr_nonref = (*addr).clone();
2808 let mut port_nonref = (*port).clone();
2809 nativeNetAddress::OnionV2 {
2810 addr: addr_nonref.data,
2814 NetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
2815 let mut ed25519_pubkey_nonref = (*ed25519_pubkey).clone();
2816 let mut checksum_nonref = (*checksum).clone();
2817 let mut version_nonref = (*version).clone();
2818 let mut port_nonref = (*port).clone();
2819 nativeNetAddress::OnionV3 {
2820 ed25519_pubkey: ed25519_pubkey_nonref.data,
2821 checksum: checksum_nonref,
2822 version: version_nonref,
2829 pub(crate) fn into_native(self) -> nativeNetAddress {
2831 NetAddress::IPv4 {mut addr, mut port, } => {
2832 nativeNetAddress::IPv4 {
2837 NetAddress::IPv6 {mut addr, mut port, } => {
2838 nativeNetAddress::IPv6 {
2843 NetAddress::OnionV2 {mut addr, mut port, } => {
2844 nativeNetAddress::OnionV2 {
2849 NetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
2850 nativeNetAddress::OnionV3 {
2851 ed25519_pubkey: ed25519_pubkey.data,
2860 pub(crate) fn from_native(native: &nativeNetAddress) -> Self {
2862 nativeNetAddress::IPv4 {ref addr, ref port, } => {
2863 let mut addr_nonref = (*addr).clone();
2864 let mut port_nonref = (*port).clone();
2866 addr: crate::c_types::FourBytes { data: addr_nonref },
2870 nativeNetAddress::IPv6 {ref addr, ref port, } => {
2871 let mut addr_nonref = (*addr).clone();
2872 let mut port_nonref = (*port).clone();
2874 addr: crate::c_types::SixteenBytes { data: addr_nonref },
2878 nativeNetAddress::OnionV2 {ref addr, ref port, } => {
2879 let mut addr_nonref = (*addr).clone();
2880 let mut port_nonref = (*port).clone();
2881 NetAddress::OnionV2 {
2882 addr: crate::c_types::TenBytes { data: addr_nonref },
2886 nativeNetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
2887 let mut ed25519_pubkey_nonref = (*ed25519_pubkey).clone();
2888 let mut checksum_nonref = (*checksum).clone();
2889 let mut version_nonref = (*version).clone();
2890 let mut port_nonref = (*port).clone();
2891 NetAddress::OnionV3 {
2892 ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey_nonref },
2893 checksum: checksum_nonref,
2894 version: version_nonref,
2901 pub(crate) fn native_into(native: nativeNetAddress) -> Self {
2903 nativeNetAddress::IPv4 {mut addr, mut port, } => {
2905 addr: crate::c_types::FourBytes { data: addr },
2909 nativeNetAddress::IPv6 {mut addr, mut port, } => {
2911 addr: crate::c_types::SixteenBytes { data: addr },
2915 nativeNetAddress::OnionV2 {mut addr, mut port, } => {
2916 NetAddress::OnionV2 {
2917 addr: crate::c_types::TenBytes { data: addr },
2921 nativeNetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
2922 NetAddress::OnionV3 {
2923 ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey },
2932 /// Frees any resources used by the NetAddress
2934 pub extern "C" fn NetAddress_free(this_ptr: NetAddress) { }
2935 /// Creates a copy of the NetAddress
2937 pub extern "C" fn NetAddress_clone(orig: &NetAddress) -> NetAddress {
2941 /// Utility method to constructs a new IPv4-variant NetAddress
2942 pub extern "C" fn NetAddress_ipv4(addr: crate::c_types::FourBytes, port: u16) -> NetAddress {
2949 /// Utility method to constructs a new IPv6-variant NetAddress
2950 pub extern "C" fn NetAddress_ipv6(addr: crate::c_types::SixteenBytes, port: u16) -> NetAddress {
2957 /// Utility method to constructs a new OnionV2-variant NetAddress
2958 pub extern "C" fn NetAddress_onion_v2(addr: crate::c_types::TenBytes, port: u16) -> NetAddress {
2959 NetAddress::OnionV2 {
2965 /// Utility method to constructs a new OnionV3-variant NetAddress
2966 pub extern "C" fn NetAddress_onion_v3(ed25519_pubkey: crate::c_types::ThirtyTwoBytes, checksum: u16, version: u8, port: u16) -> NetAddress {
2967 NetAddress::OnionV3 {
2975 /// Serialize the NetAddress object into a byte array which can be read by NetAddress_read
2976 pub extern "C" fn NetAddress_write(obj: &NetAddress) -> crate::c_types::derived::CVec_u8Z {
2977 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
2980 /// Read a NetAddress from a byte array, created by NetAddress_write
2981 pub extern "C" fn NetAddress_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NetAddressDecodeErrorZ {
2982 let res = crate::c_types::deserialize_obj(ser);
2983 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() };
2987 use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport;
2988 pub(crate) type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport;
2990 /// The unsigned part of a node_announcement
2993 pub struct UnsignedNodeAnnouncement {
2994 /// A pointer to the opaque Rust object.
2996 /// Nearly everywhere, inner must be non-null, however in places where
2997 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2998 pub inner: *mut nativeUnsignedNodeAnnouncement,
2999 /// Indicates that this is the only struct which contains the same pointer.
3001 /// Rust functions which take ownership of an object provided via an argument require
3002 /// this to be true and invalidate the object pointed to by inner.
3006 impl Drop for UnsignedNodeAnnouncement {
3007 fn drop(&mut self) {
3008 if self.is_owned && !<*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) {
3009 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3013 /// Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL.
3015 pub extern "C" fn UnsignedNodeAnnouncement_free(this_obj: UnsignedNodeAnnouncement) { }
3017 /// Used only if an object of this type is returned as a trait impl by a method
3018 pub(crate) extern "C" fn UnsignedNodeAnnouncement_free_void(this_ptr: *mut c_void) {
3019 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedNodeAnnouncement); }
3022 impl UnsignedNodeAnnouncement {
3023 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedNodeAnnouncement {
3024 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3026 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedNodeAnnouncement {
3027 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3029 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3030 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedNodeAnnouncement {
3031 assert!(self.is_owned);
3032 let ret = ObjOps::untweak_ptr(self.inner);
3033 self.inner = std::ptr::null_mut();
3037 /// The advertised features
3039 pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::ln::features::NodeFeatures {
3040 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
3041 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 }
3043 /// The advertised features
3045 pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::ln::features::NodeFeatures) {
3046 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
3048 /// A strictly monotonic announcement counter, with gaps allowed
3050 pub extern "C" fn UnsignedNodeAnnouncement_get_timestamp(this_ptr: &UnsignedNodeAnnouncement) -> u32 {
3051 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
3054 /// A strictly monotonic announcement counter, with gaps allowed
3056 pub extern "C" fn UnsignedNodeAnnouncement_set_timestamp(this_ptr: &mut UnsignedNodeAnnouncement, mut val: u32) {
3057 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
3059 /// The node_id this announcement originated from (don't rebroadcast the node_announcement back
3062 pub extern "C" fn UnsignedNodeAnnouncement_get_node_id(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::PublicKey {
3063 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id;
3064 crate::c_types::PublicKey::from_rust(&inner_val)
3066 /// The node_id this announcement originated from (don't rebroadcast the node_announcement back
3069 pub extern "C" fn UnsignedNodeAnnouncement_set_node_id(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::PublicKey) {
3070 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id = val.into_rust();
3072 /// An RGB color for UI purposes
3074 pub extern "C" fn UnsignedNodeAnnouncement_get_rgb(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 3] {
3075 let mut inner_val = &mut this_ptr.get_native_mut_ref().rgb;
3078 /// An RGB color for UI purposes
3080 pub extern "C" fn UnsignedNodeAnnouncement_set_rgb(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThreeBytes) {
3081 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.rgb = val.data;
3083 /// An alias, for UI purposes. This should be sanitized before use. There is no guarantee
3086 pub extern "C" fn UnsignedNodeAnnouncement_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 32] {
3087 let mut inner_val = &mut this_ptr.get_native_mut_ref().alias;
3090 /// An alias, for UI purposes. This should be sanitized before use. There is no guarantee
3093 pub extern "C" fn UnsignedNodeAnnouncement_set_alias(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
3094 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.alias = val.data;
3096 /// List of addresses on which this node is reachable
3098 pub extern "C" fn UnsignedNodeAnnouncement_set_addresses(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_NetAddressZ) {
3099 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
3100 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.addresses = local_val;
3102 impl Clone for UnsignedNodeAnnouncement {
3103 fn clone(&self) -> Self {
3105 inner: if <*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else {
3106 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3112 /// Used only if an object of this type is returned as a trait impl by a method
3113 pub(crate) extern "C" fn UnsignedNodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3114 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedNodeAnnouncement)).clone() })) as *mut c_void
3117 /// Creates a copy of the UnsignedNodeAnnouncement
3118 pub extern "C" fn UnsignedNodeAnnouncement_clone(orig: &UnsignedNodeAnnouncement) -> UnsignedNodeAnnouncement {
3122 use lightning::ln::msgs::NodeAnnouncement as nativeNodeAnnouncementImport;
3123 pub(crate) type nativeNodeAnnouncement = nativeNodeAnnouncementImport;
3125 /// A node_announcement message to be sent or received from a peer
3128 pub struct NodeAnnouncement {
3129 /// A pointer to the opaque Rust object.
3131 /// Nearly everywhere, inner must be non-null, however in places where
3132 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3133 pub inner: *mut nativeNodeAnnouncement,
3134 /// Indicates that this is the only struct which contains the same pointer.
3136 /// Rust functions which take ownership of an object provided via an argument require
3137 /// this to be true and invalidate the object pointed to by inner.
3141 impl Drop for NodeAnnouncement {
3142 fn drop(&mut self) {
3143 if self.is_owned && !<*mut nativeNodeAnnouncement>::is_null(self.inner) {
3144 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3148 /// Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL.
3150 pub extern "C" fn NodeAnnouncement_free(this_obj: NodeAnnouncement) { }
3152 /// Used only if an object of this type is returned as a trait impl by a method
3153 pub(crate) extern "C" fn NodeAnnouncement_free_void(this_ptr: *mut c_void) {
3154 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeAnnouncement); }
3157 impl NodeAnnouncement {
3158 pub(crate) fn get_native_ref(&self) -> &'static nativeNodeAnnouncement {
3159 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3161 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeAnnouncement {
3162 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3164 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3165 pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncement {
3166 assert!(self.is_owned);
3167 let ret = ObjOps::untweak_ptr(self.inner);
3168 self.inner = std::ptr::null_mut();
3172 /// The signature by the node key
3174 pub extern "C" fn NodeAnnouncement_get_signature(this_ptr: &NodeAnnouncement) -> crate::c_types::Signature {
3175 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
3176 crate::c_types::Signature::from_rust(&inner_val)
3178 /// The signature by the node key
3180 pub extern "C" fn NodeAnnouncement_set_signature(this_ptr: &mut NodeAnnouncement, mut val: crate::c_types::Signature) {
3181 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
3183 /// The actual content of the announcement
3185 pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> crate::lightning::ln::msgs::UnsignedNodeAnnouncement {
3186 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
3187 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 }
3189 /// The actual content of the announcement
3191 pub extern "C" fn NodeAnnouncement_set_contents(this_ptr: &mut NodeAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) {
3192 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
3194 /// Constructs a new NodeAnnouncement given each field
3197 pub extern "C" fn NodeAnnouncement_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> NodeAnnouncement {
3198 NodeAnnouncement { inner: ObjOps::heap_alloc(nativeNodeAnnouncement {
3199 signature: signature_arg.into_rust(),
3200 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
3201 }), is_owned: true }
3203 impl Clone for NodeAnnouncement {
3204 fn clone(&self) -> Self {
3206 inner: if <*mut nativeNodeAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else {
3207 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3213 /// Used only if an object of this type is returned as a trait impl by a method
3214 pub(crate) extern "C" fn NodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3215 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeAnnouncement)).clone() })) as *mut c_void
3218 /// Creates a copy of the NodeAnnouncement
3219 pub extern "C" fn NodeAnnouncement_clone(orig: &NodeAnnouncement) -> NodeAnnouncement {
3223 use lightning::ln::msgs::UnsignedChannelAnnouncement as nativeUnsignedChannelAnnouncementImport;
3224 pub(crate) type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport;
3226 /// The unsigned part of a channel_announcement
3229 pub struct UnsignedChannelAnnouncement {
3230 /// A pointer to the opaque Rust object.
3232 /// Nearly everywhere, inner must be non-null, however in places where
3233 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3234 pub inner: *mut nativeUnsignedChannelAnnouncement,
3235 /// Indicates that this is the only struct which contains the same pointer.
3237 /// Rust functions which take ownership of an object provided via an argument require
3238 /// this to be true and invalidate the object pointed to by inner.
3242 impl Drop for UnsignedChannelAnnouncement {
3243 fn drop(&mut self) {
3244 if self.is_owned && !<*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) {
3245 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3249 /// Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL.
3251 pub extern "C" fn UnsignedChannelAnnouncement_free(this_obj: UnsignedChannelAnnouncement) { }
3253 /// Used only if an object of this type is returned as a trait impl by a method
3254 pub(crate) extern "C" fn UnsignedChannelAnnouncement_free_void(this_ptr: *mut c_void) {
3255 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelAnnouncement); }
3258 impl UnsignedChannelAnnouncement {
3259 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelAnnouncement {
3260 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3262 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelAnnouncement {
3263 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3265 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3266 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelAnnouncement {
3267 assert!(self.is_owned);
3268 let ret = ObjOps::untweak_ptr(self.inner);
3269 self.inner = std::ptr::null_mut();
3273 /// The advertised channel features
3275 pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::ln::features::ChannelFeatures {
3276 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
3277 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 }
3279 /// The advertised channel features
3281 pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::ln::features::ChannelFeatures) {
3282 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
3284 /// The genesis hash of the blockchain where the channel is to be opened
3286 pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &UnsignedChannelAnnouncement) -> *const [u8; 32] {
3287 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
3288 inner_val.as_inner()
3290 /// The genesis hash of the blockchain where the channel is to be opened
3292 pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
3293 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3295 /// The short channel ID
3297 pub extern "C" fn UnsignedChannelAnnouncement_get_short_channel_id(this_ptr: &UnsignedChannelAnnouncement) -> u64 {
3298 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
3301 /// The short channel ID
3303 pub extern "C" fn UnsignedChannelAnnouncement_set_short_channel_id(this_ptr: &mut UnsignedChannelAnnouncement, mut val: u64) {
3304 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
3306 /// One of the two node_ids which are endpoints of this channel
3308 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3309 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_1;
3310 crate::c_types::PublicKey::from_rust(&inner_val)
3312 /// One of the two node_ids which are endpoints of this channel
3314 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3315 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_1 = val.into_rust();
3317 /// The other of the two node_ids which are endpoints of this channel
3319 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3320 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_2;
3321 crate::c_types::PublicKey::from_rust(&inner_val)
3323 /// The other of the two node_ids which are endpoints of this channel
3325 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3326 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_2 = val.into_rust();
3328 /// The funding key for the first node
3330 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3331 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_1;
3332 crate::c_types::PublicKey::from_rust(&inner_val)
3334 /// The funding key for the first node
3336 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3337 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_1 = val.into_rust();
3339 /// The funding key for the second node
3341 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3342 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_2;
3343 crate::c_types::PublicKey::from_rust(&inner_val)
3345 /// The funding key for the second node
3347 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3348 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_2 = val.into_rust();
3350 impl Clone for UnsignedChannelAnnouncement {
3351 fn clone(&self) -> Self {
3353 inner: if <*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else {
3354 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3360 /// Used only if an object of this type is returned as a trait impl by a method
3361 pub(crate) extern "C" fn UnsignedChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3362 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelAnnouncement)).clone() })) as *mut c_void
3365 /// Creates a copy of the UnsignedChannelAnnouncement
3366 pub extern "C" fn UnsignedChannelAnnouncement_clone(orig: &UnsignedChannelAnnouncement) -> UnsignedChannelAnnouncement {
3370 use lightning::ln::msgs::ChannelAnnouncement as nativeChannelAnnouncementImport;
3371 pub(crate) type nativeChannelAnnouncement = nativeChannelAnnouncementImport;
3373 /// A channel_announcement message to be sent or received from a peer
3376 pub struct ChannelAnnouncement {
3377 /// A pointer to the opaque Rust object.
3379 /// Nearly everywhere, inner must be non-null, however in places where
3380 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3381 pub inner: *mut nativeChannelAnnouncement,
3382 /// Indicates that this is the only struct which contains the same pointer.
3384 /// Rust functions which take ownership of an object provided via an argument require
3385 /// this to be true and invalidate the object pointed to by inner.
3389 impl Drop for ChannelAnnouncement {
3390 fn drop(&mut self) {
3391 if self.is_owned && !<*mut nativeChannelAnnouncement>::is_null(self.inner) {
3392 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3396 /// Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL.
3398 pub extern "C" fn ChannelAnnouncement_free(this_obj: ChannelAnnouncement) { }
3400 /// Used only if an object of this type is returned as a trait impl by a method
3401 pub(crate) extern "C" fn ChannelAnnouncement_free_void(this_ptr: *mut c_void) {
3402 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelAnnouncement); }
3405 impl ChannelAnnouncement {
3406 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelAnnouncement {
3407 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3409 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelAnnouncement {
3410 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3412 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3413 pub(crate) fn take_inner(mut self) -> *mut nativeChannelAnnouncement {
3414 assert!(self.is_owned);
3415 let ret = ObjOps::untweak_ptr(self.inner);
3416 self.inner = std::ptr::null_mut();
3420 /// Authentication of the announcement by the first public node
3422 pub extern "C" fn ChannelAnnouncement_get_node_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3423 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_1;
3424 crate::c_types::Signature::from_rust(&inner_val)
3426 /// Authentication of the announcement by the first public node
3428 pub extern "C" fn ChannelAnnouncement_set_node_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3429 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_1 = val.into_rust();
3431 /// Authentication of the announcement by the second public node
3433 pub extern "C" fn ChannelAnnouncement_get_node_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3434 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_2;
3435 crate::c_types::Signature::from_rust(&inner_val)
3437 /// Authentication of the announcement by the second public node
3439 pub extern "C" fn ChannelAnnouncement_set_node_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3440 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_2 = val.into_rust();
3442 /// Proof of funding UTXO ownership by the first public node
3444 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3445 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_1;
3446 crate::c_types::Signature::from_rust(&inner_val)
3448 /// Proof of funding UTXO ownership by the first public node
3450 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3451 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_1 = val.into_rust();
3453 /// Proof of funding UTXO ownership by the second public node
3455 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3456 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_2;
3457 crate::c_types::Signature::from_rust(&inner_val)
3459 /// Proof of funding UTXO ownership by the second public node
3461 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3462 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_2 = val.into_rust();
3464 /// The actual announcement
3466 pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncement) -> crate::lightning::ln::msgs::UnsignedChannelAnnouncement {
3467 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
3468 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 }
3470 /// The actual announcement
3472 pub extern "C" fn ChannelAnnouncement_set_contents(this_ptr: &mut ChannelAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) {
3473 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
3475 /// Constructs a new ChannelAnnouncement given each field
3478 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 {
3479 ChannelAnnouncement { inner: ObjOps::heap_alloc(nativeChannelAnnouncement {
3480 node_signature_1: node_signature_1_arg.into_rust(),
3481 node_signature_2: node_signature_2_arg.into_rust(),
3482 bitcoin_signature_1: bitcoin_signature_1_arg.into_rust(),
3483 bitcoin_signature_2: bitcoin_signature_2_arg.into_rust(),
3484 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
3485 }), is_owned: true }
3487 impl Clone for ChannelAnnouncement {
3488 fn clone(&self) -> Self {
3490 inner: if <*mut nativeChannelAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else {
3491 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3497 /// Used only if an object of this type is returned as a trait impl by a method
3498 pub(crate) extern "C" fn ChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3499 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelAnnouncement)).clone() })) as *mut c_void
3502 /// Creates a copy of the ChannelAnnouncement
3503 pub extern "C" fn ChannelAnnouncement_clone(orig: &ChannelAnnouncement) -> ChannelAnnouncement {
3507 use lightning::ln::msgs::UnsignedChannelUpdate as nativeUnsignedChannelUpdateImport;
3508 pub(crate) type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport;
3510 /// The unsigned part of a channel_update
3513 pub struct UnsignedChannelUpdate {
3514 /// A pointer to the opaque Rust object.
3516 /// Nearly everywhere, inner must be non-null, however in places where
3517 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3518 pub inner: *mut nativeUnsignedChannelUpdate,
3519 /// Indicates that this is the only struct which contains the same pointer.
3521 /// Rust functions which take ownership of an object provided via an argument require
3522 /// this to be true and invalidate the object pointed to by inner.
3526 impl Drop for UnsignedChannelUpdate {
3527 fn drop(&mut self) {
3528 if self.is_owned && !<*mut nativeUnsignedChannelUpdate>::is_null(self.inner) {
3529 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3533 /// Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL.
3535 pub extern "C" fn UnsignedChannelUpdate_free(this_obj: UnsignedChannelUpdate) { }
3537 /// Used only if an object of this type is returned as a trait impl by a method
3538 pub(crate) extern "C" fn UnsignedChannelUpdate_free_void(this_ptr: *mut c_void) {
3539 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelUpdate); }
3542 impl UnsignedChannelUpdate {
3543 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelUpdate {
3544 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3546 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelUpdate {
3547 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3549 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3550 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelUpdate {
3551 assert!(self.is_owned);
3552 let ret = ObjOps::untweak_ptr(self.inner);
3553 self.inner = std::ptr::null_mut();
3557 /// The genesis hash of the blockchain where the channel is to be opened
3559 pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChannelUpdate) -> *const [u8; 32] {
3560 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
3561 inner_val.as_inner()
3563 /// The genesis hash of the blockchain where the channel is to be opened
3565 pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::ThirtyTwoBytes) {
3566 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3568 /// The short channel ID
3570 pub extern "C" fn UnsignedChannelUpdate_get_short_channel_id(this_ptr: &UnsignedChannelUpdate) -> u64 {
3571 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
3574 /// The short channel ID
3576 pub extern "C" fn UnsignedChannelUpdate_set_short_channel_id(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
3577 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
3579 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
3581 pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannelUpdate) -> u32 {
3582 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
3585 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
3587 pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3588 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
3592 pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 {
3593 let mut inner_val = &mut this_ptr.get_native_mut_ref().flags;
3598 pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) {
3599 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.flags = val;
3601 /// The number of blocks such that if:
3602 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
3603 /// then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines
3604 /// the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a
3605 /// cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10,
3606 /// then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before
3607 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
3608 /// constructing the route.
3610 pub extern "C" fn UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr: &UnsignedChannelUpdate) -> u16 {
3611 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
3614 /// The number of blocks such that if:
3615 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
3616 /// then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines
3617 /// the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a
3618 /// cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10,
3619 /// then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before
3620 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
3621 /// constructing the route.
3623 pub extern "C" fn UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr: &mut UnsignedChannelUpdate, mut val: u16) {
3624 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
3626 /// The minimum HTLC size incoming to sender, in milli-satoshi
3628 pub extern "C" fn UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
3629 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
3632 /// The minimum HTLC size incoming to sender, in milli-satoshi
3634 pub extern "C" fn UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
3635 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
3637 /// The base HTLC fee charged by sender, in milli-satoshi
3639 pub extern "C" fn UnsignedChannelUpdate_get_fee_base_msat(this_ptr: &UnsignedChannelUpdate) -> u32 {
3640 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat;
3643 /// The base HTLC fee charged by sender, in milli-satoshi
3645 pub extern "C" fn UnsignedChannelUpdate_set_fee_base_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3646 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val;
3648 /// The amount to fee multiplier, in micro-satoshi
3650 pub extern "C" fn UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr: &UnsignedChannelUpdate) -> u32 {
3651 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths;
3654 /// The amount to fee multiplier, in micro-satoshi
3656 pub extern "C" fn UnsignedChannelUpdate_set_fee_proportional_millionths(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3657 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val;
3659 impl Clone for UnsignedChannelUpdate {
3660 fn clone(&self) -> Self {
3662 inner: if <*mut nativeUnsignedChannelUpdate>::is_null(self.inner) { std::ptr::null_mut() } else {
3663 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3669 /// Used only if an object of this type is returned as a trait impl by a method
3670 pub(crate) extern "C" fn UnsignedChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
3671 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelUpdate)).clone() })) as *mut c_void
3674 /// Creates a copy of the UnsignedChannelUpdate
3675 pub extern "C" fn UnsignedChannelUpdate_clone(orig: &UnsignedChannelUpdate) -> UnsignedChannelUpdate {
3679 use lightning::ln::msgs::ChannelUpdate as nativeChannelUpdateImport;
3680 pub(crate) type nativeChannelUpdate = nativeChannelUpdateImport;
3682 /// A channel_update message to be sent or received from a peer
3685 pub struct ChannelUpdate {
3686 /// A pointer to the opaque Rust object.
3688 /// Nearly everywhere, inner must be non-null, however in places where
3689 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3690 pub inner: *mut nativeChannelUpdate,
3691 /// Indicates that this is the only struct which contains the same pointer.
3693 /// Rust functions which take ownership of an object provided via an argument require
3694 /// this to be true and invalidate the object pointed to by inner.
3698 impl Drop for ChannelUpdate {
3699 fn drop(&mut self) {
3700 if self.is_owned && !<*mut nativeChannelUpdate>::is_null(self.inner) {
3701 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3705 /// Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL.
3707 pub extern "C" fn ChannelUpdate_free(this_obj: ChannelUpdate) { }
3709 /// Used only if an object of this type is returned as a trait impl by a method
3710 pub(crate) extern "C" fn ChannelUpdate_free_void(this_ptr: *mut c_void) {
3711 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelUpdate); }
3714 impl ChannelUpdate {
3715 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelUpdate {
3716 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3718 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelUpdate {
3719 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3721 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3722 pub(crate) fn take_inner(mut self) -> *mut nativeChannelUpdate {
3723 assert!(self.is_owned);
3724 let ret = ObjOps::untweak_ptr(self.inner);
3725 self.inner = std::ptr::null_mut();
3729 /// A signature of the channel update
3731 pub extern "C" fn ChannelUpdate_get_signature(this_ptr: &ChannelUpdate) -> crate::c_types::Signature {
3732 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
3733 crate::c_types::Signature::from_rust(&inner_val)
3735 /// A signature of the channel update
3737 pub extern "C" fn ChannelUpdate_set_signature(this_ptr: &mut ChannelUpdate, mut val: crate::c_types::Signature) {
3738 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
3740 /// The actual channel update
3742 pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate::lightning::ln::msgs::UnsignedChannelUpdate {
3743 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
3744 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 }
3746 /// The actual channel update
3748 pub extern "C" fn ChannelUpdate_set_contents(this_ptr: &mut ChannelUpdate, mut val: crate::lightning::ln::msgs::UnsignedChannelUpdate) {
3749 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
3751 /// Constructs a new ChannelUpdate given each field
3754 pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> ChannelUpdate {
3755 ChannelUpdate { inner: ObjOps::heap_alloc(nativeChannelUpdate {
3756 signature: signature_arg.into_rust(),
3757 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
3758 }), is_owned: true }
3760 impl Clone for ChannelUpdate {
3761 fn clone(&self) -> Self {
3763 inner: if <*mut nativeChannelUpdate>::is_null(self.inner) { std::ptr::null_mut() } else {
3764 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3770 /// Used only if an object of this type is returned as a trait impl by a method
3771 pub(crate) extern "C" fn ChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
3772 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelUpdate)).clone() })) as *mut c_void
3775 /// Creates a copy of the ChannelUpdate
3776 pub extern "C" fn ChannelUpdate_clone(orig: &ChannelUpdate) -> ChannelUpdate {
3780 use lightning::ln::msgs::QueryChannelRange as nativeQueryChannelRangeImport;
3781 pub(crate) type nativeQueryChannelRange = nativeQueryChannelRangeImport;
3783 /// A query_channel_range message is used to query a peer for channel
3784 /// UTXOs in a range of blocks. The recipient of a query makes a best
3785 /// effort to reply to the query using one or more reply_channel_range
3789 pub struct QueryChannelRange {
3790 /// A pointer to the opaque Rust object.
3792 /// Nearly everywhere, inner must be non-null, however in places where
3793 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3794 pub inner: *mut nativeQueryChannelRange,
3795 /// Indicates that this is the only struct which contains the same pointer.
3797 /// Rust functions which take ownership of an object provided via an argument require
3798 /// this to be true and invalidate the object pointed to by inner.
3802 impl Drop for QueryChannelRange {
3803 fn drop(&mut self) {
3804 if self.is_owned && !<*mut nativeQueryChannelRange>::is_null(self.inner) {
3805 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3809 /// Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL.
3811 pub extern "C" fn QueryChannelRange_free(this_obj: QueryChannelRange) { }
3813 /// Used only if an object of this type is returned as a trait impl by a method
3814 pub(crate) extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) {
3815 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryChannelRange); }
3818 impl QueryChannelRange {
3819 pub(crate) fn get_native_ref(&self) -> &'static nativeQueryChannelRange {
3820 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3822 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryChannelRange {
3823 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3825 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3826 pub(crate) fn take_inner(mut self) -> *mut nativeQueryChannelRange {
3827 assert!(self.is_owned);
3828 let ret = ObjOps::untweak_ptr(self.inner);
3829 self.inner = std::ptr::null_mut();
3833 /// The genesis hash of the blockchain being queried
3835 pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *const [u8; 32] {
3836 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
3837 inner_val.as_inner()
3839 /// The genesis hash of the blockchain being queried
3841 pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
3842 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3844 /// The height of the first block for the channel UTXOs being queried
3846 pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 {
3847 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
3850 /// The height of the first block for the channel UTXOs being queried
3852 pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChannelRange, mut val: u32) {
3853 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
3855 /// The number of blocks to include in the query results
3857 pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 {
3858 let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
3861 /// The number of blocks to include in the query results
3863 pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryChannelRange, mut val: u32) {
3864 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
3866 /// Constructs a new QueryChannelRange given each field
3869 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 {
3870 QueryChannelRange { inner: ObjOps::heap_alloc(nativeQueryChannelRange {
3871 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3872 first_blocknum: first_blocknum_arg,
3873 number_of_blocks: number_of_blocks_arg,
3874 }), is_owned: true }
3876 impl Clone for QueryChannelRange {
3877 fn clone(&self) -> Self {
3879 inner: if <*mut nativeQueryChannelRange>::is_null(self.inner) { std::ptr::null_mut() } else {
3880 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3886 /// Used only if an object of this type is returned as a trait impl by a method
3887 pub(crate) extern "C" fn QueryChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
3888 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryChannelRange)).clone() })) as *mut c_void
3891 /// Creates a copy of the QueryChannelRange
3892 pub extern "C" fn QueryChannelRange_clone(orig: &QueryChannelRange) -> QueryChannelRange {
3896 use lightning::ln::msgs::ReplyChannelRange as nativeReplyChannelRangeImport;
3897 pub(crate) type nativeReplyChannelRange = nativeReplyChannelRangeImport;
3899 /// A reply_channel_range message is a reply to a query_channel_range
3900 /// message. Multiple reply_channel_range messages can be sent in reply
3901 /// to a single query_channel_range message. The query recipient makes a
3902 /// best effort to respond based on their local network view which may
3903 /// not be a perfect view of the network. The short_channel_ids in the
3904 /// reply are encoded. We only support encoding_type=0 uncompressed
3905 /// serialization and do not support encoding_type=1 zlib serialization.
3908 pub struct ReplyChannelRange {
3909 /// A pointer to the opaque Rust object.
3911 /// Nearly everywhere, inner must be non-null, however in places where
3912 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3913 pub inner: *mut nativeReplyChannelRange,
3914 /// Indicates that this is the only struct which contains the same pointer.
3916 /// Rust functions which take ownership of an object provided via an argument require
3917 /// this to be true and invalidate the object pointed to by inner.
3921 impl Drop for ReplyChannelRange {
3922 fn drop(&mut self) {
3923 if self.is_owned && !<*mut nativeReplyChannelRange>::is_null(self.inner) {
3924 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3928 /// Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL.
3930 pub extern "C" fn ReplyChannelRange_free(this_obj: ReplyChannelRange) { }
3932 /// Used only if an object of this type is returned as a trait impl by a method
3933 pub(crate) extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) {
3934 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyChannelRange); }
3937 impl ReplyChannelRange {
3938 pub(crate) fn get_native_ref(&self) -> &'static nativeReplyChannelRange {
3939 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3941 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyChannelRange {
3942 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3944 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3945 pub(crate) fn take_inner(mut self) -> *mut nativeReplyChannelRange {
3946 assert!(self.is_owned);
3947 let ret = ObjOps::untweak_ptr(self.inner);
3948 self.inner = std::ptr::null_mut();
3952 /// The genesis hash of the blockchain being queried
3954 pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *const [u8; 32] {
3955 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
3956 inner_val.as_inner()
3958 /// The genesis hash of the blockchain being queried
3960 pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
3961 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3963 /// The height of the first block in the range of the reply
3965 pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 {
3966 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
3969 /// The height of the first block in the range of the reply
3971 pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChannelRange, mut val: u32) {
3972 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
3974 /// The number of blocks included in the range of the reply
3976 pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 {
3977 let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
3980 /// The number of blocks included in the range of the reply
3982 pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyChannelRange, mut val: u32) {
3983 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
3985 /// True when this is the final reply for a query
3987 pub extern "C" fn ReplyChannelRange_get_sync_complete(this_ptr: &ReplyChannelRange) -> bool {
3988 let mut inner_val = &mut this_ptr.get_native_mut_ref().sync_complete;
3991 /// True when this is the final reply for a query
3993 pub extern "C" fn ReplyChannelRange_set_sync_complete(this_ptr: &mut ReplyChannelRange, mut val: bool) {
3994 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sync_complete = val;
3996 /// The short_channel_ids in the channel range
3998 pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::derived::CVec_u64Z) {
3999 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
4000 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
4002 /// Constructs a new ReplyChannelRange given each field
4005 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 {
4006 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 }); };
4007 ReplyChannelRange { inner: ObjOps::heap_alloc(nativeReplyChannelRange {
4008 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4009 first_blocknum: first_blocknum_arg,
4010 number_of_blocks: number_of_blocks_arg,
4011 sync_complete: sync_complete_arg,
4012 short_channel_ids: local_short_channel_ids_arg,
4013 }), is_owned: true }
4015 impl Clone for ReplyChannelRange {
4016 fn clone(&self) -> Self {
4018 inner: if <*mut nativeReplyChannelRange>::is_null(self.inner) { std::ptr::null_mut() } else {
4019 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4025 /// Used only if an object of this type is returned as a trait impl by a method
4026 pub(crate) extern "C" fn ReplyChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
4027 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyChannelRange)).clone() })) as *mut c_void
4030 /// Creates a copy of the ReplyChannelRange
4031 pub extern "C" fn ReplyChannelRange_clone(orig: &ReplyChannelRange) -> ReplyChannelRange {
4035 use lightning::ln::msgs::QueryShortChannelIds as nativeQueryShortChannelIdsImport;
4036 pub(crate) type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport;
4038 /// A query_short_channel_ids message is used to query a peer for
4039 /// routing gossip messages related to one or more short_channel_ids.
4040 /// The query recipient will reply with the latest, if available,
4041 /// channel_announcement, channel_update and node_announcement messages
4042 /// it maintains for the requested short_channel_ids followed by a
4043 /// reply_short_channel_ids_end message. The short_channel_ids sent in
4044 /// this query are encoded. We only support encoding_type=0 uncompressed
4045 /// serialization and do not support encoding_type=1 zlib serialization.
4048 pub struct QueryShortChannelIds {
4049 /// A pointer to the opaque Rust object.
4051 /// Nearly everywhere, inner must be non-null, however in places where
4052 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4053 pub inner: *mut nativeQueryShortChannelIds,
4054 /// Indicates that this is the only struct which contains the same pointer.
4056 /// Rust functions which take ownership of an object provided via an argument require
4057 /// this to be true and invalidate the object pointed to by inner.
4061 impl Drop for QueryShortChannelIds {
4062 fn drop(&mut self) {
4063 if self.is_owned && !<*mut nativeQueryShortChannelIds>::is_null(self.inner) {
4064 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4068 /// Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL.
4070 pub extern "C" fn QueryShortChannelIds_free(this_obj: QueryShortChannelIds) { }
4072 /// Used only if an object of this type is returned as a trait impl by a method
4073 pub(crate) extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) {
4074 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryShortChannelIds); }
4077 impl QueryShortChannelIds {
4078 pub(crate) fn get_native_ref(&self) -> &'static nativeQueryShortChannelIds {
4079 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4081 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryShortChannelIds {
4082 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4084 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4085 pub(crate) fn take_inner(mut self) -> *mut nativeQueryShortChannelIds {
4086 assert!(self.is_owned);
4087 let ret = ObjOps::untweak_ptr(self.inner);
4088 self.inner = std::ptr::null_mut();
4092 /// The genesis hash of the blockchain being queried
4094 pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *const [u8; 32] {
4095 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4096 inner_val.as_inner()
4098 /// The genesis hash of the blockchain being queried
4100 pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::ThirtyTwoBytes) {
4101 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4103 /// The short_channel_ids that are being queried
4105 pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::derived::CVec_u64Z) {
4106 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
4107 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
4109 /// Constructs a new QueryShortChannelIds given each field
4112 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 {
4113 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 }); };
4114 QueryShortChannelIds { inner: ObjOps::heap_alloc(nativeQueryShortChannelIds {
4115 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4116 short_channel_ids: local_short_channel_ids_arg,
4117 }), is_owned: true }
4119 impl Clone for QueryShortChannelIds {
4120 fn clone(&self) -> Self {
4122 inner: if <*mut nativeQueryShortChannelIds>::is_null(self.inner) { std::ptr::null_mut() } else {
4123 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4129 /// Used only if an object of this type is returned as a trait impl by a method
4130 pub(crate) extern "C" fn QueryShortChannelIds_clone_void(this_ptr: *const c_void) -> *mut c_void {
4131 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryShortChannelIds)).clone() })) as *mut c_void
4134 /// Creates a copy of the QueryShortChannelIds
4135 pub extern "C" fn QueryShortChannelIds_clone(orig: &QueryShortChannelIds) -> QueryShortChannelIds {
4139 use lightning::ln::msgs::ReplyShortChannelIdsEnd as nativeReplyShortChannelIdsEndImport;
4140 pub(crate) type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport;
4142 /// A reply_short_channel_ids_end message is sent as a reply to a
4143 /// query_short_channel_ids message. The query recipient makes a best
4144 /// effort to respond based on their local network view which may not be
4145 /// a perfect view of the network.
4148 pub struct ReplyShortChannelIdsEnd {
4149 /// A pointer to the opaque Rust object.
4151 /// Nearly everywhere, inner must be non-null, however in places where
4152 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4153 pub inner: *mut nativeReplyShortChannelIdsEnd,
4154 /// Indicates that this is the only struct which contains the same pointer.
4156 /// Rust functions which take ownership of an object provided via an argument require
4157 /// this to be true and invalidate the object pointed to by inner.
4161 impl Drop for ReplyShortChannelIdsEnd {
4162 fn drop(&mut self) {
4163 if self.is_owned && !<*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) {
4164 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4168 /// Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL.
4170 pub extern "C" fn ReplyShortChannelIdsEnd_free(this_obj: ReplyShortChannelIdsEnd) { }
4172 /// Used only if an object of this type is returned as a trait impl by a method
4173 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) {
4174 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyShortChannelIdsEnd); }
4177 impl ReplyShortChannelIdsEnd {
4178 pub(crate) fn get_native_ref(&self) -> &'static nativeReplyShortChannelIdsEnd {
4179 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4181 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyShortChannelIdsEnd {
4182 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4184 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4185 pub(crate) fn take_inner(mut self) -> *mut nativeReplyShortChannelIdsEnd {
4186 assert!(self.is_owned);
4187 let ret = ObjOps::untweak_ptr(self.inner);
4188 self.inner = std::ptr::null_mut();
4192 /// The genesis hash of the blockchain that was queried
4194 pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *const [u8; 32] {
4195 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4196 inner_val.as_inner()
4198 /// The genesis hash of the blockchain that was queried
4200 pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) {
4201 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4203 /// Indicates if the query recipient maintains up-to-date channel
4204 /// information for the chain_hash
4206 pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool {
4207 let mut inner_val = &mut this_ptr.get_native_mut_ref().full_information;
4210 /// Indicates if the query recipient maintains up-to-date channel
4211 /// information for the chain_hash
4213 pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: bool) {
4214 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.full_information = val;
4216 /// Constructs a new ReplyShortChannelIdsEnd given each field
4219 pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd {
4220 ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(nativeReplyShortChannelIdsEnd {
4221 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4222 full_information: full_information_arg,
4223 }), is_owned: true }
4225 impl Clone for ReplyShortChannelIdsEnd {
4226 fn clone(&self) -> Self {
4228 inner: if <*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) { std::ptr::null_mut() } else {
4229 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4235 /// Used only if an object of this type is returned as a trait impl by a method
4236 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_void) -> *mut c_void {
4237 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyShortChannelIdsEnd)).clone() })) as *mut c_void
4240 /// Creates a copy of the ReplyShortChannelIdsEnd
4241 pub extern "C" fn ReplyShortChannelIdsEnd_clone(orig: &ReplyShortChannelIdsEnd) -> ReplyShortChannelIdsEnd {
4245 use lightning::ln::msgs::GossipTimestampFilter as nativeGossipTimestampFilterImport;
4246 pub(crate) type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport;
4248 /// A gossip_timestamp_filter message is used by a node to request
4249 /// gossip relay for messages in the requested time range when the
4250 /// gossip_queries feature has been negotiated.
4253 pub struct GossipTimestampFilter {
4254 /// A pointer to the opaque Rust object.
4256 /// Nearly everywhere, inner must be non-null, however in places where
4257 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4258 pub inner: *mut nativeGossipTimestampFilter,
4259 /// Indicates that this is the only struct which contains the same pointer.
4261 /// Rust functions which take ownership of an object provided via an argument require
4262 /// this to be true and invalidate the object pointed to by inner.
4266 impl Drop for GossipTimestampFilter {
4267 fn drop(&mut self) {
4268 if self.is_owned && !<*mut nativeGossipTimestampFilter>::is_null(self.inner) {
4269 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4273 /// Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL.
4275 pub extern "C" fn GossipTimestampFilter_free(this_obj: GossipTimestampFilter) { }
4277 /// Used only if an object of this type is returned as a trait impl by a method
4278 pub(crate) extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) {
4279 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeGossipTimestampFilter); }
4282 impl GossipTimestampFilter {
4283 pub(crate) fn get_native_ref(&self) -> &'static nativeGossipTimestampFilter {
4284 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4286 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeGossipTimestampFilter {
4287 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4289 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4290 pub(crate) fn take_inner(mut self) -> *mut nativeGossipTimestampFilter {
4291 assert!(self.is_owned);
4292 let ret = ObjOps::untweak_ptr(self.inner);
4293 self.inner = std::ptr::null_mut();
4297 /// The genesis hash of the blockchain for channel and node information
4299 pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *const [u8; 32] {
4300 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4301 inner_val.as_inner()
4303 /// The genesis hash of the blockchain for channel and node information
4305 pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) {
4306 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4308 /// The starting unix timestamp
4310 pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 {
4311 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_timestamp;
4314 /// The starting unix timestamp
4316 pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
4317 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_timestamp = val;
4319 /// The range of information in seconds
4321 pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 {
4322 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp_range;
4325 /// The range of information in seconds
4327 pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
4328 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp_range = val;
4330 /// Constructs a new GossipTimestampFilter given each field
4333 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 {
4334 GossipTimestampFilter { inner: ObjOps::heap_alloc(nativeGossipTimestampFilter {
4335 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4336 first_timestamp: first_timestamp_arg,
4337 timestamp_range: timestamp_range_arg,
4338 }), is_owned: true }
4340 impl Clone for GossipTimestampFilter {
4341 fn clone(&self) -> Self {
4343 inner: if <*mut nativeGossipTimestampFilter>::is_null(self.inner) { std::ptr::null_mut() } else {
4344 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4350 /// Used only if an object of this type is returned as a trait impl by a method
4351 pub(crate) extern "C" fn GossipTimestampFilter_clone_void(this_ptr: *const c_void) -> *mut c_void {
4352 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeGossipTimestampFilter)).clone() })) as *mut c_void
4355 /// Creates a copy of the GossipTimestampFilter
4356 pub extern "C" fn GossipTimestampFilter_clone(orig: &GossipTimestampFilter) -> GossipTimestampFilter {
4359 /// Used to put an error message in a LightningError
4363 pub enum ErrorAction {
4364 /// The peer took some action which made us think they were useless. Disconnect them.
4366 /// An error message which we should make an effort to send before we disconnect.
4368 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
4369 msg: crate::lightning::ln::msgs::ErrorMessage,
4371 /// The peer did something harmless that we weren't able to process, just log and ignore
4373 /// The peer did something harmless that we weren't able to meaningfully process.
4374 /// If the error is logged, log it at the given level.
4375 IgnoreAndLog(crate::lightning::util::logger::Level),
4376 /// The peer did something incorrect. Tell them.
4378 /// The message to send.
4379 msg: crate::lightning::ln::msgs::ErrorMessage,
4382 use lightning::ln::msgs::ErrorAction as nativeErrorAction;
4385 pub(crate) fn to_native(&self) -> nativeErrorAction {
4387 ErrorAction::DisconnectPeer {ref msg, } => {
4388 let mut msg_nonref = (*msg).clone();
4389 let mut local_msg_nonref = if msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg_nonref.take_inner()) } }) };
4390 nativeErrorAction::DisconnectPeer {
4391 msg: local_msg_nonref,
4394 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
4395 ErrorAction::IgnoreAndLog (ref a, ) => {
4396 let mut a_nonref = (*a).clone();
4397 nativeErrorAction::IgnoreAndLog (
4398 a_nonref.into_native(),
4401 ErrorAction::SendErrorMessage {ref msg, } => {
4402 let mut msg_nonref = (*msg).clone();
4403 nativeErrorAction::SendErrorMessage {
4404 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
4410 pub(crate) fn into_native(self) -> nativeErrorAction {
4412 ErrorAction::DisconnectPeer {mut msg, } => {
4413 let mut local_msg = if msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg.take_inner()) } }) };
4414 nativeErrorAction::DisconnectPeer {
4418 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
4419 ErrorAction::IgnoreAndLog (mut a, ) => {
4420 nativeErrorAction::IgnoreAndLog (
4424 ErrorAction::SendErrorMessage {mut msg, } => {
4425 nativeErrorAction::SendErrorMessage {
4426 msg: *unsafe { Box::from_raw(msg.take_inner()) },
4432 pub(crate) fn from_native(native: &nativeErrorAction) -> Self {
4434 nativeErrorAction::DisconnectPeer {ref msg, } => {
4435 let mut msg_nonref = (*msg).clone();
4436 let mut local_msg_nonref = crate::lightning::ln::msgs::ErrorMessage { inner: if msg_nonref.is_none() { std::ptr::null_mut() } else { { ObjOps::heap_alloc((msg_nonref.unwrap())) } }, is_owned: true };
4437 ErrorAction::DisconnectPeer {
4438 msg: local_msg_nonref,
4441 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
4442 nativeErrorAction::IgnoreAndLog (ref a, ) => {
4443 let mut a_nonref = (*a).clone();
4444 ErrorAction::IgnoreAndLog (
4445 crate::lightning::util::logger::Level::native_into(a_nonref),
4448 nativeErrorAction::SendErrorMessage {ref msg, } => {
4449 let mut msg_nonref = (*msg).clone();
4450 ErrorAction::SendErrorMessage {
4451 msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
4457 pub(crate) fn native_into(native: nativeErrorAction) -> Self {
4459 nativeErrorAction::DisconnectPeer {mut msg, } => {
4460 let mut local_msg = crate::lightning::ln::msgs::ErrorMessage { inner: if msg.is_none() { std::ptr::null_mut() } else { { ObjOps::heap_alloc((msg.unwrap())) } }, is_owned: true };
4461 ErrorAction::DisconnectPeer {
4465 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
4466 nativeErrorAction::IgnoreAndLog (mut a, ) => {
4467 ErrorAction::IgnoreAndLog (
4468 crate::lightning::util::logger::Level::native_into(a),
4471 nativeErrorAction::SendErrorMessage {mut msg, } => {
4472 ErrorAction::SendErrorMessage {
4473 msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
4479 /// Frees any resources used by the ErrorAction
4481 pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { }
4482 /// Creates a copy of the ErrorAction
4484 pub extern "C" fn ErrorAction_clone(orig: &ErrorAction) -> ErrorAction {
4488 /// Utility method to constructs a new DisconnectPeer-variant ErrorAction
4489 pub extern "C" fn ErrorAction_disconnect_peer(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
4490 ErrorAction::DisconnectPeer {
4495 /// Utility method to constructs a new IgnoreError-variant ErrorAction
4496 pub extern "C" fn ErrorAction_ignore_error() -> ErrorAction {
4497 ErrorAction::IgnoreError}
4499 /// Utility method to constructs a new IgnoreAndLog-variant ErrorAction
4500 pub extern "C" fn ErrorAction_ignore_and_log(a: crate::lightning::util::logger::Level) -> ErrorAction {
4501 ErrorAction::IgnoreAndLog(a, )
4504 /// Utility method to constructs a new SendErrorMessage-variant ErrorAction
4505 pub extern "C" fn ErrorAction_send_error_message(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
4506 ErrorAction::SendErrorMessage {
4511 use lightning::ln::msgs::LightningError as nativeLightningErrorImport;
4512 pub(crate) type nativeLightningError = nativeLightningErrorImport;
4514 /// An Err type for failure to process messages.
4517 pub struct LightningError {
4518 /// A pointer to the opaque Rust object.
4520 /// Nearly everywhere, inner must be non-null, however in places where
4521 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4522 pub inner: *mut nativeLightningError,
4523 /// Indicates that this is the only struct which contains the same pointer.
4525 /// Rust functions which take ownership of an object provided via an argument require
4526 /// this to be true and invalidate the object pointed to by inner.
4530 impl Drop for LightningError {
4531 fn drop(&mut self) {
4532 if self.is_owned && !<*mut nativeLightningError>::is_null(self.inner) {
4533 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4537 /// Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL.
4539 pub extern "C" fn LightningError_free(this_obj: LightningError) { }
4541 /// Used only if an object of this type is returned as a trait impl by a method
4542 pub(crate) extern "C" fn LightningError_free_void(this_ptr: *mut c_void) {
4543 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeLightningError); }
4546 impl LightningError {
4547 pub(crate) fn get_native_ref(&self) -> &'static nativeLightningError {
4548 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4550 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLightningError {
4551 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4553 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4554 pub(crate) fn take_inner(mut self) -> *mut nativeLightningError {
4555 assert!(self.is_owned);
4556 let ret = ObjOps::untweak_ptr(self.inner);
4557 self.inner = std::ptr::null_mut();
4561 /// A human-readable message describing the error
4563 pub extern "C" fn LightningError_get_err(this_ptr: &LightningError) -> crate::c_types::Str {
4564 let mut inner_val = &mut this_ptr.get_native_mut_ref().err;
4565 inner_val.as_str().into()
4567 /// A human-readable message describing the error
4569 pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: crate::c_types::Str) {
4570 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.err = val.into_string();
4572 /// The action which should be taken against the offending peer.
4574 pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate::lightning::ln::msgs::ErrorAction {
4575 let mut inner_val = &mut this_ptr.get_native_mut_ref().action;
4576 crate::lightning::ln::msgs::ErrorAction::from_native(inner_val)
4578 /// The action which should be taken against the offending peer.
4580 pub extern "C" fn LightningError_set_action(this_ptr: &mut LightningError, mut val: crate::lightning::ln::msgs::ErrorAction) {
4581 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.action = val.into_native();
4583 /// Constructs a new LightningError given each field
4586 pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::Str, mut action_arg: crate::lightning::ln::msgs::ErrorAction) -> LightningError {
4587 LightningError { inner: ObjOps::heap_alloc(nativeLightningError {
4588 err: err_arg.into_string(),
4589 action: action_arg.into_native(),
4590 }), is_owned: true }
4592 impl Clone for LightningError {
4593 fn clone(&self) -> Self {
4595 inner: if <*mut nativeLightningError>::is_null(self.inner) { std::ptr::null_mut() } else {
4596 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4602 /// Used only if an object of this type is returned as a trait impl by a method
4603 pub(crate) extern "C" fn LightningError_clone_void(this_ptr: *const c_void) -> *mut c_void {
4604 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeLightningError)).clone() })) as *mut c_void
4607 /// Creates a copy of the LightningError
4608 pub extern "C" fn LightningError_clone(orig: &LightningError) -> LightningError {
4612 use lightning::ln::msgs::CommitmentUpdate as nativeCommitmentUpdateImport;
4613 pub(crate) type nativeCommitmentUpdate = nativeCommitmentUpdateImport;
4615 /// Struct used to return values from revoke_and_ack messages, containing a bunch of commitment
4616 /// transaction updates if they were pending.
4619 pub struct CommitmentUpdate {
4620 /// A pointer to the opaque Rust object.
4622 /// Nearly everywhere, inner must be non-null, however in places where
4623 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4624 pub inner: *mut nativeCommitmentUpdate,
4625 /// Indicates that this is the only struct which contains the same pointer.
4627 /// Rust functions which take ownership of an object provided via an argument require
4628 /// this to be true and invalidate the object pointed to by inner.
4632 impl Drop for CommitmentUpdate {
4633 fn drop(&mut self) {
4634 if self.is_owned && !<*mut nativeCommitmentUpdate>::is_null(self.inner) {
4635 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4639 /// Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL.
4641 pub extern "C" fn CommitmentUpdate_free(this_obj: CommitmentUpdate) { }
4643 /// Used only if an object of this type is returned as a trait impl by a method
4644 pub(crate) extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) {
4645 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentUpdate); }
4648 impl CommitmentUpdate {
4649 pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentUpdate {
4650 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4652 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentUpdate {
4653 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4655 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4656 pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentUpdate {
4657 assert!(self.is_owned);
4658 let ret = ObjOps::untweak_ptr(self.inner);
4659 self.inner = std::ptr::null_mut();
4663 /// update_add_htlc messages which should be sent
4665 pub extern "C" fn CommitmentUpdate_get_update_add_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateAddHTLCZ {
4666 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_add_htlcs;
4667 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 } }); };
4668 local_inner_val.into()
4670 /// update_add_htlc messages which should be sent
4672 pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) {
4673 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4674 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_add_htlcs = local_val;
4676 /// update_fulfill_htlc messages which should be sent
4678 pub extern "C" fn CommitmentUpdate_get_update_fulfill_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFulfillHTLCZ {
4679 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fulfill_htlcs;
4680 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 } }); };
4681 local_inner_val.into()
4683 /// update_fulfill_htlc messages which should be sent
4685 pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) {
4686 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4687 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fulfill_htlcs = local_val;
4689 /// update_fail_htlc messages which should be sent
4691 pub extern "C" fn CommitmentUpdate_get_update_fail_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailHTLCZ {
4692 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_htlcs;
4693 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 } }); };
4694 local_inner_val.into()
4696 /// update_fail_htlc messages which should be sent
4698 pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) {
4699 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4700 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_htlcs = local_val;
4702 /// update_fail_malformed_htlc messages which should be sent
4704 pub extern "C" fn CommitmentUpdate_get_update_fail_malformed_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ {
4705 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_malformed_htlcs;
4706 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 } }); };
4707 local_inner_val.into()
4709 /// update_fail_malformed_htlc messages which should be sent
4711 pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) {
4712 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4713 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_malformed_htlcs = local_val;
4715 /// An update_fee message which should be sent
4717 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
4719 pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::UpdateFee {
4720 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fee;
4721 let mut local_inner_val = crate::lightning::ln::msgs::UpdateFee { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::msgs::UpdateFee<>) as *mut _ }, is_owned: false };
4724 /// An update_fee message which should be sent
4726 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
4728 pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::UpdateFee) {
4729 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
4730 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fee = local_val;
4732 /// Finally, the commitment_signed message which should be sent
4734 pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::CommitmentSigned {
4735 let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_signed;
4736 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 }
4738 /// Finally, the commitment_signed message which should be sent
4740 pub extern "C" fn CommitmentUpdate_set_commitment_signed(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::CommitmentSigned) {
4741 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_signed = *unsafe { Box::from_raw(val.take_inner()) };
4743 /// Constructs a new CommitmentUpdate given each field
4746 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 {
4747 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()) } }); };
4748 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()) } }); };
4749 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()) } }); };
4750 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()) } }); };
4751 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()) } }) };
4752 CommitmentUpdate { inner: ObjOps::heap_alloc(nativeCommitmentUpdate {
4753 update_add_htlcs: local_update_add_htlcs_arg,
4754 update_fulfill_htlcs: local_update_fulfill_htlcs_arg,
4755 update_fail_htlcs: local_update_fail_htlcs_arg,
4756 update_fail_malformed_htlcs: local_update_fail_malformed_htlcs_arg,
4757 update_fee: local_update_fee_arg,
4758 commitment_signed: *unsafe { Box::from_raw(commitment_signed_arg.take_inner()) },
4759 }), is_owned: true }
4761 impl Clone for CommitmentUpdate {
4762 fn clone(&self) -> Self {
4764 inner: if <*mut nativeCommitmentUpdate>::is_null(self.inner) { std::ptr::null_mut() } else {
4765 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4771 /// Used only if an object of this type is returned as a trait impl by a method
4772 pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
4773 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentUpdate)).clone() })) as *mut c_void
4776 /// Creates a copy of the CommitmentUpdate
4777 pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentUpdate {
4780 /// A trait to describe an object which can receive channel messages.
4782 /// Messages MAY be called in parallel when they originate from different their_node_ids, however
4783 /// they MUST NOT be called in parallel when the two calls have the same their_node_id.
4785 pub struct ChannelMessageHandler {
4786 /// An opaque pointer which is passed to your function implementations as an argument.
4787 /// This has no meaning in the LDK, and can be NULL or any other value.
4788 pub this_arg: *mut c_void,
4789 /// Handle an incoming open_channel message from the given peer.
4790 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),
4791 /// Handle an incoming accept_channel message from the given peer.
4792 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),
4793 /// Handle an incoming funding_created message from the given peer.
4794 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),
4795 /// Handle an incoming funding_signed message from the given peer.
4796 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),
4797 /// Handle an incoming funding_locked message from the given peer.
4798 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),
4799 /// Handle an incoming shutdown message from the given peer.
4800 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),
4801 /// Handle an incoming closing_signed message from the given peer.
4802 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),
4803 /// Handle an incoming update_add_htlc message from the given peer.
4804 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),
4805 /// Handle an incoming update_fulfill_htlc message from the given peer.
4806 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),
4807 /// Handle an incoming update_fail_htlc message from the given peer.
4808 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),
4809 /// Handle an incoming update_fail_malformed_htlc message from the given peer.
4810 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),
4811 /// Handle an incoming commitment_signed message from the given peer.
4812 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),
4813 /// Handle an incoming revoke_and_ack message from the given peer.
4814 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),
4815 /// Handle an incoming update_fee message from the given peer.
4816 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),
4817 /// Handle an incoming announcement_signatures message from the given peer.
4818 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),
4819 /// Indicates a connection to the peer failed/an existing connection was lost. If no connection
4820 /// is believed to be possible in the future (eg they're sending us messages we don't
4821 /// understand or indicate they require unknown feature bits), no_connection_possible is set
4822 /// and any outstanding channels should be failed.
4823 pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, no_connection_possible: bool),
4824 /// Handle a peer reconnecting, possibly generating channel_reestablish message(s).
4825 pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Init),
4826 /// Handle an incoming channel_reestablish message from the given peer.
4827 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),
4828 /// Handle an incoming channel update from the given peer.
4829 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),
4830 /// Handle an incoming error message from the given peer.
4831 pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ErrorMessage),
4832 /// Implementation of MessageSendEventsProvider for this object.
4833 pub MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider,
4834 /// Frees any resources associated with this object given its this_arg pointer.
4835 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
4836 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
4838 unsafe impl Send for ChannelMessageHandler {}
4839 unsafe impl Sync for ChannelMessageHandler {}
4841 pub(crate) extern "C" fn ChannelMessageHandler_clone_fields(orig: &ChannelMessageHandler) -> ChannelMessageHandler {
4842 ChannelMessageHandler {
4843 this_arg: orig.this_arg,
4844 handle_open_channel: Clone::clone(&orig.handle_open_channel),
4845 handle_accept_channel: Clone::clone(&orig.handle_accept_channel),
4846 handle_funding_created: Clone::clone(&orig.handle_funding_created),
4847 handle_funding_signed: Clone::clone(&orig.handle_funding_signed),
4848 handle_funding_locked: Clone::clone(&orig.handle_funding_locked),
4849 handle_shutdown: Clone::clone(&orig.handle_shutdown),
4850 handle_closing_signed: Clone::clone(&orig.handle_closing_signed),
4851 handle_update_add_htlc: Clone::clone(&orig.handle_update_add_htlc),
4852 handle_update_fulfill_htlc: Clone::clone(&orig.handle_update_fulfill_htlc),
4853 handle_update_fail_htlc: Clone::clone(&orig.handle_update_fail_htlc),
4854 handle_update_fail_malformed_htlc: Clone::clone(&orig.handle_update_fail_malformed_htlc),
4855 handle_commitment_signed: Clone::clone(&orig.handle_commitment_signed),
4856 handle_revoke_and_ack: Clone::clone(&orig.handle_revoke_and_ack),
4857 handle_update_fee: Clone::clone(&orig.handle_update_fee),
4858 handle_announcement_signatures: Clone::clone(&orig.handle_announcement_signatures),
4859 peer_disconnected: Clone::clone(&orig.peer_disconnected),
4860 peer_connected: Clone::clone(&orig.peer_connected),
4861 handle_channel_reestablish: Clone::clone(&orig.handle_channel_reestablish),
4862 handle_channel_update: Clone::clone(&orig.handle_channel_update),
4863 handle_error: Clone::clone(&orig.handle_error),
4864 MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
4865 free: Clone::clone(&orig.free),
4868 impl lightning::util::events::MessageSendEventsProvider for ChannelMessageHandler {
4869 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
4870 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
4871 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
4876 use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler;
4877 impl rustChannelMessageHandler for ChannelMessageHandler {
4878 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) {
4879 (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 })
4881 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) {
4882 (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 })
4884 fn handle_funding_created(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::FundingCreated) {
4885 (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 })
4887 fn handle_funding_signed(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::FundingSigned) {
4888 (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 })
4890 fn handle_funding_locked(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::FundingLocked) {
4891 (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 })
4893 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) {
4894 (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 })
4896 fn handle_closing_signed(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ClosingSigned) {
4897 (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 })
4899 fn handle_update_add_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateAddHTLC) {
4900 (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 })
4902 fn handle_update_fulfill_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFulfillHTLC) {
4903 (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 })
4905 fn handle_update_fail_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailHTLC) {
4906 (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 })
4908 fn handle_update_fail_malformed_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) {
4909 (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 })
4911 fn handle_commitment_signed(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::CommitmentSigned) {
4912 (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 })
4914 fn handle_revoke_and_ack(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::RevokeAndACK) {
4915 (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 })
4917 fn handle_update_fee(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFee) {
4918 (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 })
4920 fn handle_announcement_signatures(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::AnnouncementSignatures) {
4921 (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 })
4923 fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut no_connection_possible: bool) {
4924 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), no_connection_possible)
4926 fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::Init) {
4927 (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 })
4929 fn handle_channel_reestablish(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ChannelReestablish) {
4930 (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 })
4932 fn handle_channel_update(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ChannelUpdate) {
4933 (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 })
4935 fn handle_error(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ErrorMessage) {
4936 (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 })
4940 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
4941 // directly as a Deref trait in higher-level structs:
4942 impl std::ops::Deref for ChannelMessageHandler {
4944 fn deref(&self) -> &Self {
4948 /// Calls the free function if one is set
4950 pub extern "C" fn ChannelMessageHandler_free(this_ptr: ChannelMessageHandler) { }
4951 impl Drop for ChannelMessageHandler {
4952 fn drop(&mut self) {
4953 if let Some(f) = self.free {
4958 /// A trait to describe an object which can receive routing messages.
4960 /// # Implementor DoS Warnings
4962 /// For `gossip_queries` messages there are potential DoS vectors when handling
4963 /// inbound queries. Implementors using an on-disk network graph should be aware of
4964 /// repeated disk I/O for queries accessing different parts of the network graph.
4966 pub struct RoutingMessageHandler {
4967 /// An opaque pointer which is passed to your function implementations as an argument.
4968 /// This has no meaning in the LDK, and can be NULL or any other value.
4969 pub this_arg: *mut c_void,
4970 /// Handle an incoming node_announcement message, returning true if it should be forwarded on,
4971 /// false or returning an Err otherwise.
4973 pub handle_node_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
4974 /// Handle a channel_announcement message, returning true if it should be forwarded on, false
4975 /// or returning an Err otherwise.
4977 pub handle_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
4978 /// Handle an incoming channel_update message, returning true if it should be forwarded on,
4979 /// false or returning an Err otherwise.
4981 pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ,
4982 /// Gets a subset of the channel announcements and updates required to dump our routing table
4983 /// to a remote node, starting at the short_channel_id indicated by starting_point and
4984 /// including the batch_amount entries immediately higher in numerical value than starting_point.
4986 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,
4987 /// Gets a subset of the node announcements required to dump our routing table to a remote node,
4988 /// starting at the node *after* the provided publickey and including batch_amount entries
4989 /// immediately higher (as defined by <PublicKey as Ord>::cmp) than starting_point.
4990 /// If None is provided for starting_point, we start at the first node.
4992 /// Note that starting_point (or a relevant inner pointer) may be NULL or all-0s to represent None
4994 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,
4995 /// Called when a connection is established with a peer. This can be used to
4996 /// perform routing table synchronization using a strategy defined by the
4998 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),
4999 /// Handles the reply of a query we initiated to learn about channels
5000 /// for a given range of blocks. We can expect to receive one or more
5001 /// replies to a single query.
5003 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,
5004 /// Handles the reply of a query we initiated asking for routing gossip
5005 /// messages for a list of channels. We should receive this message when
5006 /// a node has completed its best effort to send us the pertaining routing
5007 /// gossip messages.
5009 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,
5010 /// Handles when a peer asks us to send a list of short_channel_ids
5011 /// for the requested range of blocks.
5013 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,
5014 /// Handles when a peer asks us to send routing gossip messages for a
5015 /// list of short_channel_ids.
5017 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,
5018 /// Implementation of MessageSendEventsProvider for this object.
5019 pub MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider,
5020 /// Frees any resources associated with this object given its this_arg pointer.
5021 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
5022 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
5024 unsafe impl Send for RoutingMessageHandler {}
5025 unsafe impl Sync for RoutingMessageHandler {}
5027 pub(crate) extern "C" fn RoutingMessageHandler_clone_fields(orig: &RoutingMessageHandler) -> RoutingMessageHandler {
5028 RoutingMessageHandler {
5029 this_arg: orig.this_arg,
5030 handle_node_announcement: Clone::clone(&orig.handle_node_announcement),
5031 handle_channel_announcement: Clone::clone(&orig.handle_channel_announcement),
5032 handle_channel_update: Clone::clone(&orig.handle_channel_update),
5033 get_next_channel_announcements: Clone::clone(&orig.get_next_channel_announcements),
5034 get_next_node_announcements: Clone::clone(&orig.get_next_node_announcements),
5035 sync_routing_table: Clone::clone(&orig.sync_routing_table),
5036 handle_reply_channel_range: Clone::clone(&orig.handle_reply_channel_range),
5037 handle_reply_short_channel_ids_end: Clone::clone(&orig.handle_reply_short_channel_ids_end),
5038 handle_query_channel_range: Clone::clone(&orig.handle_query_channel_range),
5039 handle_query_short_channel_ids: Clone::clone(&orig.handle_query_short_channel_ids),
5040 MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
5041 free: Clone::clone(&orig.free),
5044 impl lightning::util::events::MessageSendEventsProvider for RoutingMessageHandler {
5045 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
5046 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
5047 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
5052 use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler;
5053 impl rustRoutingMessageHandler for RoutingMessageHandler {
5054 fn handle_node_announcement(&self, mut msg: &lightning::ln::msgs::NodeAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
5055 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 });
5056 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()) } })};
5059 fn handle_channel_announcement(&self, mut msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
5060 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 });
5061 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()) } })};
5064 fn handle_channel_update(&self, mut msg: &lightning::ln::msgs::ChannelUpdate) -> Result<bool, lightning::ln::msgs::LightningError> {
5065 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 });
5066 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()) } })};
5069 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>)> {
5070 let mut ret = (self.get_next_channel_announcements)(self.this_arg, starting_point, batch_amount);
5071 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 }); };
5074 fn get_next_node_announcements(&self, mut starting_point: Option<&bitcoin::secp256k1::key::PublicKey>, mut batch_amount: u8) -> Vec<lightning::ln::msgs::NodeAnnouncement> {
5075 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())) } };
5076 let mut ret = (self.get_next_node_announcements)(self.this_arg, local_starting_point, batch_amount);
5077 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
5080 fn sync_routing_table(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut init: &lightning::ln::msgs::Init) {
5081 (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 })
5083 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> {
5084 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 });
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_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> {
5089 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 });
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 handle_query_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: lightning::ln::msgs::QueryChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
5094 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 });
5095 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()) } })};
5098 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> {
5099 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 });
5100 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()) } })};
5105 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
5106 // directly as a Deref trait in higher-level structs:
5107 impl std::ops::Deref for RoutingMessageHandler {
5109 fn deref(&self) -> &Self {
5113 /// Calls the free function if one is set
5115 pub extern "C" fn RoutingMessageHandler_free(this_ptr: RoutingMessageHandler) { }
5116 impl Drop for RoutingMessageHandler {
5117 fn drop(&mut self) {
5118 if let Some(f) = self.free {
5123 mod fuzzy_internal_msgs {
5125 use std::str::FromStr;
5126 use std::ffi::c_void;
5127 use core::convert::Infallible;
5128 use bitcoin::hashes::Hash;
5129 use crate::c_types::*;
5133 /// Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read
5134 pub extern "C" fn AcceptChannel_write(obj: &AcceptChannel) -> crate::c_types::derived::CVec_u8Z {
5135 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5138 pub(crate) extern "C" fn AcceptChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5139 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannel) })
5142 /// Read a AcceptChannel from a byte array, created by AcceptChannel_write
5143 pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelDecodeErrorZ {
5144 let res = crate::c_types::deserialize_obj(ser);
5145 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() };
5149 /// Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read
5150 pub extern "C" fn AnnouncementSignatures_write(obj: &AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z {
5151 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5154 pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5155 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAnnouncementSignatures) })
5158 /// Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write
5159 pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AnnouncementSignaturesDecodeErrorZ {
5160 let res = crate::c_types::deserialize_obj(ser);
5161 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() };
5165 /// Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read
5166 pub extern "C" fn ChannelReestablish_write(obj: &ChannelReestablish) -> crate::c_types::derived::CVec_u8Z {
5167 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5170 pub(crate) extern "C" fn ChannelReestablish_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5171 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReestablish) })
5174 /// Read a ChannelReestablish from a byte array, created by ChannelReestablish_write
5175 pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReestablishDecodeErrorZ {
5176 let res = crate::c_types::deserialize_obj(ser);
5177 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() };
5181 /// Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read
5182 pub extern "C" fn ClosingSigned_write(obj: &ClosingSigned) -> crate::c_types::derived::CVec_u8Z {
5183 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5186 pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5187 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSigned) })
5190 /// Read a ClosingSigned from a byte array, created by ClosingSigned_write
5191 pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedDecodeErrorZ {
5192 let res = crate::c_types::deserialize_obj(ser);
5193 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() };
5197 /// Serialize the ClosingSignedFeeRange object into a byte array which can be read by ClosingSignedFeeRange_read
5198 pub extern "C" fn ClosingSignedFeeRange_write(obj: &ClosingSignedFeeRange) -> crate::c_types::derived::CVec_u8Z {
5199 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5202 pub(crate) extern "C" fn ClosingSignedFeeRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5203 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSignedFeeRange) })
5206 /// Read a ClosingSignedFeeRange from a byte array, created by ClosingSignedFeeRange_write
5207 pub extern "C" fn ClosingSignedFeeRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedFeeRangeDecodeErrorZ {
5208 let res = crate::c_types::deserialize_obj(ser);
5209 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() };
5213 /// Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read
5214 pub extern "C" fn CommitmentSigned_write(obj: &CommitmentSigned) -> crate::c_types::derived::CVec_u8Z {
5215 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5218 pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5219 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentSigned) })
5222 /// Read a CommitmentSigned from a byte array, created by CommitmentSigned_write
5223 pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CommitmentSignedDecodeErrorZ {
5224 let res = crate::c_types::deserialize_obj(ser);
5225 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() };
5229 /// Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read
5230 pub extern "C" fn FundingCreated_write(obj: &FundingCreated) -> crate::c_types::derived::CVec_u8Z {
5231 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5234 pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5235 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingCreated) })
5238 /// Read a FundingCreated from a byte array, created by FundingCreated_write
5239 pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingCreatedDecodeErrorZ {
5240 let res = crate::c_types::deserialize_obj(ser);
5241 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() };
5245 /// Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read
5246 pub extern "C" fn FundingSigned_write(obj: &FundingSigned) -> crate::c_types::derived::CVec_u8Z {
5247 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5250 pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5251 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingSigned) })
5254 /// Read a FundingSigned from a byte array, created by FundingSigned_write
5255 pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingSignedDecodeErrorZ {
5256 let res = crate::c_types::deserialize_obj(ser);
5257 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() };
5261 /// Serialize the FundingLocked object into a byte array which can be read by FundingLocked_read
5262 pub extern "C" fn FundingLocked_write(obj: &FundingLocked) -> crate::c_types::derived::CVec_u8Z {
5263 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5266 pub(crate) extern "C" fn FundingLocked_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5267 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingLocked) })
5270 /// Read a FundingLocked from a byte array, created by FundingLocked_write
5271 pub extern "C" fn FundingLocked_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingLockedDecodeErrorZ {
5272 let res = crate::c_types::deserialize_obj(ser);
5273 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() };
5277 /// Serialize the Init object into a byte array which can be read by Init_read
5278 pub extern "C" fn Init_write(obj: &Init) -> crate::c_types::derived::CVec_u8Z {
5279 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5282 pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5283 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInit) })
5286 /// Read a Init from a byte array, created by Init_write
5287 pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitDecodeErrorZ {
5288 let res = crate::c_types::deserialize_obj(ser);
5289 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() };
5293 /// Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read
5294 pub extern "C" fn OpenChannel_write(obj: &OpenChannel) -> crate::c_types::derived::CVec_u8Z {
5295 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5298 pub(crate) extern "C" fn OpenChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5299 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannel) })
5302 /// Read a OpenChannel from a byte array, created by OpenChannel_write
5303 pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelDecodeErrorZ {
5304 let res = crate::c_types::deserialize_obj(ser);
5305 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() };
5309 /// Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read
5310 pub extern "C" fn RevokeAndACK_write(obj: &RevokeAndACK) -> crate::c_types::derived::CVec_u8Z {
5311 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5314 pub(crate) extern "C" fn RevokeAndACK_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5315 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevokeAndACK) })
5318 /// Read a RevokeAndACK from a byte array, created by RevokeAndACK_write
5319 pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RevokeAndACKDecodeErrorZ {
5320 let res = crate::c_types::deserialize_obj(ser);
5321 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() };
5325 /// Serialize the Shutdown object into a byte array which can be read by Shutdown_read
5326 pub extern "C" fn Shutdown_write(obj: &Shutdown) -> crate::c_types::derived::CVec_u8Z {
5327 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5330 pub(crate) extern "C" fn Shutdown_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5331 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeShutdown) })
5334 /// Read a Shutdown from a byte array, created by Shutdown_write
5335 pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ShutdownDecodeErrorZ {
5336 let res = crate::c_types::deserialize_obj(ser);
5337 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() };
5341 /// Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read
5342 pub extern "C" fn UpdateFailHTLC_write(obj: &UpdateFailHTLC) -> crate::c_types::derived::CVec_u8Z {
5343 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5346 pub(crate) extern "C" fn UpdateFailHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5347 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailHTLC) })
5350 /// Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write
5351 pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailHTLCDecodeErrorZ {
5352 let res = crate::c_types::deserialize_obj(ser);
5353 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() };
5357 /// Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read
5358 pub extern "C" fn UpdateFailMalformedHTLC_write(obj: &UpdateFailMalformedHTLC) -> crate::c_types::derived::CVec_u8Z {
5359 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5362 pub(crate) extern "C" fn UpdateFailMalformedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5363 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailMalformedHTLC) })
5366 /// Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write
5367 pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailMalformedHTLCDecodeErrorZ {
5368 let res = crate::c_types::deserialize_obj(ser);
5369 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() };
5373 /// Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read
5374 pub extern "C" fn UpdateFee_write(obj: &UpdateFee) -> crate::c_types::derived::CVec_u8Z {
5375 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5378 pub(crate) extern "C" fn UpdateFee_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5379 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFee) })
5382 /// Read a UpdateFee from a byte array, created by UpdateFee_write
5383 pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFeeDecodeErrorZ {
5384 let res = crate::c_types::deserialize_obj(ser);
5385 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() };
5389 /// Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read
5390 pub extern "C" fn UpdateFulfillHTLC_write(obj: &UpdateFulfillHTLC) -> crate::c_types::derived::CVec_u8Z {
5391 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5394 pub(crate) extern "C" fn UpdateFulfillHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5395 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFulfillHTLC) })
5398 /// Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write
5399 pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFulfillHTLCDecodeErrorZ {
5400 let res = crate::c_types::deserialize_obj(ser);
5401 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() };
5405 /// Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read
5406 pub extern "C" fn UpdateAddHTLC_write(obj: &UpdateAddHTLC) -> crate::c_types::derived::CVec_u8Z {
5407 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5410 pub(crate) extern "C" fn UpdateAddHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5411 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateAddHTLC) })
5414 /// Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write
5415 pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateAddHTLCDecodeErrorZ {
5416 let res = crate::c_types::deserialize_obj(ser);
5417 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() };
5421 /// Serialize the Ping object into a byte array which can be read by Ping_read
5422 pub extern "C" fn Ping_write(obj: &Ping) -> crate::c_types::derived::CVec_u8Z {
5423 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5426 pub(crate) extern "C" fn Ping_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5427 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePing) })
5430 /// Read a Ping from a byte array, created by Ping_write
5431 pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PingDecodeErrorZ {
5432 let res = crate::c_types::deserialize_obj(ser);
5433 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() };
5437 /// Serialize the Pong object into a byte array which can be read by Pong_read
5438 pub extern "C" fn Pong_write(obj: &Pong) -> crate::c_types::derived::CVec_u8Z {
5439 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5442 pub(crate) extern "C" fn Pong_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5443 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePong) })
5446 /// Read a Pong from a byte array, created by Pong_write
5447 pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PongDecodeErrorZ {
5448 let res = crate::c_types::deserialize_obj(ser);
5449 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() };
5453 /// Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read
5454 pub extern "C" fn UnsignedChannelAnnouncement_write(obj: &UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
5455 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5458 pub(crate) extern "C" fn UnsignedChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5459 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelAnnouncement) })
5462 /// Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write
5463 pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelAnnouncementDecodeErrorZ {
5464 let res = crate::c_types::deserialize_obj(ser);
5465 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() };
5469 /// Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read
5470 pub extern "C" fn ChannelAnnouncement_write(obj: &ChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
5471 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5474 pub(crate) extern "C" fn ChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5475 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelAnnouncement) })
5478 /// Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write
5479 pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelAnnouncementDecodeErrorZ {
5480 let res = crate::c_types::deserialize_obj(ser);
5481 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() };
5485 /// Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read
5486 pub extern "C" fn UnsignedChannelUpdate_write(obj: &UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
5487 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5490 pub(crate) extern "C" fn UnsignedChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5491 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelUpdate) })
5494 /// Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write
5495 pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelUpdateDecodeErrorZ {
5496 let res = crate::c_types::deserialize_obj(ser);
5497 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() };
5501 /// Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read
5502 pub extern "C" fn ChannelUpdate_write(obj: &ChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
5503 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5506 pub(crate) extern "C" fn ChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5507 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdate) })
5510 /// Read a ChannelUpdate from a byte array, created by ChannelUpdate_write
5511 pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelUpdateDecodeErrorZ {
5512 let res = crate::c_types::deserialize_obj(ser);
5513 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() };
5517 /// Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read
5518 pub extern "C" fn ErrorMessage_write(obj: &ErrorMessage) -> crate::c_types::derived::CVec_u8Z {
5519 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5522 pub(crate) extern "C" fn ErrorMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5523 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeErrorMessage) })
5526 /// Read a ErrorMessage from a byte array, created by ErrorMessage_write
5527 pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ErrorMessageDecodeErrorZ {
5528 let res = crate::c_types::deserialize_obj(ser);
5529 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::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() };
5533 /// Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read
5534 pub extern "C" fn UnsignedNodeAnnouncement_write(obj: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
5535 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5538 pub(crate) extern "C" fn UnsignedNodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5539 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedNodeAnnouncement) })
5542 /// Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write
5543 pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedNodeAnnouncementDecodeErrorZ {
5544 let res = crate::c_types::deserialize_obj(ser);
5545 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::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() };
5549 /// Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read
5550 pub extern "C" fn NodeAnnouncement_write(obj: &NodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
5551 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5554 pub(crate) extern "C" fn NodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5555 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncement) })
5558 /// Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write
5559 pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementDecodeErrorZ {
5560 let res = crate::c_types::deserialize_obj(ser);
5561 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::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() };
5565 /// Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write
5566 pub extern "C" fn QueryShortChannelIds_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryShortChannelIdsDecodeErrorZ {
5567 let res = crate::c_types::deserialize_obj(ser);
5568 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() };
5572 /// Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read
5573 pub extern "C" fn QueryShortChannelIds_write(obj: &QueryShortChannelIds) -> crate::c_types::derived::CVec_u8Z {
5574 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5577 pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5578 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) })
5581 /// Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read
5582 pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z {
5583 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5586 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5587 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) })
5590 /// Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write
5591 pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyShortChannelIdsEndDecodeErrorZ {
5592 let res = crate::c_types::deserialize_obj(ser);
5593 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::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() };
5596 ///\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
5599 pub extern "C" fn QueryChannelRange_end_blocknum(this_arg: &QueryChannelRange) -> u32 {
5600 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.end_blocknum();
5605 /// Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read
5606 pub extern "C" fn QueryChannelRange_write(obj: &QueryChannelRange) -> crate::c_types::derived::CVec_u8Z {
5607 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5610 pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5611 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) })
5614 /// Read a QueryChannelRange from a byte array, created by QueryChannelRange_write
5615 pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ {
5616 let res = crate::c_types::deserialize_obj(ser);
5617 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() };
5621 /// Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write
5622 pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyChannelRangeDecodeErrorZ {
5623 let res = crate::c_types::deserialize_obj(ser);
5624 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() };
5628 /// Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read
5629 pub extern "C" fn ReplyChannelRange_write(obj: &ReplyChannelRange) -> crate::c_types::derived::CVec_u8Z {
5630 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5633 pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5634 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) })
5637 /// Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read
5638 pub extern "C" fn GossipTimestampFilter_write(obj: &GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z {
5639 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5642 pub(crate) extern "C" fn GossipTimestampFilter_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5643 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeGossipTimestampFilter) })
5646 /// Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write
5647 pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_GossipTimestampFilterDecodeErrorZ {
5648 let res = crate::c_types::deserialize_obj(ser);
5649 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() };