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 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 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 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 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 _) 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 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 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 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 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 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 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 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 extern "C" fn OpenChannel_free_void(this_ptr: *mut c_void) {
525 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeOpenChannel); }
529 pub(crate) fn get_native_ref(&self) -> &'static nativeOpenChannel {
530 unsafe { &*ObjOps::untweak_ptr(self.inner) }
532 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOpenChannel {
533 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
535 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
536 pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannel {
537 assert!(self.is_owned);
538 let ret = ObjOps::untweak_ptr(self.inner);
539 self.inner = std::ptr::null_mut();
543 /// The genesis hash of the blockchain where the channel is to be opened
545 pub extern "C" fn OpenChannel_get_chain_hash(this_ptr: &OpenChannel) -> *const [u8; 32] {
546 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
549 /// The genesis hash of the blockchain where the channel is to be opened
551 pub extern "C" fn OpenChannel_set_chain_hash(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
552 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
554 /// A temporary channel ID, until the funding outpoint is announced
556 pub extern "C" fn OpenChannel_get_temporary_channel_id(this_ptr: &OpenChannel) -> *const [u8; 32] {
557 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
560 /// A temporary channel ID, until the funding outpoint is announced
562 pub extern "C" fn OpenChannel_set_temporary_channel_id(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
563 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
565 /// The channel value
567 pub extern "C" fn OpenChannel_get_funding_satoshis(this_ptr: &OpenChannel) -> u64 {
568 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
571 /// The channel value
573 pub extern "C" fn OpenChannel_set_funding_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
574 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
576 /// The amount to push to the counterparty as part of the open, in milli-satoshi
578 pub extern "C" fn OpenChannel_get_push_msat(this_ptr: &OpenChannel) -> u64 {
579 let mut inner_val = &mut this_ptr.get_native_mut_ref().push_msat;
582 /// The amount to push to the counterparty as part of the open, in milli-satoshi
584 pub extern "C" fn OpenChannel_set_push_msat(this_ptr: &mut OpenChannel, mut val: u64) {
585 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.push_msat = val;
587 /// The threshold below which outputs on transactions broadcast by sender will be omitted
589 pub extern "C" fn OpenChannel_get_dust_limit_satoshis(this_ptr: &OpenChannel) -> u64 {
590 let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
593 /// The threshold below which outputs on transactions broadcast by sender will be omitted
595 pub extern "C" fn OpenChannel_set_dust_limit_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
596 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
598 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
600 pub extern "C" fn OpenChannel_get_max_htlc_value_in_flight_msat(this_ptr: &OpenChannel) -> u64 {
601 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
604 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
606 pub extern "C" fn OpenChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut OpenChannel, mut val: u64) {
607 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
609 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
611 pub extern "C" fn OpenChannel_get_channel_reserve_satoshis(this_ptr: &OpenChannel) -> u64 {
612 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
615 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
617 pub extern "C" fn OpenChannel_set_channel_reserve_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
618 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
620 /// The minimum HTLC size incoming to sender, in milli-satoshi
622 pub extern "C" fn OpenChannel_get_htlc_minimum_msat(this_ptr: &OpenChannel) -> u64 {
623 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
626 /// The minimum HTLC size incoming to sender, in milli-satoshi
628 pub extern "C" fn OpenChannel_set_htlc_minimum_msat(this_ptr: &mut OpenChannel, mut val: u64) {
629 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
631 /// The feerate per 1000-weight of sender generated transactions, until updated by update_fee
633 pub extern "C" fn OpenChannel_get_feerate_per_kw(this_ptr: &OpenChannel) -> u32 {
634 let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
637 /// The feerate per 1000-weight of sender generated transactions, until updated by update_fee
639 pub extern "C" fn OpenChannel_set_feerate_per_kw(this_ptr: &mut OpenChannel, mut val: u32) {
640 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
642 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
644 pub extern "C" fn OpenChannel_get_to_self_delay(this_ptr: &OpenChannel) -> u16 {
645 let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
648 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
650 pub extern "C" fn OpenChannel_set_to_self_delay(this_ptr: &mut OpenChannel, mut val: u16) {
651 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
653 /// The maximum number of inbound HTLCs towards sender
655 pub extern "C" fn OpenChannel_get_max_accepted_htlcs(this_ptr: &OpenChannel) -> u16 {
656 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
659 /// The maximum number of inbound HTLCs towards sender
661 pub extern "C" fn OpenChannel_set_max_accepted_htlcs(this_ptr: &mut OpenChannel, mut val: u16) {
662 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
664 /// The sender's key controlling the funding transaction
666 pub extern "C" fn OpenChannel_get_funding_pubkey(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
667 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
668 crate::c_types::PublicKey::from_rust(&inner_val)
670 /// The sender's key controlling the funding transaction
672 pub extern "C" fn OpenChannel_set_funding_pubkey(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
673 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
675 /// Used to derive a revocation key for transactions broadcast by counterparty
677 pub extern "C" fn OpenChannel_get_revocation_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
678 let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
679 crate::c_types::PublicKey::from_rust(&inner_val)
681 /// Used to derive a revocation key for transactions broadcast by counterparty
683 pub extern "C" fn OpenChannel_set_revocation_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
684 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
686 /// A payment key to sender for transactions broadcast by counterparty
688 pub extern "C" fn OpenChannel_get_payment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
689 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_point;
690 crate::c_types::PublicKey::from_rust(&inner_val)
692 /// A payment key to sender for transactions broadcast by counterparty
694 pub extern "C" fn OpenChannel_set_payment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
695 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_point = val.into_rust();
697 /// Used to derive a payment key to sender for transactions broadcast by sender
699 pub extern "C" fn OpenChannel_get_delayed_payment_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
700 let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
701 crate::c_types::PublicKey::from_rust(&inner_val)
703 /// Used to derive a payment key to sender for transactions broadcast by sender
705 pub extern "C" fn OpenChannel_set_delayed_payment_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
706 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
708 /// Used to derive an HTLC payment key to sender
710 pub extern "C" fn OpenChannel_get_htlc_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
711 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
712 crate::c_types::PublicKey::from_rust(&inner_val)
714 /// Used to derive an HTLC payment key to sender
716 pub extern "C" fn OpenChannel_set_htlc_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
717 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
719 /// The first to-be-broadcast-by-sender transaction's per commitment point
721 pub extern "C" fn OpenChannel_get_first_per_commitment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
722 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
723 crate::c_types::PublicKey::from_rust(&inner_val)
725 /// The first to-be-broadcast-by-sender transaction's per commitment point
727 pub extern "C" fn OpenChannel_set_first_per_commitment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
728 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
732 pub extern "C" fn OpenChannel_get_channel_flags(this_ptr: &OpenChannel) -> u8 {
733 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_flags;
738 pub extern "C" fn OpenChannel_set_channel_flags(this_ptr: &mut OpenChannel, mut val: u8) {
739 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_flags = val;
741 impl Clone for OpenChannel {
742 fn clone(&self) -> Self {
744 inner: if <*mut nativeOpenChannel>::is_null(self.inner) { std::ptr::null_mut() } else {
745 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
751 /// Used only if an object of this type is returned as a trait impl by a method
752 pub(crate) extern "C" fn OpenChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
753 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOpenChannel)).clone() })) as *mut c_void
756 /// Creates a copy of the OpenChannel
757 pub extern "C" fn OpenChannel_clone(orig: &OpenChannel) -> OpenChannel {
761 use lightning::ln::msgs::AcceptChannel as nativeAcceptChannelImport;
762 type nativeAcceptChannel = nativeAcceptChannelImport;
764 /// An accept_channel message to be sent or received from a peer
767 pub struct AcceptChannel {
768 /// A pointer to the opaque Rust object.
770 /// Nearly everywhere, inner must be non-null, however in places where
771 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
772 pub inner: *mut nativeAcceptChannel,
773 /// Indicates that this is the only struct which contains the same pointer.
775 /// Rust functions which take ownership of an object provided via an argument require
776 /// this to be true and invalidate the object pointed to by inner.
780 impl Drop for AcceptChannel {
782 if self.is_owned && !<*mut nativeAcceptChannel>::is_null(self.inner) {
783 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
787 /// Frees any resources used by the AcceptChannel, if is_owned is set and inner is non-NULL.
789 pub extern "C" fn AcceptChannel_free(this_obj: AcceptChannel) { }
791 /// Used only if an object of this type is returned as a trait impl by a method
792 extern "C" fn AcceptChannel_free_void(this_ptr: *mut c_void) {
793 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeAcceptChannel); }
797 pub(crate) fn get_native_ref(&self) -> &'static nativeAcceptChannel {
798 unsafe { &*ObjOps::untweak_ptr(self.inner) }
800 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAcceptChannel {
801 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
803 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
804 pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannel {
805 assert!(self.is_owned);
806 let ret = ObjOps::untweak_ptr(self.inner);
807 self.inner = std::ptr::null_mut();
811 /// A temporary channel ID, until the funding outpoint is announced
813 pub extern "C" fn AcceptChannel_get_temporary_channel_id(this_ptr: &AcceptChannel) -> *const [u8; 32] {
814 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
817 /// A temporary channel ID, until the funding outpoint is announced
819 pub extern "C" fn AcceptChannel_set_temporary_channel_id(this_ptr: &mut AcceptChannel, mut val: crate::c_types::ThirtyTwoBytes) {
820 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
822 /// The threshold below which outputs on transactions broadcast by sender will be omitted
824 pub extern "C" fn AcceptChannel_get_dust_limit_satoshis(this_ptr: &AcceptChannel) -> u64 {
825 let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
828 /// The threshold below which outputs on transactions broadcast by sender will be omitted
830 pub extern "C" fn AcceptChannel_set_dust_limit_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
831 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
833 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
835 pub extern "C" fn AcceptChannel_get_max_htlc_value_in_flight_msat(this_ptr: &AcceptChannel) -> u64 {
836 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
839 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
841 pub extern "C" fn AcceptChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
842 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
844 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
846 pub extern "C" fn AcceptChannel_get_channel_reserve_satoshis(this_ptr: &AcceptChannel) -> u64 {
847 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
850 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
852 pub extern "C" fn AcceptChannel_set_channel_reserve_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
853 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
855 /// The minimum HTLC size incoming to sender, in milli-satoshi
857 pub extern "C" fn AcceptChannel_get_htlc_minimum_msat(this_ptr: &AcceptChannel) -> u64 {
858 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
861 /// The minimum HTLC size incoming to sender, in milli-satoshi
863 pub extern "C" fn AcceptChannel_set_htlc_minimum_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
864 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
866 /// Minimum depth of the funding transaction before the channel is considered open
868 pub extern "C" fn AcceptChannel_get_minimum_depth(this_ptr: &AcceptChannel) -> u32 {
869 let mut inner_val = &mut this_ptr.get_native_mut_ref().minimum_depth;
872 /// Minimum depth of the funding transaction before the channel is considered open
874 pub extern "C" fn AcceptChannel_set_minimum_depth(this_ptr: &mut AcceptChannel, mut val: u32) {
875 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.minimum_depth = val;
877 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
879 pub extern "C" fn AcceptChannel_get_to_self_delay(this_ptr: &AcceptChannel) -> u16 {
880 let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
883 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
885 pub extern "C" fn AcceptChannel_set_to_self_delay(this_ptr: &mut AcceptChannel, mut val: u16) {
886 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
888 /// The maximum number of inbound HTLCs towards sender
890 pub extern "C" fn AcceptChannel_get_max_accepted_htlcs(this_ptr: &AcceptChannel) -> u16 {
891 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
894 /// The maximum number of inbound HTLCs towards sender
896 pub extern "C" fn AcceptChannel_set_max_accepted_htlcs(this_ptr: &mut AcceptChannel, mut val: u16) {
897 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
899 /// The sender's key controlling the funding transaction
901 pub extern "C" fn AcceptChannel_get_funding_pubkey(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
902 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
903 crate::c_types::PublicKey::from_rust(&inner_val)
905 /// The sender's key controlling the funding transaction
907 pub extern "C" fn AcceptChannel_set_funding_pubkey(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
908 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
910 /// Used to derive a revocation key for transactions broadcast by counterparty
912 pub extern "C" fn AcceptChannel_get_revocation_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
913 let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
914 crate::c_types::PublicKey::from_rust(&inner_val)
916 /// Used to derive a revocation key for transactions broadcast by counterparty
918 pub extern "C" fn AcceptChannel_set_revocation_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
919 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
921 /// A payment key to sender for transactions broadcast by counterparty
923 pub extern "C" fn AcceptChannel_get_payment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
924 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_point;
925 crate::c_types::PublicKey::from_rust(&inner_val)
927 /// A payment key to sender for transactions broadcast by counterparty
929 pub extern "C" fn AcceptChannel_set_payment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
930 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_point = val.into_rust();
932 /// Used to derive a payment key to sender for transactions broadcast by sender
934 pub extern "C" fn AcceptChannel_get_delayed_payment_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
935 let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
936 crate::c_types::PublicKey::from_rust(&inner_val)
938 /// Used to derive a payment key to sender for transactions broadcast by sender
940 pub extern "C" fn AcceptChannel_set_delayed_payment_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
941 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
943 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
945 pub extern "C" fn AcceptChannel_get_htlc_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
946 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
947 crate::c_types::PublicKey::from_rust(&inner_val)
949 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
951 pub extern "C" fn AcceptChannel_set_htlc_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
952 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
954 /// The first to-be-broadcast-by-sender transaction's per commitment point
956 pub extern "C" fn AcceptChannel_get_first_per_commitment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
957 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
958 crate::c_types::PublicKey::from_rust(&inner_val)
960 /// The first to-be-broadcast-by-sender transaction's per commitment point
962 pub extern "C" fn AcceptChannel_set_first_per_commitment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
963 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
965 impl Clone for AcceptChannel {
966 fn clone(&self) -> Self {
968 inner: if <*mut nativeAcceptChannel>::is_null(self.inner) { std::ptr::null_mut() } else {
969 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
975 /// Used only if an object of this type is returned as a trait impl by a method
976 pub(crate) extern "C" fn AcceptChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
977 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAcceptChannel)).clone() })) as *mut c_void
980 /// Creates a copy of the AcceptChannel
981 pub extern "C" fn AcceptChannel_clone(orig: &AcceptChannel) -> AcceptChannel {
985 use lightning::ln::msgs::FundingCreated as nativeFundingCreatedImport;
986 type nativeFundingCreated = nativeFundingCreatedImport;
988 /// A funding_created message to be sent or received from a peer
991 pub struct FundingCreated {
992 /// A pointer to the opaque Rust object.
994 /// Nearly everywhere, inner must be non-null, however in places where
995 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
996 pub inner: *mut nativeFundingCreated,
997 /// Indicates that this is the only struct which contains the same pointer.
999 /// Rust functions which take ownership of an object provided via an argument require
1000 /// this to be true and invalidate the object pointed to by inner.
1004 impl Drop for FundingCreated {
1005 fn drop(&mut self) {
1006 if self.is_owned && !<*mut nativeFundingCreated>::is_null(self.inner) {
1007 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1011 /// Frees any resources used by the FundingCreated, if is_owned is set and inner is non-NULL.
1013 pub extern "C" fn FundingCreated_free(this_obj: FundingCreated) { }
1015 /// Used only if an object of this type is returned as a trait impl by a method
1016 extern "C" fn FundingCreated_free_void(this_ptr: *mut c_void) {
1017 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingCreated); }
1020 impl FundingCreated {
1021 pub(crate) fn get_native_ref(&self) -> &'static nativeFundingCreated {
1022 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1024 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingCreated {
1025 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1027 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1028 pub(crate) fn take_inner(mut self) -> *mut nativeFundingCreated {
1029 assert!(self.is_owned);
1030 let ret = ObjOps::untweak_ptr(self.inner);
1031 self.inner = std::ptr::null_mut();
1035 /// A temporary channel ID, until the funding is established
1037 pub extern "C" fn FundingCreated_get_temporary_channel_id(this_ptr: &FundingCreated) -> *const [u8; 32] {
1038 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
1041 /// A temporary channel ID, until the funding is established
1043 pub extern "C" fn FundingCreated_set_temporary_channel_id(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
1044 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
1046 /// The funding transaction ID
1048 pub extern "C" fn FundingCreated_get_funding_txid(this_ptr: &FundingCreated) -> *const [u8; 32] {
1049 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_txid;
1050 inner_val.as_inner()
1052 /// The funding transaction ID
1054 pub extern "C" fn FundingCreated_set_funding_txid(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
1055 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_txid = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
1057 /// The specific output index funding this channel
1059 pub extern "C" fn FundingCreated_get_funding_output_index(this_ptr: &FundingCreated) -> u16 {
1060 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_index;
1063 /// The specific output index funding this channel
1065 pub extern "C" fn FundingCreated_set_funding_output_index(this_ptr: &mut FundingCreated, mut val: u16) {
1066 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_index = val;
1068 /// The signature of the channel initiator (funder) on the initial commitment transaction
1070 pub extern "C" fn FundingCreated_get_signature(this_ptr: &FundingCreated) -> crate::c_types::Signature {
1071 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
1072 crate::c_types::Signature::from_rust(&inner_val)
1074 /// The signature of the channel initiator (funder) on the initial commitment transaction
1076 pub extern "C" fn FundingCreated_set_signature(this_ptr: &mut FundingCreated, mut val: crate::c_types::Signature) {
1077 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
1079 /// Constructs a new FundingCreated given each field
1082 pub extern "C" fn FundingCreated_new(mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_txid_arg: crate::c_types::ThirtyTwoBytes, mut funding_output_index_arg: u16, mut signature_arg: crate::c_types::Signature) -> FundingCreated {
1083 FundingCreated { inner: ObjOps::heap_alloc(nativeFundingCreated {
1084 temporary_channel_id: temporary_channel_id_arg.data,
1085 funding_txid: ::bitcoin::hash_types::Txid::from_slice(&funding_txid_arg.data[..]).unwrap(),
1086 funding_output_index: funding_output_index_arg,
1087 signature: signature_arg.into_rust(),
1088 }), is_owned: true }
1090 impl Clone for FundingCreated {
1091 fn clone(&self) -> Self {
1093 inner: if <*mut nativeFundingCreated>::is_null(self.inner) { std::ptr::null_mut() } else {
1094 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1100 /// Used only if an object of this type is returned as a trait impl by a method
1101 pub(crate) extern "C" fn FundingCreated_clone_void(this_ptr: *const c_void) -> *mut c_void {
1102 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingCreated)).clone() })) as *mut c_void
1105 /// Creates a copy of the FundingCreated
1106 pub extern "C" fn FundingCreated_clone(orig: &FundingCreated) -> FundingCreated {
1110 use lightning::ln::msgs::FundingSigned as nativeFundingSignedImport;
1111 type nativeFundingSigned = nativeFundingSignedImport;
1113 /// A funding_signed message to be sent or received from a peer
1116 pub struct FundingSigned {
1117 /// A pointer to the opaque Rust object.
1119 /// Nearly everywhere, inner must be non-null, however in places where
1120 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1121 pub inner: *mut nativeFundingSigned,
1122 /// Indicates that this is the only struct which contains the same pointer.
1124 /// Rust functions which take ownership of an object provided via an argument require
1125 /// this to be true and invalidate the object pointed to by inner.
1129 impl Drop for FundingSigned {
1130 fn drop(&mut self) {
1131 if self.is_owned && !<*mut nativeFundingSigned>::is_null(self.inner) {
1132 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1136 /// Frees any resources used by the FundingSigned, if is_owned is set and inner is non-NULL.
1138 pub extern "C" fn FundingSigned_free(this_obj: FundingSigned) { }
1140 /// Used only if an object of this type is returned as a trait impl by a method
1141 extern "C" fn FundingSigned_free_void(this_ptr: *mut c_void) {
1142 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingSigned); }
1145 impl FundingSigned {
1146 pub(crate) fn get_native_ref(&self) -> &'static nativeFundingSigned {
1147 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1149 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingSigned {
1150 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1152 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1153 pub(crate) fn take_inner(mut self) -> *mut nativeFundingSigned {
1154 assert!(self.is_owned);
1155 let ret = ObjOps::untweak_ptr(self.inner);
1156 self.inner = std::ptr::null_mut();
1162 pub extern "C" fn FundingSigned_get_channel_id(this_ptr: &FundingSigned) -> *const [u8; 32] {
1163 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1168 pub extern "C" fn FundingSigned_set_channel_id(this_ptr: &mut FundingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
1169 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1171 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
1173 pub extern "C" fn FundingSigned_get_signature(this_ptr: &FundingSigned) -> crate::c_types::Signature {
1174 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
1175 crate::c_types::Signature::from_rust(&inner_val)
1177 /// The signature of the channel acceptor (fundee) on the initial commitment transaction
1179 pub extern "C" fn FundingSigned_set_signature(this_ptr: &mut FundingSigned, mut val: crate::c_types::Signature) {
1180 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
1182 /// Constructs a new FundingSigned given each field
1185 pub extern "C" fn FundingSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut signature_arg: crate::c_types::Signature) -> FundingSigned {
1186 FundingSigned { inner: ObjOps::heap_alloc(nativeFundingSigned {
1187 channel_id: channel_id_arg.data,
1188 signature: signature_arg.into_rust(),
1189 }), is_owned: true }
1191 impl Clone for FundingSigned {
1192 fn clone(&self) -> Self {
1194 inner: if <*mut nativeFundingSigned>::is_null(self.inner) { std::ptr::null_mut() } else {
1195 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1201 /// Used only if an object of this type is returned as a trait impl by a method
1202 pub(crate) extern "C" fn FundingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
1203 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingSigned)).clone() })) as *mut c_void
1206 /// Creates a copy of the FundingSigned
1207 pub extern "C" fn FundingSigned_clone(orig: &FundingSigned) -> FundingSigned {
1211 use lightning::ln::msgs::FundingLocked as nativeFundingLockedImport;
1212 type nativeFundingLocked = nativeFundingLockedImport;
1214 /// A funding_locked message to be sent or received from a peer
1217 pub struct FundingLocked {
1218 /// A pointer to the opaque Rust object.
1220 /// Nearly everywhere, inner must be non-null, however in places where
1221 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1222 pub inner: *mut nativeFundingLocked,
1223 /// Indicates that this is the only struct which contains the same pointer.
1225 /// Rust functions which take ownership of an object provided via an argument require
1226 /// this to be true and invalidate the object pointed to by inner.
1230 impl Drop for FundingLocked {
1231 fn drop(&mut self) {
1232 if self.is_owned && !<*mut nativeFundingLocked>::is_null(self.inner) {
1233 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1237 /// Frees any resources used by the FundingLocked, if is_owned is set and inner is non-NULL.
1239 pub extern "C" fn FundingLocked_free(this_obj: FundingLocked) { }
1241 /// Used only if an object of this type is returned as a trait impl by a method
1242 extern "C" fn FundingLocked_free_void(this_ptr: *mut c_void) {
1243 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingLocked); }
1246 impl FundingLocked {
1247 pub(crate) fn get_native_ref(&self) -> &'static nativeFundingLocked {
1248 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1250 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingLocked {
1251 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1253 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1254 pub(crate) fn take_inner(mut self) -> *mut nativeFundingLocked {
1255 assert!(self.is_owned);
1256 let ret = ObjOps::untweak_ptr(self.inner);
1257 self.inner = std::ptr::null_mut();
1263 pub extern "C" fn FundingLocked_get_channel_id(this_ptr: &FundingLocked) -> *const [u8; 32] {
1264 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1269 pub extern "C" fn FundingLocked_set_channel_id(this_ptr: &mut FundingLocked, mut val: crate::c_types::ThirtyTwoBytes) {
1270 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1272 /// The per-commitment point of the second commitment transaction
1274 pub extern "C" fn FundingLocked_get_next_per_commitment_point(this_ptr: &FundingLocked) -> crate::c_types::PublicKey {
1275 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
1276 crate::c_types::PublicKey::from_rust(&inner_val)
1278 /// The per-commitment point of the second commitment transaction
1280 pub extern "C" fn FundingLocked_set_next_per_commitment_point(this_ptr: &mut FundingLocked, mut val: crate::c_types::PublicKey) {
1281 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
1283 /// Constructs a new FundingLocked given each field
1286 pub extern "C" fn FundingLocked_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut next_per_commitment_point_arg: crate::c_types::PublicKey) -> FundingLocked {
1287 FundingLocked { inner: ObjOps::heap_alloc(nativeFundingLocked {
1288 channel_id: channel_id_arg.data,
1289 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
1290 }), is_owned: true }
1292 impl Clone for FundingLocked {
1293 fn clone(&self) -> Self {
1295 inner: if <*mut nativeFundingLocked>::is_null(self.inner) { std::ptr::null_mut() } else {
1296 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1302 /// Used only if an object of this type is returned as a trait impl by a method
1303 pub(crate) extern "C" fn FundingLocked_clone_void(this_ptr: *const c_void) -> *mut c_void {
1304 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingLocked)).clone() })) as *mut c_void
1307 /// Creates a copy of the FundingLocked
1308 pub extern "C" fn FundingLocked_clone(orig: &FundingLocked) -> FundingLocked {
1312 use lightning::ln::msgs::Shutdown as nativeShutdownImport;
1313 type nativeShutdown = nativeShutdownImport;
1315 /// A shutdown message to be sent or received from a peer
1318 pub struct Shutdown {
1319 /// A pointer to the opaque Rust object.
1321 /// Nearly everywhere, inner must be non-null, however in places where
1322 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1323 pub inner: *mut nativeShutdown,
1324 /// Indicates that this is the only struct which contains the same pointer.
1326 /// Rust functions which take ownership of an object provided via an argument require
1327 /// this to be true and invalidate the object pointed to by inner.
1331 impl Drop for Shutdown {
1332 fn drop(&mut self) {
1333 if self.is_owned && !<*mut nativeShutdown>::is_null(self.inner) {
1334 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1338 /// Frees any resources used by the Shutdown, if is_owned is set and inner is non-NULL.
1340 pub extern "C" fn Shutdown_free(this_obj: Shutdown) { }
1342 /// Used only if an object of this type is returned as a trait impl by a method
1343 extern "C" fn Shutdown_free_void(this_ptr: *mut c_void) {
1344 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeShutdown); }
1348 pub(crate) fn get_native_ref(&self) -> &'static nativeShutdown {
1349 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1351 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeShutdown {
1352 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1354 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1355 pub(crate) fn take_inner(mut self) -> *mut nativeShutdown {
1356 assert!(self.is_owned);
1357 let ret = ObjOps::untweak_ptr(self.inner);
1358 self.inner = std::ptr::null_mut();
1364 pub extern "C" fn Shutdown_get_channel_id(this_ptr: &Shutdown) -> *const [u8; 32] {
1365 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1370 pub extern "C" fn Shutdown_set_channel_id(this_ptr: &mut Shutdown, mut val: crate::c_types::ThirtyTwoBytes) {
1371 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1373 /// The destination of this peer's funds on closing.
1374 /// Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
1376 pub extern "C" fn Shutdown_get_scriptpubkey(this_ptr: &Shutdown) -> crate::c_types::u8slice {
1377 let mut inner_val = &mut this_ptr.get_native_mut_ref().scriptpubkey;
1378 crate::c_types::u8slice::from_slice(&inner_val[..])
1380 /// The destination of this peer's funds on closing.
1381 /// Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
1383 pub extern "C" fn Shutdown_set_scriptpubkey(this_ptr: &mut Shutdown, mut val: crate::c_types::derived::CVec_u8Z) {
1384 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.scriptpubkey = ::bitcoin::blockdata::script::Script::from(val.into_rust());
1386 /// Constructs a new Shutdown given each field
1389 pub extern "C" fn Shutdown_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut scriptpubkey_arg: crate::c_types::derived::CVec_u8Z) -> Shutdown {
1390 Shutdown { inner: ObjOps::heap_alloc(nativeShutdown {
1391 channel_id: channel_id_arg.data,
1392 scriptpubkey: ::bitcoin::blockdata::script::Script::from(scriptpubkey_arg.into_rust()),
1393 }), is_owned: true }
1395 impl Clone for Shutdown {
1396 fn clone(&self) -> Self {
1398 inner: if <*mut nativeShutdown>::is_null(self.inner) { std::ptr::null_mut() } else {
1399 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1405 /// Used only if an object of this type is returned as a trait impl by a method
1406 pub(crate) extern "C" fn Shutdown_clone_void(this_ptr: *const c_void) -> *mut c_void {
1407 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeShutdown)).clone() })) as *mut c_void
1410 /// Creates a copy of the Shutdown
1411 pub extern "C" fn Shutdown_clone(orig: &Shutdown) -> Shutdown {
1415 use lightning::ln::msgs::ClosingSignedFeeRange as nativeClosingSignedFeeRangeImport;
1416 type nativeClosingSignedFeeRange = nativeClosingSignedFeeRangeImport;
1418 /// The minimum and maximum fees which the sender is willing to place on the closing transaction.
1419 /// This is provided in [`ClosingSigned`] by both sides to indicate the fee range they are willing
1423 pub struct ClosingSignedFeeRange {
1424 /// A pointer to the opaque Rust object.
1426 /// Nearly everywhere, inner must be non-null, however in places where
1427 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1428 pub inner: *mut nativeClosingSignedFeeRange,
1429 /// Indicates that this is the only struct which contains the same pointer.
1431 /// Rust functions which take ownership of an object provided via an argument require
1432 /// this to be true and invalidate the object pointed to by inner.
1436 impl Drop for ClosingSignedFeeRange {
1437 fn drop(&mut self) {
1438 if self.is_owned && !<*mut nativeClosingSignedFeeRange>::is_null(self.inner) {
1439 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1443 /// Frees any resources used by the ClosingSignedFeeRange, if is_owned is set and inner is non-NULL.
1445 pub extern "C" fn ClosingSignedFeeRange_free(this_obj: ClosingSignedFeeRange) { }
1447 /// Used only if an object of this type is returned as a trait impl by a method
1448 extern "C" fn ClosingSignedFeeRange_free_void(this_ptr: *mut c_void) {
1449 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeClosingSignedFeeRange); }
1452 impl ClosingSignedFeeRange {
1453 pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSignedFeeRange {
1454 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1456 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSignedFeeRange {
1457 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1459 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1460 pub(crate) fn take_inner(mut self) -> *mut nativeClosingSignedFeeRange {
1461 assert!(self.is_owned);
1462 let ret = ObjOps::untweak_ptr(self.inner);
1463 self.inner = std::ptr::null_mut();
1467 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
1470 pub extern "C" fn ClosingSignedFeeRange_get_min_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
1471 let mut inner_val = &mut this_ptr.get_native_mut_ref().min_fee_satoshis;
1474 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
1477 pub extern "C" fn ClosingSignedFeeRange_set_min_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
1478 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_fee_satoshis = val;
1480 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
1483 pub extern "C" fn ClosingSignedFeeRange_get_max_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
1484 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_fee_satoshis;
1487 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
1490 pub extern "C" fn ClosingSignedFeeRange_set_max_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
1491 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_fee_satoshis = val;
1493 /// Constructs a new ClosingSignedFeeRange given each field
1496 pub extern "C" fn ClosingSignedFeeRange_new(mut min_fee_satoshis_arg: u64, mut max_fee_satoshis_arg: u64) -> ClosingSignedFeeRange {
1497 ClosingSignedFeeRange { inner: ObjOps::heap_alloc(nativeClosingSignedFeeRange {
1498 min_fee_satoshis: min_fee_satoshis_arg,
1499 max_fee_satoshis: max_fee_satoshis_arg,
1500 }), is_owned: true }
1502 impl Clone for ClosingSignedFeeRange {
1503 fn clone(&self) -> Self {
1505 inner: if <*mut nativeClosingSignedFeeRange>::is_null(self.inner) { std::ptr::null_mut() } else {
1506 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1512 /// Used only if an object of this type is returned as a trait impl by a method
1513 pub(crate) extern "C" fn ClosingSignedFeeRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
1514 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClosingSignedFeeRange)).clone() })) as *mut c_void
1517 /// Creates a copy of the ClosingSignedFeeRange
1518 pub extern "C" fn ClosingSignedFeeRange_clone(orig: &ClosingSignedFeeRange) -> ClosingSignedFeeRange {
1522 use lightning::ln::msgs::ClosingSigned as nativeClosingSignedImport;
1523 type nativeClosingSigned = nativeClosingSignedImport;
1525 /// A closing_signed message to be sent or received from a peer
1528 pub struct ClosingSigned {
1529 /// A pointer to the opaque Rust object.
1531 /// Nearly everywhere, inner must be non-null, however in places where
1532 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1533 pub inner: *mut nativeClosingSigned,
1534 /// Indicates that this is the only struct which contains the same pointer.
1536 /// Rust functions which take ownership of an object provided via an argument require
1537 /// this to be true and invalidate the object pointed to by inner.
1541 impl Drop for ClosingSigned {
1542 fn drop(&mut self) {
1543 if self.is_owned && !<*mut nativeClosingSigned>::is_null(self.inner) {
1544 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1548 /// Frees any resources used by the ClosingSigned, if is_owned is set and inner is non-NULL.
1550 pub extern "C" fn ClosingSigned_free(this_obj: ClosingSigned) { }
1552 /// Used only if an object of this type is returned as a trait impl by a method
1553 extern "C" fn ClosingSigned_free_void(this_ptr: *mut c_void) {
1554 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeClosingSigned); }
1557 impl ClosingSigned {
1558 pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSigned {
1559 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1561 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSigned {
1562 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1564 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1565 pub(crate) fn take_inner(mut self) -> *mut nativeClosingSigned {
1566 assert!(self.is_owned);
1567 let ret = ObjOps::untweak_ptr(self.inner);
1568 self.inner = std::ptr::null_mut();
1574 pub extern "C" fn ClosingSigned_get_channel_id(this_ptr: &ClosingSigned) -> *const [u8; 32] {
1575 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1580 pub extern "C" fn ClosingSigned_set_channel_id(this_ptr: &mut ClosingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
1581 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1583 /// The proposed total fee for the closing transaction
1585 pub extern "C" fn ClosingSigned_get_fee_satoshis(this_ptr: &ClosingSigned) -> u64 {
1586 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_satoshis;
1589 /// The proposed total fee for the closing transaction
1591 pub extern "C" fn ClosingSigned_set_fee_satoshis(this_ptr: &mut ClosingSigned, mut val: u64) {
1592 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_satoshis = val;
1594 /// A signature on the closing transaction
1596 pub extern "C" fn ClosingSigned_get_signature(this_ptr: &ClosingSigned) -> crate::c_types::Signature {
1597 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
1598 crate::c_types::Signature::from_rust(&inner_val)
1600 /// A signature on the closing transaction
1602 pub extern "C" fn ClosingSigned_set_signature(this_ptr: &mut ClosingSigned, mut val: crate::c_types::Signature) {
1603 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
1605 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
1608 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1610 pub extern "C" fn ClosingSigned_get_fee_range(this_ptr: &ClosingSigned) -> crate::lightning::ln::msgs::ClosingSignedFeeRange {
1611 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_range;
1612 let mut local_inner_val = crate::lightning::ln::msgs::ClosingSignedFeeRange { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const _) as *mut _ }, is_owned: false };
1615 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
1618 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1620 pub extern "C" fn ClosingSigned_set_fee_range(this_ptr: &mut ClosingSigned, mut val: crate::lightning::ln::msgs::ClosingSignedFeeRange) {
1621 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1622 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_range = local_val;
1624 /// Constructs a new ClosingSigned given each field
1627 pub extern "C" fn ClosingSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut fee_satoshis_arg: u64, mut signature_arg: crate::c_types::Signature, mut fee_range_arg: crate::lightning::ln::msgs::ClosingSignedFeeRange) -> ClosingSigned {
1628 let mut local_fee_range_arg = if fee_range_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(fee_range_arg.take_inner()) } }) };
1629 ClosingSigned { inner: ObjOps::heap_alloc(nativeClosingSigned {
1630 channel_id: channel_id_arg.data,
1631 fee_satoshis: fee_satoshis_arg,
1632 signature: signature_arg.into_rust(),
1633 fee_range: local_fee_range_arg,
1634 }), is_owned: true }
1636 impl Clone for ClosingSigned {
1637 fn clone(&self) -> Self {
1639 inner: if <*mut nativeClosingSigned>::is_null(self.inner) { std::ptr::null_mut() } else {
1640 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1646 /// Used only if an object of this type is returned as a trait impl by a method
1647 pub(crate) extern "C" fn ClosingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
1648 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClosingSigned)).clone() })) as *mut c_void
1651 /// Creates a copy of the ClosingSigned
1652 pub extern "C" fn ClosingSigned_clone(orig: &ClosingSigned) -> ClosingSigned {
1656 use lightning::ln::msgs::UpdateAddHTLC as nativeUpdateAddHTLCImport;
1657 type nativeUpdateAddHTLC = nativeUpdateAddHTLCImport;
1659 /// An update_add_htlc message to be sent or received from a peer
1662 pub struct UpdateAddHTLC {
1663 /// A pointer to the opaque Rust object.
1665 /// Nearly everywhere, inner must be non-null, however in places where
1666 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1667 pub inner: *mut nativeUpdateAddHTLC,
1668 /// Indicates that this is the only struct which contains the same pointer.
1670 /// Rust functions which take ownership of an object provided via an argument require
1671 /// this to be true and invalidate the object pointed to by inner.
1675 impl Drop for UpdateAddHTLC {
1676 fn drop(&mut self) {
1677 if self.is_owned && !<*mut nativeUpdateAddHTLC>::is_null(self.inner) {
1678 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1682 /// Frees any resources used by the UpdateAddHTLC, if is_owned is set and inner is non-NULL.
1684 pub extern "C" fn UpdateAddHTLC_free(this_obj: UpdateAddHTLC) { }
1686 /// Used only if an object of this type is returned as a trait impl by a method
1687 extern "C" fn UpdateAddHTLC_free_void(this_ptr: *mut c_void) {
1688 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateAddHTLC); }
1691 impl UpdateAddHTLC {
1692 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateAddHTLC {
1693 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1695 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateAddHTLC {
1696 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1698 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1699 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateAddHTLC {
1700 assert!(self.is_owned);
1701 let ret = ObjOps::untweak_ptr(self.inner);
1702 self.inner = std::ptr::null_mut();
1708 pub extern "C" fn UpdateAddHTLC_get_channel_id(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
1709 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1714 pub extern "C" fn UpdateAddHTLC_set_channel_id(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1715 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1719 pub extern "C" fn UpdateAddHTLC_get_htlc_id(this_ptr: &UpdateAddHTLC) -> u64 {
1720 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
1725 pub extern "C" fn UpdateAddHTLC_set_htlc_id(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
1726 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
1728 /// The HTLC value in milli-satoshi
1730 pub extern "C" fn UpdateAddHTLC_get_amount_msat(this_ptr: &UpdateAddHTLC) -> u64 {
1731 let mut inner_val = &mut this_ptr.get_native_mut_ref().amount_msat;
1734 /// The HTLC value in milli-satoshi
1736 pub extern "C" fn UpdateAddHTLC_set_amount_msat(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
1737 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.amount_msat = val;
1739 /// The payment hash, the pre-image of which controls HTLC redemption
1741 pub extern "C" fn UpdateAddHTLC_get_payment_hash(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
1742 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_hash;
1745 /// The payment hash, the pre-image of which controls HTLC redemption
1747 pub extern "C" fn UpdateAddHTLC_set_payment_hash(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1748 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_hash = ::lightning::ln::PaymentHash(val.data);
1750 /// The expiry height of the HTLC
1752 pub extern "C" fn UpdateAddHTLC_get_cltv_expiry(this_ptr: &UpdateAddHTLC) -> u32 {
1753 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry;
1756 /// The expiry height of the HTLC
1758 pub extern "C" fn UpdateAddHTLC_set_cltv_expiry(this_ptr: &mut UpdateAddHTLC, mut val: u32) {
1759 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry = val;
1761 impl Clone for UpdateAddHTLC {
1762 fn clone(&self) -> Self {
1764 inner: if <*mut nativeUpdateAddHTLC>::is_null(self.inner) { std::ptr::null_mut() } else {
1765 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1771 /// Used only if an object of this type is returned as a trait impl by a method
1772 pub(crate) extern "C" fn UpdateAddHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1773 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateAddHTLC)).clone() })) as *mut c_void
1776 /// Creates a copy of the UpdateAddHTLC
1777 pub extern "C" fn UpdateAddHTLC_clone(orig: &UpdateAddHTLC) -> UpdateAddHTLC {
1781 use lightning::ln::msgs::UpdateFulfillHTLC as nativeUpdateFulfillHTLCImport;
1782 type nativeUpdateFulfillHTLC = nativeUpdateFulfillHTLCImport;
1784 /// An update_fulfill_htlc message to be sent or received from a peer
1787 pub struct UpdateFulfillHTLC {
1788 /// A pointer to the opaque Rust object.
1790 /// Nearly everywhere, inner must be non-null, however in places where
1791 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1792 pub inner: *mut nativeUpdateFulfillHTLC,
1793 /// Indicates that this is the only struct which contains the same pointer.
1795 /// Rust functions which take ownership of an object provided via an argument require
1796 /// this to be true and invalidate the object pointed to by inner.
1800 impl Drop for UpdateFulfillHTLC {
1801 fn drop(&mut self) {
1802 if self.is_owned && !<*mut nativeUpdateFulfillHTLC>::is_null(self.inner) {
1803 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1807 /// Frees any resources used by the UpdateFulfillHTLC, if is_owned is set and inner is non-NULL.
1809 pub extern "C" fn UpdateFulfillHTLC_free(this_obj: UpdateFulfillHTLC) { }
1811 /// Used only if an object of this type is returned as a trait impl by a method
1812 extern "C" fn UpdateFulfillHTLC_free_void(this_ptr: *mut c_void) {
1813 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFulfillHTLC); }
1816 impl UpdateFulfillHTLC {
1817 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFulfillHTLC {
1818 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1820 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFulfillHTLC {
1821 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1823 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1824 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFulfillHTLC {
1825 assert!(self.is_owned);
1826 let ret = ObjOps::untweak_ptr(self.inner);
1827 self.inner = std::ptr::null_mut();
1833 pub extern "C" fn UpdateFulfillHTLC_get_channel_id(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
1834 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1839 pub extern "C" fn UpdateFulfillHTLC_set_channel_id(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1840 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1844 pub extern "C" fn UpdateFulfillHTLC_get_htlc_id(this_ptr: &UpdateFulfillHTLC) -> u64 {
1845 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
1850 pub extern "C" fn UpdateFulfillHTLC_set_htlc_id(this_ptr: &mut UpdateFulfillHTLC, mut val: u64) {
1851 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
1853 /// The pre-image of the payment hash, allowing HTLC redemption
1855 pub extern "C" fn UpdateFulfillHTLC_get_payment_preimage(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
1856 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_preimage;
1859 /// The pre-image of the payment hash, allowing HTLC redemption
1861 pub extern "C" fn UpdateFulfillHTLC_set_payment_preimage(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1862 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_preimage = ::lightning::ln::PaymentPreimage(val.data);
1864 /// Constructs a new UpdateFulfillHTLC given each field
1867 pub extern "C" fn UpdateFulfillHTLC_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut htlc_id_arg: u64, mut payment_preimage_arg: crate::c_types::ThirtyTwoBytes) -> UpdateFulfillHTLC {
1868 UpdateFulfillHTLC { inner: ObjOps::heap_alloc(nativeUpdateFulfillHTLC {
1869 channel_id: channel_id_arg.data,
1870 htlc_id: htlc_id_arg,
1871 payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_arg.data),
1872 }), is_owned: true }
1874 impl Clone for UpdateFulfillHTLC {
1875 fn clone(&self) -> Self {
1877 inner: if <*mut nativeUpdateFulfillHTLC>::is_null(self.inner) { std::ptr::null_mut() } else {
1878 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1884 /// Used only if an object of this type is returned as a trait impl by a method
1885 pub(crate) extern "C" fn UpdateFulfillHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1886 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFulfillHTLC)).clone() })) as *mut c_void
1889 /// Creates a copy of the UpdateFulfillHTLC
1890 pub extern "C" fn UpdateFulfillHTLC_clone(orig: &UpdateFulfillHTLC) -> UpdateFulfillHTLC {
1894 use lightning::ln::msgs::UpdateFailHTLC as nativeUpdateFailHTLCImport;
1895 type nativeUpdateFailHTLC = nativeUpdateFailHTLCImport;
1897 /// An update_fail_htlc message to be sent or received from a peer
1900 pub struct UpdateFailHTLC {
1901 /// A pointer to the opaque Rust object.
1903 /// Nearly everywhere, inner must be non-null, however in places where
1904 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1905 pub inner: *mut nativeUpdateFailHTLC,
1906 /// Indicates that this is the only struct which contains the same pointer.
1908 /// Rust functions which take ownership of an object provided via an argument require
1909 /// this to be true and invalidate the object pointed to by inner.
1913 impl Drop for UpdateFailHTLC {
1914 fn drop(&mut self) {
1915 if self.is_owned && !<*mut nativeUpdateFailHTLC>::is_null(self.inner) {
1916 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1920 /// Frees any resources used by the UpdateFailHTLC, if is_owned is set and inner is non-NULL.
1922 pub extern "C" fn UpdateFailHTLC_free(this_obj: UpdateFailHTLC) { }
1924 /// Used only if an object of this type is returned as a trait impl by a method
1925 extern "C" fn UpdateFailHTLC_free_void(this_ptr: *mut c_void) {
1926 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFailHTLC); }
1929 impl UpdateFailHTLC {
1930 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailHTLC {
1931 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1933 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailHTLC {
1934 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1936 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1937 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailHTLC {
1938 assert!(self.is_owned);
1939 let ret = ObjOps::untweak_ptr(self.inner);
1940 self.inner = std::ptr::null_mut();
1946 pub extern "C" fn UpdateFailHTLC_get_channel_id(this_ptr: &UpdateFailHTLC) -> *const [u8; 32] {
1947 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1952 pub extern "C" fn UpdateFailHTLC_set_channel_id(this_ptr: &mut UpdateFailHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1953 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1957 pub extern "C" fn UpdateFailHTLC_get_htlc_id(this_ptr: &UpdateFailHTLC) -> u64 {
1958 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
1963 pub extern "C" fn UpdateFailHTLC_set_htlc_id(this_ptr: &mut UpdateFailHTLC, mut val: u64) {
1964 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
1966 impl Clone for UpdateFailHTLC {
1967 fn clone(&self) -> Self {
1969 inner: if <*mut nativeUpdateFailHTLC>::is_null(self.inner) { std::ptr::null_mut() } else {
1970 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1976 /// Used only if an object of this type is returned as a trait impl by a method
1977 pub(crate) extern "C" fn UpdateFailHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1978 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailHTLC)).clone() })) as *mut c_void
1981 /// Creates a copy of the UpdateFailHTLC
1982 pub extern "C" fn UpdateFailHTLC_clone(orig: &UpdateFailHTLC) -> UpdateFailHTLC {
1986 use lightning::ln::msgs::UpdateFailMalformedHTLC as nativeUpdateFailMalformedHTLCImport;
1987 type nativeUpdateFailMalformedHTLC = nativeUpdateFailMalformedHTLCImport;
1989 /// An update_fail_malformed_htlc message to be sent or received from a peer
1992 pub struct UpdateFailMalformedHTLC {
1993 /// A pointer to the opaque Rust object.
1995 /// Nearly everywhere, inner must be non-null, however in places where
1996 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1997 pub inner: *mut nativeUpdateFailMalformedHTLC,
1998 /// Indicates that this is the only struct which contains the same pointer.
2000 /// Rust functions which take ownership of an object provided via an argument require
2001 /// this to be true and invalidate the object pointed to by inner.
2005 impl Drop for UpdateFailMalformedHTLC {
2006 fn drop(&mut self) {
2007 if self.is_owned && !<*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) {
2008 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2012 /// Frees any resources used by the UpdateFailMalformedHTLC, if is_owned is set and inner is non-NULL.
2014 pub extern "C" fn UpdateFailMalformedHTLC_free(this_obj: UpdateFailMalformedHTLC) { }
2016 /// Used only if an object of this type is returned as a trait impl by a method
2017 extern "C" fn UpdateFailMalformedHTLC_free_void(this_ptr: *mut c_void) {
2018 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFailMalformedHTLC); }
2021 impl UpdateFailMalformedHTLC {
2022 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailMalformedHTLC {
2023 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2025 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailMalformedHTLC {
2026 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2028 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2029 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailMalformedHTLC {
2030 assert!(self.is_owned);
2031 let ret = ObjOps::untweak_ptr(self.inner);
2032 self.inner = std::ptr::null_mut();
2038 pub extern "C" fn UpdateFailMalformedHTLC_get_channel_id(this_ptr: &UpdateFailMalformedHTLC) -> *const [u8; 32] {
2039 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2044 pub extern "C" fn UpdateFailMalformedHTLC_set_channel_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
2045 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2049 pub extern "C" fn UpdateFailMalformedHTLC_get_htlc_id(this_ptr: &UpdateFailMalformedHTLC) -> u64 {
2050 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
2055 pub extern "C" fn UpdateFailMalformedHTLC_set_htlc_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u64) {
2056 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
2058 /// The failure code
2060 pub extern "C" fn UpdateFailMalformedHTLC_get_failure_code(this_ptr: &UpdateFailMalformedHTLC) -> u16 {
2061 let mut inner_val = &mut this_ptr.get_native_mut_ref().failure_code;
2064 /// The failure code
2066 pub extern "C" fn UpdateFailMalformedHTLC_set_failure_code(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u16) {
2067 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.failure_code = val;
2069 impl Clone for UpdateFailMalformedHTLC {
2070 fn clone(&self) -> Self {
2072 inner: if <*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) { std::ptr::null_mut() } else {
2073 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2079 /// Used only if an object of this type is returned as a trait impl by a method
2080 pub(crate) extern "C" fn UpdateFailMalformedHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
2081 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailMalformedHTLC)).clone() })) as *mut c_void
2084 /// Creates a copy of the UpdateFailMalformedHTLC
2085 pub extern "C" fn UpdateFailMalformedHTLC_clone(orig: &UpdateFailMalformedHTLC) -> UpdateFailMalformedHTLC {
2089 use lightning::ln::msgs::CommitmentSigned as nativeCommitmentSignedImport;
2090 type nativeCommitmentSigned = nativeCommitmentSignedImport;
2092 /// A commitment_signed message to be sent or received from a peer
2095 pub struct CommitmentSigned {
2096 /// A pointer to the opaque Rust object.
2098 /// Nearly everywhere, inner must be non-null, however in places where
2099 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2100 pub inner: *mut nativeCommitmentSigned,
2101 /// Indicates that this is the only struct which contains the same pointer.
2103 /// Rust functions which take ownership of an object provided via an argument require
2104 /// this to be true and invalidate the object pointed to by inner.
2108 impl Drop for CommitmentSigned {
2109 fn drop(&mut self) {
2110 if self.is_owned && !<*mut nativeCommitmentSigned>::is_null(self.inner) {
2111 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2115 /// Frees any resources used by the CommitmentSigned, if is_owned is set and inner is non-NULL.
2117 pub extern "C" fn CommitmentSigned_free(this_obj: CommitmentSigned) { }
2119 /// Used only if an object of this type is returned as a trait impl by a method
2120 extern "C" fn CommitmentSigned_free_void(this_ptr: *mut c_void) {
2121 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentSigned); }
2124 impl CommitmentSigned {
2125 pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentSigned {
2126 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2128 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentSigned {
2129 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2131 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2132 pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentSigned {
2133 assert!(self.is_owned);
2134 let ret = ObjOps::untweak_ptr(self.inner);
2135 self.inner = std::ptr::null_mut();
2141 pub extern "C" fn CommitmentSigned_get_channel_id(this_ptr: &CommitmentSigned) -> *const [u8; 32] {
2142 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2147 pub extern "C" fn CommitmentSigned_set_channel_id(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::ThirtyTwoBytes) {
2148 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2150 /// A signature on the commitment transaction
2152 pub extern "C" fn CommitmentSigned_get_signature(this_ptr: &CommitmentSigned) -> crate::c_types::Signature {
2153 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
2154 crate::c_types::Signature::from_rust(&inner_val)
2156 /// A signature on the commitment transaction
2158 pub extern "C" fn CommitmentSigned_set_signature(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::Signature) {
2159 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
2161 /// Signatures on the HTLC transactions
2163 pub extern "C" fn CommitmentSigned_set_htlc_signatures(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::derived::CVec_SignatureZ) {
2164 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_rust() }); };
2165 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_signatures = local_val;
2167 /// Constructs a new CommitmentSigned given each field
2170 pub extern "C" fn CommitmentSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut signature_arg: crate::c_types::Signature, mut htlc_signatures_arg: crate::c_types::derived::CVec_SignatureZ) -> CommitmentSigned {
2171 let mut local_htlc_signatures_arg = Vec::new(); for mut item in htlc_signatures_arg.into_rust().drain(..) { local_htlc_signatures_arg.push( { item.into_rust() }); };
2172 CommitmentSigned { inner: ObjOps::heap_alloc(nativeCommitmentSigned {
2173 channel_id: channel_id_arg.data,
2174 signature: signature_arg.into_rust(),
2175 htlc_signatures: local_htlc_signatures_arg,
2176 }), is_owned: true }
2178 impl Clone for CommitmentSigned {
2179 fn clone(&self) -> Self {
2181 inner: if <*mut nativeCommitmentSigned>::is_null(self.inner) { std::ptr::null_mut() } else {
2182 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2188 /// Used only if an object of this type is returned as a trait impl by a method
2189 pub(crate) extern "C" fn CommitmentSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
2190 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentSigned)).clone() })) as *mut c_void
2193 /// Creates a copy of the CommitmentSigned
2194 pub extern "C" fn CommitmentSigned_clone(orig: &CommitmentSigned) -> CommitmentSigned {
2198 use lightning::ln::msgs::RevokeAndACK as nativeRevokeAndACKImport;
2199 type nativeRevokeAndACK = nativeRevokeAndACKImport;
2201 /// A revoke_and_ack message to be sent or received from a peer
2204 pub struct RevokeAndACK {
2205 /// A pointer to the opaque Rust object.
2207 /// Nearly everywhere, inner must be non-null, however in places where
2208 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2209 pub inner: *mut nativeRevokeAndACK,
2210 /// Indicates that this is the only struct which contains the same pointer.
2212 /// Rust functions which take ownership of an object provided via an argument require
2213 /// this to be true and invalidate the object pointed to by inner.
2217 impl Drop for RevokeAndACK {
2218 fn drop(&mut self) {
2219 if self.is_owned && !<*mut nativeRevokeAndACK>::is_null(self.inner) {
2220 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2224 /// Frees any resources used by the RevokeAndACK, if is_owned is set and inner is non-NULL.
2226 pub extern "C" fn RevokeAndACK_free(this_obj: RevokeAndACK) { }
2228 /// Used only if an object of this type is returned as a trait impl by a method
2229 extern "C" fn RevokeAndACK_free_void(this_ptr: *mut c_void) {
2230 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRevokeAndACK); }
2234 pub(crate) fn get_native_ref(&self) -> &'static nativeRevokeAndACK {
2235 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2237 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRevokeAndACK {
2238 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2240 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2241 pub(crate) fn take_inner(mut self) -> *mut nativeRevokeAndACK {
2242 assert!(self.is_owned);
2243 let ret = ObjOps::untweak_ptr(self.inner);
2244 self.inner = std::ptr::null_mut();
2250 pub extern "C" fn RevokeAndACK_get_channel_id(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
2251 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2256 pub extern "C" fn RevokeAndACK_set_channel_id(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
2257 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2259 /// The secret corresponding to the per-commitment point
2261 pub extern "C" fn RevokeAndACK_get_per_commitment_secret(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
2262 let mut inner_val = &mut this_ptr.get_native_mut_ref().per_commitment_secret;
2265 /// The secret corresponding to the per-commitment point
2267 pub extern "C" fn RevokeAndACK_set_per_commitment_secret(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
2268 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.per_commitment_secret = val.data;
2270 /// The next sender-broadcast commitment transaction's per-commitment point
2272 pub extern "C" fn RevokeAndACK_get_next_per_commitment_point(this_ptr: &RevokeAndACK) -> crate::c_types::PublicKey {
2273 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
2274 crate::c_types::PublicKey::from_rust(&inner_val)
2276 /// The next sender-broadcast commitment transaction's per-commitment point
2278 pub extern "C" fn RevokeAndACK_set_next_per_commitment_point(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::PublicKey) {
2279 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
2281 /// Constructs a new RevokeAndACK given each field
2284 pub extern "C" fn RevokeAndACK_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut per_commitment_secret_arg: crate::c_types::ThirtyTwoBytes, mut next_per_commitment_point_arg: crate::c_types::PublicKey) -> RevokeAndACK {
2285 RevokeAndACK { inner: ObjOps::heap_alloc(nativeRevokeAndACK {
2286 channel_id: channel_id_arg.data,
2287 per_commitment_secret: per_commitment_secret_arg.data,
2288 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
2289 }), is_owned: true }
2291 impl Clone for RevokeAndACK {
2292 fn clone(&self) -> Self {
2294 inner: if <*mut nativeRevokeAndACK>::is_null(self.inner) { std::ptr::null_mut() } else {
2295 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2301 /// Used only if an object of this type is returned as a trait impl by a method
2302 pub(crate) extern "C" fn RevokeAndACK_clone_void(this_ptr: *const c_void) -> *mut c_void {
2303 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRevokeAndACK)).clone() })) as *mut c_void
2306 /// Creates a copy of the RevokeAndACK
2307 pub extern "C" fn RevokeAndACK_clone(orig: &RevokeAndACK) -> RevokeAndACK {
2311 use lightning::ln::msgs::UpdateFee as nativeUpdateFeeImport;
2312 type nativeUpdateFee = nativeUpdateFeeImport;
2314 /// An update_fee message to be sent or received from a peer
2317 pub struct UpdateFee {
2318 /// A pointer to the opaque Rust object.
2320 /// Nearly everywhere, inner must be non-null, however in places where
2321 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2322 pub inner: *mut nativeUpdateFee,
2323 /// Indicates that this is the only struct which contains the same pointer.
2325 /// Rust functions which take ownership of an object provided via an argument require
2326 /// this to be true and invalidate the object pointed to by inner.
2330 impl Drop for UpdateFee {
2331 fn drop(&mut self) {
2332 if self.is_owned && !<*mut nativeUpdateFee>::is_null(self.inner) {
2333 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2337 /// Frees any resources used by the UpdateFee, if is_owned is set and inner is non-NULL.
2339 pub extern "C" fn UpdateFee_free(this_obj: UpdateFee) { }
2341 /// Used only if an object of this type is returned as a trait impl by a method
2342 extern "C" fn UpdateFee_free_void(this_ptr: *mut c_void) {
2343 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFee); }
2347 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFee {
2348 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2350 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFee {
2351 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2353 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2354 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFee {
2355 assert!(self.is_owned);
2356 let ret = ObjOps::untweak_ptr(self.inner);
2357 self.inner = std::ptr::null_mut();
2363 pub extern "C" fn UpdateFee_get_channel_id(this_ptr: &UpdateFee) -> *const [u8; 32] {
2364 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2369 pub extern "C" fn UpdateFee_set_channel_id(this_ptr: &mut UpdateFee, mut val: crate::c_types::ThirtyTwoBytes) {
2370 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2372 /// Fee rate per 1000-weight of the transaction
2374 pub extern "C" fn UpdateFee_get_feerate_per_kw(this_ptr: &UpdateFee) -> u32 {
2375 let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
2378 /// Fee rate per 1000-weight of the transaction
2380 pub extern "C" fn UpdateFee_set_feerate_per_kw(this_ptr: &mut UpdateFee, mut val: u32) {
2381 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
2383 /// Constructs a new UpdateFee given each field
2386 pub extern "C" fn UpdateFee_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut feerate_per_kw_arg: u32) -> UpdateFee {
2387 UpdateFee { inner: ObjOps::heap_alloc(nativeUpdateFee {
2388 channel_id: channel_id_arg.data,
2389 feerate_per_kw: feerate_per_kw_arg,
2390 }), is_owned: true }
2392 impl Clone for UpdateFee {
2393 fn clone(&self) -> Self {
2395 inner: if <*mut nativeUpdateFee>::is_null(self.inner) { std::ptr::null_mut() } else {
2396 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2402 /// Used only if an object of this type is returned as a trait impl by a method
2403 pub(crate) extern "C" fn UpdateFee_clone_void(this_ptr: *const c_void) -> *mut c_void {
2404 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFee)).clone() })) as *mut c_void
2407 /// Creates a copy of the UpdateFee
2408 pub extern "C" fn UpdateFee_clone(orig: &UpdateFee) -> UpdateFee {
2412 use lightning::ln::msgs::DataLossProtect as nativeDataLossProtectImport;
2413 type nativeDataLossProtect = nativeDataLossProtectImport;
2415 /// Proof that the sender knows the per-commitment secret of the previous commitment transaction.
2416 /// This is used to convince the recipient that the channel is at a certain commitment
2417 /// number even if they lost that data due to a local failure. Of course, the peer may lie
2418 /// and even later commitments may have been revoked.
2421 pub struct DataLossProtect {
2422 /// A pointer to the opaque Rust object.
2424 /// Nearly everywhere, inner must be non-null, however in places where
2425 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2426 pub inner: *mut nativeDataLossProtect,
2427 /// Indicates that this is the only struct which contains the same pointer.
2429 /// Rust functions which take ownership of an object provided via an argument require
2430 /// this to be true and invalidate the object pointed to by inner.
2434 impl Drop for DataLossProtect {
2435 fn drop(&mut self) {
2436 if self.is_owned && !<*mut nativeDataLossProtect>::is_null(self.inner) {
2437 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2441 /// Frees any resources used by the DataLossProtect, if is_owned is set and inner is non-NULL.
2443 pub extern "C" fn DataLossProtect_free(this_obj: DataLossProtect) { }
2445 /// Used only if an object of this type is returned as a trait impl by a method
2446 extern "C" fn DataLossProtect_free_void(this_ptr: *mut c_void) {
2447 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDataLossProtect); }
2450 impl DataLossProtect {
2451 pub(crate) fn get_native_ref(&self) -> &'static nativeDataLossProtect {
2452 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2454 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeDataLossProtect {
2455 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2457 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2458 pub(crate) fn take_inner(mut self) -> *mut nativeDataLossProtect {
2459 assert!(self.is_owned);
2460 let ret = ObjOps::untweak_ptr(self.inner);
2461 self.inner = std::ptr::null_mut();
2465 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
2466 /// belonging to the recipient
2468 pub extern "C" fn DataLossProtect_get_your_last_per_commitment_secret(this_ptr: &DataLossProtect) -> *const [u8; 32] {
2469 let mut inner_val = &mut this_ptr.get_native_mut_ref().your_last_per_commitment_secret;
2472 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
2473 /// belonging to the recipient
2475 pub extern "C" fn DataLossProtect_set_your_last_per_commitment_secret(this_ptr: &mut DataLossProtect, mut val: crate::c_types::ThirtyTwoBytes) {
2476 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.your_last_per_commitment_secret = val.data;
2478 /// The sender's per-commitment point for their current commitment transaction
2480 pub extern "C" fn DataLossProtect_get_my_current_per_commitment_point(this_ptr: &DataLossProtect) -> crate::c_types::PublicKey {
2481 let mut inner_val = &mut this_ptr.get_native_mut_ref().my_current_per_commitment_point;
2482 crate::c_types::PublicKey::from_rust(&inner_val)
2484 /// The sender's per-commitment point for their current commitment transaction
2486 pub extern "C" fn DataLossProtect_set_my_current_per_commitment_point(this_ptr: &mut DataLossProtect, mut val: crate::c_types::PublicKey) {
2487 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.my_current_per_commitment_point = val.into_rust();
2489 /// Constructs a new DataLossProtect given each field
2492 pub extern "C" fn DataLossProtect_new(mut your_last_per_commitment_secret_arg: crate::c_types::ThirtyTwoBytes, mut my_current_per_commitment_point_arg: crate::c_types::PublicKey) -> DataLossProtect {
2493 DataLossProtect { inner: ObjOps::heap_alloc(nativeDataLossProtect {
2494 your_last_per_commitment_secret: your_last_per_commitment_secret_arg.data,
2495 my_current_per_commitment_point: my_current_per_commitment_point_arg.into_rust(),
2496 }), is_owned: true }
2498 impl Clone for DataLossProtect {
2499 fn clone(&self) -> Self {
2501 inner: if <*mut nativeDataLossProtect>::is_null(self.inner) { std::ptr::null_mut() } else {
2502 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2508 /// Used only if an object of this type is returned as a trait impl by a method
2509 pub(crate) extern "C" fn DataLossProtect_clone_void(this_ptr: *const c_void) -> *mut c_void {
2510 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDataLossProtect)).clone() })) as *mut c_void
2513 /// Creates a copy of the DataLossProtect
2514 pub extern "C" fn DataLossProtect_clone(orig: &DataLossProtect) -> DataLossProtect {
2518 use lightning::ln::msgs::ChannelReestablish as nativeChannelReestablishImport;
2519 type nativeChannelReestablish = nativeChannelReestablishImport;
2521 /// A channel_reestablish message to be sent or received from a peer
2524 pub struct ChannelReestablish {
2525 /// A pointer to the opaque Rust object.
2527 /// Nearly everywhere, inner must be non-null, however in places where
2528 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2529 pub inner: *mut nativeChannelReestablish,
2530 /// Indicates that this is the only struct which contains the same pointer.
2532 /// Rust functions which take ownership of an object provided via an argument require
2533 /// this to be true and invalidate the object pointed to by inner.
2537 impl Drop for ChannelReestablish {
2538 fn drop(&mut self) {
2539 if self.is_owned && !<*mut nativeChannelReestablish>::is_null(self.inner) {
2540 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2544 /// Frees any resources used by the ChannelReestablish, if is_owned is set and inner is non-NULL.
2546 pub extern "C" fn ChannelReestablish_free(this_obj: ChannelReestablish) { }
2548 /// Used only if an object of this type is returned as a trait impl by a method
2549 extern "C" fn ChannelReestablish_free_void(this_ptr: *mut c_void) {
2550 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelReestablish); }
2553 impl ChannelReestablish {
2554 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelReestablish {
2555 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2557 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelReestablish {
2558 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2560 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2561 pub(crate) fn take_inner(mut self) -> *mut nativeChannelReestablish {
2562 assert!(self.is_owned);
2563 let ret = ObjOps::untweak_ptr(self.inner);
2564 self.inner = std::ptr::null_mut();
2570 pub extern "C" fn ChannelReestablish_get_channel_id(this_ptr: &ChannelReestablish) -> *const [u8; 32] {
2571 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2576 pub extern "C" fn ChannelReestablish_set_channel_id(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) {
2577 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2579 /// The next commitment number for the sender
2581 pub extern "C" fn ChannelReestablish_get_next_local_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
2582 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_local_commitment_number;
2585 /// The next commitment number for the sender
2587 pub extern "C" fn ChannelReestablish_set_next_local_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
2588 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_local_commitment_number = val;
2590 /// The next commitment number for the recipient
2592 pub extern "C" fn ChannelReestablish_get_next_remote_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
2593 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_remote_commitment_number;
2596 /// The next commitment number for the recipient
2598 pub extern "C" fn ChannelReestablish_set_next_remote_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
2599 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_remote_commitment_number = val;
2601 impl Clone for ChannelReestablish {
2602 fn clone(&self) -> Self {
2604 inner: if <*mut nativeChannelReestablish>::is_null(self.inner) { std::ptr::null_mut() } else {
2605 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2611 /// Used only if an object of this type is returned as a trait impl by a method
2612 pub(crate) extern "C" fn ChannelReestablish_clone_void(this_ptr: *const c_void) -> *mut c_void {
2613 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelReestablish)).clone() })) as *mut c_void
2616 /// Creates a copy of the ChannelReestablish
2617 pub extern "C" fn ChannelReestablish_clone(orig: &ChannelReestablish) -> ChannelReestablish {
2621 use lightning::ln::msgs::AnnouncementSignatures as nativeAnnouncementSignaturesImport;
2622 type nativeAnnouncementSignatures = nativeAnnouncementSignaturesImport;
2624 /// An announcement_signatures message to be sent or received from a peer
2627 pub struct AnnouncementSignatures {
2628 /// A pointer to the opaque Rust object.
2630 /// Nearly everywhere, inner must be non-null, however in places where
2631 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2632 pub inner: *mut nativeAnnouncementSignatures,
2633 /// Indicates that this is the only struct which contains the same pointer.
2635 /// Rust functions which take ownership of an object provided via an argument require
2636 /// this to be true and invalidate the object pointed to by inner.
2640 impl Drop for AnnouncementSignatures {
2641 fn drop(&mut self) {
2642 if self.is_owned && !<*mut nativeAnnouncementSignatures>::is_null(self.inner) {
2643 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2647 /// Frees any resources used by the AnnouncementSignatures, if is_owned is set and inner is non-NULL.
2649 pub extern "C" fn AnnouncementSignatures_free(this_obj: AnnouncementSignatures) { }
2651 /// Used only if an object of this type is returned as a trait impl by a method
2652 extern "C" fn AnnouncementSignatures_free_void(this_ptr: *mut c_void) {
2653 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeAnnouncementSignatures); }
2656 impl AnnouncementSignatures {
2657 pub(crate) fn get_native_ref(&self) -> &'static nativeAnnouncementSignatures {
2658 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2660 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAnnouncementSignatures {
2661 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2663 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2664 pub(crate) fn take_inner(mut self) -> *mut nativeAnnouncementSignatures {
2665 assert!(self.is_owned);
2666 let ret = ObjOps::untweak_ptr(self.inner);
2667 self.inner = std::ptr::null_mut();
2673 pub extern "C" fn AnnouncementSignatures_get_channel_id(this_ptr: &AnnouncementSignatures) -> *const [u8; 32] {
2674 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2679 pub extern "C" fn AnnouncementSignatures_set_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
2680 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2682 /// The short channel ID
2684 pub extern "C" fn AnnouncementSignatures_get_short_channel_id(this_ptr: &AnnouncementSignatures) -> u64 {
2685 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
2688 /// The short channel ID
2690 pub extern "C" fn AnnouncementSignatures_set_short_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: u64) {
2691 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
2693 /// A signature by the node key
2695 pub extern "C" fn AnnouncementSignatures_get_node_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
2696 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature;
2697 crate::c_types::Signature::from_rust(&inner_val)
2699 /// A signature by the node key
2701 pub extern "C" fn AnnouncementSignatures_set_node_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
2702 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature = val.into_rust();
2704 /// A signature by the funding key
2706 pub extern "C" fn AnnouncementSignatures_get_bitcoin_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
2707 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature;
2708 crate::c_types::Signature::from_rust(&inner_val)
2710 /// A signature by the funding key
2712 pub extern "C" fn AnnouncementSignatures_set_bitcoin_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
2713 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature = val.into_rust();
2715 /// Constructs a new AnnouncementSignatures given each field
2718 pub extern "C" fn AnnouncementSignatures_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_id_arg: u64, mut node_signature_arg: crate::c_types::Signature, mut bitcoin_signature_arg: crate::c_types::Signature) -> AnnouncementSignatures {
2719 AnnouncementSignatures { inner: ObjOps::heap_alloc(nativeAnnouncementSignatures {
2720 channel_id: channel_id_arg.data,
2721 short_channel_id: short_channel_id_arg,
2722 node_signature: node_signature_arg.into_rust(),
2723 bitcoin_signature: bitcoin_signature_arg.into_rust(),
2724 }), is_owned: true }
2726 impl Clone for AnnouncementSignatures {
2727 fn clone(&self) -> Self {
2729 inner: if <*mut nativeAnnouncementSignatures>::is_null(self.inner) { std::ptr::null_mut() } else {
2730 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2736 /// Used only if an object of this type is returned as a trait impl by a method
2737 pub(crate) extern "C" fn AnnouncementSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
2738 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAnnouncementSignatures)).clone() })) as *mut c_void
2741 /// Creates a copy of the AnnouncementSignatures
2742 pub extern "C" fn AnnouncementSignatures_clone(orig: &AnnouncementSignatures) -> AnnouncementSignatures {
2745 /// An address which can be used to connect to a remote peer
2749 pub enum NetAddress {
2750 /// An IPv4 address/port on which the peer is listening.
2752 /// The 4-byte IPv4 address
2753 addr: crate::c_types::FourBytes,
2754 /// The port on which the node is listening
2757 /// An IPv6 address/port on which the peer is listening.
2759 /// The 16-byte IPv6 address
2760 addr: crate::c_types::SixteenBytes,
2761 /// The port on which the node is listening
2764 /// An old-style Tor onion address/port on which the peer is listening.
2766 /// The bytes (usually encoded in base32 with \".onion\" appended)
2767 addr: crate::c_types::TenBytes,
2768 /// The port on which the node is listening
2771 /// A new-style Tor onion address/port on which the peer is listening.
2772 /// To create the human-readable \"hostname\", concatenate ed25519_pubkey, checksum, and version,
2773 /// wrap as base32 and append \".onion\".
2775 /// The ed25519 long-term public key of the peer
2776 ed25519_pubkey: crate::c_types::ThirtyTwoBytes,
2777 /// The checksum of the pubkey and version, as included in the onion address
2779 /// The version byte, as defined by the Tor Onion v3 spec.
2781 /// The port on which the node is listening
2785 use lightning::ln::msgs::NetAddress as nativeNetAddress;
2788 pub(crate) fn to_native(&self) -> nativeNetAddress {
2790 NetAddress::IPv4 {ref addr, ref port, } => {
2791 let mut addr_nonref = (*addr).clone();
2792 let mut port_nonref = (*port).clone();
2793 nativeNetAddress::IPv4 {
2794 addr: addr_nonref.data,
2798 NetAddress::IPv6 {ref addr, ref port, } => {
2799 let mut addr_nonref = (*addr).clone();
2800 let mut port_nonref = (*port).clone();
2801 nativeNetAddress::IPv6 {
2802 addr: addr_nonref.data,
2806 NetAddress::OnionV2 {ref addr, ref port, } => {
2807 let mut addr_nonref = (*addr).clone();
2808 let mut port_nonref = (*port).clone();
2809 nativeNetAddress::OnionV2 {
2810 addr: addr_nonref.data,
2814 NetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
2815 let mut ed25519_pubkey_nonref = (*ed25519_pubkey).clone();
2816 let mut checksum_nonref = (*checksum).clone();
2817 let mut version_nonref = (*version).clone();
2818 let mut port_nonref = (*port).clone();
2819 nativeNetAddress::OnionV3 {
2820 ed25519_pubkey: ed25519_pubkey_nonref.data,
2821 checksum: checksum_nonref,
2822 version: version_nonref,
2829 pub(crate) fn into_native(self) -> nativeNetAddress {
2831 NetAddress::IPv4 {mut addr, mut port, } => {
2832 nativeNetAddress::IPv4 {
2837 NetAddress::IPv6 {mut addr, mut port, } => {
2838 nativeNetAddress::IPv6 {
2843 NetAddress::OnionV2 {mut addr, mut port, } => {
2844 nativeNetAddress::OnionV2 {
2849 NetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
2850 nativeNetAddress::OnionV3 {
2851 ed25519_pubkey: ed25519_pubkey.data,
2860 pub(crate) fn from_native(native: &nativeNetAddress) -> Self {
2862 nativeNetAddress::IPv4 {ref addr, ref port, } => {
2863 let mut addr_nonref = (*addr).clone();
2864 let mut port_nonref = (*port).clone();
2866 addr: crate::c_types::FourBytes { data: addr_nonref },
2870 nativeNetAddress::IPv6 {ref addr, ref port, } => {
2871 let mut addr_nonref = (*addr).clone();
2872 let mut port_nonref = (*port).clone();
2874 addr: crate::c_types::SixteenBytes { data: addr_nonref },
2878 nativeNetAddress::OnionV2 {ref addr, ref port, } => {
2879 let mut addr_nonref = (*addr).clone();
2880 let mut port_nonref = (*port).clone();
2881 NetAddress::OnionV2 {
2882 addr: crate::c_types::TenBytes { data: addr_nonref },
2886 nativeNetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
2887 let mut ed25519_pubkey_nonref = (*ed25519_pubkey).clone();
2888 let mut checksum_nonref = (*checksum).clone();
2889 let mut version_nonref = (*version).clone();
2890 let mut port_nonref = (*port).clone();
2891 NetAddress::OnionV3 {
2892 ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey_nonref },
2893 checksum: checksum_nonref,
2894 version: version_nonref,
2901 pub(crate) fn native_into(native: nativeNetAddress) -> Self {
2903 nativeNetAddress::IPv4 {mut addr, mut port, } => {
2905 addr: crate::c_types::FourBytes { data: addr },
2909 nativeNetAddress::IPv6 {mut addr, mut port, } => {
2911 addr: crate::c_types::SixteenBytes { data: addr },
2915 nativeNetAddress::OnionV2 {mut addr, mut port, } => {
2916 NetAddress::OnionV2 {
2917 addr: crate::c_types::TenBytes { data: addr },
2921 nativeNetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
2922 NetAddress::OnionV3 {
2923 ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey },
2932 /// Frees any resources used by the NetAddress
2934 pub extern "C" fn NetAddress_free(this_ptr: NetAddress) { }
2935 /// Creates a copy of the NetAddress
2937 pub extern "C" fn NetAddress_clone(orig: &NetAddress) -> NetAddress {
2941 /// Utility method to constructs a new IPv4-variant NetAddress
2942 pub extern "C" fn NetAddress_ipv4(addr: crate::c_types::FourBytes, port: u16) -> NetAddress {
2949 /// Utility method to constructs a new IPv6-variant NetAddress
2950 pub extern "C" fn NetAddress_ipv6(addr: crate::c_types::SixteenBytes, port: u16) -> NetAddress {
2957 /// Utility method to constructs a new OnionV2-variant NetAddress
2958 pub extern "C" fn NetAddress_onion_v2(addr: crate::c_types::TenBytes, port: u16) -> NetAddress {
2959 NetAddress::OnionV2 {
2965 /// Utility method to constructs a new OnionV3-variant NetAddress
2966 pub extern "C" fn NetAddress_onion_v3(ed25519_pubkey: crate::c_types::ThirtyTwoBytes, checksum: u16, version: u8, port: u16) -> NetAddress {
2967 NetAddress::OnionV3 {
2975 /// Serialize the NetAddress object into a byte array which can be read by NetAddress_read
2976 pub extern "C" fn NetAddress_write(obj: &NetAddress) -> crate::c_types::derived::CVec_u8Z {
2977 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
2980 /// Read a Result from a byte array, created by Result_write
2981 pub extern "C" fn Result_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CResult_NetAddressu8ZDecodeErrorZ {
2982 let res = crate::c_types::deserialize_obj(ser);
2983 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = match o { 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( { e }).into() }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
2987 /// Read a NetAddress from a byte array, created by NetAddress_write
2988 pub extern "C" fn NetAddress_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NetAddressDecodeErrorZ {
2989 let res = crate::c_types::deserialize_obj(ser);
2990 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() };
2994 use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport;
2995 type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport;
2997 /// The unsigned part of a node_announcement
3000 pub struct UnsignedNodeAnnouncement {
3001 /// A pointer to the opaque Rust object.
3003 /// Nearly everywhere, inner must be non-null, however in places where
3004 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3005 pub inner: *mut nativeUnsignedNodeAnnouncement,
3006 /// Indicates that this is the only struct which contains the same pointer.
3008 /// Rust functions which take ownership of an object provided via an argument require
3009 /// this to be true and invalidate the object pointed to by inner.
3013 impl Drop for UnsignedNodeAnnouncement {
3014 fn drop(&mut self) {
3015 if self.is_owned && !<*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) {
3016 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3020 /// Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL.
3022 pub extern "C" fn UnsignedNodeAnnouncement_free(this_obj: UnsignedNodeAnnouncement) { }
3024 /// Used only if an object of this type is returned as a trait impl by a method
3025 extern "C" fn UnsignedNodeAnnouncement_free_void(this_ptr: *mut c_void) {
3026 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedNodeAnnouncement); }
3029 impl UnsignedNodeAnnouncement {
3030 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedNodeAnnouncement {
3031 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3033 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedNodeAnnouncement {
3034 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3036 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3037 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedNodeAnnouncement {
3038 assert!(self.is_owned);
3039 let ret = ObjOps::untweak_ptr(self.inner);
3040 self.inner = std::ptr::null_mut();
3044 /// The advertised features
3046 pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::ln::features::NodeFeatures {
3047 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
3048 crate::lightning::ln::features::NodeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false }
3050 /// The advertised features
3052 pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::ln::features::NodeFeatures) {
3053 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
3055 /// A strictly monotonic announcement counter, with gaps allowed
3057 pub extern "C" fn UnsignedNodeAnnouncement_get_timestamp(this_ptr: &UnsignedNodeAnnouncement) -> u32 {
3058 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
3061 /// A strictly monotonic announcement counter, with gaps allowed
3063 pub extern "C" fn UnsignedNodeAnnouncement_set_timestamp(this_ptr: &mut UnsignedNodeAnnouncement, mut val: u32) {
3064 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
3066 /// The node_id this announcement originated from (don't rebroadcast the node_announcement back
3069 pub extern "C" fn UnsignedNodeAnnouncement_get_node_id(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::PublicKey {
3070 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id;
3071 crate::c_types::PublicKey::from_rust(&inner_val)
3073 /// The node_id this announcement originated from (don't rebroadcast the node_announcement back
3076 pub extern "C" fn UnsignedNodeAnnouncement_set_node_id(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::PublicKey) {
3077 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id = val.into_rust();
3079 /// An RGB color for UI purposes
3081 pub extern "C" fn UnsignedNodeAnnouncement_get_rgb(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 3] {
3082 let mut inner_val = &mut this_ptr.get_native_mut_ref().rgb;
3085 /// An RGB color for UI purposes
3087 pub extern "C" fn UnsignedNodeAnnouncement_set_rgb(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThreeBytes) {
3088 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.rgb = val.data;
3090 /// An alias, for UI purposes. This should be sanitized before use. There is no guarantee
3093 pub extern "C" fn UnsignedNodeAnnouncement_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 32] {
3094 let mut inner_val = &mut this_ptr.get_native_mut_ref().alias;
3097 /// An alias, for UI purposes. This should be sanitized before use. There is no guarantee
3100 pub extern "C" fn UnsignedNodeAnnouncement_set_alias(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
3101 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.alias = val.data;
3103 /// List of addresses on which this node is reachable
3105 pub extern "C" fn UnsignedNodeAnnouncement_set_addresses(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_NetAddressZ) {
3106 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
3107 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.addresses = local_val;
3109 impl Clone for UnsignedNodeAnnouncement {
3110 fn clone(&self) -> Self {
3112 inner: if <*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else {
3113 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3119 /// Used only if an object of this type is returned as a trait impl by a method
3120 pub(crate) extern "C" fn UnsignedNodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3121 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedNodeAnnouncement)).clone() })) as *mut c_void
3124 /// Creates a copy of the UnsignedNodeAnnouncement
3125 pub extern "C" fn UnsignedNodeAnnouncement_clone(orig: &UnsignedNodeAnnouncement) -> UnsignedNodeAnnouncement {
3129 use lightning::ln::msgs::NodeAnnouncement as nativeNodeAnnouncementImport;
3130 type nativeNodeAnnouncement = nativeNodeAnnouncementImport;
3132 /// A node_announcement message to be sent or received from a peer
3135 pub struct NodeAnnouncement {
3136 /// A pointer to the opaque Rust object.
3138 /// Nearly everywhere, inner must be non-null, however in places where
3139 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3140 pub inner: *mut nativeNodeAnnouncement,
3141 /// Indicates that this is the only struct which contains the same pointer.
3143 /// Rust functions which take ownership of an object provided via an argument require
3144 /// this to be true and invalidate the object pointed to by inner.
3148 impl Drop for NodeAnnouncement {
3149 fn drop(&mut self) {
3150 if self.is_owned && !<*mut nativeNodeAnnouncement>::is_null(self.inner) {
3151 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3155 /// Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL.
3157 pub extern "C" fn NodeAnnouncement_free(this_obj: NodeAnnouncement) { }
3159 /// Used only if an object of this type is returned as a trait impl by a method
3160 extern "C" fn NodeAnnouncement_free_void(this_ptr: *mut c_void) {
3161 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeAnnouncement); }
3164 impl NodeAnnouncement {
3165 pub(crate) fn get_native_ref(&self) -> &'static nativeNodeAnnouncement {
3166 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3168 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeAnnouncement {
3169 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3171 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3172 pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncement {
3173 assert!(self.is_owned);
3174 let ret = ObjOps::untweak_ptr(self.inner);
3175 self.inner = std::ptr::null_mut();
3179 /// The signature by the node key
3181 pub extern "C" fn NodeAnnouncement_get_signature(this_ptr: &NodeAnnouncement) -> crate::c_types::Signature {
3182 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
3183 crate::c_types::Signature::from_rust(&inner_val)
3185 /// The signature by the node key
3187 pub extern "C" fn NodeAnnouncement_set_signature(this_ptr: &mut NodeAnnouncement, mut val: crate::c_types::Signature) {
3188 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
3190 /// The actual content of the announcement
3192 pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> crate::lightning::ln::msgs::UnsignedNodeAnnouncement {
3193 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
3194 crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false }
3196 /// The actual content of the announcement
3198 pub extern "C" fn NodeAnnouncement_set_contents(this_ptr: &mut NodeAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) {
3199 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
3201 /// Constructs a new NodeAnnouncement given each field
3204 pub extern "C" fn NodeAnnouncement_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> NodeAnnouncement {
3205 NodeAnnouncement { inner: ObjOps::heap_alloc(nativeNodeAnnouncement {
3206 signature: signature_arg.into_rust(),
3207 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
3208 }), is_owned: true }
3210 impl Clone for NodeAnnouncement {
3211 fn clone(&self) -> Self {
3213 inner: if <*mut nativeNodeAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else {
3214 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3220 /// Used only if an object of this type is returned as a trait impl by a method
3221 pub(crate) extern "C" fn NodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3222 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeAnnouncement)).clone() })) as *mut c_void
3225 /// Creates a copy of the NodeAnnouncement
3226 pub extern "C" fn NodeAnnouncement_clone(orig: &NodeAnnouncement) -> NodeAnnouncement {
3230 use lightning::ln::msgs::UnsignedChannelAnnouncement as nativeUnsignedChannelAnnouncementImport;
3231 type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport;
3233 /// The unsigned part of a channel_announcement
3236 pub struct UnsignedChannelAnnouncement {
3237 /// A pointer to the opaque Rust object.
3239 /// Nearly everywhere, inner must be non-null, however in places where
3240 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3241 pub inner: *mut nativeUnsignedChannelAnnouncement,
3242 /// Indicates that this is the only struct which contains the same pointer.
3244 /// Rust functions which take ownership of an object provided via an argument require
3245 /// this to be true and invalidate the object pointed to by inner.
3249 impl Drop for UnsignedChannelAnnouncement {
3250 fn drop(&mut self) {
3251 if self.is_owned && !<*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) {
3252 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3256 /// Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL.
3258 pub extern "C" fn UnsignedChannelAnnouncement_free(this_obj: UnsignedChannelAnnouncement) { }
3260 /// Used only if an object of this type is returned as a trait impl by a method
3261 extern "C" fn UnsignedChannelAnnouncement_free_void(this_ptr: *mut c_void) {
3262 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelAnnouncement); }
3265 impl UnsignedChannelAnnouncement {
3266 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelAnnouncement {
3267 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3269 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelAnnouncement {
3270 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3272 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3273 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelAnnouncement {
3274 assert!(self.is_owned);
3275 let ret = ObjOps::untweak_ptr(self.inner);
3276 self.inner = std::ptr::null_mut();
3280 /// The advertised channel features
3282 pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::ln::features::ChannelFeatures {
3283 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
3284 crate::lightning::ln::features::ChannelFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false }
3286 /// The advertised channel features
3288 pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::ln::features::ChannelFeatures) {
3289 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
3291 /// The genesis hash of the blockchain where the channel is to be opened
3293 pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &UnsignedChannelAnnouncement) -> *const [u8; 32] {
3294 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
3295 inner_val.as_inner()
3297 /// The genesis hash of the blockchain where the channel is to be opened
3299 pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
3300 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3302 /// The short channel ID
3304 pub extern "C" fn UnsignedChannelAnnouncement_get_short_channel_id(this_ptr: &UnsignedChannelAnnouncement) -> u64 {
3305 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
3308 /// The short channel ID
3310 pub extern "C" fn UnsignedChannelAnnouncement_set_short_channel_id(this_ptr: &mut UnsignedChannelAnnouncement, mut val: u64) {
3311 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
3313 /// One of the two node_ids which are endpoints of this channel
3315 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3316 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_1;
3317 crate::c_types::PublicKey::from_rust(&inner_val)
3319 /// One of the two node_ids which are endpoints of this channel
3321 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3322 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_1 = val.into_rust();
3324 /// The other of the two node_ids which are endpoints of this channel
3326 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3327 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_2;
3328 crate::c_types::PublicKey::from_rust(&inner_val)
3330 /// The other of the two node_ids which are endpoints of this channel
3332 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3333 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_2 = val.into_rust();
3335 /// The funding key for the first node
3337 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3338 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_1;
3339 crate::c_types::PublicKey::from_rust(&inner_val)
3341 /// The funding key for the first node
3343 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3344 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_1 = val.into_rust();
3346 /// The funding key for the second node
3348 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3349 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_2;
3350 crate::c_types::PublicKey::from_rust(&inner_val)
3352 /// The funding key for the second node
3354 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3355 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_2 = val.into_rust();
3357 impl Clone for UnsignedChannelAnnouncement {
3358 fn clone(&self) -> Self {
3360 inner: if <*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else {
3361 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3367 /// Used only if an object of this type is returned as a trait impl by a method
3368 pub(crate) extern "C" fn UnsignedChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3369 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelAnnouncement)).clone() })) as *mut c_void
3372 /// Creates a copy of the UnsignedChannelAnnouncement
3373 pub extern "C" fn UnsignedChannelAnnouncement_clone(orig: &UnsignedChannelAnnouncement) -> UnsignedChannelAnnouncement {
3377 use lightning::ln::msgs::ChannelAnnouncement as nativeChannelAnnouncementImport;
3378 type nativeChannelAnnouncement = nativeChannelAnnouncementImport;
3380 /// A channel_announcement message to be sent or received from a peer
3383 pub struct ChannelAnnouncement {
3384 /// A pointer to the opaque Rust object.
3386 /// Nearly everywhere, inner must be non-null, however in places where
3387 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3388 pub inner: *mut nativeChannelAnnouncement,
3389 /// Indicates that this is the only struct which contains the same pointer.
3391 /// Rust functions which take ownership of an object provided via an argument require
3392 /// this to be true and invalidate the object pointed to by inner.
3396 impl Drop for ChannelAnnouncement {
3397 fn drop(&mut self) {
3398 if self.is_owned && !<*mut nativeChannelAnnouncement>::is_null(self.inner) {
3399 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3403 /// Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL.
3405 pub extern "C" fn ChannelAnnouncement_free(this_obj: ChannelAnnouncement) { }
3407 /// Used only if an object of this type is returned as a trait impl by a method
3408 extern "C" fn ChannelAnnouncement_free_void(this_ptr: *mut c_void) {
3409 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelAnnouncement); }
3412 impl ChannelAnnouncement {
3413 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelAnnouncement {
3414 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3416 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelAnnouncement {
3417 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3419 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3420 pub(crate) fn take_inner(mut self) -> *mut nativeChannelAnnouncement {
3421 assert!(self.is_owned);
3422 let ret = ObjOps::untweak_ptr(self.inner);
3423 self.inner = std::ptr::null_mut();
3427 /// Authentication of the announcement by the first public node
3429 pub extern "C" fn ChannelAnnouncement_get_node_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3430 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_1;
3431 crate::c_types::Signature::from_rust(&inner_val)
3433 /// Authentication of the announcement by the first public node
3435 pub extern "C" fn ChannelAnnouncement_set_node_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3436 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_1 = val.into_rust();
3438 /// Authentication of the announcement by the second public node
3440 pub extern "C" fn ChannelAnnouncement_get_node_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3441 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_2;
3442 crate::c_types::Signature::from_rust(&inner_val)
3444 /// Authentication of the announcement by the second public node
3446 pub extern "C" fn ChannelAnnouncement_set_node_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3447 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_2 = val.into_rust();
3449 /// Proof of funding UTXO ownership by the first public node
3451 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3452 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_1;
3453 crate::c_types::Signature::from_rust(&inner_val)
3455 /// Proof of funding UTXO ownership by the first public node
3457 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3458 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_1 = val.into_rust();
3460 /// Proof of funding UTXO ownership by the second public node
3462 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3463 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_2;
3464 crate::c_types::Signature::from_rust(&inner_val)
3466 /// Proof of funding UTXO ownership by the second public node
3468 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3469 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_2 = val.into_rust();
3471 /// The actual announcement
3473 pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncement) -> crate::lightning::ln::msgs::UnsignedChannelAnnouncement {
3474 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
3475 crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false }
3477 /// The actual announcement
3479 pub extern "C" fn ChannelAnnouncement_set_contents(this_ptr: &mut ChannelAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) {
3480 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
3482 /// Constructs a new ChannelAnnouncement given each field
3485 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 {
3486 ChannelAnnouncement { inner: ObjOps::heap_alloc(nativeChannelAnnouncement {
3487 node_signature_1: node_signature_1_arg.into_rust(),
3488 node_signature_2: node_signature_2_arg.into_rust(),
3489 bitcoin_signature_1: bitcoin_signature_1_arg.into_rust(),
3490 bitcoin_signature_2: bitcoin_signature_2_arg.into_rust(),
3491 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
3492 }), is_owned: true }
3494 impl Clone for ChannelAnnouncement {
3495 fn clone(&self) -> Self {
3497 inner: if <*mut nativeChannelAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else {
3498 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3504 /// Used only if an object of this type is returned as a trait impl by a method
3505 pub(crate) extern "C" fn ChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3506 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelAnnouncement)).clone() })) as *mut c_void
3509 /// Creates a copy of the ChannelAnnouncement
3510 pub extern "C" fn ChannelAnnouncement_clone(orig: &ChannelAnnouncement) -> ChannelAnnouncement {
3514 use lightning::ln::msgs::UnsignedChannelUpdate as nativeUnsignedChannelUpdateImport;
3515 type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport;
3517 /// The unsigned part of a channel_update
3520 pub struct UnsignedChannelUpdate {
3521 /// A pointer to the opaque Rust object.
3523 /// Nearly everywhere, inner must be non-null, however in places where
3524 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3525 pub inner: *mut nativeUnsignedChannelUpdate,
3526 /// Indicates that this is the only struct which contains the same pointer.
3528 /// Rust functions which take ownership of an object provided via an argument require
3529 /// this to be true and invalidate the object pointed to by inner.
3533 impl Drop for UnsignedChannelUpdate {
3534 fn drop(&mut self) {
3535 if self.is_owned && !<*mut nativeUnsignedChannelUpdate>::is_null(self.inner) {
3536 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3540 /// Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL.
3542 pub extern "C" fn UnsignedChannelUpdate_free(this_obj: UnsignedChannelUpdate) { }
3544 /// Used only if an object of this type is returned as a trait impl by a method
3545 extern "C" fn UnsignedChannelUpdate_free_void(this_ptr: *mut c_void) {
3546 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelUpdate); }
3549 impl UnsignedChannelUpdate {
3550 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelUpdate {
3551 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3553 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelUpdate {
3554 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3556 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3557 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelUpdate {
3558 assert!(self.is_owned);
3559 let ret = ObjOps::untweak_ptr(self.inner);
3560 self.inner = std::ptr::null_mut();
3564 /// The genesis hash of the blockchain where the channel is to be opened
3566 pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChannelUpdate) -> *const [u8; 32] {
3567 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
3568 inner_val.as_inner()
3570 /// The genesis hash of the blockchain where the channel is to be opened
3572 pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::ThirtyTwoBytes) {
3573 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3575 /// The short channel ID
3577 pub extern "C" fn UnsignedChannelUpdate_get_short_channel_id(this_ptr: &UnsignedChannelUpdate) -> u64 {
3578 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
3581 /// The short channel ID
3583 pub extern "C" fn UnsignedChannelUpdate_set_short_channel_id(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
3584 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
3586 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
3588 pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannelUpdate) -> u32 {
3589 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
3592 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
3594 pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3595 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
3599 pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 {
3600 let mut inner_val = &mut this_ptr.get_native_mut_ref().flags;
3605 pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) {
3606 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.flags = val;
3608 /// The number of blocks such that if:
3609 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
3610 /// then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines
3611 /// the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a
3612 /// cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10,
3613 /// then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before
3614 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
3615 /// constructing the route.
3617 pub extern "C" fn UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr: &UnsignedChannelUpdate) -> u16 {
3618 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
3621 /// The number of blocks such that if:
3622 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
3623 /// then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines
3624 /// the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a
3625 /// cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10,
3626 /// then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before
3627 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
3628 /// constructing the route.
3630 pub extern "C" fn UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr: &mut UnsignedChannelUpdate, mut val: u16) {
3631 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
3633 /// The minimum HTLC size incoming to sender, in milli-satoshi
3635 pub extern "C" fn UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
3636 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
3639 /// The minimum HTLC size incoming to sender, in milli-satoshi
3641 pub extern "C" fn UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
3642 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
3644 /// The base HTLC fee charged by sender, in milli-satoshi
3646 pub extern "C" fn UnsignedChannelUpdate_get_fee_base_msat(this_ptr: &UnsignedChannelUpdate) -> u32 {
3647 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat;
3650 /// The base HTLC fee charged by sender, in milli-satoshi
3652 pub extern "C" fn UnsignedChannelUpdate_set_fee_base_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3653 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val;
3655 /// The amount to fee multiplier, in micro-satoshi
3657 pub extern "C" fn UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr: &UnsignedChannelUpdate) -> u32 {
3658 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths;
3661 /// The amount to fee multiplier, in micro-satoshi
3663 pub extern "C" fn UnsignedChannelUpdate_set_fee_proportional_millionths(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3664 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val;
3666 impl Clone for UnsignedChannelUpdate {
3667 fn clone(&self) -> Self {
3669 inner: if <*mut nativeUnsignedChannelUpdate>::is_null(self.inner) { std::ptr::null_mut() } else {
3670 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3676 /// Used only if an object of this type is returned as a trait impl by a method
3677 pub(crate) extern "C" fn UnsignedChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
3678 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelUpdate)).clone() })) as *mut c_void
3681 /// Creates a copy of the UnsignedChannelUpdate
3682 pub extern "C" fn UnsignedChannelUpdate_clone(orig: &UnsignedChannelUpdate) -> UnsignedChannelUpdate {
3686 use lightning::ln::msgs::ChannelUpdate as nativeChannelUpdateImport;
3687 type nativeChannelUpdate = nativeChannelUpdateImport;
3689 /// A channel_update message to be sent or received from a peer
3692 pub struct ChannelUpdate {
3693 /// A pointer to the opaque Rust object.
3695 /// Nearly everywhere, inner must be non-null, however in places where
3696 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3697 pub inner: *mut nativeChannelUpdate,
3698 /// Indicates that this is the only struct which contains the same pointer.
3700 /// Rust functions which take ownership of an object provided via an argument require
3701 /// this to be true and invalidate the object pointed to by inner.
3705 impl Drop for ChannelUpdate {
3706 fn drop(&mut self) {
3707 if self.is_owned && !<*mut nativeChannelUpdate>::is_null(self.inner) {
3708 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3712 /// Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL.
3714 pub extern "C" fn ChannelUpdate_free(this_obj: ChannelUpdate) { }
3716 /// Used only if an object of this type is returned as a trait impl by a method
3717 extern "C" fn ChannelUpdate_free_void(this_ptr: *mut c_void) {
3718 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelUpdate); }
3721 impl ChannelUpdate {
3722 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelUpdate {
3723 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3725 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelUpdate {
3726 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3728 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3729 pub(crate) fn take_inner(mut self) -> *mut nativeChannelUpdate {
3730 assert!(self.is_owned);
3731 let ret = ObjOps::untweak_ptr(self.inner);
3732 self.inner = std::ptr::null_mut();
3736 /// A signature of the channel update
3738 pub extern "C" fn ChannelUpdate_get_signature(this_ptr: &ChannelUpdate) -> crate::c_types::Signature {
3739 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
3740 crate::c_types::Signature::from_rust(&inner_val)
3742 /// A signature of the channel update
3744 pub extern "C" fn ChannelUpdate_set_signature(this_ptr: &mut ChannelUpdate, mut val: crate::c_types::Signature) {
3745 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
3747 /// The actual channel update
3749 pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate::lightning::ln::msgs::UnsignedChannelUpdate {
3750 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
3751 crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false }
3753 /// The actual channel update
3755 pub extern "C" fn ChannelUpdate_set_contents(this_ptr: &mut ChannelUpdate, mut val: crate::lightning::ln::msgs::UnsignedChannelUpdate) {
3756 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
3758 /// Constructs a new ChannelUpdate given each field
3761 pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> ChannelUpdate {
3762 ChannelUpdate { inner: ObjOps::heap_alloc(nativeChannelUpdate {
3763 signature: signature_arg.into_rust(),
3764 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
3765 }), is_owned: true }
3767 impl Clone for ChannelUpdate {
3768 fn clone(&self) -> Self {
3770 inner: if <*mut nativeChannelUpdate>::is_null(self.inner) { std::ptr::null_mut() } else {
3771 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3777 /// Used only if an object of this type is returned as a trait impl by a method
3778 pub(crate) extern "C" fn ChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
3779 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelUpdate)).clone() })) as *mut c_void
3782 /// Creates a copy of the ChannelUpdate
3783 pub extern "C" fn ChannelUpdate_clone(orig: &ChannelUpdate) -> ChannelUpdate {
3787 use lightning::ln::msgs::QueryChannelRange as nativeQueryChannelRangeImport;
3788 type nativeQueryChannelRange = nativeQueryChannelRangeImport;
3790 /// A query_channel_range message is used to query a peer for channel
3791 /// UTXOs in a range of blocks. The recipient of a query makes a best
3792 /// effort to reply to the query using one or more reply_channel_range
3796 pub struct QueryChannelRange {
3797 /// A pointer to the opaque Rust object.
3799 /// Nearly everywhere, inner must be non-null, however in places where
3800 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3801 pub inner: *mut nativeQueryChannelRange,
3802 /// Indicates that this is the only struct which contains the same pointer.
3804 /// Rust functions which take ownership of an object provided via an argument require
3805 /// this to be true and invalidate the object pointed to by inner.
3809 impl Drop for QueryChannelRange {
3810 fn drop(&mut self) {
3811 if self.is_owned && !<*mut nativeQueryChannelRange>::is_null(self.inner) {
3812 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3816 /// Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL.
3818 pub extern "C" fn QueryChannelRange_free(this_obj: QueryChannelRange) { }
3820 /// Used only if an object of this type is returned as a trait impl by a method
3821 extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) {
3822 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryChannelRange); }
3825 impl QueryChannelRange {
3826 pub(crate) fn get_native_ref(&self) -> &'static nativeQueryChannelRange {
3827 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3829 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryChannelRange {
3830 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3832 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3833 pub(crate) fn take_inner(mut self) -> *mut nativeQueryChannelRange {
3834 assert!(self.is_owned);
3835 let ret = ObjOps::untweak_ptr(self.inner);
3836 self.inner = std::ptr::null_mut();
3840 /// The genesis hash of the blockchain being queried
3842 pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *const [u8; 32] {
3843 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
3844 inner_val.as_inner()
3846 /// The genesis hash of the blockchain being queried
3848 pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
3849 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3851 /// The height of the first block for the channel UTXOs being queried
3853 pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 {
3854 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
3857 /// The height of the first block for the channel UTXOs being queried
3859 pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChannelRange, mut val: u32) {
3860 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
3862 /// The number of blocks to include in the query results
3864 pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 {
3865 let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
3868 /// The number of blocks to include in the query results
3870 pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryChannelRange, mut val: u32) {
3871 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
3873 /// Constructs a new QueryChannelRange given each field
3876 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 {
3877 QueryChannelRange { inner: ObjOps::heap_alloc(nativeQueryChannelRange {
3878 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3879 first_blocknum: first_blocknum_arg,
3880 number_of_blocks: number_of_blocks_arg,
3881 }), is_owned: true }
3883 impl Clone for QueryChannelRange {
3884 fn clone(&self) -> Self {
3886 inner: if <*mut nativeQueryChannelRange>::is_null(self.inner) { std::ptr::null_mut() } else {
3887 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3893 /// Used only if an object of this type is returned as a trait impl by a method
3894 pub(crate) extern "C" fn QueryChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
3895 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryChannelRange)).clone() })) as *mut c_void
3898 /// Creates a copy of the QueryChannelRange
3899 pub extern "C" fn QueryChannelRange_clone(orig: &QueryChannelRange) -> QueryChannelRange {
3903 use lightning::ln::msgs::ReplyChannelRange as nativeReplyChannelRangeImport;
3904 type nativeReplyChannelRange = nativeReplyChannelRangeImport;
3906 /// A reply_channel_range message is a reply to a query_channel_range
3907 /// message. Multiple reply_channel_range messages can be sent in reply
3908 /// to a single query_channel_range message. The query recipient makes a
3909 /// best effort to respond based on their local network view which may
3910 /// not be a perfect view of the network. The short_channel_ids in the
3911 /// reply are encoded. We only support encoding_type=0 uncompressed
3912 /// serialization and do not support encoding_type=1 zlib serialization.
3915 pub struct ReplyChannelRange {
3916 /// A pointer to the opaque Rust object.
3918 /// Nearly everywhere, inner must be non-null, however in places where
3919 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3920 pub inner: *mut nativeReplyChannelRange,
3921 /// Indicates that this is the only struct which contains the same pointer.
3923 /// Rust functions which take ownership of an object provided via an argument require
3924 /// this to be true and invalidate the object pointed to by inner.
3928 impl Drop for ReplyChannelRange {
3929 fn drop(&mut self) {
3930 if self.is_owned && !<*mut nativeReplyChannelRange>::is_null(self.inner) {
3931 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3935 /// Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL.
3937 pub extern "C" fn ReplyChannelRange_free(this_obj: ReplyChannelRange) { }
3939 /// Used only if an object of this type is returned as a trait impl by a method
3940 extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) {
3941 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyChannelRange); }
3944 impl ReplyChannelRange {
3945 pub(crate) fn get_native_ref(&self) -> &'static nativeReplyChannelRange {
3946 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3948 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyChannelRange {
3949 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3951 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3952 pub(crate) fn take_inner(mut self) -> *mut nativeReplyChannelRange {
3953 assert!(self.is_owned);
3954 let ret = ObjOps::untweak_ptr(self.inner);
3955 self.inner = std::ptr::null_mut();
3959 /// The genesis hash of the blockchain being queried
3961 pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *const [u8; 32] {
3962 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
3963 inner_val.as_inner()
3965 /// The genesis hash of the blockchain being queried
3967 pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
3968 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3970 /// The height of the first block in the range of the reply
3972 pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 {
3973 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
3976 /// The height of the first block in the range of the reply
3978 pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChannelRange, mut val: u32) {
3979 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
3981 /// The number of blocks included in the range of the reply
3983 pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 {
3984 let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
3987 /// The number of blocks included in the range of the reply
3989 pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyChannelRange, mut val: u32) {
3990 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
3992 /// True when this is the final reply for a query
3994 pub extern "C" fn ReplyChannelRange_get_sync_complete(this_ptr: &ReplyChannelRange) -> bool {
3995 let mut inner_val = &mut this_ptr.get_native_mut_ref().sync_complete;
3998 /// True when this is the final reply for a query
4000 pub extern "C" fn ReplyChannelRange_set_sync_complete(this_ptr: &mut ReplyChannelRange, mut val: bool) {
4001 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sync_complete = val;
4003 /// The short_channel_ids in the channel range
4005 pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::derived::CVec_u64Z) {
4006 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
4007 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
4009 /// Constructs a new ReplyChannelRange given each field
4012 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 {
4013 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 }); };
4014 ReplyChannelRange { inner: ObjOps::heap_alloc(nativeReplyChannelRange {
4015 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4016 first_blocknum: first_blocknum_arg,
4017 number_of_blocks: number_of_blocks_arg,
4018 sync_complete: sync_complete_arg,
4019 short_channel_ids: local_short_channel_ids_arg,
4020 }), is_owned: true }
4022 impl Clone for ReplyChannelRange {
4023 fn clone(&self) -> Self {
4025 inner: if <*mut nativeReplyChannelRange>::is_null(self.inner) { std::ptr::null_mut() } else {
4026 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4032 /// Used only if an object of this type is returned as a trait impl by a method
4033 pub(crate) extern "C" fn ReplyChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
4034 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyChannelRange)).clone() })) as *mut c_void
4037 /// Creates a copy of the ReplyChannelRange
4038 pub extern "C" fn ReplyChannelRange_clone(orig: &ReplyChannelRange) -> ReplyChannelRange {
4042 use lightning::ln::msgs::QueryShortChannelIds as nativeQueryShortChannelIdsImport;
4043 type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport;
4045 /// A query_short_channel_ids message is used to query a peer for
4046 /// routing gossip messages related to one or more short_channel_ids.
4047 /// The query recipient will reply with the latest, if available,
4048 /// channel_announcement, channel_update and node_announcement messages
4049 /// it maintains for the requested short_channel_ids followed by a
4050 /// reply_short_channel_ids_end message. The short_channel_ids sent in
4051 /// this query are encoded. We only support encoding_type=0 uncompressed
4052 /// serialization and do not support encoding_type=1 zlib serialization.
4055 pub struct QueryShortChannelIds {
4056 /// A pointer to the opaque Rust object.
4058 /// Nearly everywhere, inner must be non-null, however in places where
4059 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4060 pub inner: *mut nativeQueryShortChannelIds,
4061 /// Indicates that this is the only struct which contains the same pointer.
4063 /// Rust functions which take ownership of an object provided via an argument require
4064 /// this to be true and invalidate the object pointed to by inner.
4068 impl Drop for QueryShortChannelIds {
4069 fn drop(&mut self) {
4070 if self.is_owned && !<*mut nativeQueryShortChannelIds>::is_null(self.inner) {
4071 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4075 /// Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL.
4077 pub extern "C" fn QueryShortChannelIds_free(this_obj: QueryShortChannelIds) { }
4079 /// Used only if an object of this type is returned as a trait impl by a method
4080 extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) {
4081 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryShortChannelIds); }
4084 impl QueryShortChannelIds {
4085 pub(crate) fn get_native_ref(&self) -> &'static nativeQueryShortChannelIds {
4086 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4088 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryShortChannelIds {
4089 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4091 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4092 pub(crate) fn take_inner(mut self) -> *mut nativeQueryShortChannelIds {
4093 assert!(self.is_owned);
4094 let ret = ObjOps::untweak_ptr(self.inner);
4095 self.inner = std::ptr::null_mut();
4099 /// The genesis hash of the blockchain being queried
4101 pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *const [u8; 32] {
4102 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4103 inner_val.as_inner()
4105 /// The genesis hash of the blockchain being queried
4107 pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::ThirtyTwoBytes) {
4108 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4110 /// The short_channel_ids that are being queried
4112 pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::derived::CVec_u64Z) {
4113 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
4114 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
4116 /// Constructs a new QueryShortChannelIds given each field
4119 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 {
4120 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 }); };
4121 QueryShortChannelIds { inner: ObjOps::heap_alloc(nativeQueryShortChannelIds {
4122 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4123 short_channel_ids: local_short_channel_ids_arg,
4124 }), is_owned: true }
4126 impl Clone for QueryShortChannelIds {
4127 fn clone(&self) -> Self {
4129 inner: if <*mut nativeQueryShortChannelIds>::is_null(self.inner) { std::ptr::null_mut() } else {
4130 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4136 /// Used only if an object of this type is returned as a trait impl by a method
4137 pub(crate) extern "C" fn QueryShortChannelIds_clone_void(this_ptr: *const c_void) -> *mut c_void {
4138 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryShortChannelIds)).clone() })) as *mut c_void
4141 /// Creates a copy of the QueryShortChannelIds
4142 pub extern "C" fn QueryShortChannelIds_clone(orig: &QueryShortChannelIds) -> QueryShortChannelIds {
4146 use lightning::ln::msgs::ReplyShortChannelIdsEnd as nativeReplyShortChannelIdsEndImport;
4147 type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport;
4149 /// A reply_short_channel_ids_end message is sent as a reply to a
4150 /// query_short_channel_ids message. The query recipient makes a best
4151 /// effort to respond based on their local network view which may not be
4152 /// a perfect view of the network.
4155 pub struct ReplyShortChannelIdsEnd {
4156 /// A pointer to the opaque Rust object.
4158 /// Nearly everywhere, inner must be non-null, however in places where
4159 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4160 pub inner: *mut nativeReplyShortChannelIdsEnd,
4161 /// Indicates that this is the only struct which contains the same pointer.
4163 /// Rust functions which take ownership of an object provided via an argument require
4164 /// this to be true and invalidate the object pointed to by inner.
4168 impl Drop for ReplyShortChannelIdsEnd {
4169 fn drop(&mut self) {
4170 if self.is_owned && !<*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) {
4171 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4175 /// Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL.
4177 pub extern "C" fn ReplyShortChannelIdsEnd_free(this_obj: ReplyShortChannelIdsEnd) { }
4179 /// Used only if an object of this type is returned as a trait impl by a method
4180 extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) {
4181 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyShortChannelIdsEnd); }
4184 impl ReplyShortChannelIdsEnd {
4185 pub(crate) fn get_native_ref(&self) -> &'static nativeReplyShortChannelIdsEnd {
4186 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4188 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyShortChannelIdsEnd {
4189 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4191 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4192 pub(crate) fn take_inner(mut self) -> *mut nativeReplyShortChannelIdsEnd {
4193 assert!(self.is_owned);
4194 let ret = ObjOps::untweak_ptr(self.inner);
4195 self.inner = std::ptr::null_mut();
4199 /// The genesis hash of the blockchain that was queried
4201 pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *const [u8; 32] {
4202 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4203 inner_val.as_inner()
4205 /// The genesis hash of the blockchain that was queried
4207 pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) {
4208 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4210 /// Indicates if the query recipient maintains up-to-date channel
4211 /// information for the chain_hash
4213 pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool {
4214 let mut inner_val = &mut this_ptr.get_native_mut_ref().full_information;
4217 /// Indicates if the query recipient maintains up-to-date channel
4218 /// information for the chain_hash
4220 pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: bool) {
4221 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.full_information = val;
4223 /// Constructs a new ReplyShortChannelIdsEnd given each field
4226 pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd {
4227 ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(nativeReplyShortChannelIdsEnd {
4228 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4229 full_information: full_information_arg,
4230 }), is_owned: true }
4232 impl Clone for ReplyShortChannelIdsEnd {
4233 fn clone(&self) -> Self {
4235 inner: if <*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) { std::ptr::null_mut() } else {
4236 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4242 /// Used only if an object of this type is returned as a trait impl by a method
4243 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_void) -> *mut c_void {
4244 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyShortChannelIdsEnd)).clone() })) as *mut c_void
4247 /// Creates a copy of the ReplyShortChannelIdsEnd
4248 pub extern "C" fn ReplyShortChannelIdsEnd_clone(orig: &ReplyShortChannelIdsEnd) -> ReplyShortChannelIdsEnd {
4252 use lightning::ln::msgs::GossipTimestampFilter as nativeGossipTimestampFilterImport;
4253 type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport;
4255 /// A gossip_timestamp_filter message is used by a node to request
4256 /// gossip relay for messages in the requested time range when the
4257 /// gossip_queries feature has been negotiated.
4260 pub struct GossipTimestampFilter {
4261 /// A pointer to the opaque Rust object.
4263 /// Nearly everywhere, inner must be non-null, however in places where
4264 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4265 pub inner: *mut nativeGossipTimestampFilter,
4266 /// Indicates that this is the only struct which contains the same pointer.
4268 /// Rust functions which take ownership of an object provided via an argument require
4269 /// this to be true and invalidate the object pointed to by inner.
4273 impl Drop for GossipTimestampFilter {
4274 fn drop(&mut self) {
4275 if self.is_owned && !<*mut nativeGossipTimestampFilter>::is_null(self.inner) {
4276 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4280 /// Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL.
4282 pub extern "C" fn GossipTimestampFilter_free(this_obj: GossipTimestampFilter) { }
4284 /// Used only if an object of this type is returned as a trait impl by a method
4285 extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) {
4286 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeGossipTimestampFilter); }
4289 impl GossipTimestampFilter {
4290 pub(crate) fn get_native_ref(&self) -> &'static nativeGossipTimestampFilter {
4291 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4293 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeGossipTimestampFilter {
4294 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4296 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4297 pub(crate) fn take_inner(mut self) -> *mut nativeGossipTimestampFilter {
4298 assert!(self.is_owned);
4299 let ret = ObjOps::untweak_ptr(self.inner);
4300 self.inner = std::ptr::null_mut();
4304 /// The genesis hash of the blockchain for channel and node information
4306 pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *const [u8; 32] {
4307 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4308 inner_val.as_inner()
4310 /// The genesis hash of the blockchain for channel and node information
4312 pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) {
4313 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4315 /// The starting unix timestamp
4317 pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 {
4318 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_timestamp;
4321 /// The starting unix timestamp
4323 pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
4324 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_timestamp = val;
4326 /// The range of information in seconds
4328 pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 {
4329 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp_range;
4332 /// The range of information in seconds
4334 pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
4335 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp_range = val;
4337 /// Constructs a new GossipTimestampFilter given each field
4340 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 {
4341 GossipTimestampFilter { inner: ObjOps::heap_alloc(nativeGossipTimestampFilter {
4342 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4343 first_timestamp: first_timestamp_arg,
4344 timestamp_range: timestamp_range_arg,
4345 }), is_owned: true }
4347 impl Clone for GossipTimestampFilter {
4348 fn clone(&self) -> Self {
4350 inner: if <*mut nativeGossipTimestampFilter>::is_null(self.inner) { std::ptr::null_mut() } else {
4351 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4357 /// Used only if an object of this type is returned as a trait impl by a method
4358 pub(crate) extern "C" fn GossipTimestampFilter_clone_void(this_ptr: *const c_void) -> *mut c_void {
4359 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeGossipTimestampFilter)).clone() })) as *mut c_void
4362 /// Creates a copy of the GossipTimestampFilter
4363 pub extern "C" fn GossipTimestampFilter_clone(orig: &GossipTimestampFilter) -> GossipTimestampFilter {
4366 /// Used to put an error message in a LightningError
4370 pub enum ErrorAction {
4371 /// The peer took some action which made us think they were useless. Disconnect them.
4373 /// An error message which we should make an effort to send before we disconnect.
4375 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
4376 msg: crate::lightning::ln::msgs::ErrorMessage,
4378 /// The peer did something harmless that we weren't able to process, just log and ignore
4380 /// The peer did something harmless that we weren't able to meaningfully process.
4381 /// If the error is logged, log it at the given level.
4382 IgnoreAndLog(crate::lightning::util::logger::Level),
4383 /// The peer did something incorrect. Tell them.
4385 /// The message to send.
4386 msg: crate::lightning::ln::msgs::ErrorMessage,
4389 use lightning::ln::msgs::ErrorAction as nativeErrorAction;
4392 pub(crate) fn to_native(&self) -> nativeErrorAction {
4394 ErrorAction::DisconnectPeer {ref msg, } => {
4395 let mut msg_nonref = (*msg).clone();
4396 let mut local_msg_nonref = if msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg_nonref.take_inner()) } }) };
4397 nativeErrorAction::DisconnectPeer {
4398 msg: local_msg_nonref,
4401 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
4402 ErrorAction::IgnoreAndLog (ref a, ) => {
4403 let mut a_nonref = (*a).clone();
4404 nativeErrorAction::IgnoreAndLog (
4405 a_nonref.into_native(),
4408 ErrorAction::SendErrorMessage {ref msg, } => {
4409 let mut msg_nonref = (*msg).clone();
4410 nativeErrorAction::SendErrorMessage {
4411 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
4417 pub(crate) fn into_native(self) -> nativeErrorAction {
4419 ErrorAction::DisconnectPeer {mut msg, } => {
4420 let mut local_msg = if msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg.take_inner()) } }) };
4421 nativeErrorAction::DisconnectPeer {
4425 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
4426 ErrorAction::IgnoreAndLog (mut a, ) => {
4427 nativeErrorAction::IgnoreAndLog (
4431 ErrorAction::SendErrorMessage {mut msg, } => {
4432 nativeErrorAction::SendErrorMessage {
4433 msg: *unsafe { Box::from_raw(msg.take_inner()) },
4439 pub(crate) fn from_native(native: &nativeErrorAction) -> Self {
4441 nativeErrorAction::DisconnectPeer {ref msg, } => {
4442 let mut msg_nonref = (*msg).clone();
4443 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 };
4444 ErrorAction::DisconnectPeer {
4445 msg: local_msg_nonref,
4448 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
4449 nativeErrorAction::IgnoreAndLog (ref a, ) => {
4450 let mut a_nonref = (*a).clone();
4451 ErrorAction::IgnoreAndLog (
4452 crate::lightning::util::logger::Level::native_into(a_nonref),
4455 nativeErrorAction::SendErrorMessage {ref msg, } => {
4456 let mut msg_nonref = (*msg).clone();
4457 ErrorAction::SendErrorMessage {
4458 msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
4464 pub(crate) fn native_into(native: nativeErrorAction) -> Self {
4466 nativeErrorAction::DisconnectPeer {mut msg, } => {
4467 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 };
4468 ErrorAction::DisconnectPeer {
4472 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
4473 nativeErrorAction::IgnoreAndLog (mut a, ) => {
4474 ErrorAction::IgnoreAndLog (
4475 crate::lightning::util::logger::Level::native_into(a),
4478 nativeErrorAction::SendErrorMessage {mut msg, } => {
4479 ErrorAction::SendErrorMessage {
4480 msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
4486 /// Frees any resources used by the ErrorAction
4488 pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { }
4489 /// Creates a copy of the ErrorAction
4491 pub extern "C" fn ErrorAction_clone(orig: &ErrorAction) -> ErrorAction {
4495 /// Utility method to constructs a new DisconnectPeer-variant ErrorAction
4496 pub extern "C" fn ErrorAction_disconnect_peer(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
4497 ErrorAction::DisconnectPeer {
4502 /// Utility method to constructs a new IgnoreError-variant ErrorAction
4503 pub extern "C" fn ErrorAction_ignore_error() -> ErrorAction {
4504 ErrorAction::IgnoreError}
4506 /// Utility method to constructs a new IgnoreAndLog-variant ErrorAction
4507 pub extern "C" fn ErrorAction_ignore_and_log(a: crate::lightning::util::logger::Level) -> ErrorAction {
4508 ErrorAction::IgnoreAndLog(a, )
4511 /// Utility method to constructs a new SendErrorMessage-variant ErrorAction
4512 pub extern "C" fn ErrorAction_send_error_message(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
4513 ErrorAction::SendErrorMessage {
4518 use lightning::ln::msgs::LightningError as nativeLightningErrorImport;
4519 type nativeLightningError = nativeLightningErrorImport;
4521 /// An Err type for failure to process messages.
4524 pub struct LightningError {
4525 /// A pointer to the opaque Rust object.
4527 /// Nearly everywhere, inner must be non-null, however in places where
4528 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4529 pub inner: *mut nativeLightningError,
4530 /// Indicates that this is the only struct which contains the same pointer.
4532 /// Rust functions which take ownership of an object provided via an argument require
4533 /// this to be true and invalidate the object pointed to by inner.
4537 impl Drop for LightningError {
4538 fn drop(&mut self) {
4539 if self.is_owned && !<*mut nativeLightningError>::is_null(self.inner) {
4540 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4544 /// Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL.
4546 pub extern "C" fn LightningError_free(this_obj: LightningError) { }
4548 /// Used only if an object of this type is returned as a trait impl by a method
4549 extern "C" fn LightningError_free_void(this_ptr: *mut c_void) {
4550 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeLightningError); }
4553 impl LightningError {
4554 pub(crate) fn get_native_ref(&self) -> &'static nativeLightningError {
4555 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4557 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLightningError {
4558 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4560 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4561 pub(crate) fn take_inner(mut self) -> *mut nativeLightningError {
4562 assert!(self.is_owned);
4563 let ret = ObjOps::untweak_ptr(self.inner);
4564 self.inner = std::ptr::null_mut();
4568 /// A human-readable message describing the error
4570 pub extern "C" fn LightningError_get_err(this_ptr: &LightningError) -> crate::c_types::Str {
4571 let mut inner_val = &mut this_ptr.get_native_mut_ref().err;
4572 inner_val.as_str().into()
4574 /// A human-readable message describing the error
4576 pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: crate::c_types::Str) {
4577 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.err = val.into_string();
4579 /// The action which should be taken against the offending peer.
4581 pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate::lightning::ln::msgs::ErrorAction {
4582 let mut inner_val = &mut this_ptr.get_native_mut_ref().action;
4583 crate::lightning::ln::msgs::ErrorAction::from_native(inner_val)
4585 /// The action which should be taken against the offending peer.
4587 pub extern "C" fn LightningError_set_action(this_ptr: &mut LightningError, mut val: crate::lightning::ln::msgs::ErrorAction) {
4588 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.action = val.into_native();
4590 /// Constructs a new LightningError given each field
4593 pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::Str, mut action_arg: crate::lightning::ln::msgs::ErrorAction) -> LightningError {
4594 LightningError { inner: ObjOps::heap_alloc(nativeLightningError {
4595 err: err_arg.into_string(),
4596 action: action_arg.into_native(),
4597 }), is_owned: true }
4599 impl Clone for LightningError {
4600 fn clone(&self) -> Self {
4602 inner: if <*mut nativeLightningError>::is_null(self.inner) { std::ptr::null_mut() } else {
4603 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4609 /// Used only if an object of this type is returned as a trait impl by a method
4610 pub(crate) extern "C" fn LightningError_clone_void(this_ptr: *const c_void) -> *mut c_void {
4611 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeLightningError)).clone() })) as *mut c_void
4614 /// Creates a copy of the LightningError
4615 pub extern "C" fn LightningError_clone(orig: &LightningError) -> LightningError {
4619 use lightning::ln::msgs::CommitmentUpdate as nativeCommitmentUpdateImport;
4620 type nativeCommitmentUpdate = nativeCommitmentUpdateImport;
4622 /// Struct used to return values from revoke_and_ack messages, containing a bunch of commitment
4623 /// transaction updates if they were pending.
4626 pub struct CommitmentUpdate {
4627 /// A pointer to the opaque Rust object.
4629 /// Nearly everywhere, inner must be non-null, however in places where
4630 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4631 pub inner: *mut nativeCommitmentUpdate,
4632 /// Indicates that this is the only struct which contains the same pointer.
4634 /// Rust functions which take ownership of an object provided via an argument require
4635 /// this to be true and invalidate the object pointed to by inner.
4639 impl Drop for CommitmentUpdate {
4640 fn drop(&mut self) {
4641 if self.is_owned && !<*mut nativeCommitmentUpdate>::is_null(self.inner) {
4642 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4646 /// Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL.
4648 pub extern "C" fn CommitmentUpdate_free(this_obj: CommitmentUpdate) { }
4650 /// Used only if an object of this type is returned as a trait impl by a method
4651 extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) {
4652 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentUpdate); }
4655 impl CommitmentUpdate {
4656 pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentUpdate {
4657 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4659 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentUpdate {
4660 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4662 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4663 pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentUpdate {
4664 assert!(self.is_owned);
4665 let ret = ObjOps::untweak_ptr(self.inner);
4666 self.inner = std::ptr::null_mut();
4670 /// update_add_htlc messages which should be sent
4672 pub extern "C" fn CommitmentUpdate_get_update_add_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateAddHTLCZ {
4673 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_add_htlcs;
4674 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 _) as *mut _) }, is_owned: false } }); };
4675 local_inner_val.into()
4677 /// update_add_htlc messages which should be sent
4679 pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) {
4680 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4681 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_add_htlcs = local_val;
4683 /// update_fulfill_htlc messages which should be sent
4685 pub extern "C" fn CommitmentUpdate_get_update_fulfill_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFulfillHTLCZ {
4686 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fulfill_htlcs;
4687 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 _) as *mut _) }, is_owned: false } }); };
4688 local_inner_val.into()
4690 /// update_fulfill_htlc messages which should be sent
4692 pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) {
4693 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4694 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fulfill_htlcs = local_val;
4696 /// update_fail_htlc messages which should be sent
4698 pub extern "C" fn CommitmentUpdate_get_update_fail_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailHTLCZ {
4699 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_htlcs;
4700 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 _) as *mut _) }, is_owned: false } }); };
4701 local_inner_val.into()
4703 /// update_fail_htlc messages which should be sent
4705 pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) {
4706 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4707 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_htlcs = local_val;
4709 /// update_fail_malformed_htlc messages which should be sent
4711 pub extern "C" fn CommitmentUpdate_get_update_fail_malformed_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ {
4712 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_malformed_htlcs;
4713 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 _) as *mut _) }, is_owned: false } }); };
4714 local_inner_val.into()
4716 /// update_fail_malformed_htlc messages which should be sent
4718 pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) {
4719 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4720 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_malformed_htlcs = local_val;
4722 /// An update_fee message which should be sent
4724 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
4726 pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::UpdateFee {
4727 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fee;
4728 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 _) as *mut _ }, is_owned: false };
4731 /// An update_fee message which should be sent
4733 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
4735 pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::UpdateFee) {
4736 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
4737 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fee = local_val;
4739 /// Finally, the commitment_signed message which should be sent
4741 pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::CommitmentSigned {
4742 let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_signed;
4743 crate::lightning::ln::msgs::CommitmentSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false }
4745 /// Finally, the commitment_signed message which should be sent
4747 pub extern "C" fn CommitmentUpdate_set_commitment_signed(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::CommitmentSigned) {
4748 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_signed = *unsafe { Box::from_raw(val.take_inner()) };
4750 /// Constructs a new CommitmentUpdate given each field
4753 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 {
4754 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()) } }); };
4755 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()) } }); };
4756 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()) } }); };
4757 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()) } }); };
4758 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()) } }) };
4759 CommitmentUpdate { inner: ObjOps::heap_alloc(nativeCommitmentUpdate {
4760 update_add_htlcs: local_update_add_htlcs_arg,
4761 update_fulfill_htlcs: local_update_fulfill_htlcs_arg,
4762 update_fail_htlcs: local_update_fail_htlcs_arg,
4763 update_fail_malformed_htlcs: local_update_fail_malformed_htlcs_arg,
4764 update_fee: local_update_fee_arg,
4765 commitment_signed: *unsafe { Box::from_raw(commitment_signed_arg.take_inner()) },
4766 }), is_owned: true }
4768 impl Clone for CommitmentUpdate {
4769 fn clone(&self) -> Self {
4771 inner: if <*mut nativeCommitmentUpdate>::is_null(self.inner) { std::ptr::null_mut() } else {
4772 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4778 /// Used only if an object of this type is returned as a trait impl by a method
4779 pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
4780 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentUpdate)).clone() })) as *mut c_void
4783 /// Creates a copy of the CommitmentUpdate
4784 pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentUpdate {
4787 /// A trait to describe an object which can receive channel messages.
4789 /// Messages MAY be called in parallel when they originate from different their_node_ids, however
4790 /// they MUST NOT be called in parallel when the two calls have the same their_node_id.
4792 pub struct ChannelMessageHandler {
4793 /// An opaque pointer which is passed to your function implementations as an argument.
4794 /// This has no meaning in the LDK, and can be NULL or any other value.
4795 pub this_arg: *mut c_void,
4796 /// Handle an incoming open_channel message from the given peer.
4797 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),
4798 /// Handle an incoming accept_channel message from the given peer.
4799 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),
4800 /// Handle an incoming funding_created message from the given peer.
4801 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),
4802 /// Handle an incoming funding_signed message from the given peer.
4803 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),
4804 /// Handle an incoming funding_locked message from the given peer.
4805 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),
4806 /// Handle an incoming shutdown message from the given peer.
4807 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),
4808 /// Handle an incoming closing_signed message from the given peer.
4809 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),
4810 /// Handle an incoming update_add_htlc message from the given peer.
4811 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),
4812 /// Handle an incoming update_fulfill_htlc message from the given peer.
4813 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),
4814 /// Handle an incoming update_fail_htlc message from the given peer.
4815 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),
4816 /// Handle an incoming update_fail_malformed_htlc message from the given peer.
4817 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),
4818 /// Handle an incoming commitment_signed message from the given peer.
4819 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),
4820 /// Handle an incoming revoke_and_ack message from the given peer.
4821 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),
4822 /// Handle an incoming update_fee message from the given peer.
4823 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),
4824 /// Handle an incoming announcement_signatures message from the given peer.
4825 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),
4826 /// Indicates a connection to the peer failed/an existing connection was lost. If no connection
4827 /// is believed to be possible in the future (eg they're sending us messages we don't
4828 /// understand or indicate they require unknown feature bits), no_connection_possible is set
4829 /// and any outstanding channels should be failed.
4830 pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, no_connection_possible: bool),
4831 /// Handle a peer reconnecting, possibly generating channel_reestablish message(s).
4832 pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Init),
4833 /// Handle an incoming channel_reestablish message from the given peer.
4834 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),
4835 /// Handle an incoming channel update from the given peer.
4836 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),
4837 /// Handle an incoming error message from the given peer.
4838 pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ErrorMessage),
4839 /// Implementation of MessageSendEventsProvider for this object.
4840 pub MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider,
4841 /// Frees any resources associated with this object given its this_arg pointer.
4842 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
4843 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
4845 unsafe impl Send for ChannelMessageHandler {}
4846 unsafe impl Sync for ChannelMessageHandler {}
4848 pub(crate) extern "C" fn ChannelMessageHandler_clone_fields(orig: &ChannelMessageHandler) -> ChannelMessageHandler {
4849 ChannelMessageHandler {
4850 this_arg: orig.this_arg,
4851 handle_open_channel: Clone::clone(&orig.handle_open_channel),
4852 handle_accept_channel: Clone::clone(&orig.handle_accept_channel),
4853 handle_funding_created: Clone::clone(&orig.handle_funding_created),
4854 handle_funding_signed: Clone::clone(&orig.handle_funding_signed),
4855 handle_funding_locked: Clone::clone(&orig.handle_funding_locked),
4856 handle_shutdown: Clone::clone(&orig.handle_shutdown),
4857 handle_closing_signed: Clone::clone(&orig.handle_closing_signed),
4858 handle_update_add_htlc: Clone::clone(&orig.handle_update_add_htlc),
4859 handle_update_fulfill_htlc: Clone::clone(&orig.handle_update_fulfill_htlc),
4860 handle_update_fail_htlc: Clone::clone(&orig.handle_update_fail_htlc),
4861 handle_update_fail_malformed_htlc: Clone::clone(&orig.handle_update_fail_malformed_htlc),
4862 handle_commitment_signed: Clone::clone(&orig.handle_commitment_signed),
4863 handle_revoke_and_ack: Clone::clone(&orig.handle_revoke_and_ack),
4864 handle_update_fee: Clone::clone(&orig.handle_update_fee),
4865 handle_announcement_signatures: Clone::clone(&orig.handle_announcement_signatures),
4866 peer_disconnected: Clone::clone(&orig.peer_disconnected),
4867 peer_connected: Clone::clone(&orig.peer_connected),
4868 handle_channel_reestablish: Clone::clone(&orig.handle_channel_reestablish),
4869 handle_channel_update: Clone::clone(&orig.handle_channel_update),
4870 handle_error: Clone::clone(&orig.handle_error),
4871 MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
4872 free: Clone::clone(&orig.free),
4875 impl lightning::util::events::MessageSendEventsProvider for ChannelMessageHandler {
4876 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
4877 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
4878 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
4883 use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler;
4884 impl rustChannelMessageHandler for ChannelMessageHandler {
4885 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) {
4886 (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 _) as *mut _) }, is_owned: false })
4888 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) {
4889 (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 _) as *mut _) }, is_owned: false })
4891 fn handle_funding_created(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::FundingCreated) {
4892 (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 _) as *mut _) }, is_owned: false })
4894 fn handle_funding_signed(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::FundingSigned) {
4895 (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 _) as *mut _) }, is_owned: false })
4897 fn handle_funding_locked(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::FundingLocked) {
4898 (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 _) as *mut _) }, is_owned: false })
4900 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) {
4901 (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 _) as *mut _) }, is_owned: false }, &crate::lightning::ln::msgs::Shutdown { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const _) as *mut _) }, is_owned: false })
4903 fn handle_closing_signed(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ClosingSigned) {
4904 (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 _) as *mut _) }, is_owned: false })
4906 fn handle_update_add_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateAddHTLC) {
4907 (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 _) as *mut _) }, is_owned: false })
4909 fn handle_update_fulfill_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFulfillHTLC) {
4910 (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 _) as *mut _) }, is_owned: false })
4912 fn handle_update_fail_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailHTLC) {
4913 (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 _) as *mut _) }, is_owned: false })
4915 fn handle_update_fail_malformed_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) {
4916 (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 _) as *mut _) }, is_owned: false })
4918 fn handle_commitment_signed(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::CommitmentSigned) {
4919 (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 _) as *mut _) }, is_owned: false })
4921 fn handle_revoke_and_ack(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::RevokeAndACK) {
4922 (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 _) as *mut _) }, is_owned: false })
4924 fn handle_update_fee(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFee) {
4925 (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 _) as *mut _) }, is_owned: false })
4927 fn handle_announcement_signatures(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::AnnouncementSignatures) {
4928 (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 _) as *mut _) }, is_owned: false })
4930 fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut no_connection_possible: bool) {
4931 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), no_connection_possible)
4933 fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::Init) {
4934 (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 _) as *mut _) }, is_owned: false })
4936 fn handle_channel_reestablish(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ChannelReestablish) {
4937 (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 _) as *mut _) }, is_owned: false })
4939 fn handle_channel_update(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ChannelUpdate) {
4940 (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 _) as *mut _) }, is_owned: false })
4942 fn handle_error(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ErrorMessage) {
4943 (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 _) as *mut _) }, is_owned: false })
4947 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
4948 // directly as a Deref trait in higher-level structs:
4949 impl std::ops::Deref for ChannelMessageHandler {
4951 fn deref(&self) -> &Self {
4955 /// Calls the free function if one is set
4957 pub extern "C" fn ChannelMessageHandler_free(this_ptr: ChannelMessageHandler) { }
4958 impl Drop for ChannelMessageHandler {
4959 fn drop(&mut self) {
4960 if let Some(f) = self.free {
4965 /// A trait to describe an object which can receive routing messages.
4967 /// # Implementor DoS Warnings
4969 /// For `gossip_queries` messages there are potential DoS vectors when handling
4970 /// inbound queries. Implementors using an on-disk network graph should be aware of
4971 /// repeated disk I/O for queries accessing different parts of the network graph.
4973 pub struct RoutingMessageHandler {
4974 /// An opaque pointer which is passed to your function implementations as an argument.
4975 /// This has no meaning in the LDK, and can be NULL or any other value.
4976 pub this_arg: *mut c_void,
4977 /// Handle an incoming node_announcement message, returning true if it should be forwarded on,
4978 /// false or returning an Err otherwise.
4980 pub handle_node_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
4981 /// Handle a channel_announcement message, returning true if it should be forwarded on, false
4982 /// or returning an Err otherwise.
4984 pub handle_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
4985 /// Handle an incoming channel_update message, returning true if it should be forwarded on,
4986 /// false or returning an Err otherwise.
4988 pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ,
4989 /// Gets a subset of the channel announcements and updates required to dump our routing table
4990 /// to a remote node, starting at the short_channel_id indicated by starting_point and
4991 /// including the batch_amount entries immediately higher in numerical value than starting_point.
4993 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,
4994 /// Gets a subset of the node announcements required to dump our routing table to a remote node,
4995 /// starting at the node *after* the provided publickey and including batch_amount entries
4996 /// immediately higher (as defined by <PublicKey as Ord>::cmp) than starting_point.
4997 /// If None is provided for starting_point, we start at the first node.
4999 /// Note that starting_point (or a relevant inner pointer) may be NULL or all-0s to represent None
5001 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,
5002 /// Called when a connection is established with a peer. This can be used to
5003 /// perform routing table synchronization using a strategy defined by the
5005 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),
5006 /// Handles the reply of a query we initiated to learn about channels
5007 /// for a given range of blocks. We can expect to receive one or more
5008 /// replies to a single query.
5010 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,
5011 /// Handles the reply of a query we initiated asking for routing gossip
5012 /// messages for a list of channels. We should receive this message when
5013 /// a node has completed its best effort to send us the pertaining routing
5014 /// gossip messages.
5016 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,
5017 /// Handles when a peer asks us to send a list of short_channel_ids
5018 /// for the requested range of blocks.
5020 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,
5021 /// Handles when a peer asks us to send routing gossip messages for a
5022 /// list of short_channel_ids.
5024 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,
5025 /// Implementation of MessageSendEventsProvider for this object.
5026 pub MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider,
5027 /// Frees any resources associated with this object given its this_arg pointer.
5028 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
5029 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
5031 unsafe impl Send for RoutingMessageHandler {}
5032 unsafe impl Sync for RoutingMessageHandler {}
5034 pub(crate) extern "C" fn RoutingMessageHandler_clone_fields(orig: &RoutingMessageHandler) -> RoutingMessageHandler {
5035 RoutingMessageHandler {
5036 this_arg: orig.this_arg,
5037 handle_node_announcement: Clone::clone(&orig.handle_node_announcement),
5038 handle_channel_announcement: Clone::clone(&orig.handle_channel_announcement),
5039 handle_channel_update: Clone::clone(&orig.handle_channel_update),
5040 get_next_channel_announcements: Clone::clone(&orig.get_next_channel_announcements),
5041 get_next_node_announcements: Clone::clone(&orig.get_next_node_announcements),
5042 sync_routing_table: Clone::clone(&orig.sync_routing_table),
5043 handle_reply_channel_range: Clone::clone(&orig.handle_reply_channel_range),
5044 handle_reply_short_channel_ids_end: Clone::clone(&orig.handle_reply_short_channel_ids_end),
5045 handle_query_channel_range: Clone::clone(&orig.handle_query_channel_range),
5046 handle_query_short_channel_ids: Clone::clone(&orig.handle_query_short_channel_ids),
5047 MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
5048 free: Clone::clone(&orig.free),
5051 impl lightning::util::events::MessageSendEventsProvider for RoutingMessageHandler {
5052 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
5053 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
5054 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
5059 use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler;
5060 impl rustRoutingMessageHandler for RoutingMessageHandler {
5061 fn handle_node_announcement(&self, mut msg: &lightning::ln::msgs::NodeAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
5062 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 _) as *mut _) }, is_owned: false });
5063 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()) } })};
5066 fn handle_channel_announcement(&self, mut msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
5067 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 _) as *mut _) }, is_owned: false });
5068 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()) } })};
5071 fn handle_channel_update(&self, mut msg: &lightning::ln::msgs::ChannelUpdate) -> Result<bool, lightning::ln::msgs::LightningError> {
5072 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 _) as *mut _) }, is_owned: false });
5073 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()) } })};
5076 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>)> {
5077 let mut ret = (self.get_next_channel_announcements)(self.this_arg, starting_point, batch_amount);
5078 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 }); };
5081 fn get_next_node_announcements(&self, mut starting_point: Option<&bitcoin::secp256k1::key::PublicKey>, mut batch_amount: u8) -> Vec<lightning::ln::msgs::NodeAnnouncement> {
5082 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())) } };
5083 let mut ret = (self.get_next_node_announcements)(self.this_arg, local_starting_point, batch_amount);
5084 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
5087 fn sync_routing_table(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut init: &lightning::ln::msgs::Init) {
5088 (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 _) as *mut _) }, is_owned: false })
5090 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> {
5091 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 });
5092 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()) } })};
5095 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> {
5096 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 });
5097 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()) } })};
5100 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> {
5101 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 });
5102 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
5105 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> {
5106 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 });
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()) } })};
5112 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
5113 // directly as a Deref trait in higher-level structs:
5114 impl std::ops::Deref for RoutingMessageHandler {
5116 fn deref(&self) -> &Self {
5120 /// Calls the free function if one is set
5122 pub extern "C" fn RoutingMessageHandler_free(this_ptr: RoutingMessageHandler) { }
5123 impl Drop for RoutingMessageHandler {
5124 fn drop(&mut self) {
5125 if let Some(f) = self.free {
5130 mod fuzzy_internal_msgs {
5132 use std::str::FromStr;
5133 use std::ffi::c_void;
5134 use core::convert::Infallible;
5135 use bitcoin::hashes::Hash;
5136 use crate::c_types::*;
5140 /// Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read
5141 pub extern "C" fn AcceptChannel_write(obj: &AcceptChannel) -> crate::c_types::derived::CVec_u8Z {
5142 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5145 pub(crate) extern "C" fn AcceptChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5146 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannel) })
5149 /// Read a AcceptChannel from a byte array, created by AcceptChannel_write
5150 pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelDecodeErrorZ {
5151 let res = crate::c_types::deserialize_obj(ser);
5152 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() };
5156 /// Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read
5157 pub extern "C" fn AnnouncementSignatures_write(obj: &AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z {
5158 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5161 pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5162 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAnnouncementSignatures) })
5165 /// Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write
5166 pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AnnouncementSignaturesDecodeErrorZ {
5167 let res = crate::c_types::deserialize_obj(ser);
5168 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() };
5172 /// Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read
5173 pub extern "C" fn ChannelReestablish_write(obj: &ChannelReestablish) -> crate::c_types::derived::CVec_u8Z {
5174 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5177 pub(crate) extern "C" fn ChannelReestablish_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5178 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReestablish) })
5181 /// Read a ChannelReestablish from a byte array, created by ChannelReestablish_write
5182 pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReestablishDecodeErrorZ {
5183 let res = crate::c_types::deserialize_obj(ser);
5184 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() };
5188 /// Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read
5189 pub extern "C" fn ClosingSigned_write(obj: &ClosingSigned) -> crate::c_types::derived::CVec_u8Z {
5190 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5193 pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5194 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSigned) })
5197 /// Read a ClosingSigned from a byte array, created by ClosingSigned_write
5198 pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedDecodeErrorZ {
5199 let res = crate::c_types::deserialize_obj(ser);
5200 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() };
5204 /// Serialize the ClosingSignedFeeRange object into a byte array which can be read by ClosingSignedFeeRange_read
5205 pub extern "C" fn ClosingSignedFeeRange_write(obj: &ClosingSignedFeeRange) -> crate::c_types::derived::CVec_u8Z {
5206 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5209 pub(crate) extern "C" fn ClosingSignedFeeRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5210 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSignedFeeRange) })
5213 /// Read a ClosingSignedFeeRange from a byte array, created by ClosingSignedFeeRange_write
5214 pub extern "C" fn ClosingSignedFeeRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedFeeRangeDecodeErrorZ {
5215 let res = crate::c_types::deserialize_obj(ser);
5216 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() };
5220 /// Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read
5221 pub extern "C" fn CommitmentSigned_write(obj: &CommitmentSigned) -> crate::c_types::derived::CVec_u8Z {
5222 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5225 pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5226 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentSigned) })
5229 /// Read a CommitmentSigned from a byte array, created by CommitmentSigned_write
5230 pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CommitmentSignedDecodeErrorZ {
5231 let res = crate::c_types::deserialize_obj(ser);
5232 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() };
5236 /// Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read
5237 pub extern "C" fn FundingCreated_write(obj: &FundingCreated) -> crate::c_types::derived::CVec_u8Z {
5238 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5241 pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5242 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingCreated) })
5245 /// Read a FundingCreated from a byte array, created by FundingCreated_write
5246 pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingCreatedDecodeErrorZ {
5247 let res = crate::c_types::deserialize_obj(ser);
5248 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() };
5252 /// Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read
5253 pub extern "C" fn FundingSigned_write(obj: &FundingSigned) -> crate::c_types::derived::CVec_u8Z {
5254 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5257 pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5258 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingSigned) })
5261 /// Read a FundingSigned from a byte array, created by FundingSigned_write
5262 pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingSignedDecodeErrorZ {
5263 let res = crate::c_types::deserialize_obj(ser);
5264 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() };
5268 /// Serialize the FundingLocked object into a byte array which can be read by FundingLocked_read
5269 pub extern "C" fn FundingLocked_write(obj: &FundingLocked) -> crate::c_types::derived::CVec_u8Z {
5270 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5273 pub(crate) extern "C" fn FundingLocked_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5274 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingLocked) })
5277 /// Read a FundingLocked from a byte array, created by FundingLocked_write
5278 pub extern "C" fn FundingLocked_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingLockedDecodeErrorZ {
5279 let res = crate::c_types::deserialize_obj(ser);
5280 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() };
5284 /// Serialize the Init object into a byte array which can be read by Init_read
5285 pub extern "C" fn Init_write(obj: &Init) -> crate::c_types::derived::CVec_u8Z {
5286 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5289 pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5290 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInit) })
5293 /// Read a Init from a byte array, created by Init_write
5294 pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitDecodeErrorZ {
5295 let res = crate::c_types::deserialize_obj(ser);
5296 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() };
5300 /// Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read
5301 pub extern "C" fn OpenChannel_write(obj: &OpenChannel) -> crate::c_types::derived::CVec_u8Z {
5302 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5305 pub(crate) extern "C" fn OpenChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5306 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannel) })
5309 /// Read a OpenChannel from a byte array, created by OpenChannel_write
5310 pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelDecodeErrorZ {
5311 let res = crate::c_types::deserialize_obj(ser);
5312 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() };
5316 /// Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read
5317 pub extern "C" fn RevokeAndACK_write(obj: &RevokeAndACK) -> crate::c_types::derived::CVec_u8Z {
5318 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5321 pub(crate) extern "C" fn RevokeAndACK_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5322 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevokeAndACK) })
5325 /// Read a RevokeAndACK from a byte array, created by RevokeAndACK_write
5326 pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RevokeAndACKDecodeErrorZ {
5327 let res = crate::c_types::deserialize_obj(ser);
5328 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() };
5332 /// Serialize the Shutdown object into a byte array which can be read by Shutdown_read
5333 pub extern "C" fn Shutdown_write(obj: &Shutdown) -> crate::c_types::derived::CVec_u8Z {
5334 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5337 pub(crate) extern "C" fn Shutdown_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5338 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeShutdown) })
5341 /// Read a Shutdown from a byte array, created by Shutdown_write
5342 pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ShutdownDecodeErrorZ {
5343 let res = crate::c_types::deserialize_obj(ser);
5344 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() };
5348 /// Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read
5349 pub extern "C" fn UpdateFailHTLC_write(obj: &UpdateFailHTLC) -> crate::c_types::derived::CVec_u8Z {
5350 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5353 pub(crate) extern "C" fn UpdateFailHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5354 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailHTLC) })
5357 /// Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write
5358 pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailHTLCDecodeErrorZ {
5359 let res = crate::c_types::deserialize_obj(ser);
5360 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() };
5364 /// Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read
5365 pub extern "C" fn UpdateFailMalformedHTLC_write(obj: &UpdateFailMalformedHTLC) -> crate::c_types::derived::CVec_u8Z {
5366 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5369 pub(crate) extern "C" fn UpdateFailMalformedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5370 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailMalformedHTLC) })
5373 /// Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write
5374 pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailMalformedHTLCDecodeErrorZ {
5375 let res = crate::c_types::deserialize_obj(ser);
5376 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() };
5380 /// Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read
5381 pub extern "C" fn UpdateFee_write(obj: &UpdateFee) -> crate::c_types::derived::CVec_u8Z {
5382 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5385 pub(crate) extern "C" fn UpdateFee_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5386 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFee) })
5389 /// Read a UpdateFee from a byte array, created by UpdateFee_write
5390 pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFeeDecodeErrorZ {
5391 let res = crate::c_types::deserialize_obj(ser);
5392 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() };
5396 /// Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read
5397 pub extern "C" fn UpdateFulfillHTLC_write(obj: &UpdateFulfillHTLC) -> crate::c_types::derived::CVec_u8Z {
5398 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5401 pub(crate) extern "C" fn UpdateFulfillHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5402 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFulfillHTLC) })
5405 /// Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write
5406 pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFulfillHTLCDecodeErrorZ {
5407 let res = crate::c_types::deserialize_obj(ser);
5408 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() };
5412 /// Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read
5413 pub extern "C" fn UpdateAddHTLC_write(obj: &UpdateAddHTLC) -> crate::c_types::derived::CVec_u8Z {
5414 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5417 pub(crate) extern "C" fn UpdateAddHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5418 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateAddHTLC) })
5421 /// Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write
5422 pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateAddHTLCDecodeErrorZ {
5423 let res = crate::c_types::deserialize_obj(ser);
5424 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() };
5428 /// Serialize the Ping object into a byte array which can be read by Ping_read
5429 pub extern "C" fn Ping_write(obj: &Ping) -> crate::c_types::derived::CVec_u8Z {
5430 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5433 pub(crate) extern "C" fn Ping_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5434 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePing) })
5437 /// Read a Ping from a byte array, created by Ping_write
5438 pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PingDecodeErrorZ {
5439 let res = crate::c_types::deserialize_obj(ser);
5440 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() };
5444 /// Serialize the Pong object into a byte array which can be read by Pong_read
5445 pub extern "C" fn Pong_write(obj: &Pong) -> crate::c_types::derived::CVec_u8Z {
5446 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5449 pub(crate) extern "C" fn Pong_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5450 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePong) })
5453 /// Read a Pong from a byte array, created by Pong_write
5454 pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PongDecodeErrorZ {
5455 let res = crate::c_types::deserialize_obj(ser);
5456 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() };
5460 /// Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read
5461 pub extern "C" fn UnsignedChannelAnnouncement_write(obj: &UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
5462 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5465 pub(crate) extern "C" fn UnsignedChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5466 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelAnnouncement) })
5469 /// Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write
5470 pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelAnnouncementDecodeErrorZ {
5471 let res = crate::c_types::deserialize_obj(ser);
5472 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() };
5476 /// Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read
5477 pub extern "C" fn ChannelAnnouncement_write(obj: &ChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
5478 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5481 pub(crate) extern "C" fn ChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5482 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelAnnouncement) })
5485 /// Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write
5486 pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelAnnouncementDecodeErrorZ {
5487 let res = crate::c_types::deserialize_obj(ser);
5488 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() };
5492 /// Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read
5493 pub extern "C" fn UnsignedChannelUpdate_write(obj: &UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
5494 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5497 pub(crate) extern "C" fn UnsignedChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5498 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelUpdate) })
5501 /// Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write
5502 pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelUpdateDecodeErrorZ {
5503 let res = crate::c_types::deserialize_obj(ser);
5504 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() };
5508 /// Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read
5509 pub extern "C" fn ChannelUpdate_write(obj: &ChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
5510 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5513 pub(crate) extern "C" fn ChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5514 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdate) })
5517 /// Read a ChannelUpdate from a byte array, created by ChannelUpdate_write
5518 pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelUpdateDecodeErrorZ {
5519 let res = crate::c_types::deserialize_obj(ser);
5520 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() };
5524 /// Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read
5525 pub extern "C" fn ErrorMessage_write(obj: &ErrorMessage) -> crate::c_types::derived::CVec_u8Z {
5526 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5529 pub(crate) extern "C" fn ErrorMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5530 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeErrorMessage) })
5533 /// Read a ErrorMessage from a byte array, created by ErrorMessage_write
5534 pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ErrorMessageDecodeErrorZ {
5535 let res = crate::c_types::deserialize_obj(ser);
5536 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() };
5540 /// Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read
5541 pub extern "C" fn UnsignedNodeAnnouncement_write(obj: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
5542 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5545 pub(crate) extern "C" fn UnsignedNodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5546 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedNodeAnnouncement) })
5549 /// Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write
5550 pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedNodeAnnouncementDecodeErrorZ {
5551 let res = crate::c_types::deserialize_obj(ser);
5552 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() };
5556 /// Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read
5557 pub extern "C" fn NodeAnnouncement_write(obj: &NodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
5558 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5561 pub(crate) extern "C" fn NodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5562 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncement) })
5565 /// Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write
5566 pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementDecodeErrorZ {
5567 let res = crate::c_types::deserialize_obj(ser);
5568 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::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() };
5572 /// Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write
5573 pub extern "C" fn QueryShortChannelIds_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryShortChannelIdsDecodeErrorZ {
5574 let res = crate::c_types::deserialize_obj(ser);
5575 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() };
5579 /// Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read
5580 pub extern "C" fn QueryShortChannelIds_write(obj: &QueryShortChannelIds) -> crate::c_types::derived::CVec_u8Z {
5581 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5584 pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5585 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) })
5588 /// Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read
5589 pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z {
5590 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5593 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5594 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) })
5597 /// Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write
5598 pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyShortChannelIdsEndDecodeErrorZ {
5599 let res = crate::c_types::deserialize_obj(ser);
5600 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() };
5603 ///\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
5606 pub extern "C" fn QueryChannelRange_end_blocknum(this_arg: &QueryChannelRange) -> u32 {
5607 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.end_blocknum();
5612 /// Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read
5613 pub extern "C" fn QueryChannelRange_write(obj: &QueryChannelRange) -> crate::c_types::derived::CVec_u8Z {
5614 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5617 pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5618 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) })
5621 /// Read a QueryChannelRange from a byte array, created by QueryChannelRange_write
5622 pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ {
5623 let res = crate::c_types::deserialize_obj(ser);
5624 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::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() };
5628 /// Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write
5629 pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyChannelRangeDecodeErrorZ {
5630 let res = crate::c_types::deserialize_obj(ser);
5631 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() };
5635 /// Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read
5636 pub extern "C" fn ReplyChannelRange_write(obj: &ReplyChannelRange) -> crate::c_types::derived::CVec_u8Z {
5637 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5640 pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5641 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) })
5644 /// Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read
5645 pub extern "C" fn GossipTimestampFilter_write(obj: &GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z {
5646 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5649 pub(crate) extern "C" fn GossipTimestampFilter_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5650 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeGossipTimestampFilter) })
5653 /// Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write
5654 pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_GossipTimestampFilterDecodeErrorZ {
5655 let res = crate::c_types::deserialize_obj(ser);
5656 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() };