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 /// The channel type that this channel will represent. If none is set, we derive the channel
742 /// type from the intersection of our feature bits with our counterparty's feature bits from
743 /// the Init message.
745 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
747 pub extern "C" fn OpenChannel_get_channel_type(this_ptr: &OpenChannel) -> crate::lightning::ln::features::ChannelTypeFeatures {
748 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
749 let mut local_inner_val = crate::lightning::ln::features::ChannelTypeFeatures { 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::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false };
752 /// The channel type that this channel will represent. If none is set, we derive the channel
753 /// type from the intersection of our feature bits with our counterparty's feature bits from
754 /// the Init message.
756 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
758 pub extern "C" fn OpenChannel_set_channel_type(this_ptr: &mut OpenChannel, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
759 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
760 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
762 impl Clone for OpenChannel {
763 fn clone(&self) -> Self {
765 inner: if <*mut nativeOpenChannel>::is_null(self.inner) { std::ptr::null_mut() } else {
766 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
772 /// Used only if an object of this type is returned as a trait impl by a method
773 pub(crate) extern "C" fn OpenChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
774 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOpenChannel)).clone() })) as *mut c_void
777 /// Creates a copy of the OpenChannel
778 pub extern "C" fn OpenChannel_clone(orig: &OpenChannel) -> OpenChannel {
782 use lightning::ln::msgs::AcceptChannel as nativeAcceptChannelImport;
783 pub(crate) type nativeAcceptChannel = nativeAcceptChannelImport;
785 /// An accept_channel message to be sent or received from a peer
788 pub struct AcceptChannel {
789 /// A pointer to the opaque Rust object.
791 /// Nearly everywhere, inner must be non-null, however in places where
792 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
793 pub inner: *mut nativeAcceptChannel,
794 /// Indicates that this is the only struct which contains the same pointer.
796 /// Rust functions which take ownership of an object provided via an argument require
797 /// this to be true and invalidate the object pointed to by inner.
801 impl Drop for AcceptChannel {
803 if self.is_owned && !<*mut nativeAcceptChannel>::is_null(self.inner) {
804 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
808 /// Frees any resources used by the AcceptChannel, if is_owned is set and inner is non-NULL.
810 pub extern "C" fn AcceptChannel_free(this_obj: AcceptChannel) { }
812 /// Used only if an object of this type is returned as a trait impl by a method
813 pub(crate) extern "C" fn AcceptChannel_free_void(this_ptr: *mut c_void) {
814 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeAcceptChannel); }
818 pub(crate) fn get_native_ref(&self) -> &'static nativeAcceptChannel {
819 unsafe { &*ObjOps::untweak_ptr(self.inner) }
821 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAcceptChannel {
822 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
824 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
825 pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannel {
826 assert!(self.is_owned);
827 let ret = ObjOps::untweak_ptr(self.inner);
828 self.inner = std::ptr::null_mut();
832 /// A temporary channel ID, until the funding outpoint is announced
834 pub extern "C" fn AcceptChannel_get_temporary_channel_id(this_ptr: &AcceptChannel) -> *const [u8; 32] {
835 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
838 /// A temporary channel ID, until the funding outpoint is announced
840 pub extern "C" fn AcceptChannel_set_temporary_channel_id(this_ptr: &mut AcceptChannel, mut val: crate::c_types::ThirtyTwoBytes) {
841 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
843 /// The threshold below which outputs on transactions broadcast by sender will be omitted
845 pub extern "C" fn AcceptChannel_get_dust_limit_satoshis(this_ptr: &AcceptChannel) -> u64 {
846 let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
849 /// The threshold below which outputs on transactions broadcast by sender will be omitted
851 pub extern "C" fn AcceptChannel_set_dust_limit_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
852 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
854 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
856 pub extern "C" fn AcceptChannel_get_max_htlc_value_in_flight_msat(this_ptr: &AcceptChannel) -> u64 {
857 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
860 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
862 pub extern "C" fn AcceptChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
863 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
865 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
867 pub extern "C" fn AcceptChannel_get_channel_reserve_satoshis(this_ptr: &AcceptChannel) -> u64 {
868 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
871 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
873 pub extern "C" fn AcceptChannel_set_channel_reserve_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
874 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
876 /// The minimum HTLC size incoming to sender, in milli-satoshi
878 pub extern "C" fn AcceptChannel_get_htlc_minimum_msat(this_ptr: &AcceptChannel) -> u64 {
879 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
882 /// The minimum HTLC size incoming to sender, in milli-satoshi
884 pub extern "C" fn AcceptChannel_set_htlc_minimum_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
885 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
887 /// Minimum depth of the funding transaction before the channel is considered open
889 pub extern "C" fn AcceptChannel_get_minimum_depth(this_ptr: &AcceptChannel) -> u32 {
890 let mut inner_val = &mut this_ptr.get_native_mut_ref().minimum_depth;
893 /// Minimum depth of the funding transaction before the channel is considered open
895 pub extern "C" fn AcceptChannel_set_minimum_depth(this_ptr: &mut AcceptChannel, mut val: u32) {
896 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.minimum_depth = val;
898 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
900 pub extern "C" fn AcceptChannel_get_to_self_delay(this_ptr: &AcceptChannel) -> u16 {
901 let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
904 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
906 pub extern "C" fn AcceptChannel_set_to_self_delay(this_ptr: &mut AcceptChannel, mut val: u16) {
907 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
909 /// The maximum number of inbound HTLCs towards sender
911 pub extern "C" fn AcceptChannel_get_max_accepted_htlcs(this_ptr: &AcceptChannel) -> u16 {
912 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
915 /// The maximum number of inbound HTLCs towards sender
917 pub extern "C" fn AcceptChannel_set_max_accepted_htlcs(this_ptr: &mut AcceptChannel, mut val: u16) {
918 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
920 /// The sender's key controlling the funding transaction
922 pub extern "C" fn AcceptChannel_get_funding_pubkey(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
923 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
924 crate::c_types::PublicKey::from_rust(&inner_val)
926 /// The sender's key controlling the funding transaction
928 pub extern "C" fn AcceptChannel_set_funding_pubkey(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
929 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
931 /// Used to derive a revocation key for transactions broadcast by counterparty
933 pub extern "C" fn AcceptChannel_get_revocation_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
934 let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
935 crate::c_types::PublicKey::from_rust(&inner_val)
937 /// Used to derive a revocation key for transactions broadcast by counterparty
939 pub extern "C" fn AcceptChannel_set_revocation_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
940 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
942 /// A payment key to sender for transactions broadcast by counterparty
944 pub extern "C" fn AcceptChannel_get_payment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
945 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_point;
946 crate::c_types::PublicKey::from_rust(&inner_val)
948 /// A payment key to sender for transactions broadcast by counterparty
950 pub extern "C" fn AcceptChannel_set_payment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
951 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_point = val.into_rust();
953 /// Used to derive a payment key to sender for transactions broadcast by sender
955 pub extern "C" fn AcceptChannel_get_delayed_payment_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
956 let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
957 crate::c_types::PublicKey::from_rust(&inner_val)
959 /// Used to derive a payment key to sender for transactions broadcast by sender
961 pub extern "C" fn AcceptChannel_set_delayed_payment_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
962 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
964 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
966 pub extern "C" fn AcceptChannel_get_htlc_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
967 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
968 crate::c_types::PublicKey::from_rust(&inner_val)
970 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
972 pub extern "C" fn AcceptChannel_set_htlc_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
973 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
975 /// The first to-be-broadcast-by-sender transaction's per commitment point
977 pub extern "C" fn AcceptChannel_get_first_per_commitment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
978 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
979 crate::c_types::PublicKey::from_rust(&inner_val)
981 /// The first to-be-broadcast-by-sender transaction's per commitment point
983 pub extern "C" fn AcceptChannel_set_first_per_commitment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
984 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
986 impl Clone for AcceptChannel {
987 fn clone(&self) -> Self {
989 inner: if <*mut nativeAcceptChannel>::is_null(self.inner) { std::ptr::null_mut() } else {
990 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
996 /// Used only if an object of this type is returned as a trait impl by a method
997 pub(crate) extern "C" fn AcceptChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
998 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAcceptChannel)).clone() })) as *mut c_void
1001 /// Creates a copy of the AcceptChannel
1002 pub extern "C" fn AcceptChannel_clone(orig: &AcceptChannel) -> AcceptChannel {
1006 use lightning::ln::msgs::FundingCreated as nativeFundingCreatedImport;
1007 pub(crate) type nativeFundingCreated = nativeFundingCreatedImport;
1009 /// A funding_created message to be sent or received from a peer
1012 pub struct FundingCreated {
1013 /// A pointer to the opaque Rust object.
1015 /// Nearly everywhere, inner must be non-null, however in places where
1016 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1017 pub inner: *mut nativeFundingCreated,
1018 /// Indicates that this is the only struct which contains the same pointer.
1020 /// Rust functions which take ownership of an object provided via an argument require
1021 /// this to be true and invalidate the object pointed to by inner.
1025 impl Drop for FundingCreated {
1026 fn drop(&mut self) {
1027 if self.is_owned && !<*mut nativeFundingCreated>::is_null(self.inner) {
1028 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1032 /// Frees any resources used by the FundingCreated, if is_owned is set and inner is non-NULL.
1034 pub extern "C" fn FundingCreated_free(this_obj: FundingCreated) { }
1036 /// Used only if an object of this type is returned as a trait impl by a method
1037 pub(crate) extern "C" fn FundingCreated_free_void(this_ptr: *mut c_void) {
1038 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingCreated); }
1041 impl FundingCreated {
1042 pub(crate) fn get_native_ref(&self) -> &'static nativeFundingCreated {
1043 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1045 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingCreated {
1046 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1048 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1049 pub(crate) fn take_inner(mut self) -> *mut nativeFundingCreated {
1050 assert!(self.is_owned);
1051 let ret = ObjOps::untweak_ptr(self.inner);
1052 self.inner = std::ptr::null_mut();
1056 /// A temporary channel ID, until the funding is established
1058 pub extern "C" fn FundingCreated_get_temporary_channel_id(this_ptr: &FundingCreated) -> *const [u8; 32] {
1059 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
1062 /// A temporary channel ID, until the funding is established
1064 pub extern "C" fn FundingCreated_set_temporary_channel_id(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
1065 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
1067 /// The funding transaction ID
1069 pub extern "C" fn FundingCreated_get_funding_txid(this_ptr: &FundingCreated) -> *const [u8; 32] {
1070 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_txid;
1071 inner_val.as_inner()
1073 /// The funding transaction ID
1075 pub extern "C" fn FundingCreated_set_funding_txid(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
1076 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_txid = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
1078 /// The specific output index funding this channel
1080 pub extern "C" fn FundingCreated_get_funding_output_index(this_ptr: &FundingCreated) -> u16 {
1081 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_index;
1084 /// The specific output index funding this channel
1086 pub extern "C" fn FundingCreated_set_funding_output_index(this_ptr: &mut FundingCreated, mut val: u16) {
1087 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_index = val;
1089 /// The signature of the channel initiator (funder) on the initial commitment transaction
1091 pub extern "C" fn FundingCreated_get_signature(this_ptr: &FundingCreated) -> crate::c_types::Signature {
1092 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
1093 crate::c_types::Signature::from_rust(&inner_val)
1095 /// The signature of the channel initiator (funder) on the initial commitment transaction
1097 pub extern "C" fn FundingCreated_set_signature(this_ptr: &mut FundingCreated, mut val: crate::c_types::Signature) {
1098 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
1100 /// Constructs a new FundingCreated given each field
1103 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 {
1104 FundingCreated { inner: ObjOps::heap_alloc(nativeFundingCreated {
1105 temporary_channel_id: temporary_channel_id_arg.data,
1106 funding_txid: ::bitcoin::hash_types::Txid::from_slice(&funding_txid_arg.data[..]).unwrap(),
1107 funding_output_index: funding_output_index_arg,
1108 signature: signature_arg.into_rust(),
1109 }), is_owned: true }
1111 impl Clone for FundingCreated {
1112 fn clone(&self) -> Self {
1114 inner: if <*mut nativeFundingCreated>::is_null(self.inner) { std::ptr::null_mut() } else {
1115 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1121 /// Used only if an object of this type is returned as a trait impl by a method
1122 pub(crate) extern "C" fn FundingCreated_clone_void(this_ptr: *const c_void) -> *mut c_void {
1123 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingCreated)).clone() })) as *mut c_void
1126 /// Creates a copy of the FundingCreated
1127 pub extern "C" fn FundingCreated_clone(orig: &FundingCreated) -> FundingCreated {
1131 use lightning::ln::msgs::FundingSigned as nativeFundingSignedImport;
1132 pub(crate) type nativeFundingSigned = nativeFundingSignedImport;
1134 /// A funding_signed message to be sent or received from a peer
1137 pub struct FundingSigned {
1138 /// A pointer to the opaque Rust object.
1140 /// Nearly everywhere, inner must be non-null, however in places where
1141 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1142 pub inner: *mut nativeFundingSigned,
1143 /// Indicates that this is the only struct which contains the same pointer.
1145 /// Rust functions which take ownership of an object provided via an argument require
1146 /// this to be true and invalidate the object pointed to by inner.
1150 impl Drop for FundingSigned {
1151 fn drop(&mut self) {
1152 if self.is_owned && !<*mut nativeFundingSigned>::is_null(self.inner) {
1153 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1157 /// Frees any resources used by the FundingSigned, if is_owned is set and inner is non-NULL.
1159 pub extern "C" fn FundingSigned_free(this_obj: FundingSigned) { }
1161 /// Used only if an object of this type is returned as a trait impl by a method
1162 pub(crate) extern "C" fn FundingSigned_free_void(this_ptr: *mut c_void) {
1163 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingSigned); }
1166 impl FundingSigned {
1167 pub(crate) fn get_native_ref(&self) -> &'static nativeFundingSigned {
1168 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1170 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingSigned {
1171 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1173 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1174 pub(crate) fn take_inner(mut self) -> *mut nativeFundingSigned {
1175 assert!(self.is_owned);
1176 let ret = ObjOps::untweak_ptr(self.inner);
1177 self.inner = std::ptr::null_mut();
1183 pub extern "C" fn FundingSigned_get_channel_id(this_ptr: &FundingSigned) -> *const [u8; 32] {
1184 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1189 pub extern "C" fn FundingSigned_set_channel_id(this_ptr: &mut FundingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
1190 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1192 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
1194 pub extern "C" fn FundingSigned_get_signature(this_ptr: &FundingSigned) -> crate::c_types::Signature {
1195 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
1196 crate::c_types::Signature::from_rust(&inner_val)
1198 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
1200 pub extern "C" fn FundingSigned_set_signature(this_ptr: &mut FundingSigned, mut val: crate::c_types::Signature) {
1201 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
1203 /// Constructs a new FundingSigned given each field
1206 pub extern "C" fn FundingSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut signature_arg: crate::c_types::Signature) -> FundingSigned {
1207 FundingSigned { inner: ObjOps::heap_alloc(nativeFundingSigned {
1208 channel_id: channel_id_arg.data,
1209 signature: signature_arg.into_rust(),
1210 }), is_owned: true }
1212 impl Clone for FundingSigned {
1213 fn clone(&self) -> Self {
1215 inner: if <*mut nativeFundingSigned>::is_null(self.inner) { std::ptr::null_mut() } else {
1216 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1222 /// Used only if an object of this type is returned as a trait impl by a method
1223 pub(crate) extern "C" fn FundingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
1224 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingSigned)).clone() })) as *mut c_void
1227 /// Creates a copy of the FundingSigned
1228 pub extern "C" fn FundingSigned_clone(orig: &FundingSigned) -> FundingSigned {
1232 use lightning::ln::msgs::FundingLocked as nativeFundingLockedImport;
1233 pub(crate) type nativeFundingLocked = nativeFundingLockedImport;
1235 /// A funding_locked message to be sent or received from a peer
1238 pub struct FundingLocked {
1239 /// A pointer to the opaque Rust object.
1241 /// Nearly everywhere, inner must be non-null, however in places where
1242 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1243 pub inner: *mut nativeFundingLocked,
1244 /// Indicates that this is the only struct which contains the same pointer.
1246 /// Rust functions which take ownership of an object provided via an argument require
1247 /// this to be true and invalidate the object pointed to by inner.
1251 impl Drop for FundingLocked {
1252 fn drop(&mut self) {
1253 if self.is_owned && !<*mut nativeFundingLocked>::is_null(self.inner) {
1254 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1258 /// Frees any resources used by the FundingLocked, if is_owned is set and inner is non-NULL.
1260 pub extern "C" fn FundingLocked_free(this_obj: FundingLocked) { }
1262 /// Used only if an object of this type is returned as a trait impl by a method
1263 pub(crate) extern "C" fn FundingLocked_free_void(this_ptr: *mut c_void) {
1264 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingLocked); }
1267 impl FundingLocked {
1268 pub(crate) fn get_native_ref(&self) -> &'static nativeFundingLocked {
1269 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1271 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingLocked {
1272 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1274 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1275 pub(crate) fn take_inner(mut self) -> *mut nativeFundingLocked {
1276 assert!(self.is_owned);
1277 let ret = ObjOps::untweak_ptr(self.inner);
1278 self.inner = std::ptr::null_mut();
1284 pub extern "C" fn FundingLocked_get_channel_id(this_ptr: &FundingLocked) -> *const [u8; 32] {
1285 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1290 pub extern "C" fn FundingLocked_set_channel_id(this_ptr: &mut FundingLocked, mut val: crate::c_types::ThirtyTwoBytes) {
1291 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1293 /// The per-commitment point of the second commitment transaction
1295 pub extern "C" fn FundingLocked_get_next_per_commitment_point(this_ptr: &FundingLocked) -> crate::c_types::PublicKey {
1296 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
1297 crate::c_types::PublicKey::from_rust(&inner_val)
1299 /// The per-commitment point of the second commitment transaction
1301 pub extern "C" fn FundingLocked_set_next_per_commitment_point(this_ptr: &mut FundingLocked, mut val: crate::c_types::PublicKey) {
1302 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
1304 /// Constructs a new FundingLocked given each field
1307 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 {
1308 FundingLocked { inner: ObjOps::heap_alloc(nativeFundingLocked {
1309 channel_id: channel_id_arg.data,
1310 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
1311 }), is_owned: true }
1313 impl Clone for FundingLocked {
1314 fn clone(&self) -> Self {
1316 inner: if <*mut nativeFundingLocked>::is_null(self.inner) { std::ptr::null_mut() } else {
1317 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1323 /// Used only if an object of this type is returned as a trait impl by a method
1324 pub(crate) extern "C" fn FundingLocked_clone_void(this_ptr: *const c_void) -> *mut c_void {
1325 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingLocked)).clone() })) as *mut c_void
1328 /// Creates a copy of the FundingLocked
1329 pub extern "C" fn FundingLocked_clone(orig: &FundingLocked) -> FundingLocked {
1333 use lightning::ln::msgs::Shutdown as nativeShutdownImport;
1334 pub(crate) type nativeShutdown = nativeShutdownImport;
1336 /// A shutdown message to be sent or received from a peer
1339 pub struct Shutdown {
1340 /// A pointer to the opaque Rust object.
1342 /// Nearly everywhere, inner must be non-null, however in places where
1343 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1344 pub inner: *mut nativeShutdown,
1345 /// Indicates that this is the only struct which contains the same pointer.
1347 /// Rust functions which take ownership of an object provided via an argument require
1348 /// this to be true and invalidate the object pointed to by inner.
1352 impl Drop for Shutdown {
1353 fn drop(&mut self) {
1354 if self.is_owned && !<*mut nativeShutdown>::is_null(self.inner) {
1355 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1359 /// Frees any resources used by the Shutdown, if is_owned is set and inner is non-NULL.
1361 pub extern "C" fn Shutdown_free(this_obj: Shutdown) { }
1363 /// Used only if an object of this type is returned as a trait impl by a method
1364 pub(crate) extern "C" fn Shutdown_free_void(this_ptr: *mut c_void) {
1365 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeShutdown); }
1369 pub(crate) fn get_native_ref(&self) -> &'static nativeShutdown {
1370 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1372 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeShutdown {
1373 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1375 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1376 pub(crate) fn take_inner(mut self) -> *mut nativeShutdown {
1377 assert!(self.is_owned);
1378 let ret = ObjOps::untweak_ptr(self.inner);
1379 self.inner = std::ptr::null_mut();
1385 pub extern "C" fn Shutdown_get_channel_id(this_ptr: &Shutdown) -> *const [u8; 32] {
1386 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1391 pub extern "C" fn Shutdown_set_channel_id(this_ptr: &mut Shutdown, mut val: crate::c_types::ThirtyTwoBytes) {
1392 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1394 /// The destination of this peer's funds on closing.
1395 /// Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
1397 pub extern "C" fn Shutdown_get_scriptpubkey(this_ptr: &Shutdown) -> crate::c_types::u8slice {
1398 let mut inner_val = &mut this_ptr.get_native_mut_ref().scriptpubkey;
1399 crate::c_types::u8slice::from_slice(&inner_val[..])
1401 /// The destination of this peer's funds on closing.
1402 /// Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
1404 pub extern "C" fn Shutdown_set_scriptpubkey(this_ptr: &mut Shutdown, mut val: crate::c_types::derived::CVec_u8Z) {
1405 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.scriptpubkey = ::bitcoin::blockdata::script::Script::from(val.into_rust());
1407 /// Constructs a new Shutdown given each field
1410 pub extern "C" fn Shutdown_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut scriptpubkey_arg: crate::c_types::derived::CVec_u8Z) -> Shutdown {
1411 Shutdown { inner: ObjOps::heap_alloc(nativeShutdown {
1412 channel_id: channel_id_arg.data,
1413 scriptpubkey: ::bitcoin::blockdata::script::Script::from(scriptpubkey_arg.into_rust()),
1414 }), is_owned: true }
1416 impl Clone for Shutdown {
1417 fn clone(&self) -> Self {
1419 inner: if <*mut nativeShutdown>::is_null(self.inner) { std::ptr::null_mut() } else {
1420 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1426 /// Used only if an object of this type is returned as a trait impl by a method
1427 pub(crate) extern "C" fn Shutdown_clone_void(this_ptr: *const c_void) -> *mut c_void {
1428 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeShutdown)).clone() })) as *mut c_void
1431 /// Creates a copy of the Shutdown
1432 pub extern "C" fn Shutdown_clone(orig: &Shutdown) -> Shutdown {
1436 use lightning::ln::msgs::ClosingSignedFeeRange as nativeClosingSignedFeeRangeImport;
1437 pub(crate) type nativeClosingSignedFeeRange = nativeClosingSignedFeeRangeImport;
1439 /// The minimum and maximum fees which the sender is willing to place on the closing transaction.
1440 /// This is provided in [`ClosingSigned`] by both sides to indicate the fee range they are willing
1444 pub struct ClosingSignedFeeRange {
1445 /// A pointer to the opaque Rust object.
1447 /// Nearly everywhere, inner must be non-null, however in places where
1448 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1449 pub inner: *mut nativeClosingSignedFeeRange,
1450 /// Indicates that this is the only struct which contains the same pointer.
1452 /// Rust functions which take ownership of an object provided via an argument require
1453 /// this to be true and invalidate the object pointed to by inner.
1457 impl Drop for ClosingSignedFeeRange {
1458 fn drop(&mut self) {
1459 if self.is_owned && !<*mut nativeClosingSignedFeeRange>::is_null(self.inner) {
1460 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1464 /// Frees any resources used by the ClosingSignedFeeRange, if is_owned is set and inner is non-NULL.
1466 pub extern "C" fn ClosingSignedFeeRange_free(this_obj: ClosingSignedFeeRange) { }
1468 /// Used only if an object of this type is returned as a trait impl by a method
1469 pub(crate) extern "C" fn ClosingSignedFeeRange_free_void(this_ptr: *mut c_void) {
1470 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeClosingSignedFeeRange); }
1473 impl ClosingSignedFeeRange {
1474 pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSignedFeeRange {
1475 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1477 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSignedFeeRange {
1478 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1480 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1481 pub(crate) fn take_inner(mut self) -> *mut nativeClosingSignedFeeRange {
1482 assert!(self.is_owned);
1483 let ret = ObjOps::untweak_ptr(self.inner);
1484 self.inner = std::ptr::null_mut();
1488 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
1491 pub extern "C" fn ClosingSignedFeeRange_get_min_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
1492 let mut inner_val = &mut this_ptr.get_native_mut_ref().min_fee_satoshis;
1495 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
1498 pub extern "C" fn ClosingSignedFeeRange_set_min_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
1499 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_fee_satoshis = val;
1501 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
1504 pub extern "C" fn ClosingSignedFeeRange_get_max_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
1505 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_fee_satoshis;
1508 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
1511 pub extern "C" fn ClosingSignedFeeRange_set_max_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
1512 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_fee_satoshis = val;
1514 /// Constructs a new ClosingSignedFeeRange given each field
1517 pub extern "C" fn ClosingSignedFeeRange_new(mut min_fee_satoshis_arg: u64, mut max_fee_satoshis_arg: u64) -> ClosingSignedFeeRange {
1518 ClosingSignedFeeRange { inner: ObjOps::heap_alloc(nativeClosingSignedFeeRange {
1519 min_fee_satoshis: min_fee_satoshis_arg,
1520 max_fee_satoshis: max_fee_satoshis_arg,
1521 }), is_owned: true }
1523 impl Clone for ClosingSignedFeeRange {
1524 fn clone(&self) -> Self {
1526 inner: if <*mut nativeClosingSignedFeeRange>::is_null(self.inner) { std::ptr::null_mut() } else {
1527 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1533 /// Used only if an object of this type is returned as a trait impl by a method
1534 pub(crate) extern "C" fn ClosingSignedFeeRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
1535 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClosingSignedFeeRange)).clone() })) as *mut c_void
1538 /// Creates a copy of the ClosingSignedFeeRange
1539 pub extern "C" fn ClosingSignedFeeRange_clone(orig: &ClosingSignedFeeRange) -> ClosingSignedFeeRange {
1543 use lightning::ln::msgs::ClosingSigned as nativeClosingSignedImport;
1544 pub(crate) type nativeClosingSigned = nativeClosingSignedImport;
1546 /// A closing_signed message to be sent or received from a peer
1549 pub struct ClosingSigned {
1550 /// A pointer to the opaque Rust object.
1552 /// Nearly everywhere, inner must be non-null, however in places where
1553 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1554 pub inner: *mut nativeClosingSigned,
1555 /// Indicates that this is the only struct which contains the same pointer.
1557 /// Rust functions which take ownership of an object provided via an argument require
1558 /// this to be true and invalidate the object pointed to by inner.
1562 impl Drop for ClosingSigned {
1563 fn drop(&mut self) {
1564 if self.is_owned && !<*mut nativeClosingSigned>::is_null(self.inner) {
1565 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1569 /// Frees any resources used by the ClosingSigned, if is_owned is set and inner is non-NULL.
1571 pub extern "C" fn ClosingSigned_free(this_obj: ClosingSigned) { }
1573 /// Used only if an object of this type is returned as a trait impl by a method
1574 pub(crate) extern "C" fn ClosingSigned_free_void(this_ptr: *mut c_void) {
1575 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeClosingSigned); }
1578 impl ClosingSigned {
1579 pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSigned {
1580 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1582 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSigned {
1583 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1585 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1586 pub(crate) fn take_inner(mut self) -> *mut nativeClosingSigned {
1587 assert!(self.is_owned);
1588 let ret = ObjOps::untweak_ptr(self.inner);
1589 self.inner = std::ptr::null_mut();
1595 pub extern "C" fn ClosingSigned_get_channel_id(this_ptr: &ClosingSigned) -> *const [u8; 32] {
1596 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1601 pub extern "C" fn ClosingSigned_set_channel_id(this_ptr: &mut ClosingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
1602 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1604 /// The proposed total fee for the closing transaction
1606 pub extern "C" fn ClosingSigned_get_fee_satoshis(this_ptr: &ClosingSigned) -> u64 {
1607 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_satoshis;
1610 /// The proposed total fee for the closing transaction
1612 pub extern "C" fn ClosingSigned_set_fee_satoshis(this_ptr: &mut ClosingSigned, mut val: u64) {
1613 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_satoshis = val;
1615 /// A signature on the closing transaction
1617 pub extern "C" fn ClosingSigned_get_signature(this_ptr: &ClosingSigned) -> crate::c_types::Signature {
1618 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
1619 crate::c_types::Signature::from_rust(&inner_val)
1621 /// A signature on the closing transaction
1623 pub extern "C" fn ClosingSigned_set_signature(this_ptr: &mut ClosingSigned, mut val: crate::c_types::Signature) {
1624 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
1626 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
1629 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1631 pub extern "C" fn ClosingSigned_get_fee_range(this_ptr: &ClosingSigned) -> crate::lightning::ln::msgs::ClosingSignedFeeRange {
1632 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_range;
1633 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 };
1636 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
1639 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1641 pub extern "C" fn ClosingSigned_set_fee_range(this_ptr: &mut ClosingSigned, mut val: crate::lightning::ln::msgs::ClosingSignedFeeRange) {
1642 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1643 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_range = local_val;
1645 /// Constructs a new ClosingSigned given each field
1648 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 {
1649 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()) } }) };
1650 ClosingSigned { inner: ObjOps::heap_alloc(nativeClosingSigned {
1651 channel_id: channel_id_arg.data,
1652 fee_satoshis: fee_satoshis_arg,
1653 signature: signature_arg.into_rust(),
1654 fee_range: local_fee_range_arg,
1655 }), is_owned: true }
1657 impl Clone for ClosingSigned {
1658 fn clone(&self) -> Self {
1660 inner: if <*mut nativeClosingSigned>::is_null(self.inner) { std::ptr::null_mut() } else {
1661 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1667 /// Used only if an object of this type is returned as a trait impl by a method
1668 pub(crate) extern "C" fn ClosingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
1669 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClosingSigned)).clone() })) as *mut c_void
1672 /// Creates a copy of the ClosingSigned
1673 pub extern "C" fn ClosingSigned_clone(orig: &ClosingSigned) -> ClosingSigned {
1677 use lightning::ln::msgs::UpdateAddHTLC as nativeUpdateAddHTLCImport;
1678 pub(crate) type nativeUpdateAddHTLC = nativeUpdateAddHTLCImport;
1680 /// An update_add_htlc message to be sent or received from a peer
1683 pub struct UpdateAddHTLC {
1684 /// A pointer to the opaque Rust object.
1686 /// Nearly everywhere, inner must be non-null, however in places where
1687 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1688 pub inner: *mut nativeUpdateAddHTLC,
1689 /// Indicates that this is the only struct which contains the same pointer.
1691 /// Rust functions which take ownership of an object provided via an argument require
1692 /// this to be true and invalidate the object pointed to by inner.
1696 impl Drop for UpdateAddHTLC {
1697 fn drop(&mut self) {
1698 if self.is_owned && !<*mut nativeUpdateAddHTLC>::is_null(self.inner) {
1699 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1703 /// Frees any resources used by the UpdateAddHTLC, if is_owned is set and inner is non-NULL.
1705 pub extern "C" fn UpdateAddHTLC_free(this_obj: UpdateAddHTLC) { }
1707 /// Used only if an object of this type is returned as a trait impl by a method
1708 pub(crate) extern "C" fn UpdateAddHTLC_free_void(this_ptr: *mut c_void) {
1709 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateAddHTLC); }
1712 impl UpdateAddHTLC {
1713 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateAddHTLC {
1714 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1716 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateAddHTLC {
1717 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1719 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1720 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateAddHTLC {
1721 assert!(self.is_owned);
1722 let ret = ObjOps::untweak_ptr(self.inner);
1723 self.inner = std::ptr::null_mut();
1729 pub extern "C" fn UpdateAddHTLC_get_channel_id(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
1730 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1735 pub extern "C" fn UpdateAddHTLC_set_channel_id(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1736 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1740 pub extern "C" fn UpdateAddHTLC_get_htlc_id(this_ptr: &UpdateAddHTLC) -> u64 {
1741 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
1746 pub extern "C" fn UpdateAddHTLC_set_htlc_id(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
1747 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
1749 /// The HTLC value in milli-satoshi
1751 pub extern "C" fn UpdateAddHTLC_get_amount_msat(this_ptr: &UpdateAddHTLC) -> u64 {
1752 let mut inner_val = &mut this_ptr.get_native_mut_ref().amount_msat;
1755 /// The HTLC value in milli-satoshi
1757 pub extern "C" fn UpdateAddHTLC_set_amount_msat(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
1758 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.amount_msat = val;
1760 /// The payment hash, the pre-image of which controls HTLC redemption
1762 pub extern "C" fn UpdateAddHTLC_get_payment_hash(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
1763 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_hash;
1766 /// The payment hash, the pre-image of which controls HTLC redemption
1768 pub extern "C" fn UpdateAddHTLC_set_payment_hash(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1769 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_hash = ::lightning::ln::PaymentHash(val.data);
1771 /// The expiry height of the HTLC
1773 pub extern "C" fn UpdateAddHTLC_get_cltv_expiry(this_ptr: &UpdateAddHTLC) -> u32 {
1774 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry;
1777 /// The expiry height of the HTLC
1779 pub extern "C" fn UpdateAddHTLC_set_cltv_expiry(this_ptr: &mut UpdateAddHTLC, mut val: u32) {
1780 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry = val;
1782 impl Clone for UpdateAddHTLC {
1783 fn clone(&self) -> Self {
1785 inner: if <*mut nativeUpdateAddHTLC>::is_null(self.inner) { std::ptr::null_mut() } else {
1786 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1792 /// Used only if an object of this type is returned as a trait impl by a method
1793 pub(crate) extern "C" fn UpdateAddHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1794 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateAddHTLC)).clone() })) as *mut c_void
1797 /// Creates a copy of the UpdateAddHTLC
1798 pub extern "C" fn UpdateAddHTLC_clone(orig: &UpdateAddHTLC) -> UpdateAddHTLC {
1802 use lightning::ln::msgs::UpdateFulfillHTLC as nativeUpdateFulfillHTLCImport;
1803 pub(crate) type nativeUpdateFulfillHTLC = nativeUpdateFulfillHTLCImport;
1805 /// An update_fulfill_htlc message to be sent or received from a peer
1808 pub struct UpdateFulfillHTLC {
1809 /// A pointer to the opaque Rust object.
1811 /// Nearly everywhere, inner must be non-null, however in places where
1812 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1813 pub inner: *mut nativeUpdateFulfillHTLC,
1814 /// Indicates that this is the only struct which contains the same pointer.
1816 /// Rust functions which take ownership of an object provided via an argument require
1817 /// this to be true and invalidate the object pointed to by inner.
1821 impl Drop for UpdateFulfillHTLC {
1822 fn drop(&mut self) {
1823 if self.is_owned && !<*mut nativeUpdateFulfillHTLC>::is_null(self.inner) {
1824 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1828 /// Frees any resources used by the UpdateFulfillHTLC, if is_owned is set and inner is non-NULL.
1830 pub extern "C" fn UpdateFulfillHTLC_free(this_obj: UpdateFulfillHTLC) { }
1832 /// Used only if an object of this type is returned as a trait impl by a method
1833 pub(crate) extern "C" fn UpdateFulfillHTLC_free_void(this_ptr: *mut c_void) {
1834 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFulfillHTLC); }
1837 impl UpdateFulfillHTLC {
1838 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFulfillHTLC {
1839 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1841 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFulfillHTLC {
1842 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1844 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1845 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFulfillHTLC {
1846 assert!(self.is_owned);
1847 let ret = ObjOps::untweak_ptr(self.inner);
1848 self.inner = std::ptr::null_mut();
1854 pub extern "C" fn UpdateFulfillHTLC_get_channel_id(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
1855 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1860 pub extern "C" fn UpdateFulfillHTLC_set_channel_id(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1861 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1865 pub extern "C" fn UpdateFulfillHTLC_get_htlc_id(this_ptr: &UpdateFulfillHTLC) -> u64 {
1866 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
1871 pub extern "C" fn UpdateFulfillHTLC_set_htlc_id(this_ptr: &mut UpdateFulfillHTLC, mut val: u64) {
1872 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
1874 /// The pre-image of the payment hash, allowing HTLC redemption
1876 pub extern "C" fn UpdateFulfillHTLC_get_payment_preimage(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
1877 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_preimage;
1880 /// The pre-image of the payment hash, allowing HTLC redemption
1882 pub extern "C" fn UpdateFulfillHTLC_set_payment_preimage(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1883 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_preimage = ::lightning::ln::PaymentPreimage(val.data);
1885 /// Constructs a new UpdateFulfillHTLC given each field
1888 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 {
1889 UpdateFulfillHTLC { inner: ObjOps::heap_alloc(nativeUpdateFulfillHTLC {
1890 channel_id: channel_id_arg.data,
1891 htlc_id: htlc_id_arg,
1892 payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_arg.data),
1893 }), is_owned: true }
1895 impl Clone for UpdateFulfillHTLC {
1896 fn clone(&self) -> Self {
1898 inner: if <*mut nativeUpdateFulfillHTLC>::is_null(self.inner) { std::ptr::null_mut() } else {
1899 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1905 /// Used only if an object of this type is returned as a trait impl by a method
1906 pub(crate) extern "C" fn UpdateFulfillHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1907 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFulfillHTLC)).clone() })) as *mut c_void
1910 /// Creates a copy of the UpdateFulfillHTLC
1911 pub extern "C" fn UpdateFulfillHTLC_clone(orig: &UpdateFulfillHTLC) -> UpdateFulfillHTLC {
1915 use lightning::ln::msgs::UpdateFailHTLC as nativeUpdateFailHTLCImport;
1916 pub(crate) type nativeUpdateFailHTLC = nativeUpdateFailHTLCImport;
1918 /// An update_fail_htlc message to be sent or received from a peer
1921 pub struct UpdateFailHTLC {
1922 /// A pointer to the opaque Rust object.
1924 /// Nearly everywhere, inner must be non-null, however in places where
1925 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1926 pub inner: *mut nativeUpdateFailHTLC,
1927 /// Indicates that this is the only struct which contains the same pointer.
1929 /// Rust functions which take ownership of an object provided via an argument require
1930 /// this to be true and invalidate the object pointed to by inner.
1934 impl Drop for UpdateFailHTLC {
1935 fn drop(&mut self) {
1936 if self.is_owned && !<*mut nativeUpdateFailHTLC>::is_null(self.inner) {
1937 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1941 /// Frees any resources used by the UpdateFailHTLC, if is_owned is set and inner is non-NULL.
1943 pub extern "C" fn UpdateFailHTLC_free(this_obj: UpdateFailHTLC) { }
1945 /// Used only if an object of this type is returned as a trait impl by a method
1946 pub(crate) extern "C" fn UpdateFailHTLC_free_void(this_ptr: *mut c_void) {
1947 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFailHTLC); }
1950 impl UpdateFailHTLC {
1951 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailHTLC {
1952 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1954 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailHTLC {
1955 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1957 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1958 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailHTLC {
1959 assert!(self.is_owned);
1960 let ret = ObjOps::untweak_ptr(self.inner);
1961 self.inner = std::ptr::null_mut();
1967 pub extern "C" fn UpdateFailHTLC_get_channel_id(this_ptr: &UpdateFailHTLC) -> *const [u8; 32] {
1968 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1973 pub extern "C" fn UpdateFailHTLC_set_channel_id(this_ptr: &mut UpdateFailHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1974 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1978 pub extern "C" fn UpdateFailHTLC_get_htlc_id(this_ptr: &UpdateFailHTLC) -> u64 {
1979 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
1984 pub extern "C" fn UpdateFailHTLC_set_htlc_id(this_ptr: &mut UpdateFailHTLC, mut val: u64) {
1985 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
1987 impl Clone for UpdateFailHTLC {
1988 fn clone(&self) -> Self {
1990 inner: if <*mut nativeUpdateFailHTLC>::is_null(self.inner) { std::ptr::null_mut() } else {
1991 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1997 /// Used only if an object of this type is returned as a trait impl by a method
1998 pub(crate) extern "C" fn UpdateFailHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1999 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailHTLC)).clone() })) as *mut c_void
2002 /// Creates a copy of the UpdateFailHTLC
2003 pub extern "C" fn UpdateFailHTLC_clone(orig: &UpdateFailHTLC) -> UpdateFailHTLC {
2007 use lightning::ln::msgs::UpdateFailMalformedHTLC as nativeUpdateFailMalformedHTLCImport;
2008 pub(crate) type nativeUpdateFailMalformedHTLC = nativeUpdateFailMalformedHTLCImport;
2010 /// An update_fail_malformed_htlc message to be sent or received from a peer
2013 pub struct UpdateFailMalformedHTLC {
2014 /// A pointer to the opaque Rust object.
2016 /// Nearly everywhere, inner must be non-null, however in places where
2017 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2018 pub inner: *mut nativeUpdateFailMalformedHTLC,
2019 /// Indicates that this is the only struct which contains the same pointer.
2021 /// Rust functions which take ownership of an object provided via an argument require
2022 /// this to be true and invalidate the object pointed to by inner.
2026 impl Drop for UpdateFailMalformedHTLC {
2027 fn drop(&mut self) {
2028 if self.is_owned && !<*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) {
2029 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2033 /// Frees any resources used by the UpdateFailMalformedHTLC, if is_owned is set and inner is non-NULL.
2035 pub extern "C" fn UpdateFailMalformedHTLC_free(this_obj: UpdateFailMalformedHTLC) { }
2037 /// Used only if an object of this type is returned as a trait impl by a method
2038 pub(crate) extern "C" fn UpdateFailMalformedHTLC_free_void(this_ptr: *mut c_void) {
2039 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFailMalformedHTLC); }
2042 impl UpdateFailMalformedHTLC {
2043 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailMalformedHTLC {
2044 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2046 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailMalformedHTLC {
2047 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2049 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2050 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailMalformedHTLC {
2051 assert!(self.is_owned);
2052 let ret = ObjOps::untweak_ptr(self.inner);
2053 self.inner = std::ptr::null_mut();
2059 pub extern "C" fn UpdateFailMalformedHTLC_get_channel_id(this_ptr: &UpdateFailMalformedHTLC) -> *const [u8; 32] {
2060 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2065 pub extern "C" fn UpdateFailMalformedHTLC_set_channel_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
2066 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2070 pub extern "C" fn UpdateFailMalformedHTLC_get_htlc_id(this_ptr: &UpdateFailMalformedHTLC) -> u64 {
2071 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
2076 pub extern "C" fn UpdateFailMalformedHTLC_set_htlc_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u64) {
2077 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
2079 /// The failure code
2081 pub extern "C" fn UpdateFailMalformedHTLC_get_failure_code(this_ptr: &UpdateFailMalformedHTLC) -> u16 {
2082 let mut inner_val = &mut this_ptr.get_native_mut_ref().failure_code;
2085 /// The failure code
2087 pub extern "C" fn UpdateFailMalformedHTLC_set_failure_code(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u16) {
2088 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.failure_code = val;
2090 impl Clone for UpdateFailMalformedHTLC {
2091 fn clone(&self) -> Self {
2093 inner: if <*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) { std::ptr::null_mut() } else {
2094 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2100 /// Used only if an object of this type is returned as a trait impl by a method
2101 pub(crate) extern "C" fn UpdateFailMalformedHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
2102 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailMalformedHTLC)).clone() })) as *mut c_void
2105 /// Creates a copy of the UpdateFailMalformedHTLC
2106 pub extern "C" fn UpdateFailMalformedHTLC_clone(orig: &UpdateFailMalformedHTLC) -> UpdateFailMalformedHTLC {
2110 use lightning::ln::msgs::CommitmentSigned as nativeCommitmentSignedImport;
2111 pub(crate) type nativeCommitmentSigned = nativeCommitmentSignedImport;
2113 /// A commitment_signed message to be sent or received from a peer
2116 pub struct CommitmentSigned {
2117 /// A pointer to the opaque Rust object.
2119 /// Nearly everywhere, inner must be non-null, however in places where
2120 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2121 pub inner: *mut nativeCommitmentSigned,
2122 /// Indicates that this is the only struct which contains the same pointer.
2124 /// Rust functions which take ownership of an object provided via an argument require
2125 /// this to be true and invalidate the object pointed to by inner.
2129 impl Drop for CommitmentSigned {
2130 fn drop(&mut self) {
2131 if self.is_owned && !<*mut nativeCommitmentSigned>::is_null(self.inner) {
2132 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2136 /// Frees any resources used by the CommitmentSigned, if is_owned is set and inner is non-NULL.
2138 pub extern "C" fn CommitmentSigned_free(this_obj: CommitmentSigned) { }
2140 /// Used only if an object of this type is returned as a trait impl by a method
2141 pub(crate) extern "C" fn CommitmentSigned_free_void(this_ptr: *mut c_void) {
2142 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentSigned); }
2145 impl CommitmentSigned {
2146 pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentSigned {
2147 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2149 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentSigned {
2150 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2152 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2153 pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentSigned {
2154 assert!(self.is_owned);
2155 let ret = ObjOps::untweak_ptr(self.inner);
2156 self.inner = std::ptr::null_mut();
2162 pub extern "C" fn CommitmentSigned_get_channel_id(this_ptr: &CommitmentSigned) -> *const [u8; 32] {
2163 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2168 pub extern "C" fn CommitmentSigned_set_channel_id(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::ThirtyTwoBytes) {
2169 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2171 /// A signature on the commitment transaction
2173 pub extern "C" fn CommitmentSigned_get_signature(this_ptr: &CommitmentSigned) -> crate::c_types::Signature {
2174 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
2175 crate::c_types::Signature::from_rust(&inner_val)
2177 /// A signature on the commitment transaction
2179 pub extern "C" fn CommitmentSigned_set_signature(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::Signature) {
2180 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
2182 /// Signatures on the HTLC transactions
2184 pub extern "C" fn CommitmentSigned_set_htlc_signatures(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::derived::CVec_SignatureZ) {
2185 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_rust() }); };
2186 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_signatures = local_val;
2188 /// Constructs a new CommitmentSigned given each field
2191 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 {
2192 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() }); };
2193 CommitmentSigned { inner: ObjOps::heap_alloc(nativeCommitmentSigned {
2194 channel_id: channel_id_arg.data,
2195 signature: signature_arg.into_rust(),
2196 htlc_signatures: local_htlc_signatures_arg,
2197 }), is_owned: true }
2199 impl Clone for CommitmentSigned {
2200 fn clone(&self) -> Self {
2202 inner: if <*mut nativeCommitmentSigned>::is_null(self.inner) { std::ptr::null_mut() } else {
2203 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2209 /// Used only if an object of this type is returned as a trait impl by a method
2210 pub(crate) extern "C" fn CommitmentSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
2211 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentSigned)).clone() })) as *mut c_void
2214 /// Creates a copy of the CommitmentSigned
2215 pub extern "C" fn CommitmentSigned_clone(orig: &CommitmentSigned) -> CommitmentSigned {
2219 use lightning::ln::msgs::RevokeAndACK as nativeRevokeAndACKImport;
2220 pub(crate) type nativeRevokeAndACK = nativeRevokeAndACKImport;
2222 /// A revoke_and_ack message to be sent or received from a peer
2225 pub struct RevokeAndACK {
2226 /// A pointer to the opaque Rust object.
2228 /// Nearly everywhere, inner must be non-null, however in places where
2229 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2230 pub inner: *mut nativeRevokeAndACK,
2231 /// Indicates that this is the only struct which contains the same pointer.
2233 /// Rust functions which take ownership of an object provided via an argument require
2234 /// this to be true and invalidate the object pointed to by inner.
2238 impl Drop for RevokeAndACK {
2239 fn drop(&mut self) {
2240 if self.is_owned && !<*mut nativeRevokeAndACK>::is_null(self.inner) {
2241 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2245 /// Frees any resources used by the RevokeAndACK, if is_owned is set and inner is non-NULL.
2247 pub extern "C" fn RevokeAndACK_free(this_obj: RevokeAndACK) { }
2249 /// Used only if an object of this type is returned as a trait impl by a method
2250 pub(crate) extern "C" fn RevokeAndACK_free_void(this_ptr: *mut c_void) {
2251 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRevokeAndACK); }
2255 pub(crate) fn get_native_ref(&self) -> &'static nativeRevokeAndACK {
2256 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2258 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRevokeAndACK {
2259 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2261 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2262 pub(crate) fn take_inner(mut self) -> *mut nativeRevokeAndACK {
2263 assert!(self.is_owned);
2264 let ret = ObjOps::untweak_ptr(self.inner);
2265 self.inner = std::ptr::null_mut();
2271 pub extern "C" fn RevokeAndACK_get_channel_id(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
2272 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2277 pub extern "C" fn RevokeAndACK_set_channel_id(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
2278 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2280 /// The secret corresponding to the per-commitment point
2282 pub extern "C" fn RevokeAndACK_get_per_commitment_secret(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
2283 let mut inner_val = &mut this_ptr.get_native_mut_ref().per_commitment_secret;
2286 /// The secret corresponding to the per-commitment point
2288 pub extern "C" fn RevokeAndACK_set_per_commitment_secret(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
2289 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.per_commitment_secret = val.data;
2291 /// The next sender-broadcast commitment transaction's per-commitment point
2293 pub extern "C" fn RevokeAndACK_get_next_per_commitment_point(this_ptr: &RevokeAndACK) -> crate::c_types::PublicKey {
2294 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
2295 crate::c_types::PublicKey::from_rust(&inner_val)
2297 /// The next sender-broadcast commitment transaction's per-commitment point
2299 pub extern "C" fn RevokeAndACK_set_next_per_commitment_point(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::PublicKey) {
2300 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
2302 /// Constructs a new RevokeAndACK given each field
2305 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 {
2306 RevokeAndACK { inner: ObjOps::heap_alloc(nativeRevokeAndACK {
2307 channel_id: channel_id_arg.data,
2308 per_commitment_secret: per_commitment_secret_arg.data,
2309 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
2310 }), is_owned: true }
2312 impl Clone for RevokeAndACK {
2313 fn clone(&self) -> Self {
2315 inner: if <*mut nativeRevokeAndACK>::is_null(self.inner) { std::ptr::null_mut() } else {
2316 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2322 /// Used only if an object of this type is returned as a trait impl by a method
2323 pub(crate) extern "C" fn RevokeAndACK_clone_void(this_ptr: *const c_void) -> *mut c_void {
2324 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRevokeAndACK)).clone() })) as *mut c_void
2327 /// Creates a copy of the RevokeAndACK
2328 pub extern "C" fn RevokeAndACK_clone(orig: &RevokeAndACK) -> RevokeAndACK {
2332 use lightning::ln::msgs::UpdateFee as nativeUpdateFeeImport;
2333 pub(crate) type nativeUpdateFee = nativeUpdateFeeImport;
2335 /// An update_fee message to be sent or received from a peer
2338 pub struct UpdateFee {
2339 /// A pointer to the opaque Rust object.
2341 /// Nearly everywhere, inner must be non-null, however in places where
2342 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2343 pub inner: *mut nativeUpdateFee,
2344 /// Indicates that this is the only struct which contains the same pointer.
2346 /// Rust functions which take ownership of an object provided via an argument require
2347 /// this to be true and invalidate the object pointed to by inner.
2351 impl Drop for UpdateFee {
2352 fn drop(&mut self) {
2353 if self.is_owned && !<*mut nativeUpdateFee>::is_null(self.inner) {
2354 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2358 /// Frees any resources used by the UpdateFee, if is_owned is set and inner is non-NULL.
2360 pub extern "C" fn UpdateFee_free(this_obj: UpdateFee) { }
2362 /// Used only if an object of this type is returned as a trait impl by a method
2363 pub(crate) extern "C" fn UpdateFee_free_void(this_ptr: *mut c_void) {
2364 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFee); }
2368 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFee {
2369 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2371 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFee {
2372 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2374 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2375 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFee {
2376 assert!(self.is_owned);
2377 let ret = ObjOps::untweak_ptr(self.inner);
2378 self.inner = std::ptr::null_mut();
2384 pub extern "C" fn UpdateFee_get_channel_id(this_ptr: &UpdateFee) -> *const [u8; 32] {
2385 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2390 pub extern "C" fn UpdateFee_set_channel_id(this_ptr: &mut UpdateFee, mut val: crate::c_types::ThirtyTwoBytes) {
2391 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2393 /// Fee rate per 1000-weight of the transaction
2395 pub extern "C" fn UpdateFee_get_feerate_per_kw(this_ptr: &UpdateFee) -> u32 {
2396 let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
2399 /// Fee rate per 1000-weight of the transaction
2401 pub extern "C" fn UpdateFee_set_feerate_per_kw(this_ptr: &mut UpdateFee, mut val: u32) {
2402 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
2404 /// Constructs a new UpdateFee given each field
2407 pub extern "C" fn UpdateFee_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut feerate_per_kw_arg: u32) -> UpdateFee {
2408 UpdateFee { inner: ObjOps::heap_alloc(nativeUpdateFee {
2409 channel_id: channel_id_arg.data,
2410 feerate_per_kw: feerate_per_kw_arg,
2411 }), is_owned: true }
2413 impl Clone for UpdateFee {
2414 fn clone(&self) -> Self {
2416 inner: if <*mut nativeUpdateFee>::is_null(self.inner) { std::ptr::null_mut() } else {
2417 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2423 /// Used only if an object of this type is returned as a trait impl by a method
2424 pub(crate) extern "C" fn UpdateFee_clone_void(this_ptr: *const c_void) -> *mut c_void {
2425 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFee)).clone() })) as *mut c_void
2428 /// Creates a copy of the UpdateFee
2429 pub extern "C" fn UpdateFee_clone(orig: &UpdateFee) -> UpdateFee {
2433 use lightning::ln::msgs::DataLossProtect as nativeDataLossProtectImport;
2434 pub(crate) type nativeDataLossProtect = nativeDataLossProtectImport;
2436 /// Proof that the sender knows the per-commitment secret of the previous commitment transaction.
2437 /// This is used to convince the recipient that the channel is at a certain commitment
2438 /// number even if they lost that data due to a local failure. Of course, the peer may lie
2439 /// and even later commitments may have been revoked.
2442 pub struct DataLossProtect {
2443 /// A pointer to the opaque Rust object.
2445 /// Nearly everywhere, inner must be non-null, however in places where
2446 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2447 pub inner: *mut nativeDataLossProtect,
2448 /// Indicates that this is the only struct which contains the same pointer.
2450 /// Rust functions which take ownership of an object provided via an argument require
2451 /// this to be true and invalidate the object pointed to by inner.
2455 impl Drop for DataLossProtect {
2456 fn drop(&mut self) {
2457 if self.is_owned && !<*mut nativeDataLossProtect>::is_null(self.inner) {
2458 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2462 /// Frees any resources used by the DataLossProtect, if is_owned is set and inner is non-NULL.
2464 pub extern "C" fn DataLossProtect_free(this_obj: DataLossProtect) { }
2466 /// Used only if an object of this type is returned as a trait impl by a method
2467 pub(crate) extern "C" fn DataLossProtect_free_void(this_ptr: *mut c_void) {
2468 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDataLossProtect); }
2471 impl DataLossProtect {
2472 pub(crate) fn get_native_ref(&self) -> &'static nativeDataLossProtect {
2473 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2475 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeDataLossProtect {
2476 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2478 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2479 pub(crate) fn take_inner(mut self) -> *mut nativeDataLossProtect {
2480 assert!(self.is_owned);
2481 let ret = ObjOps::untweak_ptr(self.inner);
2482 self.inner = std::ptr::null_mut();
2486 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
2487 /// belonging to the recipient
2489 pub extern "C" fn DataLossProtect_get_your_last_per_commitment_secret(this_ptr: &DataLossProtect) -> *const [u8; 32] {
2490 let mut inner_val = &mut this_ptr.get_native_mut_ref().your_last_per_commitment_secret;
2493 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
2494 /// belonging to the recipient
2496 pub extern "C" fn DataLossProtect_set_your_last_per_commitment_secret(this_ptr: &mut DataLossProtect, mut val: crate::c_types::ThirtyTwoBytes) {
2497 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.your_last_per_commitment_secret = val.data;
2499 /// The sender's per-commitment point for their current commitment transaction
2501 pub extern "C" fn DataLossProtect_get_my_current_per_commitment_point(this_ptr: &DataLossProtect) -> crate::c_types::PublicKey {
2502 let mut inner_val = &mut this_ptr.get_native_mut_ref().my_current_per_commitment_point;
2503 crate::c_types::PublicKey::from_rust(&inner_val)
2505 /// The sender's per-commitment point for their current commitment transaction
2507 pub extern "C" fn DataLossProtect_set_my_current_per_commitment_point(this_ptr: &mut DataLossProtect, mut val: crate::c_types::PublicKey) {
2508 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.my_current_per_commitment_point = val.into_rust();
2510 /// Constructs a new DataLossProtect given each field
2513 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 {
2514 DataLossProtect { inner: ObjOps::heap_alloc(nativeDataLossProtect {
2515 your_last_per_commitment_secret: your_last_per_commitment_secret_arg.data,
2516 my_current_per_commitment_point: my_current_per_commitment_point_arg.into_rust(),
2517 }), is_owned: true }
2519 impl Clone for DataLossProtect {
2520 fn clone(&self) -> Self {
2522 inner: if <*mut nativeDataLossProtect>::is_null(self.inner) { std::ptr::null_mut() } else {
2523 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2529 /// Used only if an object of this type is returned as a trait impl by a method
2530 pub(crate) extern "C" fn DataLossProtect_clone_void(this_ptr: *const c_void) -> *mut c_void {
2531 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDataLossProtect)).clone() })) as *mut c_void
2534 /// Creates a copy of the DataLossProtect
2535 pub extern "C" fn DataLossProtect_clone(orig: &DataLossProtect) -> DataLossProtect {
2539 use lightning::ln::msgs::ChannelReestablish as nativeChannelReestablishImport;
2540 pub(crate) type nativeChannelReestablish = nativeChannelReestablishImport;
2542 /// A channel_reestablish message to be sent or received from a peer
2545 pub struct ChannelReestablish {
2546 /// A pointer to the opaque Rust object.
2548 /// Nearly everywhere, inner must be non-null, however in places where
2549 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2550 pub inner: *mut nativeChannelReestablish,
2551 /// Indicates that this is the only struct which contains the same pointer.
2553 /// Rust functions which take ownership of an object provided via an argument require
2554 /// this to be true and invalidate the object pointed to by inner.
2558 impl Drop for ChannelReestablish {
2559 fn drop(&mut self) {
2560 if self.is_owned && !<*mut nativeChannelReestablish>::is_null(self.inner) {
2561 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2565 /// Frees any resources used by the ChannelReestablish, if is_owned is set and inner is non-NULL.
2567 pub extern "C" fn ChannelReestablish_free(this_obj: ChannelReestablish) { }
2569 /// Used only if an object of this type is returned as a trait impl by a method
2570 pub(crate) extern "C" fn ChannelReestablish_free_void(this_ptr: *mut c_void) {
2571 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelReestablish); }
2574 impl ChannelReestablish {
2575 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelReestablish {
2576 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2578 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelReestablish {
2579 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2581 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2582 pub(crate) fn take_inner(mut self) -> *mut nativeChannelReestablish {
2583 assert!(self.is_owned);
2584 let ret = ObjOps::untweak_ptr(self.inner);
2585 self.inner = std::ptr::null_mut();
2591 pub extern "C" fn ChannelReestablish_get_channel_id(this_ptr: &ChannelReestablish) -> *const [u8; 32] {
2592 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2597 pub extern "C" fn ChannelReestablish_set_channel_id(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) {
2598 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2600 /// The next commitment number for the sender
2602 pub extern "C" fn ChannelReestablish_get_next_local_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
2603 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_local_commitment_number;
2606 /// The next commitment number for the sender
2608 pub extern "C" fn ChannelReestablish_set_next_local_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
2609 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_local_commitment_number = val;
2611 /// The next commitment number for the recipient
2613 pub extern "C" fn ChannelReestablish_get_next_remote_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
2614 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_remote_commitment_number;
2617 /// The next commitment number for the recipient
2619 pub extern "C" fn ChannelReestablish_set_next_remote_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
2620 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_remote_commitment_number = val;
2622 impl Clone for ChannelReestablish {
2623 fn clone(&self) -> Self {
2625 inner: if <*mut nativeChannelReestablish>::is_null(self.inner) { std::ptr::null_mut() } else {
2626 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2632 /// Used only if an object of this type is returned as a trait impl by a method
2633 pub(crate) extern "C" fn ChannelReestablish_clone_void(this_ptr: *const c_void) -> *mut c_void {
2634 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelReestablish)).clone() })) as *mut c_void
2637 /// Creates a copy of the ChannelReestablish
2638 pub extern "C" fn ChannelReestablish_clone(orig: &ChannelReestablish) -> ChannelReestablish {
2642 use lightning::ln::msgs::AnnouncementSignatures as nativeAnnouncementSignaturesImport;
2643 pub(crate) type nativeAnnouncementSignatures = nativeAnnouncementSignaturesImport;
2645 /// An announcement_signatures message to be sent or received from a peer
2648 pub struct AnnouncementSignatures {
2649 /// A pointer to the opaque Rust object.
2651 /// Nearly everywhere, inner must be non-null, however in places where
2652 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2653 pub inner: *mut nativeAnnouncementSignatures,
2654 /// Indicates that this is the only struct which contains the same pointer.
2656 /// Rust functions which take ownership of an object provided via an argument require
2657 /// this to be true and invalidate the object pointed to by inner.
2661 impl Drop for AnnouncementSignatures {
2662 fn drop(&mut self) {
2663 if self.is_owned && !<*mut nativeAnnouncementSignatures>::is_null(self.inner) {
2664 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2668 /// Frees any resources used by the AnnouncementSignatures, if is_owned is set and inner is non-NULL.
2670 pub extern "C" fn AnnouncementSignatures_free(this_obj: AnnouncementSignatures) { }
2672 /// Used only if an object of this type is returned as a trait impl by a method
2673 pub(crate) extern "C" fn AnnouncementSignatures_free_void(this_ptr: *mut c_void) {
2674 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeAnnouncementSignatures); }
2677 impl AnnouncementSignatures {
2678 pub(crate) fn get_native_ref(&self) -> &'static nativeAnnouncementSignatures {
2679 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2681 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAnnouncementSignatures {
2682 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2684 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2685 pub(crate) fn take_inner(mut self) -> *mut nativeAnnouncementSignatures {
2686 assert!(self.is_owned);
2687 let ret = ObjOps::untweak_ptr(self.inner);
2688 self.inner = std::ptr::null_mut();
2694 pub extern "C" fn AnnouncementSignatures_get_channel_id(this_ptr: &AnnouncementSignatures) -> *const [u8; 32] {
2695 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2700 pub extern "C" fn AnnouncementSignatures_set_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
2701 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2703 /// The short channel ID
2705 pub extern "C" fn AnnouncementSignatures_get_short_channel_id(this_ptr: &AnnouncementSignatures) -> u64 {
2706 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
2709 /// The short channel ID
2711 pub extern "C" fn AnnouncementSignatures_set_short_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: u64) {
2712 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
2714 /// A signature by the node key
2716 pub extern "C" fn AnnouncementSignatures_get_node_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
2717 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature;
2718 crate::c_types::Signature::from_rust(&inner_val)
2720 /// A signature by the node key
2722 pub extern "C" fn AnnouncementSignatures_set_node_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
2723 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature = val.into_rust();
2725 /// A signature by the funding key
2727 pub extern "C" fn AnnouncementSignatures_get_bitcoin_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
2728 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature;
2729 crate::c_types::Signature::from_rust(&inner_val)
2731 /// A signature by the funding key
2733 pub extern "C" fn AnnouncementSignatures_set_bitcoin_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
2734 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature = val.into_rust();
2736 /// Constructs a new AnnouncementSignatures given each field
2739 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 {
2740 AnnouncementSignatures { inner: ObjOps::heap_alloc(nativeAnnouncementSignatures {
2741 channel_id: channel_id_arg.data,
2742 short_channel_id: short_channel_id_arg,
2743 node_signature: node_signature_arg.into_rust(),
2744 bitcoin_signature: bitcoin_signature_arg.into_rust(),
2745 }), is_owned: true }
2747 impl Clone for AnnouncementSignatures {
2748 fn clone(&self) -> Self {
2750 inner: if <*mut nativeAnnouncementSignatures>::is_null(self.inner) { std::ptr::null_mut() } else {
2751 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2757 /// Used only if an object of this type is returned as a trait impl by a method
2758 pub(crate) extern "C" fn AnnouncementSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
2759 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAnnouncementSignatures)).clone() })) as *mut c_void
2762 /// Creates a copy of the AnnouncementSignatures
2763 pub extern "C" fn AnnouncementSignatures_clone(orig: &AnnouncementSignatures) -> AnnouncementSignatures {
2766 /// An address which can be used to connect to a remote peer
2770 pub enum NetAddress {
2771 /// An IPv4 address/port on which the peer is listening.
2773 /// The 4-byte IPv4 address
2774 addr: crate::c_types::FourBytes,
2775 /// The port on which the node is listening
2778 /// An IPv6 address/port on which the peer is listening.
2780 /// The 16-byte IPv6 address
2781 addr: crate::c_types::SixteenBytes,
2782 /// The port on which the node is listening
2785 /// An old-style Tor onion address/port on which the peer is listening.
2787 /// This field is deprecated and the Tor network generally no longer supports V2 Onion
2788 /// addresses. Thus, the details are not parsed here.
2789 OnionV2(crate::c_types::TwelveBytes),
2790 /// A new-style Tor onion address/port on which the peer is listening.
2791 /// To create the human-readable \"hostname\", concatenate ed25519_pubkey, checksum, and version,
2792 /// wrap as base32 and append \".onion\".
2794 /// The ed25519 long-term public key of the peer
2795 ed25519_pubkey: crate::c_types::ThirtyTwoBytes,
2796 /// The checksum of the pubkey and version, as included in the onion address
2798 /// The version byte, as defined by the Tor Onion v3 spec.
2800 /// The port on which the node is listening
2804 use lightning::ln::msgs::NetAddress as nativeNetAddress;
2807 pub(crate) fn to_native(&self) -> nativeNetAddress {
2809 NetAddress::IPv4 {ref addr, ref port, } => {
2810 let mut addr_nonref = (*addr).clone();
2811 let mut port_nonref = (*port).clone();
2812 nativeNetAddress::IPv4 {
2813 addr: addr_nonref.data,
2817 NetAddress::IPv6 {ref addr, ref port, } => {
2818 let mut addr_nonref = (*addr).clone();
2819 let mut port_nonref = (*port).clone();
2820 nativeNetAddress::IPv6 {
2821 addr: addr_nonref.data,
2825 NetAddress::OnionV2 (ref a, ) => {
2826 let mut a_nonref = (*a).clone();
2827 nativeNetAddress::OnionV2 (
2831 NetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
2832 let mut ed25519_pubkey_nonref = (*ed25519_pubkey).clone();
2833 let mut checksum_nonref = (*checksum).clone();
2834 let mut version_nonref = (*version).clone();
2835 let mut port_nonref = (*port).clone();
2836 nativeNetAddress::OnionV3 {
2837 ed25519_pubkey: ed25519_pubkey_nonref.data,
2838 checksum: checksum_nonref,
2839 version: version_nonref,
2846 pub(crate) fn into_native(self) -> nativeNetAddress {
2848 NetAddress::IPv4 {mut addr, mut port, } => {
2849 nativeNetAddress::IPv4 {
2854 NetAddress::IPv6 {mut addr, mut port, } => {
2855 nativeNetAddress::IPv6 {
2860 NetAddress::OnionV2 (mut a, ) => {
2861 nativeNetAddress::OnionV2 (
2865 NetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
2866 nativeNetAddress::OnionV3 {
2867 ed25519_pubkey: ed25519_pubkey.data,
2876 pub(crate) fn from_native(native: &nativeNetAddress) -> Self {
2878 nativeNetAddress::IPv4 {ref addr, ref port, } => {
2879 let mut addr_nonref = (*addr).clone();
2880 let mut port_nonref = (*port).clone();
2882 addr: crate::c_types::FourBytes { data: addr_nonref },
2886 nativeNetAddress::IPv6 {ref addr, ref port, } => {
2887 let mut addr_nonref = (*addr).clone();
2888 let mut port_nonref = (*port).clone();
2890 addr: crate::c_types::SixteenBytes { data: addr_nonref },
2894 nativeNetAddress::OnionV2 (ref a, ) => {
2895 let mut a_nonref = (*a).clone();
2896 NetAddress::OnionV2 (
2897 crate::c_types::TwelveBytes { data: a_nonref },
2900 nativeNetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
2901 let mut ed25519_pubkey_nonref = (*ed25519_pubkey).clone();
2902 let mut checksum_nonref = (*checksum).clone();
2903 let mut version_nonref = (*version).clone();
2904 let mut port_nonref = (*port).clone();
2905 NetAddress::OnionV3 {
2906 ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey_nonref },
2907 checksum: checksum_nonref,
2908 version: version_nonref,
2915 pub(crate) fn native_into(native: nativeNetAddress) -> Self {
2917 nativeNetAddress::IPv4 {mut addr, mut port, } => {
2919 addr: crate::c_types::FourBytes { data: addr },
2923 nativeNetAddress::IPv6 {mut addr, mut port, } => {
2925 addr: crate::c_types::SixteenBytes { data: addr },
2929 nativeNetAddress::OnionV2 (mut a, ) => {
2930 NetAddress::OnionV2 (
2931 crate::c_types::TwelveBytes { data: a },
2934 nativeNetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
2935 NetAddress::OnionV3 {
2936 ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey },
2945 /// Frees any resources used by the NetAddress
2947 pub extern "C" fn NetAddress_free(this_ptr: NetAddress) { }
2948 /// Creates a copy of the NetAddress
2950 pub extern "C" fn NetAddress_clone(orig: &NetAddress) -> NetAddress {
2954 /// Utility method to constructs a new IPv4-variant NetAddress
2955 pub extern "C" fn NetAddress_ipv4(addr: crate::c_types::FourBytes, port: u16) -> NetAddress {
2962 /// Utility method to constructs a new IPv6-variant NetAddress
2963 pub extern "C" fn NetAddress_ipv6(addr: crate::c_types::SixteenBytes, port: u16) -> NetAddress {
2970 /// Utility method to constructs a new OnionV2-variant NetAddress
2971 pub extern "C" fn NetAddress_onion_v2(a: crate::c_types::TwelveBytes) -> NetAddress {
2972 NetAddress::OnionV2(a, )
2975 /// Utility method to constructs a new OnionV3-variant NetAddress
2976 pub extern "C" fn NetAddress_onion_v3(ed25519_pubkey: crate::c_types::ThirtyTwoBytes, checksum: u16, version: u8, port: u16) -> NetAddress {
2977 NetAddress::OnionV3 {
2985 /// Serialize the NetAddress object into a byte array which can be read by NetAddress_read
2986 pub extern "C" fn NetAddress_write(obj: &NetAddress) -> crate::c_types::derived::CVec_u8Z {
2987 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
2990 /// Read a NetAddress from a byte array, created by NetAddress_write
2991 pub extern "C" fn NetAddress_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NetAddressDecodeErrorZ {
2992 let res: Result<lightning::ln::msgs::NetAddress, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
2993 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() };
2997 use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport;
2998 pub(crate) type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport;
3000 /// The unsigned part of a node_announcement
3003 pub struct UnsignedNodeAnnouncement {
3004 /// A pointer to the opaque Rust object.
3006 /// Nearly everywhere, inner must be non-null, however in places where
3007 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3008 pub inner: *mut nativeUnsignedNodeAnnouncement,
3009 /// Indicates that this is the only struct which contains the same pointer.
3011 /// Rust functions which take ownership of an object provided via an argument require
3012 /// this to be true and invalidate the object pointed to by inner.
3016 impl Drop for UnsignedNodeAnnouncement {
3017 fn drop(&mut self) {
3018 if self.is_owned && !<*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) {
3019 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3023 /// Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL.
3025 pub extern "C" fn UnsignedNodeAnnouncement_free(this_obj: UnsignedNodeAnnouncement) { }
3027 /// Used only if an object of this type is returned as a trait impl by a method
3028 pub(crate) extern "C" fn UnsignedNodeAnnouncement_free_void(this_ptr: *mut c_void) {
3029 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedNodeAnnouncement); }
3032 impl UnsignedNodeAnnouncement {
3033 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedNodeAnnouncement {
3034 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3036 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedNodeAnnouncement {
3037 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3039 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3040 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedNodeAnnouncement {
3041 assert!(self.is_owned);
3042 let ret = ObjOps::untweak_ptr(self.inner);
3043 self.inner = std::ptr::null_mut();
3047 /// The advertised features
3049 pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::ln::features::NodeFeatures {
3050 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
3051 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 }
3053 /// The advertised features
3055 pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::ln::features::NodeFeatures) {
3056 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
3058 /// A strictly monotonic announcement counter, with gaps allowed
3060 pub extern "C" fn UnsignedNodeAnnouncement_get_timestamp(this_ptr: &UnsignedNodeAnnouncement) -> u32 {
3061 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
3064 /// A strictly monotonic announcement counter, with gaps allowed
3066 pub extern "C" fn UnsignedNodeAnnouncement_set_timestamp(this_ptr: &mut UnsignedNodeAnnouncement, mut val: u32) {
3067 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
3069 /// The node_id this announcement originated from (don't rebroadcast the node_announcement back
3072 pub extern "C" fn UnsignedNodeAnnouncement_get_node_id(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::PublicKey {
3073 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id;
3074 crate::c_types::PublicKey::from_rust(&inner_val)
3076 /// The node_id this announcement originated from (don't rebroadcast the node_announcement back
3079 pub extern "C" fn UnsignedNodeAnnouncement_set_node_id(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::PublicKey) {
3080 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id = val.into_rust();
3082 /// An RGB color for UI purposes
3084 pub extern "C" fn UnsignedNodeAnnouncement_get_rgb(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 3] {
3085 let mut inner_val = &mut this_ptr.get_native_mut_ref().rgb;
3088 /// An RGB color for UI purposes
3090 pub extern "C" fn UnsignedNodeAnnouncement_set_rgb(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThreeBytes) {
3091 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.rgb = val.data;
3093 /// An alias, for UI purposes. This should be sanitized before use. There is no guarantee
3096 pub extern "C" fn UnsignedNodeAnnouncement_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 32] {
3097 let mut inner_val = &mut this_ptr.get_native_mut_ref().alias;
3100 /// An alias, for UI purposes. This should be sanitized before use. There is no guarantee
3103 pub extern "C" fn UnsignedNodeAnnouncement_set_alias(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
3104 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.alias = val.data;
3106 /// List of addresses on which this node is reachable
3108 pub extern "C" fn UnsignedNodeAnnouncement_set_addresses(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_NetAddressZ) {
3109 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
3110 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.addresses = local_val;
3112 impl Clone for UnsignedNodeAnnouncement {
3113 fn clone(&self) -> Self {
3115 inner: if <*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else {
3116 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3122 /// Used only if an object of this type is returned as a trait impl by a method
3123 pub(crate) extern "C" fn UnsignedNodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3124 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedNodeAnnouncement)).clone() })) as *mut c_void
3127 /// Creates a copy of the UnsignedNodeAnnouncement
3128 pub extern "C" fn UnsignedNodeAnnouncement_clone(orig: &UnsignedNodeAnnouncement) -> UnsignedNodeAnnouncement {
3132 use lightning::ln::msgs::NodeAnnouncement as nativeNodeAnnouncementImport;
3133 pub(crate) type nativeNodeAnnouncement = nativeNodeAnnouncementImport;
3135 /// A node_announcement message to be sent or received from a peer
3138 pub struct NodeAnnouncement {
3139 /// A pointer to the opaque Rust object.
3141 /// Nearly everywhere, inner must be non-null, however in places where
3142 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3143 pub inner: *mut nativeNodeAnnouncement,
3144 /// Indicates that this is the only struct which contains the same pointer.
3146 /// Rust functions which take ownership of an object provided via an argument require
3147 /// this to be true and invalidate the object pointed to by inner.
3151 impl Drop for NodeAnnouncement {
3152 fn drop(&mut self) {
3153 if self.is_owned && !<*mut nativeNodeAnnouncement>::is_null(self.inner) {
3154 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3158 /// Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL.
3160 pub extern "C" fn NodeAnnouncement_free(this_obj: NodeAnnouncement) { }
3162 /// Used only if an object of this type is returned as a trait impl by a method
3163 pub(crate) extern "C" fn NodeAnnouncement_free_void(this_ptr: *mut c_void) {
3164 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeAnnouncement); }
3167 impl NodeAnnouncement {
3168 pub(crate) fn get_native_ref(&self) -> &'static nativeNodeAnnouncement {
3169 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3171 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeAnnouncement {
3172 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3174 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3175 pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncement {
3176 assert!(self.is_owned);
3177 let ret = ObjOps::untweak_ptr(self.inner);
3178 self.inner = std::ptr::null_mut();
3182 /// The signature by the node key
3184 pub extern "C" fn NodeAnnouncement_get_signature(this_ptr: &NodeAnnouncement) -> crate::c_types::Signature {
3185 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
3186 crate::c_types::Signature::from_rust(&inner_val)
3188 /// The signature by the node key
3190 pub extern "C" fn NodeAnnouncement_set_signature(this_ptr: &mut NodeAnnouncement, mut val: crate::c_types::Signature) {
3191 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
3193 /// The actual content of the announcement
3195 pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> crate::lightning::ln::msgs::UnsignedNodeAnnouncement {
3196 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
3197 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 }
3199 /// The actual content of the announcement
3201 pub extern "C" fn NodeAnnouncement_set_contents(this_ptr: &mut NodeAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) {
3202 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
3204 /// Constructs a new NodeAnnouncement given each field
3207 pub extern "C" fn NodeAnnouncement_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> NodeAnnouncement {
3208 NodeAnnouncement { inner: ObjOps::heap_alloc(nativeNodeAnnouncement {
3209 signature: signature_arg.into_rust(),
3210 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
3211 }), is_owned: true }
3213 impl Clone for NodeAnnouncement {
3214 fn clone(&self) -> Self {
3216 inner: if <*mut nativeNodeAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else {
3217 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3223 /// Used only if an object of this type is returned as a trait impl by a method
3224 pub(crate) extern "C" fn NodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3225 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeAnnouncement)).clone() })) as *mut c_void
3228 /// Creates a copy of the NodeAnnouncement
3229 pub extern "C" fn NodeAnnouncement_clone(orig: &NodeAnnouncement) -> NodeAnnouncement {
3233 use lightning::ln::msgs::UnsignedChannelAnnouncement as nativeUnsignedChannelAnnouncementImport;
3234 pub(crate) type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport;
3236 /// The unsigned part of a channel_announcement
3239 pub struct UnsignedChannelAnnouncement {
3240 /// A pointer to the opaque Rust object.
3242 /// Nearly everywhere, inner must be non-null, however in places where
3243 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3244 pub inner: *mut nativeUnsignedChannelAnnouncement,
3245 /// Indicates that this is the only struct which contains the same pointer.
3247 /// Rust functions which take ownership of an object provided via an argument require
3248 /// this to be true and invalidate the object pointed to by inner.
3252 impl Drop for UnsignedChannelAnnouncement {
3253 fn drop(&mut self) {
3254 if self.is_owned && !<*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) {
3255 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3259 /// Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL.
3261 pub extern "C" fn UnsignedChannelAnnouncement_free(this_obj: UnsignedChannelAnnouncement) { }
3263 /// Used only if an object of this type is returned as a trait impl by a method
3264 pub(crate) extern "C" fn UnsignedChannelAnnouncement_free_void(this_ptr: *mut c_void) {
3265 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelAnnouncement); }
3268 impl UnsignedChannelAnnouncement {
3269 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelAnnouncement {
3270 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3272 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelAnnouncement {
3273 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3275 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3276 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelAnnouncement {
3277 assert!(self.is_owned);
3278 let ret = ObjOps::untweak_ptr(self.inner);
3279 self.inner = std::ptr::null_mut();
3283 /// The advertised channel features
3285 pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::ln::features::ChannelFeatures {
3286 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
3287 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 }
3289 /// The advertised channel features
3291 pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::ln::features::ChannelFeatures) {
3292 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
3294 /// The genesis hash of the blockchain where the channel is to be opened
3296 pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &UnsignedChannelAnnouncement) -> *const [u8; 32] {
3297 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
3298 inner_val.as_inner()
3300 /// The genesis hash of the blockchain where the channel is to be opened
3302 pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
3303 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3305 /// The short channel ID
3307 pub extern "C" fn UnsignedChannelAnnouncement_get_short_channel_id(this_ptr: &UnsignedChannelAnnouncement) -> u64 {
3308 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
3311 /// The short channel ID
3313 pub extern "C" fn UnsignedChannelAnnouncement_set_short_channel_id(this_ptr: &mut UnsignedChannelAnnouncement, mut val: u64) {
3314 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
3316 /// One of the two node_ids which are endpoints of this channel
3318 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3319 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_1;
3320 crate::c_types::PublicKey::from_rust(&inner_val)
3322 /// One of the two node_ids which are endpoints of this channel
3324 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3325 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_1 = val.into_rust();
3327 /// The other of the two node_ids which are endpoints of this channel
3329 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3330 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_2;
3331 crate::c_types::PublicKey::from_rust(&inner_val)
3333 /// The other of the two node_ids which are endpoints of this channel
3335 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3336 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_2 = val.into_rust();
3338 /// The funding key for the first node
3340 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3341 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_1;
3342 crate::c_types::PublicKey::from_rust(&inner_val)
3344 /// The funding key for the first node
3346 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3347 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_1 = val.into_rust();
3349 /// The funding key for the second node
3351 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3352 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_2;
3353 crate::c_types::PublicKey::from_rust(&inner_val)
3355 /// The funding key for the second node
3357 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3358 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_2 = val.into_rust();
3360 impl Clone for UnsignedChannelAnnouncement {
3361 fn clone(&self) -> Self {
3363 inner: if <*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else {
3364 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3370 /// Used only if an object of this type is returned as a trait impl by a method
3371 pub(crate) extern "C" fn UnsignedChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3372 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelAnnouncement)).clone() })) as *mut c_void
3375 /// Creates a copy of the UnsignedChannelAnnouncement
3376 pub extern "C" fn UnsignedChannelAnnouncement_clone(orig: &UnsignedChannelAnnouncement) -> UnsignedChannelAnnouncement {
3380 use lightning::ln::msgs::ChannelAnnouncement as nativeChannelAnnouncementImport;
3381 pub(crate) type nativeChannelAnnouncement = nativeChannelAnnouncementImport;
3383 /// A channel_announcement message to be sent or received from a peer
3386 pub struct ChannelAnnouncement {
3387 /// A pointer to the opaque Rust object.
3389 /// Nearly everywhere, inner must be non-null, however in places where
3390 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3391 pub inner: *mut nativeChannelAnnouncement,
3392 /// Indicates that this is the only struct which contains the same pointer.
3394 /// Rust functions which take ownership of an object provided via an argument require
3395 /// this to be true and invalidate the object pointed to by inner.
3399 impl Drop for ChannelAnnouncement {
3400 fn drop(&mut self) {
3401 if self.is_owned && !<*mut nativeChannelAnnouncement>::is_null(self.inner) {
3402 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3406 /// Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL.
3408 pub extern "C" fn ChannelAnnouncement_free(this_obj: ChannelAnnouncement) { }
3410 /// Used only if an object of this type is returned as a trait impl by a method
3411 pub(crate) extern "C" fn ChannelAnnouncement_free_void(this_ptr: *mut c_void) {
3412 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelAnnouncement); }
3415 impl ChannelAnnouncement {
3416 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelAnnouncement {
3417 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3419 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelAnnouncement {
3420 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3422 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3423 pub(crate) fn take_inner(mut self) -> *mut nativeChannelAnnouncement {
3424 assert!(self.is_owned);
3425 let ret = ObjOps::untweak_ptr(self.inner);
3426 self.inner = std::ptr::null_mut();
3430 /// Authentication of the announcement by the first public node
3432 pub extern "C" fn ChannelAnnouncement_get_node_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3433 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_1;
3434 crate::c_types::Signature::from_rust(&inner_val)
3436 /// Authentication of the announcement by the first public node
3438 pub extern "C" fn ChannelAnnouncement_set_node_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3439 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_1 = val.into_rust();
3441 /// Authentication of the announcement by the second public node
3443 pub extern "C" fn ChannelAnnouncement_get_node_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3444 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_2;
3445 crate::c_types::Signature::from_rust(&inner_val)
3447 /// Authentication of the announcement by the second public node
3449 pub extern "C" fn ChannelAnnouncement_set_node_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3450 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_2 = val.into_rust();
3452 /// Proof of funding UTXO ownership by the first public node
3454 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3455 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_1;
3456 crate::c_types::Signature::from_rust(&inner_val)
3458 /// Proof of funding UTXO ownership by the first public node
3460 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3461 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_1 = val.into_rust();
3463 /// Proof of funding UTXO ownership by the second public node
3465 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3466 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_2;
3467 crate::c_types::Signature::from_rust(&inner_val)
3469 /// Proof of funding UTXO ownership by the second public node
3471 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3472 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_2 = val.into_rust();
3474 /// The actual announcement
3476 pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncement) -> crate::lightning::ln::msgs::UnsignedChannelAnnouncement {
3477 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
3478 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 }
3480 /// The actual announcement
3482 pub extern "C" fn ChannelAnnouncement_set_contents(this_ptr: &mut ChannelAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) {
3483 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
3485 /// Constructs a new ChannelAnnouncement given each field
3488 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 {
3489 ChannelAnnouncement { inner: ObjOps::heap_alloc(nativeChannelAnnouncement {
3490 node_signature_1: node_signature_1_arg.into_rust(),
3491 node_signature_2: node_signature_2_arg.into_rust(),
3492 bitcoin_signature_1: bitcoin_signature_1_arg.into_rust(),
3493 bitcoin_signature_2: bitcoin_signature_2_arg.into_rust(),
3494 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
3495 }), is_owned: true }
3497 impl Clone for ChannelAnnouncement {
3498 fn clone(&self) -> Self {
3500 inner: if <*mut nativeChannelAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else {
3501 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3507 /// Used only if an object of this type is returned as a trait impl by a method
3508 pub(crate) extern "C" fn ChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3509 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelAnnouncement)).clone() })) as *mut c_void
3512 /// Creates a copy of the ChannelAnnouncement
3513 pub extern "C" fn ChannelAnnouncement_clone(orig: &ChannelAnnouncement) -> ChannelAnnouncement {
3517 use lightning::ln::msgs::UnsignedChannelUpdate as nativeUnsignedChannelUpdateImport;
3518 pub(crate) type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport;
3520 /// The unsigned part of a channel_update
3523 pub struct UnsignedChannelUpdate {
3524 /// A pointer to the opaque Rust object.
3526 /// Nearly everywhere, inner must be non-null, however in places where
3527 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3528 pub inner: *mut nativeUnsignedChannelUpdate,
3529 /// Indicates that this is the only struct which contains the same pointer.
3531 /// Rust functions which take ownership of an object provided via an argument require
3532 /// this to be true and invalidate the object pointed to by inner.
3536 impl Drop for UnsignedChannelUpdate {
3537 fn drop(&mut self) {
3538 if self.is_owned && !<*mut nativeUnsignedChannelUpdate>::is_null(self.inner) {
3539 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3543 /// Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL.
3545 pub extern "C" fn UnsignedChannelUpdate_free(this_obj: UnsignedChannelUpdate) { }
3547 /// Used only if an object of this type is returned as a trait impl by a method
3548 pub(crate) extern "C" fn UnsignedChannelUpdate_free_void(this_ptr: *mut c_void) {
3549 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelUpdate); }
3552 impl UnsignedChannelUpdate {
3553 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelUpdate {
3554 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3556 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelUpdate {
3557 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3559 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3560 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelUpdate {
3561 assert!(self.is_owned);
3562 let ret = ObjOps::untweak_ptr(self.inner);
3563 self.inner = std::ptr::null_mut();
3567 /// The genesis hash of the blockchain where the channel is to be opened
3569 pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChannelUpdate) -> *const [u8; 32] {
3570 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
3571 inner_val.as_inner()
3573 /// The genesis hash of the blockchain where the channel is to be opened
3575 pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::ThirtyTwoBytes) {
3576 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3578 /// The short channel ID
3580 pub extern "C" fn UnsignedChannelUpdate_get_short_channel_id(this_ptr: &UnsignedChannelUpdate) -> u64 {
3581 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
3584 /// The short channel ID
3586 pub extern "C" fn UnsignedChannelUpdate_set_short_channel_id(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
3587 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
3589 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
3591 pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannelUpdate) -> u32 {
3592 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
3595 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
3597 pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3598 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
3602 pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 {
3603 let mut inner_val = &mut this_ptr.get_native_mut_ref().flags;
3608 pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) {
3609 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.flags = val;
3611 /// The number of blocks such that if:
3612 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
3613 /// then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines
3614 /// the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a
3615 /// cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10,
3616 /// then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before
3617 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
3618 /// constructing the route.
3620 pub extern "C" fn UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr: &UnsignedChannelUpdate) -> u16 {
3621 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
3624 /// The number of blocks such that if:
3625 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
3626 /// then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines
3627 /// the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a
3628 /// cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10,
3629 /// then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before
3630 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
3631 /// constructing the route.
3633 pub extern "C" fn UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr: &mut UnsignedChannelUpdate, mut val: u16) {
3634 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
3636 /// The minimum HTLC size incoming to sender, in milli-satoshi
3638 pub extern "C" fn UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
3639 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
3642 /// The minimum HTLC size incoming to sender, in milli-satoshi
3644 pub extern "C" fn UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
3645 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
3647 /// The base HTLC fee charged by sender, in milli-satoshi
3649 pub extern "C" fn UnsignedChannelUpdate_get_fee_base_msat(this_ptr: &UnsignedChannelUpdate) -> u32 {
3650 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat;
3653 /// The base HTLC fee charged by sender, in milli-satoshi
3655 pub extern "C" fn UnsignedChannelUpdate_set_fee_base_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3656 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val;
3658 /// The amount to fee multiplier, in micro-satoshi
3660 pub extern "C" fn UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr: &UnsignedChannelUpdate) -> u32 {
3661 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths;
3664 /// The amount to fee multiplier, in micro-satoshi
3666 pub extern "C" fn UnsignedChannelUpdate_set_fee_proportional_millionths(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3667 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val;
3669 impl Clone for UnsignedChannelUpdate {
3670 fn clone(&self) -> Self {
3672 inner: if <*mut nativeUnsignedChannelUpdate>::is_null(self.inner) { std::ptr::null_mut() } else {
3673 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3679 /// Used only if an object of this type is returned as a trait impl by a method
3680 pub(crate) extern "C" fn UnsignedChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
3681 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelUpdate)).clone() })) as *mut c_void
3684 /// Creates a copy of the UnsignedChannelUpdate
3685 pub extern "C" fn UnsignedChannelUpdate_clone(orig: &UnsignedChannelUpdate) -> UnsignedChannelUpdate {
3689 use lightning::ln::msgs::ChannelUpdate as nativeChannelUpdateImport;
3690 pub(crate) type nativeChannelUpdate = nativeChannelUpdateImport;
3692 /// A channel_update message to be sent or received from a peer
3695 pub struct ChannelUpdate {
3696 /// A pointer to the opaque Rust object.
3698 /// Nearly everywhere, inner must be non-null, however in places where
3699 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3700 pub inner: *mut nativeChannelUpdate,
3701 /// Indicates that this is the only struct which contains the same pointer.
3703 /// Rust functions which take ownership of an object provided via an argument require
3704 /// this to be true and invalidate the object pointed to by inner.
3708 impl Drop for ChannelUpdate {
3709 fn drop(&mut self) {
3710 if self.is_owned && !<*mut nativeChannelUpdate>::is_null(self.inner) {
3711 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3715 /// Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL.
3717 pub extern "C" fn ChannelUpdate_free(this_obj: ChannelUpdate) { }
3719 /// Used only if an object of this type is returned as a trait impl by a method
3720 pub(crate) extern "C" fn ChannelUpdate_free_void(this_ptr: *mut c_void) {
3721 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelUpdate); }
3724 impl ChannelUpdate {
3725 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelUpdate {
3726 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3728 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelUpdate {
3729 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3731 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3732 pub(crate) fn take_inner(mut self) -> *mut nativeChannelUpdate {
3733 assert!(self.is_owned);
3734 let ret = ObjOps::untweak_ptr(self.inner);
3735 self.inner = std::ptr::null_mut();
3739 /// A signature of the channel update
3741 pub extern "C" fn ChannelUpdate_get_signature(this_ptr: &ChannelUpdate) -> crate::c_types::Signature {
3742 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
3743 crate::c_types::Signature::from_rust(&inner_val)
3745 /// A signature of the channel update
3747 pub extern "C" fn ChannelUpdate_set_signature(this_ptr: &mut ChannelUpdate, mut val: crate::c_types::Signature) {
3748 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
3750 /// The actual channel update
3752 pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate::lightning::ln::msgs::UnsignedChannelUpdate {
3753 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
3754 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 }
3756 /// The actual channel update
3758 pub extern "C" fn ChannelUpdate_set_contents(this_ptr: &mut ChannelUpdate, mut val: crate::lightning::ln::msgs::UnsignedChannelUpdate) {
3759 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
3761 /// Constructs a new ChannelUpdate given each field
3764 pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> ChannelUpdate {
3765 ChannelUpdate { inner: ObjOps::heap_alloc(nativeChannelUpdate {
3766 signature: signature_arg.into_rust(),
3767 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
3768 }), is_owned: true }
3770 impl Clone for ChannelUpdate {
3771 fn clone(&self) -> Self {
3773 inner: if <*mut nativeChannelUpdate>::is_null(self.inner) { std::ptr::null_mut() } else {
3774 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3780 /// Used only if an object of this type is returned as a trait impl by a method
3781 pub(crate) extern "C" fn ChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
3782 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelUpdate)).clone() })) as *mut c_void
3785 /// Creates a copy of the ChannelUpdate
3786 pub extern "C" fn ChannelUpdate_clone(orig: &ChannelUpdate) -> ChannelUpdate {
3790 use lightning::ln::msgs::QueryChannelRange as nativeQueryChannelRangeImport;
3791 pub(crate) type nativeQueryChannelRange = nativeQueryChannelRangeImport;
3793 /// A query_channel_range message is used to query a peer for channel
3794 /// UTXOs in a range of blocks. The recipient of a query makes a best
3795 /// effort to reply to the query using one or more reply_channel_range
3799 pub struct QueryChannelRange {
3800 /// A pointer to the opaque Rust object.
3802 /// Nearly everywhere, inner must be non-null, however in places where
3803 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3804 pub inner: *mut nativeQueryChannelRange,
3805 /// Indicates that this is the only struct which contains the same pointer.
3807 /// Rust functions which take ownership of an object provided via an argument require
3808 /// this to be true and invalidate the object pointed to by inner.
3812 impl Drop for QueryChannelRange {
3813 fn drop(&mut self) {
3814 if self.is_owned && !<*mut nativeQueryChannelRange>::is_null(self.inner) {
3815 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3819 /// Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL.
3821 pub extern "C" fn QueryChannelRange_free(this_obj: QueryChannelRange) { }
3823 /// Used only if an object of this type is returned as a trait impl by a method
3824 pub(crate) extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) {
3825 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryChannelRange); }
3828 impl QueryChannelRange {
3829 pub(crate) fn get_native_ref(&self) -> &'static nativeQueryChannelRange {
3830 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3832 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryChannelRange {
3833 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3835 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3836 pub(crate) fn take_inner(mut self) -> *mut nativeQueryChannelRange {
3837 assert!(self.is_owned);
3838 let ret = ObjOps::untweak_ptr(self.inner);
3839 self.inner = std::ptr::null_mut();
3843 /// The genesis hash of the blockchain being queried
3845 pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *const [u8; 32] {
3846 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
3847 inner_val.as_inner()
3849 /// The genesis hash of the blockchain being queried
3851 pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
3852 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3854 /// The height of the first block for the channel UTXOs being queried
3856 pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 {
3857 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
3860 /// The height of the first block for the channel UTXOs being queried
3862 pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChannelRange, mut val: u32) {
3863 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
3865 /// The number of blocks to include in the query results
3867 pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 {
3868 let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
3871 /// The number of blocks to include in the query results
3873 pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryChannelRange, mut val: u32) {
3874 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
3876 /// Constructs a new QueryChannelRange given each field
3879 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 {
3880 QueryChannelRange { inner: ObjOps::heap_alloc(nativeQueryChannelRange {
3881 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3882 first_blocknum: first_blocknum_arg,
3883 number_of_blocks: number_of_blocks_arg,
3884 }), is_owned: true }
3886 impl Clone for QueryChannelRange {
3887 fn clone(&self) -> Self {
3889 inner: if <*mut nativeQueryChannelRange>::is_null(self.inner) { std::ptr::null_mut() } else {
3890 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3896 /// Used only if an object of this type is returned as a trait impl by a method
3897 pub(crate) extern "C" fn QueryChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
3898 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryChannelRange)).clone() })) as *mut c_void
3901 /// Creates a copy of the QueryChannelRange
3902 pub extern "C" fn QueryChannelRange_clone(orig: &QueryChannelRange) -> QueryChannelRange {
3906 use lightning::ln::msgs::ReplyChannelRange as nativeReplyChannelRangeImport;
3907 pub(crate) type nativeReplyChannelRange = nativeReplyChannelRangeImport;
3909 /// A reply_channel_range message is a reply to a query_channel_range
3910 /// message. Multiple reply_channel_range messages can be sent in reply
3911 /// to a single query_channel_range message. The query recipient makes a
3912 /// best effort to respond based on their local network view which may
3913 /// not be a perfect view of the network. The short_channel_ids in the
3914 /// reply are encoded. We only support encoding_type=0 uncompressed
3915 /// serialization and do not support encoding_type=1 zlib serialization.
3918 pub struct ReplyChannelRange {
3919 /// A pointer to the opaque Rust object.
3921 /// Nearly everywhere, inner must be non-null, however in places where
3922 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3923 pub inner: *mut nativeReplyChannelRange,
3924 /// Indicates that this is the only struct which contains the same pointer.
3926 /// Rust functions which take ownership of an object provided via an argument require
3927 /// this to be true and invalidate the object pointed to by inner.
3931 impl Drop for ReplyChannelRange {
3932 fn drop(&mut self) {
3933 if self.is_owned && !<*mut nativeReplyChannelRange>::is_null(self.inner) {
3934 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3938 /// Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL.
3940 pub extern "C" fn ReplyChannelRange_free(this_obj: ReplyChannelRange) { }
3942 /// Used only if an object of this type is returned as a trait impl by a method
3943 pub(crate) extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) {
3944 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyChannelRange); }
3947 impl ReplyChannelRange {
3948 pub(crate) fn get_native_ref(&self) -> &'static nativeReplyChannelRange {
3949 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3951 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyChannelRange {
3952 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3954 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3955 pub(crate) fn take_inner(mut self) -> *mut nativeReplyChannelRange {
3956 assert!(self.is_owned);
3957 let ret = ObjOps::untweak_ptr(self.inner);
3958 self.inner = std::ptr::null_mut();
3962 /// The genesis hash of the blockchain being queried
3964 pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *const [u8; 32] {
3965 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
3966 inner_val.as_inner()
3968 /// The genesis hash of the blockchain being queried
3970 pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
3971 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3973 /// The height of the first block in the range of the reply
3975 pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 {
3976 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
3979 /// The height of the first block in the range of the reply
3981 pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChannelRange, mut val: u32) {
3982 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
3984 /// The number of blocks included in the range of the reply
3986 pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 {
3987 let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
3990 /// The number of blocks included in the range of the reply
3992 pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyChannelRange, mut val: u32) {
3993 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
3995 /// True when this is the final reply for a query
3997 pub extern "C" fn ReplyChannelRange_get_sync_complete(this_ptr: &ReplyChannelRange) -> bool {
3998 let mut inner_val = &mut this_ptr.get_native_mut_ref().sync_complete;
4001 /// True when this is the final reply for a query
4003 pub extern "C" fn ReplyChannelRange_set_sync_complete(this_ptr: &mut ReplyChannelRange, mut val: bool) {
4004 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sync_complete = val;
4006 /// The short_channel_ids in the channel range
4008 pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::derived::CVec_u64Z) {
4009 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
4010 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
4012 /// Constructs a new ReplyChannelRange given each field
4015 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 {
4016 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 }); };
4017 ReplyChannelRange { inner: ObjOps::heap_alloc(nativeReplyChannelRange {
4018 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4019 first_blocknum: first_blocknum_arg,
4020 number_of_blocks: number_of_blocks_arg,
4021 sync_complete: sync_complete_arg,
4022 short_channel_ids: local_short_channel_ids_arg,
4023 }), is_owned: true }
4025 impl Clone for ReplyChannelRange {
4026 fn clone(&self) -> Self {
4028 inner: if <*mut nativeReplyChannelRange>::is_null(self.inner) { std::ptr::null_mut() } else {
4029 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4035 /// Used only if an object of this type is returned as a trait impl by a method
4036 pub(crate) extern "C" fn ReplyChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
4037 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyChannelRange)).clone() })) as *mut c_void
4040 /// Creates a copy of the ReplyChannelRange
4041 pub extern "C" fn ReplyChannelRange_clone(orig: &ReplyChannelRange) -> ReplyChannelRange {
4045 use lightning::ln::msgs::QueryShortChannelIds as nativeQueryShortChannelIdsImport;
4046 pub(crate) type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport;
4048 /// A query_short_channel_ids message is used to query a peer for
4049 /// routing gossip messages related to one or more short_channel_ids.
4050 /// The query recipient will reply with the latest, if available,
4051 /// channel_announcement, channel_update and node_announcement messages
4052 /// it maintains for the requested short_channel_ids followed by a
4053 /// reply_short_channel_ids_end message. The short_channel_ids sent in
4054 /// this query are encoded. We only support encoding_type=0 uncompressed
4055 /// serialization and do not support encoding_type=1 zlib serialization.
4058 pub struct QueryShortChannelIds {
4059 /// A pointer to the opaque Rust object.
4061 /// Nearly everywhere, inner must be non-null, however in places where
4062 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4063 pub inner: *mut nativeQueryShortChannelIds,
4064 /// Indicates that this is the only struct which contains the same pointer.
4066 /// Rust functions which take ownership of an object provided via an argument require
4067 /// this to be true and invalidate the object pointed to by inner.
4071 impl Drop for QueryShortChannelIds {
4072 fn drop(&mut self) {
4073 if self.is_owned && !<*mut nativeQueryShortChannelIds>::is_null(self.inner) {
4074 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4078 /// Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL.
4080 pub extern "C" fn QueryShortChannelIds_free(this_obj: QueryShortChannelIds) { }
4082 /// Used only if an object of this type is returned as a trait impl by a method
4083 pub(crate) extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) {
4084 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryShortChannelIds); }
4087 impl QueryShortChannelIds {
4088 pub(crate) fn get_native_ref(&self) -> &'static nativeQueryShortChannelIds {
4089 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4091 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryShortChannelIds {
4092 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4094 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4095 pub(crate) fn take_inner(mut self) -> *mut nativeQueryShortChannelIds {
4096 assert!(self.is_owned);
4097 let ret = ObjOps::untweak_ptr(self.inner);
4098 self.inner = std::ptr::null_mut();
4102 /// The genesis hash of the blockchain being queried
4104 pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *const [u8; 32] {
4105 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4106 inner_val.as_inner()
4108 /// The genesis hash of the blockchain being queried
4110 pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::ThirtyTwoBytes) {
4111 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4113 /// The short_channel_ids that are being queried
4115 pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::derived::CVec_u64Z) {
4116 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
4117 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
4119 /// Constructs a new QueryShortChannelIds given each field
4122 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 {
4123 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 }); };
4124 QueryShortChannelIds { inner: ObjOps::heap_alloc(nativeQueryShortChannelIds {
4125 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4126 short_channel_ids: local_short_channel_ids_arg,
4127 }), is_owned: true }
4129 impl Clone for QueryShortChannelIds {
4130 fn clone(&self) -> Self {
4132 inner: if <*mut nativeQueryShortChannelIds>::is_null(self.inner) { std::ptr::null_mut() } else {
4133 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4139 /// Used only if an object of this type is returned as a trait impl by a method
4140 pub(crate) extern "C" fn QueryShortChannelIds_clone_void(this_ptr: *const c_void) -> *mut c_void {
4141 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryShortChannelIds)).clone() })) as *mut c_void
4144 /// Creates a copy of the QueryShortChannelIds
4145 pub extern "C" fn QueryShortChannelIds_clone(orig: &QueryShortChannelIds) -> QueryShortChannelIds {
4149 use lightning::ln::msgs::ReplyShortChannelIdsEnd as nativeReplyShortChannelIdsEndImport;
4150 pub(crate) type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport;
4152 /// A reply_short_channel_ids_end message is sent as a reply to a
4153 /// query_short_channel_ids message. The query recipient makes a best
4154 /// effort to respond based on their local network view which may not be
4155 /// a perfect view of the network.
4158 pub struct ReplyShortChannelIdsEnd {
4159 /// A pointer to the opaque Rust object.
4161 /// Nearly everywhere, inner must be non-null, however in places where
4162 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4163 pub inner: *mut nativeReplyShortChannelIdsEnd,
4164 /// Indicates that this is the only struct which contains the same pointer.
4166 /// Rust functions which take ownership of an object provided via an argument require
4167 /// this to be true and invalidate the object pointed to by inner.
4171 impl Drop for ReplyShortChannelIdsEnd {
4172 fn drop(&mut self) {
4173 if self.is_owned && !<*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) {
4174 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4178 /// Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL.
4180 pub extern "C" fn ReplyShortChannelIdsEnd_free(this_obj: ReplyShortChannelIdsEnd) { }
4182 /// Used only if an object of this type is returned as a trait impl by a method
4183 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) {
4184 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyShortChannelIdsEnd); }
4187 impl ReplyShortChannelIdsEnd {
4188 pub(crate) fn get_native_ref(&self) -> &'static nativeReplyShortChannelIdsEnd {
4189 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4191 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyShortChannelIdsEnd {
4192 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4194 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4195 pub(crate) fn take_inner(mut self) -> *mut nativeReplyShortChannelIdsEnd {
4196 assert!(self.is_owned);
4197 let ret = ObjOps::untweak_ptr(self.inner);
4198 self.inner = std::ptr::null_mut();
4202 /// The genesis hash of the blockchain that was queried
4204 pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *const [u8; 32] {
4205 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4206 inner_val.as_inner()
4208 /// The genesis hash of the blockchain that was queried
4210 pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) {
4211 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4213 /// Indicates if the query recipient maintains up-to-date channel
4214 /// information for the chain_hash
4216 pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool {
4217 let mut inner_val = &mut this_ptr.get_native_mut_ref().full_information;
4220 /// Indicates if the query recipient maintains up-to-date channel
4221 /// information for the chain_hash
4223 pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: bool) {
4224 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.full_information = val;
4226 /// Constructs a new ReplyShortChannelIdsEnd given each field
4229 pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd {
4230 ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(nativeReplyShortChannelIdsEnd {
4231 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4232 full_information: full_information_arg,
4233 }), is_owned: true }
4235 impl Clone for ReplyShortChannelIdsEnd {
4236 fn clone(&self) -> Self {
4238 inner: if <*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) { std::ptr::null_mut() } else {
4239 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4245 /// Used only if an object of this type is returned as a trait impl by a method
4246 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_void) -> *mut c_void {
4247 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyShortChannelIdsEnd)).clone() })) as *mut c_void
4250 /// Creates a copy of the ReplyShortChannelIdsEnd
4251 pub extern "C" fn ReplyShortChannelIdsEnd_clone(orig: &ReplyShortChannelIdsEnd) -> ReplyShortChannelIdsEnd {
4255 use lightning::ln::msgs::GossipTimestampFilter as nativeGossipTimestampFilterImport;
4256 pub(crate) type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport;
4258 /// A gossip_timestamp_filter message is used by a node to request
4259 /// gossip relay for messages in the requested time range when the
4260 /// gossip_queries feature has been negotiated.
4263 pub struct GossipTimestampFilter {
4264 /// A pointer to the opaque Rust object.
4266 /// Nearly everywhere, inner must be non-null, however in places where
4267 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4268 pub inner: *mut nativeGossipTimestampFilter,
4269 /// Indicates that this is the only struct which contains the same pointer.
4271 /// Rust functions which take ownership of an object provided via an argument require
4272 /// this to be true and invalidate the object pointed to by inner.
4276 impl Drop for GossipTimestampFilter {
4277 fn drop(&mut self) {
4278 if self.is_owned && !<*mut nativeGossipTimestampFilter>::is_null(self.inner) {
4279 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4283 /// Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL.
4285 pub extern "C" fn GossipTimestampFilter_free(this_obj: GossipTimestampFilter) { }
4287 /// Used only if an object of this type is returned as a trait impl by a method
4288 pub(crate) extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) {
4289 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeGossipTimestampFilter); }
4292 impl GossipTimestampFilter {
4293 pub(crate) fn get_native_ref(&self) -> &'static nativeGossipTimestampFilter {
4294 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4296 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeGossipTimestampFilter {
4297 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4299 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4300 pub(crate) fn take_inner(mut self) -> *mut nativeGossipTimestampFilter {
4301 assert!(self.is_owned);
4302 let ret = ObjOps::untweak_ptr(self.inner);
4303 self.inner = std::ptr::null_mut();
4307 /// The genesis hash of the blockchain for channel and node information
4309 pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *const [u8; 32] {
4310 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4311 inner_val.as_inner()
4313 /// The genesis hash of the blockchain for channel and node information
4315 pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) {
4316 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4318 /// The starting unix timestamp
4320 pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 {
4321 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_timestamp;
4324 /// The starting unix timestamp
4326 pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
4327 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_timestamp = val;
4329 /// The range of information in seconds
4331 pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 {
4332 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp_range;
4335 /// The range of information in seconds
4337 pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
4338 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp_range = val;
4340 /// Constructs a new GossipTimestampFilter given each field
4343 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 {
4344 GossipTimestampFilter { inner: ObjOps::heap_alloc(nativeGossipTimestampFilter {
4345 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4346 first_timestamp: first_timestamp_arg,
4347 timestamp_range: timestamp_range_arg,
4348 }), is_owned: true }
4350 impl Clone for GossipTimestampFilter {
4351 fn clone(&self) -> Self {
4353 inner: if <*mut nativeGossipTimestampFilter>::is_null(self.inner) { std::ptr::null_mut() } else {
4354 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4360 /// Used only if an object of this type is returned as a trait impl by a method
4361 pub(crate) extern "C" fn GossipTimestampFilter_clone_void(this_ptr: *const c_void) -> *mut c_void {
4362 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeGossipTimestampFilter)).clone() })) as *mut c_void
4365 /// Creates a copy of the GossipTimestampFilter
4366 pub extern "C" fn GossipTimestampFilter_clone(orig: &GossipTimestampFilter) -> GossipTimestampFilter {
4369 /// Used to put an error message in a LightningError
4373 pub enum ErrorAction {
4374 /// The peer took some action which made us think they were useless. Disconnect them.
4376 /// An error message which we should make an effort to send before we disconnect.
4378 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
4379 msg: crate::lightning::ln::msgs::ErrorMessage,
4381 /// The peer did something harmless that we weren't able to process, just log and ignore
4383 /// The peer did something harmless that we weren't able to meaningfully process.
4384 /// If the error is logged, log it at the given level.
4385 IgnoreAndLog(crate::lightning::util::logger::Level),
4386 /// The peer provided us with a gossip message which we'd already seen. In most cases this
4387 /// should be ignored, but it may result in the message being forwarded if it is a duplicate of
4388 /// our own channel announcements.
4389 IgnoreDuplicateGossip,
4390 /// The peer did something incorrect. Tell them.
4392 /// The message to send.
4393 msg: crate::lightning::ln::msgs::ErrorMessage,
4396 use lightning::ln::msgs::ErrorAction as nativeErrorAction;
4399 pub(crate) fn to_native(&self) -> nativeErrorAction {
4401 ErrorAction::DisconnectPeer {ref msg, } => {
4402 let mut msg_nonref = (*msg).clone();
4403 let mut local_msg_nonref = if msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg_nonref.take_inner()) } }) };
4404 nativeErrorAction::DisconnectPeer {
4405 msg: local_msg_nonref,
4408 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
4409 ErrorAction::IgnoreAndLog (ref a, ) => {
4410 let mut a_nonref = (*a).clone();
4411 nativeErrorAction::IgnoreAndLog (
4412 a_nonref.into_native(),
4415 ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
4416 ErrorAction::SendErrorMessage {ref msg, } => {
4417 let mut msg_nonref = (*msg).clone();
4418 nativeErrorAction::SendErrorMessage {
4419 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
4425 pub(crate) fn into_native(self) -> nativeErrorAction {
4427 ErrorAction::DisconnectPeer {mut msg, } => {
4428 let mut local_msg = if msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg.take_inner()) } }) };
4429 nativeErrorAction::DisconnectPeer {
4433 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
4434 ErrorAction::IgnoreAndLog (mut a, ) => {
4435 nativeErrorAction::IgnoreAndLog (
4439 ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
4440 ErrorAction::SendErrorMessage {mut msg, } => {
4441 nativeErrorAction::SendErrorMessage {
4442 msg: *unsafe { Box::from_raw(msg.take_inner()) },
4448 pub(crate) fn from_native(native: &nativeErrorAction) -> Self {
4450 nativeErrorAction::DisconnectPeer {ref msg, } => {
4451 let mut msg_nonref = (*msg).clone();
4452 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 };
4453 ErrorAction::DisconnectPeer {
4454 msg: local_msg_nonref,
4457 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
4458 nativeErrorAction::IgnoreAndLog (ref a, ) => {
4459 let mut a_nonref = (*a).clone();
4460 ErrorAction::IgnoreAndLog (
4461 crate::lightning::util::logger::Level::native_into(a_nonref),
4464 nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
4465 nativeErrorAction::SendErrorMessage {ref msg, } => {
4466 let mut msg_nonref = (*msg).clone();
4467 ErrorAction::SendErrorMessage {
4468 msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
4474 pub(crate) fn native_into(native: nativeErrorAction) -> Self {
4476 nativeErrorAction::DisconnectPeer {mut msg, } => {
4477 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 };
4478 ErrorAction::DisconnectPeer {
4482 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
4483 nativeErrorAction::IgnoreAndLog (mut a, ) => {
4484 ErrorAction::IgnoreAndLog (
4485 crate::lightning::util::logger::Level::native_into(a),
4488 nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
4489 nativeErrorAction::SendErrorMessage {mut msg, } => {
4490 ErrorAction::SendErrorMessage {
4491 msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
4497 /// Frees any resources used by the ErrorAction
4499 pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { }
4500 /// Creates a copy of the ErrorAction
4502 pub extern "C" fn ErrorAction_clone(orig: &ErrorAction) -> ErrorAction {
4506 /// Utility method to constructs a new DisconnectPeer-variant ErrorAction
4507 pub extern "C" fn ErrorAction_disconnect_peer(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
4508 ErrorAction::DisconnectPeer {
4513 /// Utility method to constructs a new IgnoreError-variant ErrorAction
4514 pub extern "C" fn ErrorAction_ignore_error() -> ErrorAction {
4515 ErrorAction::IgnoreError}
4517 /// Utility method to constructs a new IgnoreAndLog-variant ErrorAction
4518 pub extern "C" fn ErrorAction_ignore_and_log(a: crate::lightning::util::logger::Level) -> ErrorAction {
4519 ErrorAction::IgnoreAndLog(a, )
4522 /// Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction
4523 pub extern "C" fn ErrorAction_ignore_duplicate_gossip() -> ErrorAction {
4524 ErrorAction::IgnoreDuplicateGossip}
4526 /// Utility method to constructs a new SendErrorMessage-variant ErrorAction
4527 pub extern "C" fn ErrorAction_send_error_message(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
4528 ErrorAction::SendErrorMessage {
4533 use lightning::ln::msgs::LightningError as nativeLightningErrorImport;
4534 pub(crate) type nativeLightningError = nativeLightningErrorImport;
4536 /// An Err type for failure to process messages.
4539 pub struct LightningError {
4540 /// A pointer to the opaque Rust object.
4542 /// Nearly everywhere, inner must be non-null, however in places where
4543 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4544 pub inner: *mut nativeLightningError,
4545 /// Indicates that this is the only struct which contains the same pointer.
4547 /// Rust functions which take ownership of an object provided via an argument require
4548 /// this to be true and invalidate the object pointed to by inner.
4552 impl Drop for LightningError {
4553 fn drop(&mut self) {
4554 if self.is_owned && !<*mut nativeLightningError>::is_null(self.inner) {
4555 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4559 /// Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL.
4561 pub extern "C" fn LightningError_free(this_obj: LightningError) { }
4563 /// Used only if an object of this type is returned as a trait impl by a method
4564 pub(crate) extern "C" fn LightningError_free_void(this_ptr: *mut c_void) {
4565 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeLightningError); }
4568 impl LightningError {
4569 pub(crate) fn get_native_ref(&self) -> &'static nativeLightningError {
4570 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4572 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLightningError {
4573 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4575 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4576 pub(crate) fn take_inner(mut self) -> *mut nativeLightningError {
4577 assert!(self.is_owned);
4578 let ret = ObjOps::untweak_ptr(self.inner);
4579 self.inner = std::ptr::null_mut();
4583 /// A human-readable message describing the error
4585 pub extern "C" fn LightningError_get_err(this_ptr: &LightningError) -> crate::c_types::Str {
4586 let mut inner_val = &mut this_ptr.get_native_mut_ref().err;
4587 inner_val.as_str().into()
4589 /// A human-readable message describing the error
4591 pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: crate::c_types::Str) {
4592 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.err = val.into_string();
4594 /// The action which should be taken against the offending peer.
4596 pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate::lightning::ln::msgs::ErrorAction {
4597 let mut inner_val = &mut this_ptr.get_native_mut_ref().action;
4598 crate::lightning::ln::msgs::ErrorAction::from_native(inner_val)
4600 /// The action which should be taken against the offending peer.
4602 pub extern "C" fn LightningError_set_action(this_ptr: &mut LightningError, mut val: crate::lightning::ln::msgs::ErrorAction) {
4603 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.action = val.into_native();
4605 /// Constructs a new LightningError given each field
4608 pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::Str, mut action_arg: crate::lightning::ln::msgs::ErrorAction) -> LightningError {
4609 LightningError { inner: ObjOps::heap_alloc(nativeLightningError {
4610 err: err_arg.into_string(),
4611 action: action_arg.into_native(),
4612 }), is_owned: true }
4614 impl Clone for LightningError {
4615 fn clone(&self) -> Self {
4617 inner: if <*mut nativeLightningError>::is_null(self.inner) { std::ptr::null_mut() } else {
4618 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4624 /// Used only if an object of this type is returned as a trait impl by a method
4625 pub(crate) extern "C" fn LightningError_clone_void(this_ptr: *const c_void) -> *mut c_void {
4626 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeLightningError)).clone() })) as *mut c_void
4629 /// Creates a copy of the LightningError
4630 pub extern "C" fn LightningError_clone(orig: &LightningError) -> LightningError {
4634 use lightning::ln::msgs::CommitmentUpdate as nativeCommitmentUpdateImport;
4635 pub(crate) type nativeCommitmentUpdate = nativeCommitmentUpdateImport;
4637 /// Struct used to return values from revoke_and_ack messages, containing a bunch of commitment
4638 /// transaction updates if they were pending.
4641 pub struct CommitmentUpdate {
4642 /// A pointer to the opaque Rust object.
4644 /// Nearly everywhere, inner must be non-null, however in places where
4645 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4646 pub inner: *mut nativeCommitmentUpdate,
4647 /// Indicates that this is the only struct which contains the same pointer.
4649 /// Rust functions which take ownership of an object provided via an argument require
4650 /// this to be true and invalidate the object pointed to by inner.
4654 impl Drop for CommitmentUpdate {
4655 fn drop(&mut self) {
4656 if self.is_owned && !<*mut nativeCommitmentUpdate>::is_null(self.inner) {
4657 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4661 /// Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL.
4663 pub extern "C" fn CommitmentUpdate_free(this_obj: CommitmentUpdate) { }
4665 /// Used only if an object of this type is returned as a trait impl by a method
4666 pub(crate) extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) {
4667 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentUpdate); }
4670 impl CommitmentUpdate {
4671 pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentUpdate {
4672 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4674 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentUpdate {
4675 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4677 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4678 pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentUpdate {
4679 assert!(self.is_owned);
4680 let ret = ObjOps::untweak_ptr(self.inner);
4681 self.inner = std::ptr::null_mut();
4685 /// update_add_htlc messages which should be sent
4687 pub extern "C" fn CommitmentUpdate_get_update_add_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateAddHTLCZ {
4688 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_add_htlcs;
4689 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 } }); };
4690 local_inner_val.into()
4692 /// update_add_htlc messages which should be sent
4694 pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) {
4695 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4696 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_add_htlcs = local_val;
4698 /// update_fulfill_htlc messages which should be sent
4700 pub extern "C" fn CommitmentUpdate_get_update_fulfill_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFulfillHTLCZ {
4701 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fulfill_htlcs;
4702 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 } }); };
4703 local_inner_val.into()
4705 /// update_fulfill_htlc messages which should be sent
4707 pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) {
4708 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4709 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fulfill_htlcs = local_val;
4711 /// update_fail_htlc messages which should be sent
4713 pub extern "C" fn CommitmentUpdate_get_update_fail_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailHTLCZ {
4714 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_htlcs;
4715 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 } }); };
4716 local_inner_val.into()
4718 /// update_fail_htlc messages which should be sent
4720 pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) {
4721 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4722 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_htlcs = local_val;
4724 /// update_fail_malformed_htlc messages which should be sent
4726 pub extern "C" fn CommitmentUpdate_get_update_fail_malformed_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ {
4727 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_malformed_htlcs;
4728 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 } }); };
4729 local_inner_val.into()
4731 /// update_fail_malformed_htlc messages which should be sent
4733 pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) {
4734 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4735 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_malformed_htlcs = local_val;
4737 /// An update_fee message which should be sent
4739 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
4741 pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::UpdateFee {
4742 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fee;
4743 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 };
4746 /// An update_fee message which should be sent
4748 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
4750 pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::UpdateFee) {
4751 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
4752 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fee = local_val;
4754 /// Finally, the commitment_signed message which should be sent
4756 pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::CommitmentSigned {
4757 let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_signed;
4758 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 }
4760 /// Finally, the commitment_signed message which should be sent
4762 pub extern "C" fn CommitmentUpdate_set_commitment_signed(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::CommitmentSigned) {
4763 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_signed = *unsafe { Box::from_raw(val.take_inner()) };
4765 /// Constructs a new CommitmentUpdate given each field
4768 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 {
4769 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()) } }); };
4770 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()) } }); };
4771 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()) } }); };
4772 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()) } }); };
4773 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()) } }) };
4774 CommitmentUpdate { inner: ObjOps::heap_alloc(nativeCommitmentUpdate {
4775 update_add_htlcs: local_update_add_htlcs_arg,
4776 update_fulfill_htlcs: local_update_fulfill_htlcs_arg,
4777 update_fail_htlcs: local_update_fail_htlcs_arg,
4778 update_fail_malformed_htlcs: local_update_fail_malformed_htlcs_arg,
4779 update_fee: local_update_fee_arg,
4780 commitment_signed: *unsafe { Box::from_raw(commitment_signed_arg.take_inner()) },
4781 }), is_owned: true }
4783 impl Clone for CommitmentUpdate {
4784 fn clone(&self) -> Self {
4786 inner: if <*mut nativeCommitmentUpdate>::is_null(self.inner) { std::ptr::null_mut() } else {
4787 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4793 /// Used only if an object of this type is returned as a trait impl by a method
4794 pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
4795 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentUpdate)).clone() })) as *mut c_void
4798 /// Creates a copy of the CommitmentUpdate
4799 pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentUpdate {
4802 /// A trait to describe an object which can receive channel messages.
4804 /// Messages MAY be called in parallel when they originate from different their_node_ids, however
4805 /// they MUST NOT be called in parallel when the two calls have the same their_node_id.
4807 pub struct ChannelMessageHandler {
4808 /// An opaque pointer which is passed to your function implementations as an argument.
4809 /// This has no meaning in the LDK, and can be NULL or any other value.
4810 pub this_arg: *mut c_void,
4811 /// Handle an incoming open_channel message from the given peer.
4812 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),
4813 /// Handle an incoming accept_channel message from the given peer.
4814 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),
4815 /// Handle an incoming funding_created message from the given peer.
4816 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),
4817 /// Handle an incoming funding_signed message from the given peer.
4818 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),
4819 /// Handle an incoming funding_locked message from the given peer.
4820 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),
4821 /// Handle an incoming shutdown message from the given peer.
4822 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),
4823 /// Handle an incoming closing_signed message from the given peer.
4824 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),
4825 /// Handle an incoming update_add_htlc message from the given peer.
4826 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),
4827 /// Handle an incoming update_fulfill_htlc message from the given peer.
4828 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),
4829 /// Handle an incoming update_fail_htlc message from the given peer.
4830 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),
4831 /// Handle an incoming update_fail_malformed_htlc message from the given peer.
4832 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),
4833 /// Handle an incoming commitment_signed message from the given peer.
4834 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),
4835 /// Handle an incoming revoke_and_ack message from the given peer.
4836 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),
4837 /// Handle an incoming update_fee message from the given peer.
4838 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),
4839 /// Handle an incoming announcement_signatures message from the given peer.
4840 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),
4841 /// Indicates a connection to the peer failed/an existing connection was lost. If no connection
4842 /// is believed to be possible in the future (eg they're sending us messages we don't
4843 /// understand or indicate they require unknown feature bits), no_connection_possible is set
4844 /// and any outstanding channels should be failed.
4845 pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, no_connection_possible: bool),
4846 /// Handle a peer reconnecting, possibly generating channel_reestablish message(s).
4847 pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Init),
4848 /// Handle an incoming channel_reestablish message from the given peer.
4849 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),
4850 /// Handle an incoming channel update from the given peer.
4851 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),
4852 /// Handle an incoming error message from the given peer.
4853 pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ErrorMessage),
4854 /// Implementation of MessageSendEventsProvider for this object.
4855 pub MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider,
4856 /// Frees any resources associated with this object given its this_arg pointer.
4857 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
4858 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
4860 unsafe impl Send for ChannelMessageHandler {}
4861 unsafe impl Sync for ChannelMessageHandler {}
4863 pub(crate) extern "C" fn ChannelMessageHandler_clone_fields(orig: &ChannelMessageHandler) -> ChannelMessageHandler {
4864 ChannelMessageHandler {
4865 this_arg: orig.this_arg,
4866 handle_open_channel: Clone::clone(&orig.handle_open_channel),
4867 handle_accept_channel: Clone::clone(&orig.handle_accept_channel),
4868 handle_funding_created: Clone::clone(&orig.handle_funding_created),
4869 handle_funding_signed: Clone::clone(&orig.handle_funding_signed),
4870 handle_funding_locked: Clone::clone(&orig.handle_funding_locked),
4871 handle_shutdown: Clone::clone(&orig.handle_shutdown),
4872 handle_closing_signed: Clone::clone(&orig.handle_closing_signed),
4873 handle_update_add_htlc: Clone::clone(&orig.handle_update_add_htlc),
4874 handle_update_fulfill_htlc: Clone::clone(&orig.handle_update_fulfill_htlc),
4875 handle_update_fail_htlc: Clone::clone(&orig.handle_update_fail_htlc),
4876 handle_update_fail_malformed_htlc: Clone::clone(&orig.handle_update_fail_malformed_htlc),
4877 handle_commitment_signed: Clone::clone(&orig.handle_commitment_signed),
4878 handle_revoke_and_ack: Clone::clone(&orig.handle_revoke_and_ack),
4879 handle_update_fee: Clone::clone(&orig.handle_update_fee),
4880 handle_announcement_signatures: Clone::clone(&orig.handle_announcement_signatures),
4881 peer_disconnected: Clone::clone(&orig.peer_disconnected),
4882 peer_connected: Clone::clone(&orig.peer_connected),
4883 handle_channel_reestablish: Clone::clone(&orig.handle_channel_reestablish),
4884 handle_channel_update: Clone::clone(&orig.handle_channel_update),
4885 handle_error: Clone::clone(&orig.handle_error),
4886 MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
4887 free: Clone::clone(&orig.free),
4890 impl lightning::util::events::MessageSendEventsProvider for ChannelMessageHandler {
4891 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
4892 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
4893 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
4898 use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler;
4899 impl rustChannelMessageHandler for ChannelMessageHandler {
4900 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) {
4901 (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 })
4903 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) {
4904 (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 })
4906 fn handle_funding_created(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::FundingCreated) {
4907 (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 })
4909 fn handle_funding_signed(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::FundingSigned) {
4910 (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 })
4912 fn handle_funding_locked(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::FundingLocked) {
4913 (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 })
4915 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) {
4916 (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 })
4918 fn handle_closing_signed(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ClosingSigned) {
4919 (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 })
4921 fn handle_update_add_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateAddHTLC) {
4922 (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 })
4924 fn handle_update_fulfill_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFulfillHTLC) {
4925 (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 })
4927 fn handle_update_fail_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailHTLC) {
4928 (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 })
4930 fn handle_update_fail_malformed_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) {
4931 (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 })
4933 fn handle_commitment_signed(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::CommitmentSigned) {
4934 (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 })
4936 fn handle_revoke_and_ack(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::RevokeAndACK) {
4937 (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 })
4939 fn handle_update_fee(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFee) {
4940 (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 })
4942 fn handle_announcement_signatures(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::AnnouncementSignatures) {
4943 (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 })
4945 fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut no_connection_possible: bool) {
4946 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), no_connection_possible)
4948 fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::Init) {
4949 (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 })
4951 fn handle_channel_reestablish(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ChannelReestablish) {
4952 (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 })
4954 fn handle_channel_update(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ChannelUpdate) {
4955 (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 })
4957 fn handle_error(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ErrorMessage) {
4958 (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 })
4962 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
4963 // directly as a Deref trait in higher-level structs:
4964 impl std::ops::Deref for ChannelMessageHandler {
4966 fn deref(&self) -> &Self {
4970 /// Calls the free function if one is set
4972 pub extern "C" fn ChannelMessageHandler_free(this_ptr: ChannelMessageHandler) { }
4973 impl Drop for ChannelMessageHandler {
4974 fn drop(&mut self) {
4975 if let Some(f) = self.free {
4980 /// A trait to describe an object which can receive routing messages.
4982 /// # Implementor DoS Warnings
4984 /// For `gossip_queries` messages there are potential DoS vectors when handling
4985 /// inbound queries. Implementors using an on-disk network graph should be aware of
4986 /// repeated disk I/O for queries accessing different parts of the network graph.
4988 pub struct RoutingMessageHandler {
4989 /// An opaque pointer which is passed to your function implementations as an argument.
4990 /// This has no meaning in the LDK, and can be NULL or any other value.
4991 pub this_arg: *mut c_void,
4992 /// Handle an incoming node_announcement message, returning true if it should be forwarded on,
4993 /// false or returning an Err otherwise.
4995 pub handle_node_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
4996 /// Handle a channel_announcement message, returning true if it should be forwarded on, false
4997 /// or returning an Err otherwise.
4999 pub handle_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
5000 /// Handle an incoming channel_update message, returning true if it should be forwarded on,
5001 /// false or returning an Err otherwise.
5003 pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ,
5004 /// Gets a subset of the channel announcements and updates required to dump our routing table
5005 /// to a remote node, starting at the short_channel_id indicated by starting_point and
5006 /// including the batch_amount entries immediately higher in numerical value than starting_point.
5008 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,
5009 /// Gets a subset of the node announcements required to dump our routing table to a remote node,
5010 /// starting at the node *after* the provided publickey and including batch_amount entries
5011 /// immediately higher (as defined by <PublicKey as Ord>::cmp) than starting_point.
5012 /// If None is provided for starting_point, we start at the first node.
5014 /// Note that starting_point (or a relevant inner pointer) may be NULL or all-0s to represent None
5016 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,
5017 /// Called when a connection is established with a peer. This can be used to
5018 /// perform routing table synchronization using a strategy defined by the
5020 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),
5021 /// Handles the reply of a query we initiated to learn about channels
5022 /// for a given range of blocks. We can expect to receive one or more
5023 /// replies to a single query.
5025 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,
5026 /// Handles the reply of a query we initiated asking for routing gossip
5027 /// messages for a list of channels. We should receive this message when
5028 /// a node has completed its best effort to send us the pertaining routing
5029 /// gossip messages.
5031 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,
5032 /// Handles when a peer asks us to send a list of short_channel_ids
5033 /// for the requested range of blocks.
5035 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,
5036 /// Handles when a peer asks us to send routing gossip messages for a
5037 /// list of short_channel_ids.
5039 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,
5040 /// Implementation of MessageSendEventsProvider for this object.
5041 pub MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider,
5042 /// Frees any resources associated with this object given its this_arg pointer.
5043 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
5044 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
5046 unsafe impl Send for RoutingMessageHandler {}
5047 unsafe impl Sync for RoutingMessageHandler {}
5049 pub(crate) extern "C" fn RoutingMessageHandler_clone_fields(orig: &RoutingMessageHandler) -> RoutingMessageHandler {
5050 RoutingMessageHandler {
5051 this_arg: orig.this_arg,
5052 handle_node_announcement: Clone::clone(&orig.handle_node_announcement),
5053 handle_channel_announcement: Clone::clone(&orig.handle_channel_announcement),
5054 handle_channel_update: Clone::clone(&orig.handle_channel_update),
5055 get_next_channel_announcements: Clone::clone(&orig.get_next_channel_announcements),
5056 get_next_node_announcements: Clone::clone(&orig.get_next_node_announcements),
5057 sync_routing_table: Clone::clone(&orig.sync_routing_table),
5058 handle_reply_channel_range: Clone::clone(&orig.handle_reply_channel_range),
5059 handle_reply_short_channel_ids_end: Clone::clone(&orig.handle_reply_short_channel_ids_end),
5060 handle_query_channel_range: Clone::clone(&orig.handle_query_channel_range),
5061 handle_query_short_channel_ids: Clone::clone(&orig.handle_query_short_channel_ids),
5062 MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
5063 free: Clone::clone(&orig.free),
5066 impl lightning::util::events::MessageSendEventsProvider for RoutingMessageHandler {
5067 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
5068 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
5069 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
5074 use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler;
5075 impl rustRoutingMessageHandler for RoutingMessageHandler {
5076 fn handle_node_announcement(&self, mut msg: &lightning::ln::msgs::NodeAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
5077 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 });
5078 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()) } })};
5081 fn handle_channel_announcement(&self, mut msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
5082 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 });
5083 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()) } })};
5086 fn handle_channel_update(&self, mut msg: &lightning::ln::msgs::ChannelUpdate) -> Result<bool, lightning::ln::msgs::LightningError> {
5087 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 });
5088 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()) } })};
5091 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>)> {
5092 let mut ret = (self.get_next_channel_announcements)(self.this_arg, starting_point, batch_amount);
5093 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 }); };
5096 fn get_next_node_announcements(&self, mut starting_point: Option<&bitcoin::secp256k1::key::PublicKey>, mut batch_amount: u8) -> Vec<lightning::ln::msgs::NodeAnnouncement> {
5097 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())) } };
5098 let mut ret = (self.get_next_node_announcements)(self.this_arg, local_starting_point, batch_amount);
5099 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
5102 fn sync_routing_table(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut init: &lightning::ln::msgs::Init) {
5103 (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 })
5105 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> {
5106 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 });
5107 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()) } })};
5110 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> {
5111 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 });
5112 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()) } })};
5115 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> {
5116 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 });
5117 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()) } })};
5120 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> {
5121 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 });
5122 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()) } })};
5127 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
5128 // directly as a Deref trait in higher-level structs:
5129 impl std::ops::Deref for RoutingMessageHandler {
5131 fn deref(&self) -> &Self {
5135 /// Calls the free function if one is set
5137 pub extern "C" fn RoutingMessageHandler_free(this_ptr: RoutingMessageHandler) { }
5138 impl Drop for RoutingMessageHandler {
5139 fn drop(&mut self) {
5140 if let Some(f) = self.free {
5145 mod fuzzy_internal_msgs {
5147 use std::str::FromStr;
5148 use std::ffi::c_void;
5149 use core::convert::Infallible;
5150 use bitcoin::hashes::Hash;
5151 use crate::c_types::*;
5155 /// Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read
5156 pub extern "C" fn AcceptChannel_write(obj: &AcceptChannel) -> crate::c_types::derived::CVec_u8Z {
5157 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5160 pub(crate) extern "C" fn AcceptChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5161 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannel) })
5164 /// Read a AcceptChannel from a byte array, created by AcceptChannel_write
5165 pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelDecodeErrorZ {
5166 let res: Result<lightning::ln::msgs::AcceptChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5167 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() };
5171 /// Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read
5172 pub extern "C" fn AnnouncementSignatures_write(obj: &AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z {
5173 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5176 pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5177 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAnnouncementSignatures) })
5180 /// Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write
5181 pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AnnouncementSignaturesDecodeErrorZ {
5182 let res: Result<lightning::ln::msgs::AnnouncementSignatures, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5183 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() };
5187 /// Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read
5188 pub extern "C" fn ChannelReestablish_write(obj: &ChannelReestablish) -> crate::c_types::derived::CVec_u8Z {
5189 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5192 pub(crate) extern "C" fn ChannelReestablish_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5193 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReestablish) })
5196 /// Read a ChannelReestablish from a byte array, created by ChannelReestablish_write
5197 pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReestablishDecodeErrorZ {
5198 let res: Result<lightning::ln::msgs::ChannelReestablish, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5199 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() };
5203 /// Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read
5204 pub extern "C" fn ClosingSigned_write(obj: &ClosingSigned) -> crate::c_types::derived::CVec_u8Z {
5205 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5208 pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5209 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSigned) })
5212 /// Read a ClosingSigned from a byte array, created by ClosingSigned_write
5213 pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedDecodeErrorZ {
5214 let res: Result<lightning::ln::msgs::ClosingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5215 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() };
5219 /// Serialize the ClosingSignedFeeRange object into a byte array which can be read by ClosingSignedFeeRange_read
5220 pub extern "C" fn ClosingSignedFeeRange_write(obj: &ClosingSignedFeeRange) -> crate::c_types::derived::CVec_u8Z {
5221 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5224 pub(crate) extern "C" fn ClosingSignedFeeRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5225 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSignedFeeRange) })
5228 /// Read a ClosingSignedFeeRange from a byte array, created by ClosingSignedFeeRange_write
5229 pub extern "C" fn ClosingSignedFeeRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedFeeRangeDecodeErrorZ {
5230 let res: Result<lightning::ln::msgs::ClosingSignedFeeRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5231 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() };
5235 /// Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read
5236 pub extern "C" fn CommitmentSigned_write(obj: &CommitmentSigned) -> crate::c_types::derived::CVec_u8Z {
5237 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5240 pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5241 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentSigned) })
5244 /// Read a CommitmentSigned from a byte array, created by CommitmentSigned_write
5245 pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CommitmentSignedDecodeErrorZ {
5246 let res: Result<lightning::ln::msgs::CommitmentSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5247 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() };
5251 /// Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read
5252 pub extern "C" fn FundingCreated_write(obj: &FundingCreated) -> crate::c_types::derived::CVec_u8Z {
5253 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5256 pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5257 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingCreated) })
5260 /// Read a FundingCreated from a byte array, created by FundingCreated_write
5261 pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingCreatedDecodeErrorZ {
5262 let res: Result<lightning::ln::msgs::FundingCreated, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5263 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() };
5267 /// Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read
5268 pub extern "C" fn FundingSigned_write(obj: &FundingSigned) -> crate::c_types::derived::CVec_u8Z {
5269 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5272 pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5273 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingSigned) })
5276 /// Read a FundingSigned from a byte array, created by FundingSigned_write
5277 pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingSignedDecodeErrorZ {
5278 let res: Result<lightning::ln::msgs::FundingSigned, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5279 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() };
5283 /// Serialize the FundingLocked object into a byte array which can be read by FundingLocked_read
5284 pub extern "C" fn FundingLocked_write(obj: &FundingLocked) -> crate::c_types::derived::CVec_u8Z {
5285 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5288 pub(crate) extern "C" fn FundingLocked_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5289 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingLocked) })
5292 /// Read a FundingLocked from a byte array, created by FundingLocked_write
5293 pub extern "C" fn FundingLocked_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingLockedDecodeErrorZ {
5294 let res: Result<lightning::ln::msgs::FundingLocked, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5295 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() };
5299 /// Serialize the Init object into a byte array which can be read by Init_read
5300 pub extern "C" fn Init_write(obj: &Init) -> crate::c_types::derived::CVec_u8Z {
5301 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5304 pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5305 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInit) })
5308 /// Read a Init from a byte array, created by Init_write
5309 pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitDecodeErrorZ {
5310 let res: Result<lightning::ln::msgs::Init, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5311 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() };
5315 /// Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read
5316 pub extern "C" fn OpenChannel_write(obj: &OpenChannel) -> crate::c_types::derived::CVec_u8Z {
5317 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5320 pub(crate) extern "C" fn OpenChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5321 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannel) })
5324 /// Read a OpenChannel from a byte array, created by OpenChannel_write
5325 pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelDecodeErrorZ {
5326 let res: Result<lightning::ln::msgs::OpenChannel, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5327 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() };
5331 /// Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read
5332 pub extern "C" fn RevokeAndACK_write(obj: &RevokeAndACK) -> crate::c_types::derived::CVec_u8Z {
5333 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5336 pub(crate) extern "C" fn RevokeAndACK_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5337 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevokeAndACK) })
5340 /// Read a RevokeAndACK from a byte array, created by RevokeAndACK_write
5341 pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RevokeAndACKDecodeErrorZ {
5342 let res: Result<lightning::ln::msgs::RevokeAndACK, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5343 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() };
5347 /// Serialize the Shutdown object into a byte array which can be read by Shutdown_read
5348 pub extern "C" fn Shutdown_write(obj: &Shutdown) -> crate::c_types::derived::CVec_u8Z {
5349 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5352 pub(crate) extern "C" fn Shutdown_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5353 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeShutdown) })
5356 /// Read a Shutdown from a byte array, created by Shutdown_write
5357 pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ShutdownDecodeErrorZ {
5358 let res: Result<lightning::ln::msgs::Shutdown, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5359 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() };
5363 /// Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read
5364 pub extern "C" fn UpdateFailHTLC_write(obj: &UpdateFailHTLC) -> crate::c_types::derived::CVec_u8Z {
5365 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5368 pub(crate) extern "C" fn UpdateFailHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5369 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailHTLC) })
5372 /// Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write
5373 pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailHTLCDecodeErrorZ {
5374 let res: Result<lightning::ln::msgs::UpdateFailHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5375 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() };
5379 /// Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read
5380 pub extern "C" fn UpdateFailMalformedHTLC_write(obj: &UpdateFailMalformedHTLC) -> crate::c_types::derived::CVec_u8Z {
5381 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5384 pub(crate) extern "C" fn UpdateFailMalformedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5385 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailMalformedHTLC) })
5388 /// Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write
5389 pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailMalformedHTLCDecodeErrorZ {
5390 let res: Result<lightning::ln::msgs::UpdateFailMalformedHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5391 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() };
5395 /// Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read
5396 pub extern "C" fn UpdateFee_write(obj: &UpdateFee) -> crate::c_types::derived::CVec_u8Z {
5397 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5400 pub(crate) extern "C" fn UpdateFee_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5401 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFee) })
5404 /// Read a UpdateFee from a byte array, created by UpdateFee_write
5405 pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFeeDecodeErrorZ {
5406 let res: Result<lightning::ln::msgs::UpdateFee, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5407 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() };
5411 /// Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read
5412 pub extern "C" fn UpdateFulfillHTLC_write(obj: &UpdateFulfillHTLC) -> crate::c_types::derived::CVec_u8Z {
5413 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5416 pub(crate) extern "C" fn UpdateFulfillHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5417 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFulfillHTLC) })
5420 /// Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write
5421 pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFulfillHTLCDecodeErrorZ {
5422 let res: Result<lightning::ln::msgs::UpdateFulfillHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5423 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() };
5427 /// Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read
5428 pub extern "C" fn UpdateAddHTLC_write(obj: &UpdateAddHTLC) -> crate::c_types::derived::CVec_u8Z {
5429 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5432 pub(crate) extern "C" fn UpdateAddHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5433 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateAddHTLC) })
5436 /// Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write
5437 pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateAddHTLCDecodeErrorZ {
5438 let res: Result<lightning::ln::msgs::UpdateAddHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5439 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() };
5443 /// Serialize the Ping object into a byte array which can be read by Ping_read
5444 pub extern "C" fn Ping_write(obj: &Ping) -> crate::c_types::derived::CVec_u8Z {
5445 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5448 pub(crate) extern "C" fn Ping_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5449 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePing) })
5452 /// Read a Ping from a byte array, created by Ping_write
5453 pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PingDecodeErrorZ {
5454 let res: Result<lightning::ln::msgs::Ping, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5455 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() };
5459 /// Serialize the Pong object into a byte array which can be read by Pong_read
5460 pub extern "C" fn Pong_write(obj: &Pong) -> crate::c_types::derived::CVec_u8Z {
5461 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5464 pub(crate) extern "C" fn Pong_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5465 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePong) })
5468 /// Read a Pong from a byte array, created by Pong_write
5469 pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PongDecodeErrorZ {
5470 let res: Result<lightning::ln::msgs::Pong, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5471 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() };
5475 /// Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read
5476 pub extern "C" fn UnsignedChannelAnnouncement_write(obj: &UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
5477 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5480 pub(crate) extern "C" fn UnsignedChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5481 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelAnnouncement) })
5484 /// Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write
5485 pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelAnnouncementDecodeErrorZ {
5486 let res: Result<lightning::ln::msgs::UnsignedChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5487 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() };
5491 /// Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read
5492 pub extern "C" fn ChannelAnnouncement_write(obj: &ChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
5493 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5496 pub(crate) extern "C" fn ChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5497 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelAnnouncement) })
5500 /// Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write
5501 pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelAnnouncementDecodeErrorZ {
5502 let res: Result<lightning::ln::msgs::ChannelAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5503 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() };
5507 /// Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read
5508 pub extern "C" fn UnsignedChannelUpdate_write(obj: &UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
5509 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5512 pub(crate) extern "C" fn UnsignedChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5513 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelUpdate) })
5516 /// Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write
5517 pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelUpdateDecodeErrorZ {
5518 let res: Result<lightning::ln::msgs::UnsignedChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5519 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() };
5523 /// Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read
5524 pub extern "C" fn ChannelUpdate_write(obj: &ChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
5525 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5528 pub(crate) extern "C" fn ChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5529 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdate) })
5532 /// Read a ChannelUpdate from a byte array, created by ChannelUpdate_write
5533 pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelUpdateDecodeErrorZ {
5534 let res: Result<lightning::ln::msgs::ChannelUpdate, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5535 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() };
5539 /// Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read
5540 pub extern "C" fn ErrorMessage_write(obj: &ErrorMessage) -> crate::c_types::derived::CVec_u8Z {
5541 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5544 pub(crate) extern "C" fn ErrorMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5545 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeErrorMessage) })
5548 /// Read a ErrorMessage from a byte array, created by ErrorMessage_write
5549 pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ErrorMessageDecodeErrorZ {
5550 let res: Result<lightning::ln::msgs::ErrorMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5551 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() };
5555 /// Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read
5556 pub extern "C" fn UnsignedNodeAnnouncement_write(obj: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
5557 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5560 pub(crate) extern "C" fn UnsignedNodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5561 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedNodeAnnouncement) })
5564 /// Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write
5565 pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedNodeAnnouncementDecodeErrorZ {
5566 let res: Result<lightning::ln::msgs::UnsignedNodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5567 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() };
5571 /// Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read
5572 pub extern "C" fn NodeAnnouncement_write(obj: &NodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
5573 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5576 pub(crate) extern "C" fn NodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5577 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncement) })
5580 /// Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write
5581 pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementDecodeErrorZ {
5582 let res: Result<lightning::ln::msgs::NodeAnnouncement, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5583 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() };
5587 /// Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write
5588 pub extern "C" fn QueryShortChannelIds_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryShortChannelIdsDecodeErrorZ {
5589 let res: Result<lightning::ln::msgs::QueryShortChannelIds, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5590 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() };
5594 /// Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read
5595 pub extern "C" fn QueryShortChannelIds_write(obj: &QueryShortChannelIds) -> crate::c_types::derived::CVec_u8Z {
5596 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5599 pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5600 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) })
5603 /// Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read
5604 pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z {
5605 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5608 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5609 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) })
5612 /// Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write
5613 pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyShortChannelIdsEndDecodeErrorZ {
5614 let res: Result<lightning::ln::msgs::ReplyShortChannelIdsEnd, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5615 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() };
5618 ///\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
5621 pub extern "C" fn QueryChannelRange_end_blocknum(this_arg: &QueryChannelRange) -> u32 {
5622 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.end_blocknum();
5627 /// Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read
5628 pub extern "C" fn QueryChannelRange_write(obj: &QueryChannelRange) -> crate::c_types::derived::CVec_u8Z {
5629 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5632 pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5633 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) })
5636 /// Read a QueryChannelRange from a byte array, created by QueryChannelRange_write
5637 pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ {
5638 let res: Result<lightning::ln::msgs::QueryChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5639 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() };
5643 /// Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write
5644 pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyChannelRangeDecodeErrorZ {
5645 let res: Result<lightning::ln::msgs::ReplyChannelRange, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5646 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::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() };
5650 /// Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read
5651 pub extern "C" fn ReplyChannelRange_write(obj: &ReplyChannelRange) -> crate::c_types::derived::CVec_u8Z {
5652 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5655 pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5656 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) })
5659 /// Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read
5660 pub extern "C" fn GossipTimestampFilter_write(obj: &GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z {
5661 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5664 pub(crate) extern "C" fn GossipTimestampFilter_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5665 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeGossipTimestampFilter) })
5668 /// Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write
5669 pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_GossipTimestampFilterDecodeErrorZ {
5670 let res: Result<lightning::ln::msgs::GossipTimestampFilter, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
5671 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() };