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 bitcoin::hashes::Hash;
29 use crate::c_types::*;
32 use lightning::ln::msgs::DecodeError as nativeDecodeErrorImport;
33 type nativeDecodeError = nativeDecodeErrorImport;
35 /// An error in decoding a message or struct.
38 pub struct DecodeError {
39 /// A pointer to the opaque Rust object.
41 /// Nearly everywhere, inner must be non-null, however in places where
42 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
43 pub inner: *mut nativeDecodeError,
44 /// Indicates that this is the only struct which contains the same pointer.
46 /// Rust functions which take ownership of an object provided via an argument require
47 /// this to be true and invalidate the object pointed to by inner.
51 impl Drop for DecodeError {
53 if self.is_owned && !<*mut nativeDecodeError>::is_null(self.inner) {
54 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
58 /// Frees any resources used by the DecodeError, if is_owned is set and inner is non-NULL.
60 pub extern "C" fn DecodeError_free(this_obj: DecodeError) { }
62 /// Used only if an object of this type is returned as a trait impl by a method
63 extern "C" fn DecodeError_free_void(this_ptr: *mut c_void) {
64 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDecodeError); }
68 pub(crate) fn get_native_ref(&self) -> &'static nativeDecodeError {
69 unsafe { &*ObjOps::untweak_ptr(self.inner) }
71 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeDecodeError {
72 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
74 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
75 pub(crate) fn take_inner(mut self) -> *mut nativeDecodeError {
76 assert!(self.is_owned);
77 let ret = ObjOps::untweak_ptr(self.inner);
78 self.inner = std::ptr::null_mut();
82 impl Clone for DecodeError {
83 fn clone(&self) -> Self {
85 inner: if <*mut nativeDecodeError>::is_null(self.inner) { std::ptr::null_mut() } else {
86 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
92 /// Used only if an object of this type is returned as a trait impl by a method
93 pub(crate) extern "C" fn DecodeError_clone_void(this_ptr: *const c_void) -> *mut c_void {
94 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDecodeError)).clone() })) as *mut c_void
97 /// Creates a copy of the DecodeError
98 pub extern "C" fn DecodeError_clone(orig: &DecodeError) -> DecodeError {
102 use lightning::ln::msgs::Init as nativeInitImport;
103 type nativeInit = nativeInitImport;
105 /// An init message to be sent or received from a peer
109 /// A pointer to the opaque Rust object.
111 /// Nearly everywhere, inner must be non-null, however in places where
112 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
113 pub inner: *mut nativeInit,
114 /// Indicates that this is the only struct which contains the same pointer.
116 /// Rust functions which take ownership of an object provided via an argument require
117 /// this to be true and invalidate the object pointed to by inner.
123 if self.is_owned && !<*mut nativeInit>::is_null(self.inner) {
124 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
128 /// Frees any resources used by the Init, if is_owned is set and inner is non-NULL.
130 pub extern "C" fn Init_free(this_obj: Init) { }
132 /// Used only if an object of this type is returned as a trait impl by a method
133 extern "C" fn Init_free_void(this_ptr: *mut c_void) {
134 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeInit); }
138 pub(crate) fn get_native_ref(&self) -> &'static nativeInit {
139 unsafe { &*ObjOps::untweak_ptr(self.inner) }
141 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInit {
142 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
144 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
145 pub(crate) fn take_inner(mut self) -> *mut nativeInit {
146 assert!(self.is_owned);
147 let ret = ObjOps::untweak_ptr(self.inner);
148 self.inner = std::ptr::null_mut();
152 /// The relevant features which the sender supports
154 pub extern "C" fn Init_get_features(this_ptr: &Init) -> crate::lightning::ln::features::InitFeatures {
155 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
156 crate::lightning::ln::features::InitFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false }
158 /// The relevant features which the sender supports
160 pub extern "C" fn Init_set_features(this_ptr: &mut Init, mut val: crate::lightning::ln::features::InitFeatures) {
161 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
163 /// Constructs a new Init given each field
166 pub extern "C" fn Init_new(mut features_arg: crate::lightning::ln::features::InitFeatures) -> Init {
167 Init { inner: ObjOps::heap_alloc(nativeInit {
168 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
171 impl Clone for Init {
172 fn clone(&self) -> Self {
174 inner: if <*mut nativeInit>::is_null(self.inner) { std::ptr::null_mut() } else {
175 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
181 /// Used only if an object of this type is returned as a trait impl by a method
182 pub(crate) extern "C" fn Init_clone_void(this_ptr: *const c_void) -> *mut c_void {
183 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInit)).clone() })) as *mut c_void
186 /// Creates a copy of the Init
187 pub extern "C" fn Init_clone(orig: &Init) -> Init {
191 use lightning::ln::msgs::ErrorMessage as nativeErrorMessageImport;
192 type nativeErrorMessage = nativeErrorMessageImport;
194 /// An error message to be sent or received from a peer
197 pub struct ErrorMessage {
198 /// A pointer to the opaque Rust object.
200 /// Nearly everywhere, inner must be non-null, however in places where
201 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
202 pub inner: *mut nativeErrorMessage,
203 /// Indicates that this is the only struct which contains the same pointer.
205 /// Rust functions which take ownership of an object provided via an argument require
206 /// this to be true and invalidate the object pointed to by inner.
210 impl Drop for ErrorMessage {
212 if self.is_owned && !<*mut nativeErrorMessage>::is_null(self.inner) {
213 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
217 /// Frees any resources used by the ErrorMessage, if is_owned is set and inner is non-NULL.
219 pub extern "C" fn ErrorMessage_free(this_obj: ErrorMessage) { }
221 /// Used only if an object of this type is returned as a trait impl by a method
222 extern "C" fn ErrorMessage_free_void(this_ptr: *mut c_void) {
223 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeErrorMessage); }
227 pub(crate) fn get_native_ref(&self) -> &'static nativeErrorMessage {
228 unsafe { &*ObjOps::untweak_ptr(self.inner) }
230 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeErrorMessage {
231 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
233 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
234 pub(crate) fn take_inner(mut self) -> *mut nativeErrorMessage {
235 assert!(self.is_owned);
236 let ret = ObjOps::untweak_ptr(self.inner);
237 self.inner = std::ptr::null_mut();
241 /// The channel ID involved in the error
243 pub extern "C" fn ErrorMessage_get_channel_id(this_ptr: &ErrorMessage) -> *const [u8; 32] {
244 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
247 /// The channel ID involved in the error
249 pub extern "C" fn ErrorMessage_set_channel_id(this_ptr: &mut ErrorMessage, mut val: crate::c_types::ThirtyTwoBytes) {
250 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
252 /// A possibly human-readable error description.
253 /// The string should be sanitized before it is used (e.g. emitted to logs
254 /// or printed to stdout). Otherwise, a well crafted error message may trigger a security
255 /// vulnerability in the terminal emulator or the logging subsystem.
257 pub extern "C" fn ErrorMessage_get_data(this_ptr: &ErrorMessage) -> crate::c_types::Str {
258 let mut inner_val = &mut this_ptr.get_native_mut_ref().data;
259 inner_val.as_str().into()
261 /// A possibly human-readable error description.
262 /// The string should be sanitized before it is used (e.g. emitted to logs
263 /// or printed to stdout). Otherwise, a well crafted error message may trigger a security
264 /// vulnerability in the terminal emulator or the logging subsystem.
266 pub extern "C" fn ErrorMessage_set_data(this_ptr: &mut ErrorMessage, mut val: crate::c_types::Str) {
267 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string();
269 /// Constructs a new ErrorMessage given each field
272 pub extern "C" fn ErrorMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::Str) -> ErrorMessage {
273 ErrorMessage { inner: ObjOps::heap_alloc(nativeErrorMessage {
274 channel_id: channel_id_arg.data,
275 data: data_arg.into_string(),
278 impl Clone for ErrorMessage {
279 fn clone(&self) -> Self {
281 inner: if <*mut nativeErrorMessage>::is_null(self.inner) { std::ptr::null_mut() } else {
282 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
288 /// Used only if an object of this type is returned as a trait impl by a method
289 pub(crate) extern "C" fn ErrorMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
290 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeErrorMessage)).clone() })) as *mut c_void
293 /// Creates a copy of the ErrorMessage
294 pub extern "C" fn ErrorMessage_clone(orig: &ErrorMessage) -> ErrorMessage {
298 use lightning::ln::msgs::Ping as nativePingImport;
299 type nativePing = nativePingImport;
301 /// A ping message to be sent or received from a peer
305 /// A pointer to the opaque Rust object.
307 /// Nearly everywhere, inner must be non-null, however in places where
308 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
309 pub inner: *mut nativePing,
310 /// Indicates that this is the only struct which contains the same pointer.
312 /// Rust functions which take ownership of an object provided via an argument require
313 /// this to be true and invalidate the object pointed to by inner.
319 if self.is_owned && !<*mut nativePing>::is_null(self.inner) {
320 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
324 /// Frees any resources used by the Ping, if is_owned is set and inner is non-NULL.
326 pub extern "C" fn Ping_free(this_obj: Ping) { }
328 /// Used only if an object of this type is returned as a trait impl by a method
329 extern "C" fn Ping_free_void(this_ptr: *mut c_void) {
330 unsafe { let _ = Box::from_raw(this_ptr as *mut nativePing); }
334 pub(crate) fn get_native_ref(&self) -> &'static nativePing {
335 unsafe { &*ObjOps::untweak_ptr(self.inner) }
337 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePing {
338 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
340 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
341 pub(crate) fn take_inner(mut self) -> *mut nativePing {
342 assert!(self.is_owned);
343 let ret = ObjOps::untweak_ptr(self.inner);
344 self.inner = std::ptr::null_mut();
348 /// The desired response length
350 pub extern "C" fn Ping_get_ponglen(this_ptr: &Ping) -> u16 {
351 let mut inner_val = &mut this_ptr.get_native_mut_ref().ponglen;
354 /// The desired response length
356 pub extern "C" fn Ping_set_ponglen(this_ptr: &mut Ping, mut val: u16) {
357 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.ponglen = val;
359 /// The ping packet size.
360 /// This field is not sent on the wire. byteslen zeros are sent.
362 pub extern "C" fn Ping_get_byteslen(this_ptr: &Ping) -> u16 {
363 let mut inner_val = &mut this_ptr.get_native_mut_ref().byteslen;
366 /// The ping packet size.
367 /// This field is not sent on the wire. byteslen zeros are sent.
369 pub extern "C" fn Ping_set_byteslen(this_ptr: &mut Ping, mut val: u16) {
370 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.byteslen = val;
372 /// Constructs a new Ping given each field
375 pub extern "C" fn Ping_new(mut ponglen_arg: u16, mut byteslen_arg: u16) -> Ping {
376 Ping { inner: ObjOps::heap_alloc(nativePing {
377 ponglen: ponglen_arg,
378 byteslen: byteslen_arg,
381 impl Clone for Ping {
382 fn clone(&self) -> Self {
384 inner: if <*mut nativePing>::is_null(self.inner) { std::ptr::null_mut() } else {
385 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
391 /// Used only if an object of this type is returned as a trait impl by a method
392 pub(crate) extern "C" fn Ping_clone_void(this_ptr: *const c_void) -> *mut c_void {
393 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePing)).clone() })) as *mut c_void
396 /// Creates a copy of the Ping
397 pub extern "C" fn Ping_clone(orig: &Ping) -> Ping {
401 use lightning::ln::msgs::Pong as nativePongImport;
402 type nativePong = nativePongImport;
404 /// A pong message to be sent or received from a peer
408 /// A pointer to the opaque Rust object.
410 /// Nearly everywhere, inner must be non-null, however in places where
411 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
412 pub inner: *mut nativePong,
413 /// Indicates that this is the only struct which contains the same pointer.
415 /// Rust functions which take ownership of an object provided via an argument require
416 /// this to be true and invalidate the object pointed to by inner.
422 if self.is_owned && !<*mut nativePong>::is_null(self.inner) {
423 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
427 /// Frees any resources used by the Pong, if is_owned is set and inner is non-NULL.
429 pub extern "C" fn Pong_free(this_obj: Pong) { }
431 /// Used only if an object of this type is returned as a trait impl by a method
432 extern "C" fn Pong_free_void(this_ptr: *mut c_void) {
433 unsafe { let _ = Box::from_raw(this_ptr as *mut nativePong); }
437 pub(crate) fn get_native_ref(&self) -> &'static nativePong {
438 unsafe { &*ObjOps::untweak_ptr(self.inner) }
440 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePong {
441 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
443 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
444 pub(crate) fn take_inner(mut self) -> *mut nativePong {
445 assert!(self.is_owned);
446 let ret = ObjOps::untweak_ptr(self.inner);
447 self.inner = std::ptr::null_mut();
451 /// The pong packet size.
452 /// This field is not sent on the wire. byteslen zeros are sent.
454 pub extern "C" fn Pong_get_byteslen(this_ptr: &Pong) -> u16 {
455 let mut inner_val = &mut this_ptr.get_native_mut_ref().byteslen;
458 /// The pong packet size.
459 /// This field is not sent on the wire. byteslen zeros are sent.
461 pub extern "C" fn Pong_set_byteslen(this_ptr: &mut Pong, mut val: u16) {
462 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.byteslen = val;
464 /// Constructs a new Pong given each field
467 pub extern "C" fn Pong_new(mut byteslen_arg: u16) -> Pong {
468 Pong { inner: ObjOps::heap_alloc(nativePong {
469 byteslen: byteslen_arg,
472 impl Clone for Pong {
473 fn clone(&self) -> Self {
475 inner: if <*mut nativePong>::is_null(self.inner) { std::ptr::null_mut() } else {
476 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
482 /// Used only if an object of this type is returned as a trait impl by a method
483 pub(crate) extern "C" fn Pong_clone_void(this_ptr: *const c_void) -> *mut c_void {
484 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePong)).clone() })) as *mut c_void
487 /// Creates a copy of the Pong
488 pub extern "C" fn Pong_clone(orig: &Pong) -> Pong {
492 use lightning::ln::msgs::OpenChannel as nativeOpenChannelImport;
493 type nativeOpenChannel = nativeOpenChannelImport;
495 /// An open_channel message to be sent or received from a peer
498 pub struct OpenChannel {
499 /// A pointer to the opaque Rust object.
501 /// Nearly everywhere, inner must be non-null, however in places where
502 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
503 pub inner: *mut nativeOpenChannel,
504 /// Indicates that this is the only struct which contains the same pointer.
506 /// Rust functions which take ownership of an object provided via an argument require
507 /// this to be true and invalidate the object pointed to by inner.
511 impl Drop for OpenChannel {
513 if self.is_owned && !<*mut nativeOpenChannel>::is_null(self.inner) {
514 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
518 /// Frees any resources used by the OpenChannel, if is_owned is set and inner is non-NULL.
520 pub extern "C" fn OpenChannel_free(this_obj: OpenChannel) { }
522 /// Used only if an object of this type is returned as a trait impl by a method
523 extern "C" fn OpenChannel_free_void(this_ptr: *mut c_void) {
524 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeOpenChannel); }
528 pub(crate) fn get_native_ref(&self) -> &'static nativeOpenChannel {
529 unsafe { &*ObjOps::untweak_ptr(self.inner) }
531 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOpenChannel {
532 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
534 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
535 pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannel {
536 assert!(self.is_owned);
537 let ret = ObjOps::untweak_ptr(self.inner);
538 self.inner = std::ptr::null_mut();
542 /// The genesis hash of the blockchain where the channel is to be opened
544 pub extern "C" fn OpenChannel_get_chain_hash(this_ptr: &OpenChannel) -> *const [u8; 32] {
545 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
548 /// The genesis hash of the blockchain where the channel is to be opened
550 pub extern "C" fn OpenChannel_set_chain_hash(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
551 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
553 /// A temporary channel ID, until the funding outpoint is announced
555 pub extern "C" fn OpenChannel_get_temporary_channel_id(this_ptr: &OpenChannel) -> *const [u8; 32] {
556 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
559 /// A temporary channel ID, until the funding outpoint is announced
561 pub extern "C" fn OpenChannel_set_temporary_channel_id(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
562 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
564 /// The channel value
566 pub extern "C" fn OpenChannel_get_funding_satoshis(this_ptr: &OpenChannel) -> u64 {
567 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis;
570 /// The channel value
572 pub extern "C" fn OpenChannel_set_funding_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
573 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val;
575 /// The amount to push to the counterparty as part of the open, in milli-satoshi
577 pub extern "C" fn OpenChannel_get_push_msat(this_ptr: &OpenChannel) -> u64 {
578 let mut inner_val = &mut this_ptr.get_native_mut_ref().push_msat;
581 /// The amount to push to the counterparty as part of the open, in milli-satoshi
583 pub extern "C" fn OpenChannel_set_push_msat(this_ptr: &mut OpenChannel, mut val: u64) {
584 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.push_msat = val;
586 /// The threshold below which outputs on transactions broadcast by sender will be omitted
588 pub extern "C" fn OpenChannel_get_dust_limit_satoshis(this_ptr: &OpenChannel) -> u64 {
589 let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
592 /// The threshold below which outputs on transactions broadcast by sender will be omitted
594 pub extern "C" fn OpenChannel_set_dust_limit_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
595 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
597 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
599 pub extern "C" fn OpenChannel_get_max_htlc_value_in_flight_msat(this_ptr: &OpenChannel) -> u64 {
600 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
603 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
605 pub extern "C" fn OpenChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut OpenChannel, mut val: u64) {
606 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
608 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
610 pub extern "C" fn OpenChannel_get_channel_reserve_satoshis(this_ptr: &OpenChannel) -> u64 {
611 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
614 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
616 pub extern "C" fn OpenChannel_set_channel_reserve_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
617 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
619 /// The minimum HTLC size incoming to sender, in milli-satoshi
621 pub extern "C" fn OpenChannel_get_htlc_minimum_msat(this_ptr: &OpenChannel) -> u64 {
622 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
625 /// The minimum HTLC size incoming to sender, in milli-satoshi
627 pub extern "C" fn OpenChannel_set_htlc_minimum_msat(this_ptr: &mut OpenChannel, mut val: u64) {
628 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
630 /// The feerate per 1000-weight of sender generated transactions, until updated by update_fee
632 pub extern "C" fn OpenChannel_get_feerate_per_kw(this_ptr: &OpenChannel) -> u32 {
633 let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
636 /// The feerate per 1000-weight of sender generated transactions, until updated by update_fee
638 pub extern "C" fn OpenChannel_set_feerate_per_kw(this_ptr: &mut OpenChannel, mut val: u32) {
639 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
641 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
643 pub extern "C" fn OpenChannel_get_to_self_delay(this_ptr: &OpenChannel) -> u16 {
644 let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
647 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
649 pub extern "C" fn OpenChannel_set_to_self_delay(this_ptr: &mut OpenChannel, mut val: u16) {
650 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
652 /// The maximum number of inbound HTLCs towards sender
654 pub extern "C" fn OpenChannel_get_max_accepted_htlcs(this_ptr: &OpenChannel) -> u16 {
655 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
658 /// The maximum number of inbound HTLCs towards sender
660 pub extern "C" fn OpenChannel_set_max_accepted_htlcs(this_ptr: &mut OpenChannel, mut val: u16) {
661 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
663 /// The sender's key controlling the funding transaction
665 pub extern "C" fn OpenChannel_get_funding_pubkey(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
666 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
667 crate::c_types::PublicKey::from_rust(&inner_val)
669 /// The sender's key controlling the funding transaction
671 pub extern "C" fn OpenChannel_set_funding_pubkey(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
672 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
674 /// Used to derive a revocation key for transactions broadcast by counterparty
676 pub extern "C" fn OpenChannel_get_revocation_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
677 let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
678 crate::c_types::PublicKey::from_rust(&inner_val)
680 /// Used to derive a revocation key for transactions broadcast by counterparty
682 pub extern "C" fn OpenChannel_set_revocation_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
683 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
685 /// A payment key to sender for transactions broadcast by counterparty
687 pub extern "C" fn OpenChannel_get_payment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
688 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_point;
689 crate::c_types::PublicKey::from_rust(&inner_val)
691 /// A payment key to sender for transactions broadcast by counterparty
693 pub extern "C" fn OpenChannel_set_payment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
694 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_point = val.into_rust();
696 /// Used to derive a payment key to sender for transactions broadcast by sender
698 pub extern "C" fn OpenChannel_get_delayed_payment_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
699 let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
700 crate::c_types::PublicKey::from_rust(&inner_val)
702 /// Used to derive a payment key to sender for transactions broadcast by sender
704 pub extern "C" fn OpenChannel_set_delayed_payment_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
705 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
707 /// Used to derive an HTLC payment key to sender
709 pub extern "C" fn OpenChannel_get_htlc_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
710 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
711 crate::c_types::PublicKey::from_rust(&inner_val)
713 /// Used to derive an HTLC payment key to sender
715 pub extern "C" fn OpenChannel_set_htlc_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
716 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
718 /// The first to-be-broadcast-by-sender transaction's per commitment point
720 pub extern "C" fn OpenChannel_get_first_per_commitment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
721 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
722 crate::c_types::PublicKey::from_rust(&inner_val)
724 /// The first to-be-broadcast-by-sender transaction's per commitment point
726 pub extern "C" fn OpenChannel_set_first_per_commitment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
727 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
731 pub extern "C" fn OpenChannel_get_channel_flags(this_ptr: &OpenChannel) -> u8 {
732 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_flags;
737 pub extern "C" fn OpenChannel_set_channel_flags(this_ptr: &mut OpenChannel, mut val: u8) {
738 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_flags = val;
740 impl Clone for OpenChannel {
741 fn clone(&self) -> Self {
743 inner: if <*mut nativeOpenChannel>::is_null(self.inner) { std::ptr::null_mut() } else {
744 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
750 /// Used only if an object of this type is returned as a trait impl by a method
751 pub(crate) extern "C" fn OpenChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
752 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOpenChannel)).clone() })) as *mut c_void
755 /// Creates a copy of the OpenChannel
756 pub extern "C" fn OpenChannel_clone(orig: &OpenChannel) -> OpenChannel {
760 use lightning::ln::msgs::AcceptChannel as nativeAcceptChannelImport;
761 type nativeAcceptChannel = nativeAcceptChannelImport;
763 /// An accept_channel message to be sent or received from a peer
766 pub struct AcceptChannel {
767 /// A pointer to the opaque Rust object.
769 /// Nearly everywhere, inner must be non-null, however in places where
770 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
771 pub inner: *mut nativeAcceptChannel,
772 /// Indicates that this is the only struct which contains the same pointer.
774 /// Rust functions which take ownership of an object provided via an argument require
775 /// this to be true and invalidate the object pointed to by inner.
779 impl Drop for AcceptChannel {
781 if self.is_owned && !<*mut nativeAcceptChannel>::is_null(self.inner) {
782 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
786 /// Frees any resources used by the AcceptChannel, if is_owned is set and inner is non-NULL.
788 pub extern "C" fn AcceptChannel_free(this_obj: AcceptChannel) { }
790 /// Used only if an object of this type is returned as a trait impl by a method
791 extern "C" fn AcceptChannel_free_void(this_ptr: *mut c_void) {
792 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeAcceptChannel); }
796 pub(crate) fn get_native_ref(&self) -> &'static nativeAcceptChannel {
797 unsafe { &*ObjOps::untweak_ptr(self.inner) }
799 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAcceptChannel {
800 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
802 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
803 pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannel {
804 assert!(self.is_owned);
805 let ret = ObjOps::untweak_ptr(self.inner);
806 self.inner = std::ptr::null_mut();
810 /// A temporary channel ID, until the funding outpoint is announced
812 pub extern "C" fn AcceptChannel_get_temporary_channel_id(this_ptr: &AcceptChannel) -> *const [u8; 32] {
813 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
816 /// A temporary channel ID, until the funding outpoint is announced
818 pub extern "C" fn AcceptChannel_set_temporary_channel_id(this_ptr: &mut AcceptChannel, mut val: crate::c_types::ThirtyTwoBytes) {
819 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
821 /// The threshold below which outputs on transactions broadcast by sender will be omitted
823 pub extern "C" fn AcceptChannel_get_dust_limit_satoshis(this_ptr: &AcceptChannel) -> u64 {
824 let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis;
827 /// The threshold below which outputs on transactions broadcast by sender will be omitted
829 pub extern "C" fn AcceptChannel_set_dust_limit_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
830 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val;
832 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
834 pub extern "C" fn AcceptChannel_get_max_htlc_value_in_flight_msat(this_ptr: &AcceptChannel) -> u64 {
835 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat;
838 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
840 pub extern "C" fn AcceptChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
841 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val;
843 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
845 pub extern "C" fn AcceptChannel_get_channel_reserve_satoshis(this_ptr: &AcceptChannel) -> u64 {
846 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis;
849 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
851 pub extern "C" fn AcceptChannel_set_channel_reserve_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
852 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val;
854 /// The minimum HTLC size incoming to sender, in milli-satoshi
856 pub extern "C" fn AcceptChannel_get_htlc_minimum_msat(this_ptr: &AcceptChannel) -> u64 {
857 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
860 /// The minimum HTLC size incoming to sender, in milli-satoshi
862 pub extern "C" fn AcceptChannel_set_htlc_minimum_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
863 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
865 /// Minimum depth of the funding transaction before the channel is considered open
867 pub extern "C" fn AcceptChannel_get_minimum_depth(this_ptr: &AcceptChannel) -> u32 {
868 let mut inner_val = &mut this_ptr.get_native_mut_ref().minimum_depth;
871 /// Minimum depth of the funding transaction before the channel is considered open
873 pub extern "C" fn AcceptChannel_set_minimum_depth(this_ptr: &mut AcceptChannel, mut val: u32) {
874 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.minimum_depth = val;
876 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
878 pub extern "C" fn AcceptChannel_get_to_self_delay(this_ptr: &AcceptChannel) -> u16 {
879 let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay;
882 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
884 pub extern "C" fn AcceptChannel_set_to_self_delay(this_ptr: &mut AcceptChannel, mut val: u16) {
885 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val;
887 /// The maximum number of inbound HTLCs towards sender
889 pub extern "C" fn AcceptChannel_get_max_accepted_htlcs(this_ptr: &AcceptChannel) -> u16 {
890 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs;
893 /// The maximum number of inbound HTLCs towards sender
895 pub extern "C" fn AcceptChannel_set_max_accepted_htlcs(this_ptr: &mut AcceptChannel, mut val: u16) {
896 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val;
898 /// The sender's key controlling the funding transaction
900 pub extern "C" fn AcceptChannel_get_funding_pubkey(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
901 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey;
902 crate::c_types::PublicKey::from_rust(&inner_val)
904 /// The sender's key controlling the funding transaction
906 pub extern "C" fn AcceptChannel_set_funding_pubkey(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
907 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust();
909 /// Used to derive a revocation key for transactions broadcast by counterparty
911 pub extern "C" fn AcceptChannel_get_revocation_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
912 let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint;
913 crate::c_types::PublicKey::from_rust(&inner_val)
915 /// Used to derive a revocation key for transactions broadcast by counterparty
917 pub extern "C" fn AcceptChannel_set_revocation_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
918 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust();
920 /// A payment key to sender for transactions broadcast by counterparty
922 pub extern "C" fn AcceptChannel_get_payment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
923 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_point;
924 crate::c_types::PublicKey::from_rust(&inner_val)
926 /// A payment key to sender for transactions broadcast by counterparty
928 pub extern "C" fn AcceptChannel_set_payment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
929 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_point = val.into_rust();
931 /// Used to derive a payment key to sender for transactions broadcast by sender
933 pub extern "C" fn AcceptChannel_get_delayed_payment_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
934 let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint;
935 crate::c_types::PublicKey::from_rust(&inner_val)
937 /// Used to derive a payment key to sender for transactions broadcast by sender
939 pub extern "C" fn AcceptChannel_set_delayed_payment_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
940 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust();
942 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
944 pub extern "C" fn AcceptChannel_get_htlc_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
945 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint;
946 crate::c_types::PublicKey::from_rust(&inner_val)
948 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
950 pub extern "C" fn AcceptChannel_set_htlc_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
951 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust();
953 /// The first to-be-broadcast-by-sender transaction's per commitment point
955 pub extern "C" fn AcceptChannel_get_first_per_commitment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
956 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point;
957 crate::c_types::PublicKey::from_rust(&inner_val)
959 /// The first to-be-broadcast-by-sender transaction's per commitment point
961 pub extern "C" fn AcceptChannel_set_first_per_commitment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
962 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
964 impl Clone for AcceptChannel {
965 fn clone(&self) -> Self {
967 inner: if <*mut nativeAcceptChannel>::is_null(self.inner) { std::ptr::null_mut() } else {
968 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
974 /// Used only if an object of this type is returned as a trait impl by a method
975 pub(crate) extern "C" fn AcceptChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
976 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAcceptChannel)).clone() })) as *mut c_void
979 /// Creates a copy of the AcceptChannel
980 pub extern "C" fn AcceptChannel_clone(orig: &AcceptChannel) -> AcceptChannel {
984 use lightning::ln::msgs::FundingCreated as nativeFundingCreatedImport;
985 type nativeFundingCreated = nativeFundingCreatedImport;
987 /// A funding_created message to be sent or received from a peer
990 pub struct FundingCreated {
991 /// A pointer to the opaque Rust object.
993 /// Nearly everywhere, inner must be non-null, however in places where
994 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
995 pub inner: *mut nativeFundingCreated,
996 /// Indicates that this is the only struct which contains the same pointer.
998 /// Rust functions which take ownership of an object provided via an argument require
999 /// this to be true and invalidate the object pointed to by inner.
1003 impl Drop for FundingCreated {
1004 fn drop(&mut self) {
1005 if self.is_owned && !<*mut nativeFundingCreated>::is_null(self.inner) {
1006 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1010 /// Frees any resources used by the FundingCreated, if is_owned is set and inner is non-NULL.
1012 pub extern "C" fn FundingCreated_free(this_obj: FundingCreated) { }
1014 /// Used only if an object of this type is returned as a trait impl by a method
1015 extern "C" fn FundingCreated_free_void(this_ptr: *mut c_void) {
1016 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingCreated); }
1019 impl FundingCreated {
1020 pub(crate) fn get_native_ref(&self) -> &'static nativeFundingCreated {
1021 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1023 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingCreated {
1024 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1026 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1027 pub(crate) fn take_inner(mut self) -> *mut nativeFundingCreated {
1028 assert!(self.is_owned);
1029 let ret = ObjOps::untweak_ptr(self.inner);
1030 self.inner = std::ptr::null_mut();
1034 /// A temporary channel ID, until the funding is established
1036 pub extern "C" fn FundingCreated_get_temporary_channel_id(this_ptr: &FundingCreated) -> *const [u8; 32] {
1037 let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id;
1040 /// A temporary channel ID, until the funding is established
1042 pub extern "C" fn FundingCreated_set_temporary_channel_id(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
1043 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data;
1045 /// The funding transaction ID
1047 pub extern "C" fn FundingCreated_get_funding_txid(this_ptr: &FundingCreated) -> *const [u8; 32] {
1048 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_txid;
1049 inner_val.as_inner()
1051 /// The funding transaction ID
1053 pub extern "C" fn FundingCreated_set_funding_txid(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
1054 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_txid = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
1056 /// The specific output index funding this channel
1058 pub extern "C" fn FundingCreated_get_funding_output_index(this_ptr: &FundingCreated) -> u16 {
1059 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_index;
1062 /// The specific output index funding this channel
1064 pub extern "C" fn FundingCreated_set_funding_output_index(this_ptr: &mut FundingCreated, mut val: u16) {
1065 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_index = val;
1067 /// The signature of the channel initiator (funder) on the funding transaction
1069 pub extern "C" fn FundingCreated_get_signature(this_ptr: &FundingCreated) -> crate::c_types::Signature {
1070 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
1071 crate::c_types::Signature::from_rust(&inner_val)
1073 /// The signature of the channel initiator (funder) on the funding transaction
1075 pub extern "C" fn FundingCreated_set_signature(this_ptr: &mut FundingCreated, mut val: crate::c_types::Signature) {
1076 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
1078 /// Constructs a new FundingCreated given each field
1081 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 {
1082 FundingCreated { inner: ObjOps::heap_alloc(nativeFundingCreated {
1083 temporary_channel_id: temporary_channel_id_arg.data,
1084 funding_txid: ::bitcoin::hash_types::Txid::from_slice(&funding_txid_arg.data[..]).unwrap(),
1085 funding_output_index: funding_output_index_arg,
1086 signature: signature_arg.into_rust(),
1087 }), is_owned: true }
1089 impl Clone for FundingCreated {
1090 fn clone(&self) -> Self {
1092 inner: if <*mut nativeFundingCreated>::is_null(self.inner) { std::ptr::null_mut() } else {
1093 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1099 /// Used only if an object of this type is returned as a trait impl by a method
1100 pub(crate) extern "C" fn FundingCreated_clone_void(this_ptr: *const c_void) -> *mut c_void {
1101 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingCreated)).clone() })) as *mut c_void
1104 /// Creates a copy of the FundingCreated
1105 pub extern "C" fn FundingCreated_clone(orig: &FundingCreated) -> FundingCreated {
1109 use lightning::ln::msgs::FundingSigned as nativeFundingSignedImport;
1110 type nativeFundingSigned = nativeFundingSignedImport;
1112 /// A funding_signed message to be sent or received from a peer
1115 pub struct FundingSigned {
1116 /// A pointer to the opaque Rust object.
1118 /// Nearly everywhere, inner must be non-null, however in places where
1119 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1120 pub inner: *mut nativeFundingSigned,
1121 /// Indicates that this is the only struct which contains the same pointer.
1123 /// Rust functions which take ownership of an object provided via an argument require
1124 /// this to be true and invalidate the object pointed to by inner.
1128 impl Drop for FundingSigned {
1129 fn drop(&mut self) {
1130 if self.is_owned && !<*mut nativeFundingSigned>::is_null(self.inner) {
1131 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1135 /// Frees any resources used by the FundingSigned, if is_owned is set and inner is non-NULL.
1137 pub extern "C" fn FundingSigned_free(this_obj: FundingSigned) { }
1139 /// Used only if an object of this type is returned as a trait impl by a method
1140 extern "C" fn FundingSigned_free_void(this_ptr: *mut c_void) {
1141 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingSigned); }
1144 impl FundingSigned {
1145 pub(crate) fn get_native_ref(&self) -> &'static nativeFundingSigned {
1146 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1148 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingSigned {
1149 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1151 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1152 pub(crate) fn take_inner(mut self) -> *mut nativeFundingSigned {
1153 assert!(self.is_owned);
1154 let ret = ObjOps::untweak_ptr(self.inner);
1155 self.inner = std::ptr::null_mut();
1161 pub extern "C" fn FundingSigned_get_channel_id(this_ptr: &FundingSigned) -> *const [u8; 32] {
1162 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1167 pub extern "C" fn FundingSigned_set_channel_id(this_ptr: &mut FundingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
1168 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1170 /// The signature of the channel acceptor (fundee) on the funding transaction
1172 pub extern "C" fn FundingSigned_get_signature(this_ptr: &FundingSigned) -> crate::c_types::Signature {
1173 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
1174 crate::c_types::Signature::from_rust(&inner_val)
1176 /// The signature of the channel acceptor (fundee) on the funding transaction
1178 pub extern "C" fn FundingSigned_set_signature(this_ptr: &mut FundingSigned, mut val: crate::c_types::Signature) {
1179 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
1181 /// Constructs a new FundingSigned given each field
1184 pub extern "C" fn FundingSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut signature_arg: crate::c_types::Signature) -> FundingSigned {
1185 FundingSigned { inner: ObjOps::heap_alloc(nativeFundingSigned {
1186 channel_id: channel_id_arg.data,
1187 signature: signature_arg.into_rust(),
1188 }), is_owned: true }
1190 impl Clone for FundingSigned {
1191 fn clone(&self) -> Self {
1193 inner: if <*mut nativeFundingSigned>::is_null(self.inner) { std::ptr::null_mut() } else {
1194 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1200 /// Used only if an object of this type is returned as a trait impl by a method
1201 pub(crate) extern "C" fn FundingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
1202 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingSigned)).clone() })) as *mut c_void
1205 /// Creates a copy of the FundingSigned
1206 pub extern "C" fn FundingSigned_clone(orig: &FundingSigned) -> FundingSigned {
1210 use lightning::ln::msgs::FundingLocked as nativeFundingLockedImport;
1211 type nativeFundingLocked = nativeFundingLockedImport;
1213 /// A funding_locked message to be sent or received from a peer
1216 pub struct FundingLocked {
1217 /// A pointer to the opaque Rust object.
1219 /// Nearly everywhere, inner must be non-null, however in places where
1220 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1221 pub inner: *mut nativeFundingLocked,
1222 /// Indicates that this is the only struct which contains the same pointer.
1224 /// Rust functions which take ownership of an object provided via an argument require
1225 /// this to be true and invalidate the object pointed to by inner.
1229 impl Drop for FundingLocked {
1230 fn drop(&mut self) {
1231 if self.is_owned && !<*mut nativeFundingLocked>::is_null(self.inner) {
1232 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1236 /// Frees any resources used by the FundingLocked, if is_owned is set and inner is non-NULL.
1238 pub extern "C" fn FundingLocked_free(this_obj: FundingLocked) { }
1240 /// Used only if an object of this type is returned as a trait impl by a method
1241 extern "C" fn FundingLocked_free_void(this_ptr: *mut c_void) {
1242 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingLocked); }
1245 impl FundingLocked {
1246 pub(crate) fn get_native_ref(&self) -> &'static nativeFundingLocked {
1247 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1249 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFundingLocked {
1250 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1252 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1253 pub(crate) fn take_inner(mut self) -> *mut nativeFundingLocked {
1254 assert!(self.is_owned);
1255 let ret = ObjOps::untweak_ptr(self.inner);
1256 self.inner = std::ptr::null_mut();
1262 pub extern "C" fn FundingLocked_get_channel_id(this_ptr: &FundingLocked) -> *const [u8; 32] {
1263 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1268 pub extern "C" fn FundingLocked_set_channel_id(this_ptr: &mut FundingLocked, mut val: crate::c_types::ThirtyTwoBytes) {
1269 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1271 /// The per-commitment point of the second commitment transaction
1273 pub extern "C" fn FundingLocked_get_next_per_commitment_point(this_ptr: &FundingLocked) -> crate::c_types::PublicKey {
1274 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
1275 crate::c_types::PublicKey::from_rust(&inner_val)
1277 /// The per-commitment point of the second commitment transaction
1279 pub extern "C" fn FundingLocked_set_next_per_commitment_point(this_ptr: &mut FundingLocked, mut val: crate::c_types::PublicKey) {
1280 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
1282 /// Constructs a new FundingLocked given each field
1285 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 {
1286 FundingLocked { inner: ObjOps::heap_alloc(nativeFundingLocked {
1287 channel_id: channel_id_arg.data,
1288 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
1289 }), is_owned: true }
1291 impl Clone for FundingLocked {
1292 fn clone(&self) -> Self {
1294 inner: if <*mut nativeFundingLocked>::is_null(self.inner) { std::ptr::null_mut() } else {
1295 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1301 /// Used only if an object of this type is returned as a trait impl by a method
1302 pub(crate) extern "C" fn FundingLocked_clone_void(this_ptr: *const c_void) -> *mut c_void {
1303 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingLocked)).clone() })) as *mut c_void
1306 /// Creates a copy of the FundingLocked
1307 pub extern "C" fn FundingLocked_clone(orig: &FundingLocked) -> FundingLocked {
1311 use lightning::ln::msgs::Shutdown as nativeShutdownImport;
1312 type nativeShutdown = nativeShutdownImport;
1314 /// A shutdown message to be sent or received from a peer
1317 pub struct Shutdown {
1318 /// A pointer to the opaque Rust object.
1320 /// Nearly everywhere, inner must be non-null, however in places where
1321 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1322 pub inner: *mut nativeShutdown,
1323 /// Indicates that this is the only struct which contains the same pointer.
1325 /// Rust functions which take ownership of an object provided via an argument require
1326 /// this to be true and invalidate the object pointed to by inner.
1330 impl Drop for Shutdown {
1331 fn drop(&mut self) {
1332 if self.is_owned && !<*mut nativeShutdown>::is_null(self.inner) {
1333 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1337 /// Frees any resources used by the Shutdown, if is_owned is set and inner is non-NULL.
1339 pub extern "C" fn Shutdown_free(this_obj: Shutdown) { }
1341 /// Used only if an object of this type is returned as a trait impl by a method
1342 extern "C" fn Shutdown_free_void(this_ptr: *mut c_void) {
1343 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeShutdown); }
1347 pub(crate) fn get_native_ref(&self) -> &'static nativeShutdown {
1348 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1350 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeShutdown {
1351 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1353 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1354 pub(crate) fn take_inner(mut self) -> *mut nativeShutdown {
1355 assert!(self.is_owned);
1356 let ret = ObjOps::untweak_ptr(self.inner);
1357 self.inner = std::ptr::null_mut();
1363 pub extern "C" fn Shutdown_get_channel_id(this_ptr: &Shutdown) -> *const [u8; 32] {
1364 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1369 pub extern "C" fn Shutdown_set_channel_id(this_ptr: &mut Shutdown, mut val: crate::c_types::ThirtyTwoBytes) {
1370 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1372 /// The destination of this peer's funds on closing.
1373 /// Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
1375 pub extern "C" fn Shutdown_get_scriptpubkey(this_ptr: &Shutdown) -> crate::c_types::u8slice {
1376 let mut inner_val = &mut this_ptr.get_native_mut_ref().scriptpubkey;
1377 crate::c_types::u8slice::from_slice(&inner_val[..])
1379 /// The destination of this peer's funds on closing.
1380 /// Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
1382 pub extern "C" fn Shutdown_set_scriptpubkey(this_ptr: &mut Shutdown, mut val: crate::c_types::derived::CVec_u8Z) {
1383 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.scriptpubkey = ::bitcoin::blockdata::script::Script::from(val.into_rust());
1385 /// Constructs a new Shutdown given each field
1388 pub extern "C" fn Shutdown_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut scriptpubkey_arg: crate::c_types::derived::CVec_u8Z) -> Shutdown {
1389 Shutdown { inner: ObjOps::heap_alloc(nativeShutdown {
1390 channel_id: channel_id_arg.data,
1391 scriptpubkey: ::bitcoin::blockdata::script::Script::from(scriptpubkey_arg.into_rust()),
1392 }), is_owned: true }
1394 impl Clone for Shutdown {
1395 fn clone(&self) -> Self {
1397 inner: if <*mut nativeShutdown>::is_null(self.inner) { std::ptr::null_mut() } else {
1398 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1404 /// Used only if an object of this type is returned as a trait impl by a method
1405 pub(crate) extern "C" fn Shutdown_clone_void(this_ptr: *const c_void) -> *mut c_void {
1406 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeShutdown)).clone() })) as *mut c_void
1409 /// Creates a copy of the Shutdown
1410 pub extern "C" fn Shutdown_clone(orig: &Shutdown) -> Shutdown {
1414 use lightning::ln::msgs::ClosingSignedFeeRange as nativeClosingSignedFeeRangeImport;
1415 type nativeClosingSignedFeeRange = nativeClosingSignedFeeRangeImport;
1417 /// The minimum and maximum fees which the sender is willing to place on the closing transaction.
1418 /// This is provided in [`ClosingSigned`] by both sides to indicate the fee range they are willing
1422 pub struct ClosingSignedFeeRange {
1423 /// A pointer to the opaque Rust object.
1425 /// Nearly everywhere, inner must be non-null, however in places where
1426 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1427 pub inner: *mut nativeClosingSignedFeeRange,
1428 /// Indicates that this is the only struct which contains the same pointer.
1430 /// Rust functions which take ownership of an object provided via an argument require
1431 /// this to be true and invalidate the object pointed to by inner.
1435 impl Drop for ClosingSignedFeeRange {
1436 fn drop(&mut self) {
1437 if self.is_owned && !<*mut nativeClosingSignedFeeRange>::is_null(self.inner) {
1438 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1442 /// Frees any resources used by the ClosingSignedFeeRange, if is_owned is set and inner is non-NULL.
1444 pub extern "C" fn ClosingSignedFeeRange_free(this_obj: ClosingSignedFeeRange) { }
1446 /// Used only if an object of this type is returned as a trait impl by a method
1447 extern "C" fn ClosingSignedFeeRange_free_void(this_ptr: *mut c_void) {
1448 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeClosingSignedFeeRange); }
1451 impl ClosingSignedFeeRange {
1452 pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSignedFeeRange {
1453 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1455 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSignedFeeRange {
1456 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1458 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1459 pub(crate) fn take_inner(mut self) -> *mut nativeClosingSignedFeeRange {
1460 assert!(self.is_owned);
1461 let ret = ObjOps::untweak_ptr(self.inner);
1462 self.inner = std::ptr::null_mut();
1466 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
1469 pub extern "C" fn ClosingSignedFeeRange_get_min_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
1470 let mut inner_val = &mut this_ptr.get_native_mut_ref().min_fee_satoshis;
1473 /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing
1476 pub extern "C" fn ClosingSignedFeeRange_set_min_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
1477 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_fee_satoshis = val;
1479 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
1482 pub extern "C" fn ClosingSignedFeeRange_get_max_fee_satoshis(this_ptr: &ClosingSignedFeeRange) -> u64 {
1483 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_fee_satoshis;
1486 /// The maximum absolute fee, in satoshis, which the sender is willing to place on the closing
1489 pub extern "C" fn ClosingSignedFeeRange_set_max_fee_satoshis(this_ptr: &mut ClosingSignedFeeRange, mut val: u64) {
1490 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_fee_satoshis = val;
1492 /// Constructs a new ClosingSignedFeeRange given each field
1495 pub extern "C" fn ClosingSignedFeeRange_new(mut min_fee_satoshis_arg: u64, mut max_fee_satoshis_arg: u64) -> ClosingSignedFeeRange {
1496 ClosingSignedFeeRange { inner: ObjOps::heap_alloc(nativeClosingSignedFeeRange {
1497 min_fee_satoshis: min_fee_satoshis_arg,
1498 max_fee_satoshis: max_fee_satoshis_arg,
1499 }), is_owned: true }
1501 impl Clone for ClosingSignedFeeRange {
1502 fn clone(&self) -> Self {
1504 inner: if <*mut nativeClosingSignedFeeRange>::is_null(self.inner) { std::ptr::null_mut() } else {
1505 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1511 /// Used only if an object of this type is returned as a trait impl by a method
1512 pub(crate) extern "C" fn ClosingSignedFeeRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
1513 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClosingSignedFeeRange)).clone() })) as *mut c_void
1516 /// Creates a copy of the ClosingSignedFeeRange
1517 pub extern "C" fn ClosingSignedFeeRange_clone(orig: &ClosingSignedFeeRange) -> ClosingSignedFeeRange {
1521 use lightning::ln::msgs::ClosingSigned as nativeClosingSignedImport;
1522 type nativeClosingSigned = nativeClosingSignedImport;
1524 /// A closing_signed message to be sent or received from a peer
1527 pub struct ClosingSigned {
1528 /// A pointer to the opaque Rust object.
1530 /// Nearly everywhere, inner must be non-null, however in places where
1531 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1532 pub inner: *mut nativeClosingSigned,
1533 /// Indicates that this is the only struct which contains the same pointer.
1535 /// Rust functions which take ownership of an object provided via an argument require
1536 /// this to be true and invalidate the object pointed to by inner.
1540 impl Drop for ClosingSigned {
1541 fn drop(&mut self) {
1542 if self.is_owned && !<*mut nativeClosingSigned>::is_null(self.inner) {
1543 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1547 /// Frees any resources used by the ClosingSigned, if is_owned is set and inner is non-NULL.
1549 pub extern "C" fn ClosingSigned_free(this_obj: ClosingSigned) { }
1551 /// Used only if an object of this type is returned as a trait impl by a method
1552 extern "C" fn ClosingSigned_free_void(this_ptr: *mut c_void) {
1553 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeClosingSigned); }
1556 impl ClosingSigned {
1557 pub(crate) fn get_native_ref(&self) -> &'static nativeClosingSigned {
1558 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1560 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingSigned {
1561 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1563 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1564 pub(crate) fn take_inner(mut self) -> *mut nativeClosingSigned {
1565 assert!(self.is_owned);
1566 let ret = ObjOps::untweak_ptr(self.inner);
1567 self.inner = std::ptr::null_mut();
1573 pub extern "C" fn ClosingSigned_get_channel_id(this_ptr: &ClosingSigned) -> *const [u8; 32] {
1574 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1579 pub extern "C" fn ClosingSigned_set_channel_id(this_ptr: &mut ClosingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
1580 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1582 /// The proposed total fee for the closing transaction
1584 pub extern "C" fn ClosingSigned_get_fee_satoshis(this_ptr: &ClosingSigned) -> u64 {
1585 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_satoshis;
1588 /// The proposed total fee for the closing transaction
1590 pub extern "C" fn ClosingSigned_set_fee_satoshis(this_ptr: &mut ClosingSigned, mut val: u64) {
1591 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_satoshis = val;
1593 /// A signature on the closing transaction
1595 pub extern "C" fn ClosingSigned_get_signature(this_ptr: &ClosingSigned) -> crate::c_types::Signature {
1596 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
1597 crate::c_types::Signature::from_rust(&inner_val)
1599 /// A signature on the closing transaction
1601 pub extern "C" fn ClosingSigned_set_signature(this_ptr: &mut ClosingSigned, mut val: crate::c_types::Signature) {
1602 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
1604 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
1607 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1609 pub extern "C" fn ClosingSigned_get_fee_range(this_ptr: &ClosingSigned) -> crate::lightning::ln::msgs::ClosingSignedFeeRange {
1610 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_range;
1611 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 };
1614 /// The minimum and maximum fees which the sender is willing to accept, provided only by new
1617 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1619 pub extern "C" fn ClosingSigned_set_fee_range(this_ptr: &mut ClosingSigned, mut val: crate::lightning::ln::msgs::ClosingSignedFeeRange) {
1620 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1621 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_range = local_val;
1623 /// Constructs a new ClosingSigned given each field
1626 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 {
1627 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()) } }) };
1628 ClosingSigned { inner: ObjOps::heap_alloc(nativeClosingSigned {
1629 channel_id: channel_id_arg.data,
1630 fee_satoshis: fee_satoshis_arg,
1631 signature: signature_arg.into_rust(),
1632 fee_range: local_fee_range_arg,
1633 }), is_owned: true }
1635 impl Clone for ClosingSigned {
1636 fn clone(&self) -> Self {
1638 inner: if <*mut nativeClosingSigned>::is_null(self.inner) { std::ptr::null_mut() } else {
1639 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1645 /// Used only if an object of this type is returned as a trait impl by a method
1646 pub(crate) extern "C" fn ClosingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
1647 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClosingSigned)).clone() })) as *mut c_void
1650 /// Creates a copy of the ClosingSigned
1651 pub extern "C" fn ClosingSigned_clone(orig: &ClosingSigned) -> ClosingSigned {
1655 use lightning::ln::msgs::UpdateAddHTLC as nativeUpdateAddHTLCImport;
1656 type nativeUpdateAddHTLC = nativeUpdateAddHTLCImport;
1658 /// An update_add_htlc message to be sent or received from a peer
1661 pub struct UpdateAddHTLC {
1662 /// A pointer to the opaque Rust object.
1664 /// Nearly everywhere, inner must be non-null, however in places where
1665 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1666 pub inner: *mut nativeUpdateAddHTLC,
1667 /// Indicates that this is the only struct which contains the same pointer.
1669 /// Rust functions which take ownership of an object provided via an argument require
1670 /// this to be true and invalidate the object pointed to by inner.
1674 impl Drop for UpdateAddHTLC {
1675 fn drop(&mut self) {
1676 if self.is_owned && !<*mut nativeUpdateAddHTLC>::is_null(self.inner) {
1677 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1681 /// Frees any resources used by the UpdateAddHTLC, if is_owned is set and inner is non-NULL.
1683 pub extern "C" fn UpdateAddHTLC_free(this_obj: UpdateAddHTLC) { }
1685 /// Used only if an object of this type is returned as a trait impl by a method
1686 extern "C" fn UpdateAddHTLC_free_void(this_ptr: *mut c_void) {
1687 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateAddHTLC); }
1690 impl UpdateAddHTLC {
1691 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateAddHTLC {
1692 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1694 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateAddHTLC {
1695 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1697 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1698 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateAddHTLC {
1699 assert!(self.is_owned);
1700 let ret = ObjOps::untweak_ptr(self.inner);
1701 self.inner = std::ptr::null_mut();
1707 pub extern "C" fn UpdateAddHTLC_get_channel_id(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
1708 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1713 pub extern "C" fn UpdateAddHTLC_set_channel_id(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1714 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1718 pub extern "C" fn UpdateAddHTLC_get_htlc_id(this_ptr: &UpdateAddHTLC) -> u64 {
1719 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
1724 pub extern "C" fn UpdateAddHTLC_set_htlc_id(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
1725 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
1727 /// The HTLC value in milli-satoshi
1729 pub extern "C" fn UpdateAddHTLC_get_amount_msat(this_ptr: &UpdateAddHTLC) -> u64 {
1730 let mut inner_val = &mut this_ptr.get_native_mut_ref().amount_msat;
1733 /// The HTLC value in milli-satoshi
1735 pub extern "C" fn UpdateAddHTLC_set_amount_msat(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
1736 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.amount_msat = val;
1738 /// The payment hash, the pre-image of which controls HTLC redemption
1740 pub extern "C" fn UpdateAddHTLC_get_payment_hash(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
1741 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_hash;
1744 /// The payment hash, the pre-image of which controls HTLC redemption
1746 pub extern "C" fn UpdateAddHTLC_set_payment_hash(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1747 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_hash = ::lightning::ln::PaymentHash(val.data);
1749 /// The expiry height of the HTLC
1751 pub extern "C" fn UpdateAddHTLC_get_cltv_expiry(this_ptr: &UpdateAddHTLC) -> u32 {
1752 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry;
1755 /// The expiry height of the HTLC
1757 pub extern "C" fn UpdateAddHTLC_set_cltv_expiry(this_ptr: &mut UpdateAddHTLC, mut val: u32) {
1758 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry = val;
1760 impl Clone for UpdateAddHTLC {
1761 fn clone(&self) -> Self {
1763 inner: if <*mut nativeUpdateAddHTLC>::is_null(self.inner) { std::ptr::null_mut() } else {
1764 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1770 /// Used only if an object of this type is returned as a trait impl by a method
1771 pub(crate) extern "C" fn UpdateAddHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1772 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateAddHTLC)).clone() })) as *mut c_void
1775 /// Creates a copy of the UpdateAddHTLC
1776 pub extern "C" fn UpdateAddHTLC_clone(orig: &UpdateAddHTLC) -> UpdateAddHTLC {
1780 use lightning::ln::msgs::UpdateFulfillHTLC as nativeUpdateFulfillHTLCImport;
1781 type nativeUpdateFulfillHTLC = nativeUpdateFulfillHTLCImport;
1783 /// An update_fulfill_htlc message to be sent or received from a peer
1786 pub struct UpdateFulfillHTLC {
1787 /// A pointer to the opaque Rust object.
1789 /// Nearly everywhere, inner must be non-null, however in places where
1790 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1791 pub inner: *mut nativeUpdateFulfillHTLC,
1792 /// Indicates that this is the only struct which contains the same pointer.
1794 /// Rust functions which take ownership of an object provided via an argument require
1795 /// this to be true and invalidate the object pointed to by inner.
1799 impl Drop for UpdateFulfillHTLC {
1800 fn drop(&mut self) {
1801 if self.is_owned && !<*mut nativeUpdateFulfillHTLC>::is_null(self.inner) {
1802 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1806 /// Frees any resources used by the UpdateFulfillHTLC, if is_owned is set and inner is non-NULL.
1808 pub extern "C" fn UpdateFulfillHTLC_free(this_obj: UpdateFulfillHTLC) { }
1810 /// Used only if an object of this type is returned as a trait impl by a method
1811 extern "C" fn UpdateFulfillHTLC_free_void(this_ptr: *mut c_void) {
1812 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFulfillHTLC); }
1815 impl UpdateFulfillHTLC {
1816 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFulfillHTLC {
1817 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1819 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFulfillHTLC {
1820 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1822 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1823 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFulfillHTLC {
1824 assert!(self.is_owned);
1825 let ret = ObjOps::untweak_ptr(self.inner);
1826 self.inner = std::ptr::null_mut();
1832 pub extern "C" fn UpdateFulfillHTLC_get_channel_id(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
1833 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1838 pub extern "C" fn UpdateFulfillHTLC_set_channel_id(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1839 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1843 pub extern "C" fn UpdateFulfillHTLC_get_htlc_id(this_ptr: &UpdateFulfillHTLC) -> u64 {
1844 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
1849 pub extern "C" fn UpdateFulfillHTLC_set_htlc_id(this_ptr: &mut UpdateFulfillHTLC, mut val: u64) {
1850 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
1852 /// The pre-image of the payment hash, allowing HTLC redemption
1854 pub extern "C" fn UpdateFulfillHTLC_get_payment_preimage(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
1855 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_preimage;
1858 /// The pre-image of the payment hash, allowing HTLC redemption
1860 pub extern "C" fn UpdateFulfillHTLC_set_payment_preimage(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1861 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_preimage = ::lightning::ln::PaymentPreimage(val.data);
1863 /// Constructs a new UpdateFulfillHTLC given each field
1866 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 {
1867 UpdateFulfillHTLC { inner: ObjOps::heap_alloc(nativeUpdateFulfillHTLC {
1868 channel_id: channel_id_arg.data,
1869 htlc_id: htlc_id_arg,
1870 payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_arg.data),
1871 }), is_owned: true }
1873 impl Clone for UpdateFulfillHTLC {
1874 fn clone(&self) -> Self {
1876 inner: if <*mut nativeUpdateFulfillHTLC>::is_null(self.inner) { std::ptr::null_mut() } else {
1877 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1883 /// Used only if an object of this type is returned as a trait impl by a method
1884 pub(crate) extern "C" fn UpdateFulfillHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1885 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFulfillHTLC)).clone() })) as *mut c_void
1888 /// Creates a copy of the UpdateFulfillHTLC
1889 pub extern "C" fn UpdateFulfillHTLC_clone(orig: &UpdateFulfillHTLC) -> UpdateFulfillHTLC {
1893 use lightning::ln::msgs::UpdateFailHTLC as nativeUpdateFailHTLCImport;
1894 type nativeUpdateFailHTLC = nativeUpdateFailHTLCImport;
1896 /// An update_fail_htlc message to be sent or received from a peer
1899 pub struct UpdateFailHTLC {
1900 /// A pointer to the opaque Rust object.
1902 /// Nearly everywhere, inner must be non-null, however in places where
1903 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1904 pub inner: *mut nativeUpdateFailHTLC,
1905 /// Indicates that this is the only struct which contains the same pointer.
1907 /// Rust functions which take ownership of an object provided via an argument require
1908 /// this to be true and invalidate the object pointed to by inner.
1912 impl Drop for UpdateFailHTLC {
1913 fn drop(&mut self) {
1914 if self.is_owned && !<*mut nativeUpdateFailHTLC>::is_null(self.inner) {
1915 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1919 /// Frees any resources used by the UpdateFailHTLC, if is_owned is set and inner is non-NULL.
1921 pub extern "C" fn UpdateFailHTLC_free(this_obj: UpdateFailHTLC) { }
1923 /// Used only if an object of this type is returned as a trait impl by a method
1924 extern "C" fn UpdateFailHTLC_free_void(this_ptr: *mut c_void) {
1925 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFailHTLC); }
1928 impl UpdateFailHTLC {
1929 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailHTLC {
1930 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1932 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailHTLC {
1933 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1935 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1936 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailHTLC {
1937 assert!(self.is_owned);
1938 let ret = ObjOps::untweak_ptr(self.inner);
1939 self.inner = std::ptr::null_mut();
1945 pub extern "C" fn UpdateFailHTLC_get_channel_id(this_ptr: &UpdateFailHTLC) -> *const [u8; 32] {
1946 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1951 pub extern "C" fn UpdateFailHTLC_set_channel_id(this_ptr: &mut UpdateFailHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1952 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
1956 pub extern "C" fn UpdateFailHTLC_get_htlc_id(this_ptr: &UpdateFailHTLC) -> u64 {
1957 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
1962 pub extern "C" fn UpdateFailHTLC_set_htlc_id(this_ptr: &mut UpdateFailHTLC, mut val: u64) {
1963 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
1965 impl Clone for UpdateFailHTLC {
1966 fn clone(&self) -> Self {
1968 inner: if <*mut nativeUpdateFailHTLC>::is_null(self.inner) { std::ptr::null_mut() } else {
1969 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1975 /// Used only if an object of this type is returned as a trait impl by a method
1976 pub(crate) extern "C" fn UpdateFailHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1977 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailHTLC)).clone() })) as *mut c_void
1980 /// Creates a copy of the UpdateFailHTLC
1981 pub extern "C" fn UpdateFailHTLC_clone(orig: &UpdateFailHTLC) -> UpdateFailHTLC {
1985 use lightning::ln::msgs::UpdateFailMalformedHTLC as nativeUpdateFailMalformedHTLCImport;
1986 type nativeUpdateFailMalformedHTLC = nativeUpdateFailMalformedHTLCImport;
1988 /// An update_fail_malformed_htlc message to be sent or received from a peer
1991 pub struct UpdateFailMalformedHTLC {
1992 /// A pointer to the opaque Rust object.
1994 /// Nearly everywhere, inner must be non-null, however in places where
1995 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1996 pub inner: *mut nativeUpdateFailMalformedHTLC,
1997 /// Indicates that this is the only struct which contains the same pointer.
1999 /// Rust functions which take ownership of an object provided via an argument require
2000 /// this to be true and invalidate the object pointed to by inner.
2004 impl Drop for UpdateFailMalformedHTLC {
2005 fn drop(&mut self) {
2006 if self.is_owned && !<*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) {
2007 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2011 /// Frees any resources used by the UpdateFailMalformedHTLC, if is_owned is set and inner is non-NULL.
2013 pub extern "C" fn UpdateFailMalformedHTLC_free(this_obj: UpdateFailMalformedHTLC) { }
2015 /// Used only if an object of this type is returned as a trait impl by a method
2016 extern "C" fn UpdateFailMalformedHTLC_free_void(this_ptr: *mut c_void) {
2017 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFailMalformedHTLC); }
2020 impl UpdateFailMalformedHTLC {
2021 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailMalformedHTLC {
2022 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2024 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailMalformedHTLC {
2025 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2027 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2028 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailMalformedHTLC {
2029 assert!(self.is_owned);
2030 let ret = ObjOps::untweak_ptr(self.inner);
2031 self.inner = std::ptr::null_mut();
2037 pub extern "C" fn UpdateFailMalformedHTLC_get_channel_id(this_ptr: &UpdateFailMalformedHTLC) -> *const [u8; 32] {
2038 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2043 pub extern "C" fn UpdateFailMalformedHTLC_set_channel_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
2044 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2048 pub extern "C" fn UpdateFailMalformedHTLC_get_htlc_id(this_ptr: &UpdateFailMalformedHTLC) -> u64 {
2049 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
2054 pub extern "C" fn UpdateFailMalformedHTLC_set_htlc_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u64) {
2055 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
2057 /// The failure code
2059 pub extern "C" fn UpdateFailMalformedHTLC_get_failure_code(this_ptr: &UpdateFailMalformedHTLC) -> u16 {
2060 let mut inner_val = &mut this_ptr.get_native_mut_ref().failure_code;
2063 /// The failure code
2065 pub extern "C" fn UpdateFailMalformedHTLC_set_failure_code(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u16) {
2066 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.failure_code = val;
2068 impl Clone for UpdateFailMalformedHTLC {
2069 fn clone(&self) -> Self {
2071 inner: if <*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) { std::ptr::null_mut() } else {
2072 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2078 /// Used only if an object of this type is returned as a trait impl by a method
2079 pub(crate) extern "C" fn UpdateFailMalformedHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
2080 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailMalformedHTLC)).clone() })) as *mut c_void
2083 /// Creates a copy of the UpdateFailMalformedHTLC
2084 pub extern "C" fn UpdateFailMalformedHTLC_clone(orig: &UpdateFailMalformedHTLC) -> UpdateFailMalformedHTLC {
2088 use lightning::ln::msgs::CommitmentSigned as nativeCommitmentSignedImport;
2089 type nativeCommitmentSigned = nativeCommitmentSignedImport;
2091 /// A commitment_signed message to be sent or received from a peer
2094 pub struct CommitmentSigned {
2095 /// A pointer to the opaque Rust object.
2097 /// Nearly everywhere, inner must be non-null, however in places where
2098 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2099 pub inner: *mut nativeCommitmentSigned,
2100 /// Indicates that this is the only struct which contains the same pointer.
2102 /// Rust functions which take ownership of an object provided via an argument require
2103 /// this to be true and invalidate the object pointed to by inner.
2107 impl Drop for CommitmentSigned {
2108 fn drop(&mut self) {
2109 if self.is_owned && !<*mut nativeCommitmentSigned>::is_null(self.inner) {
2110 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2114 /// Frees any resources used by the CommitmentSigned, if is_owned is set and inner is non-NULL.
2116 pub extern "C" fn CommitmentSigned_free(this_obj: CommitmentSigned) { }
2118 /// Used only if an object of this type is returned as a trait impl by a method
2119 extern "C" fn CommitmentSigned_free_void(this_ptr: *mut c_void) {
2120 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentSigned); }
2123 impl CommitmentSigned {
2124 pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentSigned {
2125 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2127 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentSigned {
2128 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2130 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2131 pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentSigned {
2132 assert!(self.is_owned);
2133 let ret = ObjOps::untweak_ptr(self.inner);
2134 self.inner = std::ptr::null_mut();
2140 pub extern "C" fn CommitmentSigned_get_channel_id(this_ptr: &CommitmentSigned) -> *const [u8; 32] {
2141 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2146 pub extern "C" fn CommitmentSigned_set_channel_id(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::ThirtyTwoBytes) {
2147 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2149 /// A signature on the commitment transaction
2151 pub extern "C" fn CommitmentSigned_get_signature(this_ptr: &CommitmentSigned) -> crate::c_types::Signature {
2152 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
2153 crate::c_types::Signature::from_rust(&inner_val)
2155 /// A signature on the commitment transaction
2157 pub extern "C" fn CommitmentSigned_set_signature(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::Signature) {
2158 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
2160 /// Signatures on the HTLC transactions
2162 pub extern "C" fn CommitmentSigned_set_htlc_signatures(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::derived::CVec_SignatureZ) {
2163 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_rust() }); };
2164 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_signatures = local_val;
2166 /// Constructs a new CommitmentSigned given each field
2169 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 {
2170 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() }); };
2171 CommitmentSigned { inner: ObjOps::heap_alloc(nativeCommitmentSigned {
2172 channel_id: channel_id_arg.data,
2173 signature: signature_arg.into_rust(),
2174 htlc_signatures: local_htlc_signatures_arg,
2175 }), is_owned: true }
2177 impl Clone for CommitmentSigned {
2178 fn clone(&self) -> Self {
2180 inner: if <*mut nativeCommitmentSigned>::is_null(self.inner) { std::ptr::null_mut() } else {
2181 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2187 /// Used only if an object of this type is returned as a trait impl by a method
2188 pub(crate) extern "C" fn CommitmentSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
2189 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentSigned)).clone() })) as *mut c_void
2192 /// Creates a copy of the CommitmentSigned
2193 pub extern "C" fn CommitmentSigned_clone(orig: &CommitmentSigned) -> CommitmentSigned {
2197 use lightning::ln::msgs::RevokeAndACK as nativeRevokeAndACKImport;
2198 type nativeRevokeAndACK = nativeRevokeAndACKImport;
2200 /// A revoke_and_ack message to be sent or received from a peer
2203 pub struct RevokeAndACK {
2204 /// A pointer to the opaque Rust object.
2206 /// Nearly everywhere, inner must be non-null, however in places where
2207 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2208 pub inner: *mut nativeRevokeAndACK,
2209 /// Indicates that this is the only struct which contains the same pointer.
2211 /// Rust functions which take ownership of an object provided via an argument require
2212 /// this to be true and invalidate the object pointed to by inner.
2216 impl Drop for RevokeAndACK {
2217 fn drop(&mut self) {
2218 if self.is_owned && !<*mut nativeRevokeAndACK>::is_null(self.inner) {
2219 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2223 /// Frees any resources used by the RevokeAndACK, if is_owned is set and inner is non-NULL.
2225 pub extern "C" fn RevokeAndACK_free(this_obj: RevokeAndACK) { }
2227 /// Used only if an object of this type is returned as a trait impl by a method
2228 extern "C" fn RevokeAndACK_free_void(this_ptr: *mut c_void) {
2229 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRevokeAndACK); }
2233 pub(crate) fn get_native_ref(&self) -> &'static nativeRevokeAndACK {
2234 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2236 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRevokeAndACK {
2237 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2239 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2240 pub(crate) fn take_inner(mut self) -> *mut nativeRevokeAndACK {
2241 assert!(self.is_owned);
2242 let ret = ObjOps::untweak_ptr(self.inner);
2243 self.inner = std::ptr::null_mut();
2249 pub extern "C" fn RevokeAndACK_get_channel_id(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
2250 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2255 pub extern "C" fn RevokeAndACK_set_channel_id(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
2256 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2258 /// The secret corresponding to the per-commitment point
2260 pub extern "C" fn RevokeAndACK_get_per_commitment_secret(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
2261 let mut inner_val = &mut this_ptr.get_native_mut_ref().per_commitment_secret;
2264 /// The secret corresponding to the per-commitment point
2266 pub extern "C" fn RevokeAndACK_set_per_commitment_secret(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
2267 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.per_commitment_secret = val.data;
2269 /// The next sender-broadcast commitment transaction's per-commitment point
2271 pub extern "C" fn RevokeAndACK_get_next_per_commitment_point(this_ptr: &RevokeAndACK) -> crate::c_types::PublicKey {
2272 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_per_commitment_point;
2273 crate::c_types::PublicKey::from_rust(&inner_val)
2275 /// The next sender-broadcast commitment transaction's per-commitment point
2277 pub extern "C" fn RevokeAndACK_set_next_per_commitment_point(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::PublicKey) {
2278 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_per_commitment_point = val.into_rust();
2280 /// Constructs a new RevokeAndACK given each field
2283 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 {
2284 RevokeAndACK { inner: ObjOps::heap_alloc(nativeRevokeAndACK {
2285 channel_id: channel_id_arg.data,
2286 per_commitment_secret: per_commitment_secret_arg.data,
2287 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
2288 }), is_owned: true }
2290 impl Clone for RevokeAndACK {
2291 fn clone(&self) -> Self {
2293 inner: if <*mut nativeRevokeAndACK>::is_null(self.inner) { std::ptr::null_mut() } else {
2294 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2300 /// Used only if an object of this type is returned as a trait impl by a method
2301 pub(crate) extern "C" fn RevokeAndACK_clone_void(this_ptr: *const c_void) -> *mut c_void {
2302 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRevokeAndACK)).clone() })) as *mut c_void
2305 /// Creates a copy of the RevokeAndACK
2306 pub extern "C" fn RevokeAndACK_clone(orig: &RevokeAndACK) -> RevokeAndACK {
2310 use lightning::ln::msgs::UpdateFee as nativeUpdateFeeImport;
2311 type nativeUpdateFee = nativeUpdateFeeImport;
2313 /// An update_fee message to be sent or received from a peer
2316 pub struct UpdateFee {
2317 /// A pointer to the opaque Rust object.
2319 /// Nearly everywhere, inner must be non-null, however in places where
2320 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2321 pub inner: *mut nativeUpdateFee,
2322 /// Indicates that this is the only struct which contains the same pointer.
2324 /// Rust functions which take ownership of an object provided via an argument require
2325 /// this to be true and invalidate the object pointed to by inner.
2329 impl Drop for UpdateFee {
2330 fn drop(&mut self) {
2331 if self.is_owned && !<*mut nativeUpdateFee>::is_null(self.inner) {
2332 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2336 /// Frees any resources used by the UpdateFee, if is_owned is set and inner is non-NULL.
2338 pub extern "C" fn UpdateFee_free(this_obj: UpdateFee) { }
2340 /// Used only if an object of this type is returned as a trait impl by a method
2341 extern "C" fn UpdateFee_free_void(this_ptr: *mut c_void) {
2342 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFee); }
2346 pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFee {
2347 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2349 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFee {
2350 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2352 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2353 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFee {
2354 assert!(self.is_owned);
2355 let ret = ObjOps::untweak_ptr(self.inner);
2356 self.inner = std::ptr::null_mut();
2362 pub extern "C" fn UpdateFee_get_channel_id(this_ptr: &UpdateFee) -> *const [u8; 32] {
2363 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2368 pub extern "C" fn UpdateFee_set_channel_id(this_ptr: &mut UpdateFee, mut val: crate::c_types::ThirtyTwoBytes) {
2369 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2371 /// Fee rate per 1000-weight of the transaction
2373 pub extern "C" fn UpdateFee_get_feerate_per_kw(this_ptr: &UpdateFee) -> u32 {
2374 let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw;
2377 /// Fee rate per 1000-weight of the transaction
2379 pub extern "C" fn UpdateFee_set_feerate_per_kw(this_ptr: &mut UpdateFee, mut val: u32) {
2380 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val;
2382 /// Constructs a new UpdateFee given each field
2385 pub extern "C" fn UpdateFee_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut feerate_per_kw_arg: u32) -> UpdateFee {
2386 UpdateFee { inner: ObjOps::heap_alloc(nativeUpdateFee {
2387 channel_id: channel_id_arg.data,
2388 feerate_per_kw: feerate_per_kw_arg,
2389 }), is_owned: true }
2391 impl Clone for UpdateFee {
2392 fn clone(&self) -> Self {
2394 inner: if <*mut nativeUpdateFee>::is_null(self.inner) { std::ptr::null_mut() } else {
2395 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2401 /// Used only if an object of this type is returned as a trait impl by a method
2402 pub(crate) extern "C" fn UpdateFee_clone_void(this_ptr: *const c_void) -> *mut c_void {
2403 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFee)).clone() })) as *mut c_void
2406 /// Creates a copy of the UpdateFee
2407 pub extern "C" fn UpdateFee_clone(orig: &UpdateFee) -> UpdateFee {
2411 use lightning::ln::msgs::DataLossProtect as nativeDataLossProtectImport;
2412 type nativeDataLossProtect = nativeDataLossProtectImport;
2414 /// Proof that the sender knows the per-commitment secret of the previous commitment transaction.
2415 /// This is used to convince the recipient that the channel is at a certain commitment
2416 /// number even if they lost that data due to a local failure. Of course, the peer may lie
2417 /// and even later commitments may have been revoked.
2420 pub struct DataLossProtect {
2421 /// A pointer to the opaque Rust object.
2423 /// Nearly everywhere, inner must be non-null, however in places where
2424 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2425 pub inner: *mut nativeDataLossProtect,
2426 /// Indicates that this is the only struct which contains the same pointer.
2428 /// Rust functions which take ownership of an object provided via an argument require
2429 /// this to be true and invalidate the object pointed to by inner.
2433 impl Drop for DataLossProtect {
2434 fn drop(&mut self) {
2435 if self.is_owned && !<*mut nativeDataLossProtect>::is_null(self.inner) {
2436 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2440 /// Frees any resources used by the DataLossProtect, if is_owned is set and inner is non-NULL.
2442 pub extern "C" fn DataLossProtect_free(this_obj: DataLossProtect) { }
2444 /// Used only if an object of this type is returned as a trait impl by a method
2445 extern "C" fn DataLossProtect_free_void(this_ptr: *mut c_void) {
2446 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDataLossProtect); }
2449 impl DataLossProtect {
2450 pub(crate) fn get_native_ref(&self) -> &'static nativeDataLossProtect {
2451 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2453 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeDataLossProtect {
2454 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2456 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2457 pub(crate) fn take_inner(mut self) -> *mut nativeDataLossProtect {
2458 assert!(self.is_owned);
2459 let ret = ObjOps::untweak_ptr(self.inner);
2460 self.inner = std::ptr::null_mut();
2464 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
2465 /// belonging to the recipient
2467 pub extern "C" fn DataLossProtect_get_your_last_per_commitment_secret(this_ptr: &DataLossProtect) -> *const [u8; 32] {
2468 let mut inner_val = &mut this_ptr.get_native_mut_ref().your_last_per_commitment_secret;
2471 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
2472 /// belonging to the recipient
2474 pub extern "C" fn DataLossProtect_set_your_last_per_commitment_secret(this_ptr: &mut DataLossProtect, mut val: crate::c_types::ThirtyTwoBytes) {
2475 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.your_last_per_commitment_secret = val.data;
2477 /// The sender's per-commitment point for their current commitment transaction
2479 pub extern "C" fn DataLossProtect_get_my_current_per_commitment_point(this_ptr: &DataLossProtect) -> crate::c_types::PublicKey {
2480 let mut inner_val = &mut this_ptr.get_native_mut_ref().my_current_per_commitment_point;
2481 crate::c_types::PublicKey::from_rust(&inner_val)
2483 /// The sender's per-commitment point for their current commitment transaction
2485 pub extern "C" fn DataLossProtect_set_my_current_per_commitment_point(this_ptr: &mut DataLossProtect, mut val: crate::c_types::PublicKey) {
2486 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.my_current_per_commitment_point = val.into_rust();
2488 /// Constructs a new DataLossProtect given each field
2491 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 {
2492 DataLossProtect { inner: ObjOps::heap_alloc(nativeDataLossProtect {
2493 your_last_per_commitment_secret: your_last_per_commitment_secret_arg.data,
2494 my_current_per_commitment_point: my_current_per_commitment_point_arg.into_rust(),
2495 }), is_owned: true }
2497 impl Clone for DataLossProtect {
2498 fn clone(&self) -> Self {
2500 inner: if <*mut nativeDataLossProtect>::is_null(self.inner) { std::ptr::null_mut() } else {
2501 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2507 /// Used only if an object of this type is returned as a trait impl by a method
2508 pub(crate) extern "C" fn DataLossProtect_clone_void(this_ptr: *const c_void) -> *mut c_void {
2509 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDataLossProtect)).clone() })) as *mut c_void
2512 /// Creates a copy of the DataLossProtect
2513 pub extern "C" fn DataLossProtect_clone(orig: &DataLossProtect) -> DataLossProtect {
2517 use lightning::ln::msgs::ChannelReestablish as nativeChannelReestablishImport;
2518 type nativeChannelReestablish = nativeChannelReestablishImport;
2520 /// A channel_reestablish message to be sent or received from a peer
2523 pub struct ChannelReestablish {
2524 /// A pointer to the opaque Rust object.
2526 /// Nearly everywhere, inner must be non-null, however in places where
2527 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2528 pub inner: *mut nativeChannelReestablish,
2529 /// Indicates that this is the only struct which contains the same pointer.
2531 /// Rust functions which take ownership of an object provided via an argument require
2532 /// this to be true and invalidate the object pointed to by inner.
2536 impl Drop for ChannelReestablish {
2537 fn drop(&mut self) {
2538 if self.is_owned && !<*mut nativeChannelReestablish>::is_null(self.inner) {
2539 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2543 /// Frees any resources used by the ChannelReestablish, if is_owned is set and inner is non-NULL.
2545 pub extern "C" fn ChannelReestablish_free(this_obj: ChannelReestablish) { }
2547 /// Used only if an object of this type is returned as a trait impl by a method
2548 extern "C" fn ChannelReestablish_free_void(this_ptr: *mut c_void) {
2549 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelReestablish); }
2552 impl ChannelReestablish {
2553 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelReestablish {
2554 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2556 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelReestablish {
2557 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2559 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2560 pub(crate) fn take_inner(mut self) -> *mut nativeChannelReestablish {
2561 assert!(self.is_owned);
2562 let ret = ObjOps::untweak_ptr(self.inner);
2563 self.inner = std::ptr::null_mut();
2569 pub extern "C" fn ChannelReestablish_get_channel_id(this_ptr: &ChannelReestablish) -> *const [u8; 32] {
2570 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2575 pub extern "C" fn ChannelReestablish_set_channel_id(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) {
2576 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2578 /// The next commitment number for the sender
2580 pub extern "C" fn ChannelReestablish_get_next_local_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
2581 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_local_commitment_number;
2584 /// The next commitment number for the sender
2586 pub extern "C" fn ChannelReestablish_set_next_local_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
2587 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_local_commitment_number = val;
2589 /// The next commitment number for the recipient
2591 pub extern "C" fn ChannelReestablish_get_next_remote_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
2592 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_remote_commitment_number;
2595 /// The next commitment number for the recipient
2597 pub extern "C" fn ChannelReestablish_set_next_remote_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
2598 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_remote_commitment_number = val;
2600 impl Clone for ChannelReestablish {
2601 fn clone(&self) -> Self {
2603 inner: if <*mut nativeChannelReestablish>::is_null(self.inner) { std::ptr::null_mut() } else {
2604 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2610 /// Used only if an object of this type is returned as a trait impl by a method
2611 pub(crate) extern "C" fn ChannelReestablish_clone_void(this_ptr: *const c_void) -> *mut c_void {
2612 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelReestablish)).clone() })) as *mut c_void
2615 /// Creates a copy of the ChannelReestablish
2616 pub extern "C" fn ChannelReestablish_clone(orig: &ChannelReestablish) -> ChannelReestablish {
2620 use lightning::ln::msgs::AnnouncementSignatures as nativeAnnouncementSignaturesImport;
2621 type nativeAnnouncementSignatures = nativeAnnouncementSignaturesImport;
2623 /// An announcement_signatures message to be sent or received from a peer
2626 pub struct AnnouncementSignatures {
2627 /// A pointer to the opaque Rust object.
2629 /// Nearly everywhere, inner must be non-null, however in places where
2630 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2631 pub inner: *mut nativeAnnouncementSignatures,
2632 /// Indicates that this is the only struct which contains the same pointer.
2634 /// Rust functions which take ownership of an object provided via an argument require
2635 /// this to be true and invalidate the object pointed to by inner.
2639 impl Drop for AnnouncementSignatures {
2640 fn drop(&mut self) {
2641 if self.is_owned && !<*mut nativeAnnouncementSignatures>::is_null(self.inner) {
2642 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2646 /// Frees any resources used by the AnnouncementSignatures, if is_owned is set and inner is non-NULL.
2648 pub extern "C" fn AnnouncementSignatures_free(this_obj: AnnouncementSignatures) { }
2650 /// Used only if an object of this type is returned as a trait impl by a method
2651 extern "C" fn AnnouncementSignatures_free_void(this_ptr: *mut c_void) {
2652 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeAnnouncementSignatures); }
2655 impl AnnouncementSignatures {
2656 pub(crate) fn get_native_ref(&self) -> &'static nativeAnnouncementSignatures {
2657 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2659 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAnnouncementSignatures {
2660 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2662 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2663 pub(crate) fn take_inner(mut self) -> *mut nativeAnnouncementSignatures {
2664 assert!(self.is_owned);
2665 let ret = ObjOps::untweak_ptr(self.inner);
2666 self.inner = std::ptr::null_mut();
2672 pub extern "C" fn AnnouncementSignatures_get_channel_id(this_ptr: &AnnouncementSignatures) -> *const [u8; 32] {
2673 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
2678 pub extern "C" fn AnnouncementSignatures_set_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
2679 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
2681 /// The short channel ID
2683 pub extern "C" fn AnnouncementSignatures_get_short_channel_id(this_ptr: &AnnouncementSignatures) -> u64 {
2684 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
2687 /// The short channel ID
2689 pub extern "C" fn AnnouncementSignatures_set_short_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: u64) {
2690 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
2692 /// A signature by the node key
2694 pub extern "C" fn AnnouncementSignatures_get_node_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
2695 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature;
2696 crate::c_types::Signature::from_rust(&inner_val)
2698 /// A signature by the node key
2700 pub extern "C" fn AnnouncementSignatures_set_node_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
2701 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature = val.into_rust();
2703 /// A signature by the funding key
2705 pub extern "C" fn AnnouncementSignatures_get_bitcoin_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
2706 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature;
2707 crate::c_types::Signature::from_rust(&inner_val)
2709 /// A signature by the funding key
2711 pub extern "C" fn AnnouncementSignatures_set_bitcoin_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
2712 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature = val.into_rust();
2714 /// Constructs a new AnnouncementSignatures given each field
2717 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 {
2718 AnnouncementSignatures { inner: ObjOps::heap_alloc(nativeAnnouncementSignatures {
2719 channel_id: channel_id_arg.data,
2720 short_channel_id: short_channel_id_arg,
2721 node_signature: node_signature_arg.into_rust(),
2722 bitcoin_signature: bitcoin_signature_arg.into_rust(),
2723 }), is_owned: true }
2725 impl Clone for AnnouncementSignatures {
2726 fn clone(&self) -> Self {
2728 inner: if <*mut nativeAnnouncementSignatures>::is_null(self.inner) { std::ptr::null_mut() } else {
2729 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2735 /// Used only if an object of this type is returned as a trait impl by a method
2736 pub(crate) extern "C" fn AnnouncementSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
2737 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAnnouncementSignatures)).clone() })) as *mut c_void
2740 /// Creates a copy of the AnnouncementSignatures
2741 pub extern "C" fn AnnouncementSignatures_clone(orig: &AnnouncementSignatures) -> AnnouncementSignatures {
2744 /// An address which can be used to connect to a remote peer
2748 pub enum NetAddress {
2749 /// An IPv4 address/port on which the peer is listening.
2751 /// The 4-byte IPv4 address
2752 addr: crate::c_types::FourBytes,
2753 /// The port on which the node is listening
2756 /// An IPv6 address/port on which the peer is listening.
2758 /// The 16-byte IPv6 address
2759 addr: crate::c_types::SixteenBytes,
2760 /// The port on which the node is listening
2763 /// An old-style Tor onion address/port on which the peer is listening.
2765 /// The bytes (usually encoded in base32 with \".onion\" appended)
2766 addr: crate::c_types::TenBytes,
2767 /// The port on which the node is listening
2770 /// A new-style Tor onion address/port on which the peer is listening.
2771 /// To create the human-readable \"hostname\", concatenate ed25519_pubkey, checksum, and version,
2772 /// wrap as base32 and append \".onion\".
2774 /// The ed25519 long-term public key of the peer
2775 ed25519_pubkey: crate::c_types::ThirtyTwoBytes,
2776 /// The checksum of the pubkey and version, as included in the onion address
2778 /// The version byte, as defined by the Tor Onion v3 spec.
2780 /// The port on which the node is listening
2784 use lightning::ln::msgs::NetAddress as nativeNetAddress;
2787 pub(crate) fn to_native(&self) -> nativeNetAddress {
2789 NetAddress::IPv4 {ref addr, ref port, } => {
2790 let mut addr_nonref = (*addr).clone();
2791 let mut port_nonref = (*port).clone();
2792 nativeNetAddress::IPv4 {
2793 addr: addr_nonref.data,
2797 NetAddress::IPv6 {ref addr, ref port, } => {
2798 let mut addr_nonref = (*addr).clone();
2799 let mut port_nonref = (*port).clone();
2800 nativeNetAddress::IPv6 {
2801 addr: addr_nonref.data,
2805 NetAddress::OnionV2 {ref addr, ref port, } => {
2806 let mut addr_nonref = (*addr).clone();
2807 let mut port_nonref = (*port).clone();
2808 nativeNetAddress::OnionV2 {
2809 addr: addr_nonref.data,
2813 NetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
2814 let mut ed25519_pubkey_nonref = (*ed25519_pubkey).clone();
2815 let mut checksum_nonref = (*checksum).clone();
2816 let mut version_nonref = (*version).clone();
2817 let mut port_nonref = (*port).clone();
2818 nativeNetAddress::OnionV3 {
2819 ed25519_pubkey: ed25519_pubkey_nonref.data,
2820 checksum: checksum_nonref,
2821 version: version_nonref,
2828 pub(crate) fn into_native(self) -> nativeNetAddress {
2830 NetAddress::IPv4 {mut addr, mut port, } => {
2831 nativeNetAddress::IPv4 {
2836 NetAddress::IPv6 {mut addr, mut port, } => {
2837 nativeNetAddress::IPv6 {
2842 NetAddress::OnionV2 {mut addr, mut port, } => {
2843 nativeNetAddress::OnionV2 {
2848 NetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
2849 nativeNetAddress::OnionV3 {
2850 ed25519_pubkey: ed25519_pubkey.data,
2859 pub(crate) fn from_native(native: &nativeNetAddress) -> Self {
2861 nativeNetAddress::IPv4 {ref addr, ref port, } => {
2862 let mut addr_nonref = (*addr).clone();
2863 let mut port_nonref = (*port).clone();
2865 addr: crate::c_types::FourBytes { data: addr_nonref },
2869 nativeNetAddress::IPv6 {ref addr, ref port, } => {
2870 let mut addr_nonref = (*addr).clone();
2871 let mut port_nonref = (*port).clone();
2873 addr: crate::c_types::SixteenBytes { data: addr_nonref },
2877 nativeNetAddress::OnionV2 {ref addr, ref port, } => {
2878 let mut addr_nonref = (*addr).clone();
2879 let mut port_nonref = (*port).clone();
2880 NetAddress::OnionV2 {
2881 addr: crate::c_types::TenBytes { data: addr_nonref },
2885 nativeNetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
2886 let mut ed25519_pubkey_nonref = (*ed25519_pubkey).clone();
2887 let mut checksum_nonref = (*checksum).clone();
2888 let mut version_nonref = (*version).clone();
2889 let mut port_nonref = (*port).clone();
2890 NetAddress::OnionV3 {
2891 ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey_nonref },
2892 checksum: checksum_nonref,
2893 version: version_nonref,
2900 pub(crate) fn native_into(native: nativeNetAddress) -> Self {
2902 nativeNetAddress::IPv4 {mut addr, mut port, } => {
2904 addr: crate::c_types::FourBytes { data: addr },
2908 nativeNetAddress::IPv6 {mut addr, mut port, } => {
2910 addr: crate::c_types::SixteenBytes { data: addr },
2914 nativeNetAddress::OnionV2 {mut addr, mut port, } => {
2915 NetAddress::OnionV2 {
2916 addr: crate::c_types::TenBytes { data: addr },
2920 nativeNetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
2921 NetAddress::OnionV3 {
2922 ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey },
2931 /// Frees any resources used by the NetAddress
2933 pub extern "C" fn NetAddress_free(this_ptr: NetAddress) { }
2934 /// Creates a copy of the NetAddress
2936 pub extern "C" fn NetAddress_clone(orig: &NetAddress) -> NetAddress {
2940 /// Utility method to constructs a new IPv4-variant NetAddress
2941 pub extern "C" fn NetAddress_ipv4(addr: crate::c_types::FourBytes, port: u16) -> NetAddress {
2948 /// Utility method to constructs a new IPv6-variant NetAddress
2949 pub extern "C" fn NetAddress_ipv6(addr: crate::c_types::SixteenBytes, port: u16) -> NetAddress {
2956 /// Utility method to constructs a new OnionV2-variant NetAddress
2957 pub extern "C" fn NetAddress_onion_v2(addr: crate::c_types::TenBytes, port: u16) -> NetAddress {
2958 NetAddress::OnionV2 {
2964 /// Utility method to constructs a new OnionV3-variant NetAddress
2965 pub extern "C" fn NetAddress_onion_v3(ed25519_pubkey: crate::c_types::ThirtyTwoBytes, checksum: u16, version: u8, port: u16) -> NetAddress {
2966 NetAddress::OnionV3 {
2974 /// Serialize the NetAddress object into a byte array which can be read by NetAddress_read
2975 pub extern "C" fn NetAddress_write(obj: &NetAddress) -> crate::c_types::derived::CVec_u8Z {
2976 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
2979 /// Read a Result from a byte array, created by Result_write
2980 pub extern "C" fn Result_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CResult_NetAddressu8ZDecodeErrorZ {
2981 let res = crate::c_types::deserialize_obj(ser);
2982 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() };
2986 /// Read a NetAddress from a byte array, created by NetAddress_write
2987 pub extern "C" fn NetAddress_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NetAddressDecodeErrorZ {
2988 let res = crate::c_types::deserialize_obj(ser);
2989 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() };
2993 use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport;
2994 type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport;
2996 /// The unsigned part of a node_announcement
2999 pub struct UnsignedNodeAnnouncement {
3000 /// A pointer to the opaque Rust object.
3002 /// Nearly everywhere, inner must be non-null, however in places where
3003 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3004 pub inner: *mut nativeUnsignedNodeAnnouncement,
3005 /// Indicates that this is the only struct which contains the same pointer.
3007 /// Rust functions which take ownership of an object provided via an argument require
3008 /// this to be true and invalidate the object pointed to by inner.
3012 impl Drop for UnsignedNodeAnnouncement {
3013 fn drop(&mut self) {
3014 if self.is_owned && !<*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) {
3015 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3019 /// Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL.
3021 pub extern "C" fn UnsignedNodeAnnouncement_free(this_obj: UnsignedNodeAnnouncement) { }
3023 /// Used only if an object of this type is returned as a trait impl by a method
3024 extern "C" fn UnsignedNodeAnnouncement_free_void(this_ptr: *mut c_void) {
3025 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedNodeAnnouncement); }
3028 impl UnsignedNodeAnnouncement {
3029 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedNodeAnnouncement {
3030 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3032 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedNodeAnnouncement {
3033 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3035 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3036 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedNodeAnnouncement {
3037 assert!(self.is_owned);
3038 let ret = ObjOps::untweak_ptr(self.inner);
3039 self.inner = std::ptr::null_mut();
3043 /// The advertised features
3045 pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::ln::features::NodeFeatures {
3046 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
3047 crate::lightning::ln::features::NodeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false }
3049 /// The advertised features
3051 pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::ln::features::NodeFeatures) {
3052 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
3054 /// A strictly monotonic announcement counter, with gaps allowed
3056 pub extern "C" fn UnsignedNodeAnnouncement_get_timestamp(this_ptr: &UnsignedNodeAnnouncement) -> u32 {
3057 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
3060 /// A strictly monotonic announcement counter, with gaps allowed
3062 pub extern "C" fn UnsignedNodeAnnouncement_set_timestamp(this_ptr: &mut UnsignedNodeAnnouncement, mut val: u32) {
3063 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
3065 /// The node_id this announcement originated from (don't rebroadcast the node_announcement back
3068 pub extern "C" fn UnsignedNodeAnnouncement_get_node_id(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::PublicKey {
3069 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id;
3070 crate::c_types::PublicKey::from_rust(&inner_val)
3072 /// The node_id this announcement originated from (don't rebroadcast the node_announcement back
3075 pub extern "C" fn UnsignedNodeAnnouncement_set_node_id(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::PublicKey) {
3076 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id = val.into_rust();
3078 /// An RGB color for UI purposes
3080 pub extern "C" fn UnsignedNodeAnnouncement_get_rgb(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 3] {
3081 let mut inner_val = &mut this_ptr.get_native_mut_ref().rgb;
3084 /// An RGB color for UI purposes
3086 pub extern "C" fn UnsignedNodeAnnouncement_set_rgb(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThreeBytes) {
3087 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.rgb = val.data;
3089 /// An alias, for UI purposes. This should be sanitized before use. There is no guarantee
3092 pub extern "C" fn UnsignedNodeAnnouncement_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 32] {
3093 let mut inner_val = &mut this_ptr.get_native_mut_ref().alias;
3096 /// An alias, for UI purposes. This should be sanitized before use. There is no guarantee
3099 pub extern "C" fn UnsignedNodeAnnouncement_set_alias(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
3100 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.alias = val.data;
3102 /// List of addresses on which this node is reachable
3104 pub extern "C" fn UnsignedNodeAnnouncement_set_addresses(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_NetAddressZ) {
3105 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
3106 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.addresses = local_val;
3108 impl Clone for UnsignedNodeAnnouncement {
3109 fn clone(&self) -> Self {
3111 inner: if <*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else {
3112 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3118 /// Used only if an object of this type is returned as a trait impl by a method
3119 pub(crate) extern "C" fn UnsignedNodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3120 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedNodeAnnouncement)).clone() })) as *mut c_void
3123 /// Creates a copy of the UnsignedNodeAnnouncement
3124 pub extern "C" fn UnsignedNodeAnnouncement_clone(orig: &UnsignedNodeAnnouncement) -> UnsignedNodeAnnouncement {
3128 use lightning::ln::msgs::NodeAnnouncement as nativeNodeAnnouncementImport;
3129 type nativeNodeAnnouncement = nativeNodeAnnouncementImport;
3131 /// A node_announcement message to be sent or received from a peer
3134 pub struct NodeAnnouncement {
3135 /// A pointer to the opaque Rust object.
3137 /// Nearly everywhere, inner must be non-null, however in places where
3138 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3139 pub inner: *mut nativeNodeAnnouncement,
3140 /// Indicates that this is the only struct which contains the same pointer.
3142 /// Rust functions which take ownership of an object provided via an argument require
3143 /// this to be true and invalidate the object pointed to by inner.
3147 impl Drop for NodeAnnouncement {
3148 fn drop(&mut self) {
3149 if self.is_owned && !<*mut nativeNodeAnnouncement>::is_null(self.inner) {
3150 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3154 /// Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL.
3156 pub extern "C" fn NodeAnnouncement_free(this_obj: NodeAnnouncement) { }
3158 /// Used only if an object of this type is returned as a trait impl by a method
3159 extern "C" fn NodeAnnouncement_free_void(this_ptr: *mut c_void) {
3160 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeAnnouncement); }
3163 impl NodeAnnouncement {
3164 pub(crate) fn get_native_ref(&self) -> &'static nativeNodeAnnouncement {
3165 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3167 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeAnnouncement {
3168 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3170 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3171 pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncement {
3172 assert!(self.is_owned);
3173 let ret = ObjOps::untweak_ptr(self.inner);
3174 self.inner = std::ptr::null_mut();
3178 /// The signature by the node key
3180 pub extern "C" fn NodeAnnouncement_get_signature(this_ptr: &NodeAnnouncement) -> crate::c_types::Signature {
3181 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
3182 crate::c_types::Signature::from_rust(&inner_val)
3184 /// The signature by the node key
3186 pub extern "C" fn NodeAnnouncement_set_signature(this_ptr: &mut NodeAnnouncement, mut val: crate::c_types::Signature) {
3187 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
3189 /// The actual content of the announcement
3191 pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> crate::lightning::ln::msgs::UnsignedNodeAnnouncement {
3192 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
3193 crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false }
3195 /// The actual content of the announcement
3197 pub extern "C" fn NodeAnnouncement_set_contents(this_ptr: &mut NodeAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) {
3198 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
3200 /// Constructs a new NodeAnnouncement given each field
3203 pub extern "C" fn NodeAnnouncement_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> NodeAnnouncement {
3204 NodeAnnouncement { inner: ObjOps::heap_alloc(nativeNodeAnnouncement {
3205 signature: signature_arg.into_rust(),
3206 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
3207 }), is_owned: true }
3209 impl Clone for NodeAnnouncement {
3210 fn clone(&self) -> Self {
3212 inner: if <*mut nativeNodeAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else {
3213 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3219 /// Used only if an object of this type is returned as a trait impl by a method
3220 pub(crate) extern "C" fn NodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3221 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeAnnouncement)).clone() })) as *mut c_void
3224 /// Creates a copy of the NodeAnnouncement
3225 pub extern "C" fn NodeAnnouncement_clone(orig: &NodeAnnouncement) -> NodeAnnouncement {
3229 use lightning::ln::msgs::UnsignedChannelAnnouncement as nativeUnsignedChannelAnnouncementImport;
3230 type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport;
3232 /// The unsigned part of a channel_announcement
3235 pub struct UnsignedChannelAnnouncement {
3236 /// A pointer to the opaque Rust object.
3238 /// Nearly everywhere, inner must be non-null, however in places where
3239 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3240 pub inner: *mut nativeUnsignedChannelAnnouncement,
3241 /// Indicates that this is the only struct which contains the same pointer.
3243 /// Rust functions which take ownership of an object provided via an argument require
3244 /// this to be true and invalidate the object pointed to by inner.
3248 impl Drop for UnsignedChannelAnnouncement {
3249 fn drop(&mut self) {
3250 if self.is_owned && !<*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) {
3251 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3255 /// Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL.
3257 pub extern "C" fn UnsignedChannelAnnouncement_free(this_obj: UnsignedChannelAnnouncement) { }
3259 /// Used only if an object of this type is returned as a trait impl by a method
3260 extern "C" fn UnsignedChannelAnnouncement_free_void(this_ptr: *mut c_void) {
3261 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelAnnouncement); }
3264 impl UnsignedChannelAnnouncement {
3265 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelAnnouncement {
3266 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3268 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelAnnouncement {
3269 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3271 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3272 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelAnnouncement {
3273 assert!(self.is_owned);
3274 let ret = ObjOps::untweak_ptr(self.inner);
3275 self.inner = std::ptr::null_mut();
3279 /// The advertised channel features
3281 pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::ln::features::ChannelFeatures {
3282 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
3283 crate::lightning::ln::features::ChannelFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false }
3285 /// The advertised channel features
3287 pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::ln::features::ChannelFeatures) {
3288 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
3290 /// The genesis hash of the blockchain where the channel is to be opened
3292 pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &UnsignedChannelAnnouncement) -> *const [u8; 32] {
3293 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
3294 inner_val.as_inner()
3296 /// The genesis hash of the blockchain where the channel is to be opened
3298 pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
3299 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3301 /// The short channel ID
3303 pub extern "C" fn UnsignedChannelAnnouncement_get_short_channel_id(this_ptr: &UnsignedChannelAnnouncement) -> u64 {
3304 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
3307 /// The short channel ID
3309 pub extern "C" fn UnsignedChannelAnnouncement_set_short_channel_id(this_ptr: &mut UnsignedChannelAnnouncement, mut val: u64) {
3310 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
3312 /// One of the two node_ids which are endpoints of this channel
3314 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3315 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_1;
3316 crate::c_types::PublicKey::from_rust(&inner_val)
3318 /// One of the two node_ids which are endpoints of this channel
3320 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3321 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_1 = val.into_rust();
3323 /// The other of the two node_ids which are endpoints of this channel
3325 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3326 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id_2;
3327 crate::c_types::PublicKey::from_rust(&inner_val)
3329 /// The other of the two node_ids which are endpoints of this channel
3331 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3332 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id_2 = val.into_rust();
3334 /// The funding key for the first node
3336 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3337 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_1;
3338 crate::c_types::PublicKey::from_rust(&inner_val)
3340 /// The funding key for the first node
3342 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3343 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_1 = val.into_rust();
3345 /// The funding key for the second node
3347 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
3348 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_key_2;
3349 crate::c_types::PublicKey::from_rust(&inner_val)
3351 /// The funding key for the second node
3353 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
3354 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_key_2 = val.into_rust();
3356 impl Clone for UnsignedChannelAnnouncement {
3357 fn clone(&self) -> Self {
3359 inner: if <*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else {
3360 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3366 /// Used only if an object of this type is returned as a trait impl by a method
3367 pub(crate) extern "C" fn UnsignedChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3368 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelAnnouncement)).clone() })) as *mut c_void
3371 /// Creates a copy of the UnsignedChannelAnnouncement
3372 pub extern "C" fn UnsignedChannelAnnouncement_clone(orig: &UnsignedChannelAnnouncement) -> UnsignedChannelAnnouncement {
3376 use lightning::ln::msgs::ChannelAnnouncement as nativeChannelAnnouncementImport;
3377 type nativeChannelAnnouncement = nativeChannelAnnouncementImport;
3379 /// A channel_announcement message to be sent or received from a peer
3382 pub struct ChannelAnnouncement {
3383 /// A pointer to the opaque Rust object.
3385 /// Nearly everywhere, inner must be non-null, however in places where
3386 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3387 pub inner: *mut nativeChannelAnnouncement,
3388 /// Indicates that this is the only struct which contains the same pointer.
3390 /// Rust functions which take ownership of an object provided via an argument require
3391 /// this to be true and invalidate the object pointed to by inner.
3395 impl Drop for ChannelAnnouncement {
3396 fn drop(&mut self) {
3397 if self.is_owned && !<*mut nativeChannelAnnouncement>::is_null(self.inner) {
3398 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3402 /// Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL.
3404 pub extern "C" fn ChannelAnnouncement_free(this_obj: ChannelAnnouncement) { }
3406 /// Used only if an object of this type is returned as a trait impl by a method
3407 extern "C" fn ChannelAnnouncement_free_void(this_ptr: *mut c_void) {
3408 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelAnnouncement); }
3411 impl ChannelAnnouncement {
3412 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelAnnouncement {
3413 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3415 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelAnnouncement {
3416 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3418 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3419 pub(crate) fn take_inner(mut self) -> *mut nativeChannelAnnouncement {
3420 assert!(self.is_owned);
3421 let ret = ObjOps::untweak_ptr(self.inner);
3422 self.inner = std::ptr::null_mut();
3426 /// Authentication of the announcement by the first public node
3428 pub extern "C" fn ChannelAnnouncement_get_node_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3429 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_1;
3430 crate::c_types::Signature::from_rust(&inner_val)
3432 /// Authentication of the announcement by the first public node
3434 pub extern "C" fn ChannelAnnouncement_set_node_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3435 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_1 = val.into_rust();
3437 /// Authentication of the announcement by the second public node
3439 pub extern "C" fn ChannelAnnouncement_get_node_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3440 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signature_2;
3441 crate::c_types::Signature::from_rust(&inner_val)
3443 /// Authentication of the announcement by the second public node
3445 pub extern "C" fn ChannelAnnouncement_set_node_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3446 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signature_2 = val.into_rust();
3448 /// Proof of funding UTXO ownership by the first public node
3450 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3451 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_1;
3452 crate::c_types::Signature::from_rust(&inner_val)
3454 /// Proof of funding UTXO ownership by the first public node
3456 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3457 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_1 = val.into_rust();
3459 /// Proof of funding UTXO ownership by the second public node
3461 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
3462 let mut inner_val = &mut this_ptr.get_native_mut_ref().bitcoin_signature_2;
3463 crate::c_types::Signature::from_rust(&inner_val)
3465 /// Proof of funding UTXO ownership by the second public node
3467 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
3468 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.bitcoin_signature_2 = val.into_rust();
3470 /// The actual announcement
3472 pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncement) -> crate::lightning::ln::msgs::UnsignedChannelAnnouncement {
3473 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
3474 crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false }
3476 /// The actual announcement
3478 pub extern "C" fn ChannelAnnouncement_set_contents(this_ptr: &mut ChannelAnnouncement, mut val: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) {
3479 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
3481 /// Constructs a new ChannelAnnouncement given each field
3484 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 {
3485 ChannelAnnouncement { inner: ObjOps::heap_alloc(nativeChannelAnnouncement {
3486 node_signature_1: node_signature_1_arg.into_rust(),
3487 node_signature_2: node_signature_2_arg.into_rust(),
3488 bitcoin_signature_1: bitcoin_signature_1_arg.into_rust(),
3489 bitcoin_signature_2: bitcoin_signature_2_arg.into_rust(),
3490 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
3491 }), is_owned: true }
3493 impl Clone for ChannelAnnouncement {
3494 fn clone(&self) -> Self {
3496 inner: if <*mut nativeChannelAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else {
3497 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3503 /// Used only if an object of this type is returned as a trait impl by a method
3504 pub(crate) extern "C" fn ChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
3505 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelAnnouncement)).clone() })) as *mut c_void
3508 /// Creates a copy of the ChannelAnnouncement
3509 pub extern "C" fn ChannelAnnouncement_clone(orig: &ChannelAnnouncement) -> ChannelAnnouncement {
3513 use lightning::ln::msgs::UnsignedChannelUpdate as nativeUnsignedChannelUpdateImport;
3514 type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport;
3516 /// The unsigned part of a channel_update
3519 pub struct UnsignedChannelUpdate {
3520 /// A pointer to the opaque Rust object.
3522 /// Nearly everywhere, inner must be non-null, however in places where
3523 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3524 pub inner: *mut nativeUnsignedChannelUpdate,
3525 /// Indicates that this is the only struct which contains the same pointer.
3527 /// Rust functions which take ownership of an object provided via an argument require
3528 /// this to be true and invalidate the object pointed to by inner.
3532 impl Drop for UnsignedChannelUpdate {
3533 fn drop(&mut self) {
3534 if self.is_owned && !<*mut nativeUnsignedChannelUpdate>::is_null(self.inner) {
3535 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3539 /// Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL.
3541 pub extern "C" fn UnsignedChannelUpdate_free(this_obj: UnsignedChannelUpdate) { }
3543 /// Used only if an object of this type is returned as a trait impl by a method
3544 extern "C" fn UnsignedChannelUpdate_free_void(this_ptr: *mut c_void) {
3545 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelUpdate); }
3548 impl UnsignedChannelUpdate {
3549 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedChannelUpdate {
3550 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3552 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedChannelUpdate {
3553 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3555 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3556 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelUpdate {
3557 assert!(self.is_owned);
3558 let ret = ObjOps::untweak_ptr(self.inner);
3559 self.inner = std::ptr::null_mut();
3563 /// The genesis hash of the blockchain where the channel is to be opened
3565 pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChannelUpdate) -> *const [u8; 32] {
3566 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
3567 inner_val.as_inner()
3569 /// The genesis hash of the blockchain where the channel is to be opened
3571 pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::ThirtyTwoBytes) {
3572 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3574 /// The short channel ID
3576 pub extern "C" fn UnsignedChannelUpdate_get_short_channel_id(this_ptr: &UnsignedChannelUpdate) -> u64 {
3577 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
3580 /// The short channel ID
3582 pub extern "C" fn UnsignedChannelUpdate_set_short_channel_id(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
3583 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
3585 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
3587 pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannelUpdate) -> u32 {
3588 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
3591 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
3593 pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3594 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val;
3598 pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 {
3599 let mut inner_val = &mut this_ptr.get_native_mut_ref().flags;
3604 pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) {
3605 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.flags = val;
3607 /// The number of blocks such that if:
3608 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
3609 /// then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines
3610 /// the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a
3611 /// cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10,
3612 /// then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before
3613 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
3614 /// constructing the route.
3616 pub extern "C" fn UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr: &UnsignedChannelUpdate) -> u16 {
3617 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
3620 /// The number of blocks such that if:
3621 /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
3622 /// then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines
3623 /// the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a
3624 /// cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10,
3625 /// then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before
3626 /// forwarding. Note that the HTLC sender is the one who originally sets this value when
3627 /// constructing the route.
3629 pub extern "C" fn UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr: &mut UnsignedChannelUpdate, mut val: u16) {
3630 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
3632 /// The minimum HTLC size incoming to sender, in milli-satoshi
3634 pub extern "C" fn UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
3635 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
3638 /// The minimum HTLC size incoming to sender, in milli-satoshi
3640 pub extern "C" fn UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
3641 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
3643 /// The base HTLC fee charged by sender, in milli-satoshi
3645 pub extern "C" fn UnsignedChannelUpdate_get_fee_base_msat(this_ptr: &UnsignedChannelUpdate) -> u32 {
3646 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat;
3649 /// The base HTLC fee charged by sender, in milli-satoshi
3651 pub extern "C" fn UnsignedChannelUpdate_set_fee_base_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3652 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val;
3654 /// The amount to fee multiplier, in micro-satoshi
3656 pub extern "C" fn UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr: &UnsignedChannelUpdate) -> u32 {
3657 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths;
3660 /// The amount to fee multiplier, in micro-satoshi
3662 pub extern "C" fn UnsignedChannelUpdate_set_fee_proportional_millionths(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3663 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val;
3665 impl Clone for UnsignedChannelUpdate {
3666 fn clone(&self) -> Self {
3668 inner: if <*mut nativeUnsignedChannelUpdate>::is_null(self.inner) { std::ptr::null_mut() } else {
3669 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3675 /// Used only if an object of this type is returned as a trait impl by a method
3676 pub(crate) extern "C" fn UnsignedChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
3677 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelUpdate)).clone() })) as *mut c_void
3680 /// Creates a copy of the UnsignedChannelUpdate
3681 pub extern "C" fn UnsignedChannelUpdate_clone(orig: &UnsignedChannelUpdate) -> UnsignedChannelUpdate {
3685 use lightning::ln::msgs::ChannelUpdate as nativeChannelUpdateImport;
3686 type nativeChannelUpdate = nativeChannelUpdateImport;
3688 /// A channel_update message to be sent or received from a peer
3691 pub struct ChannelUpdate {
3692 /// A pointer to the opaque Rust object.
3694 /// Nearly everywhere, inner must be non-null, however in places where
3695 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3696 pub inner: *mut nativeChannelUpdate,
3697 /// Indicates that this is the only struct which contains the same pointer.
3699 /// Rust functions which take ownership of an object provided via an argument require
3700 /// this to be true and invalidate the object pointed to by inner.
3704 impl Drop for ChannelUpdate {
3705 fn drop(&mut self) {
3706 if self.is_owned && !<*mut nativeChannelUpdate>::is_null(self.inner) {
3707 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3711 /// Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL.
3713 pub extern "C" fn ChannelUpdate_free(this_obj: ChannelUpdate) { }
3715 /// Used only if an object of this type is returned as a trait impl by a method
3716 extern "C" fn ChannelUpdate_free_void(this_ptr: *mut c_void) {
3717 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelUpdate); }
3720 impl ChannelUpdate {
3721 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelUpdate {
3722 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3724 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelUpdate {
3725 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3727 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3728 pub(crate) fn take_inner(mut self) -> *mut nativeChannelUpdate {
3729 assert!(self.is_owned);
3730 let ret = ObjOps::untweak_ptr(self.inner);
3731 self.inner = std::ptr::null_mut();
3735 /// A signature of the channel update
3737 pub extern "C" fn ChannelUpdate_get_signature(this_ptr: &ChannelUpdate) -> crate::c_types::Signature {
3738 let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
3739 crate::c_types::Signature::from_rust(&inner_val)
3741 /// A signature of the channel update
3743 pub extern "C" fn ChannelUpdate_set_signature(this_ptr: &mut ChannelUpdate, mut val: crate::c_types::Signature) {
3744 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
3746 /// The actual channel update
3748 pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate::lightning::ln::msgs::UnsignedChannelUpdate {
3749 let mut inner_val = &mut this_ptr.get_native_mut_ref().contents;
3750 crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false }
3752 /// The actual channel update
3754 pub extern "C" fn ChannelUpdate_set_contents(this_ptr: &mut ChannelUpdate, mut val: crate::lightning::ln::msgs::UnsignedChannelUpdate) {
3755 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.contents = *unsafe { Box::from_raw(val.take_inner()) };
3757 /// Constructs a new ChannelUpdate given each field
3760 pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> ChannelUpdate {
3761 ChannelUpdate { inner: ObjOps::heap_alloc(nativeChannelUpdate {
3762 signature: signature_arg.into_rust(),
3763 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
3764 }), is_owned: true }
3766 impl Clone for ChannelUpdate {
3767 fn clone(&self) -> Self {
3769 inner: if <*mut nativeChannelUpdate>::is_null(self.inner) { std::ptr::null_mut() } else {
3770 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3776 /// Used only if an object of this type is returned as a trait impl by a method
3777 pub(crate) extern "C" fn ChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
3778 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelUpdate)).clone() })) as *mut c_void
3781 /// Creates a copy of the ChannelUpdate
3782 pub extern "C" fn ChannelUpdate_clone(orig: &ChannelUpdate) -> ChannelUpdate {
3786 use lightning::ln::msgs::QueryChannelRange as nativeQueryChannelRangeImport;
3787 type nativeQueryChannelRange = nativeQueryChannelRangeImport;
3789 /// A query_channel_range message is used to query a peer for channel
3790 /// UTXOs in a range of blocks. The recipient of a query makes a best
3791 /// effort to reply to the query using one or more reply_channel_range
3795 pub struct QueryChannelRange {
3796 /// A pointer to the opaque Rust object.
3798 /// Nearly everywhere, inner must be non-null, however in places where
3799 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3800 pub inner: *mut nativeQueryChannelRange,
3801 /// Indicates that this is the only struct which contains the same pointer.
3803 /// Rust functions which take ownership of an object provided via an argument require
3804 /// this to be true and invalidate the object pointed to by inner.
3808 impl Drop for QueryChannelRange {
3809 fn drop(&mut self) {
3810 if self.is_owned && !<*mut nativeQueryChannelRange>::is_null(self.inner) {
3811 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3815 /// Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL.
3817 pub extern "C" fn QueryChannelRange_free(this_obj: QueryChannelRange) { }
3819 /// Used only if an object of this type is returned as a trait impl by a method
3820 extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) {
3821 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryChannelRange); }
3824 impl QueryChannelRange {
3825 pub(crate) fn get_native_ref(&self) -> &'static nativeQueryChannelRange {
3826 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3828 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryChannelRange {
3829 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3831 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3832 pub(crate) fn take_inner(mut self) -> *mut nativeQueryChannelRange {
3833 assert!(self.is_owned);
3834 let ret = ObjOps::untweak_ptr(self.inner);
3835 self.inner = std::ptr::null_mut();
3839 /// The genesis hash of the blockchain being queried
3841 pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *const [u8; 32] {
3842 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
3843 inner_val.as_inner()
3845 /// The genesis hash of the blockchain being queried
3847 pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
3848 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3850 /// The height of the first block for the channel UTXOs being queried
3852 pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 {
3853 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
3856 /// The height of the first block for the channel UTXOs being queried
3858 pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChannelRange, mut val: u32) {
3859 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
3861 /// The number of blocks to include in the query results
3863 pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 {
3864 let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
3867 /// The number of blocks to include in the query results
3869 pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryChannelRange, mut val: u32) {
3870 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
3872 /// Constructs a new QueryChannelRange given each field
3875 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 {
3876 QueryChannelRange { inner: ObjOps::heap_alloc(nativeQueryChannelRange {
3877 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3878 first_blocknum: first_blocknum_arg,
3879 number_of_blocks: number_of_blocks_arg,
3880 }), is_owned: true }
3882 impl Clone for QueryChannelRange {
3883 fn clone(&self) -> Self {
3885 inner: if <*mut nativeQueryChannelRange>::is_null(self.inner) { std::ptr::null_mut() } else {
3886 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
3892 /// Used only if an object of this type is returned as a trait impl by a method
3893 pub(crate) extern "C" fn QueryChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
3894 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryChannelRange)).clone() })) as *mut c_void
3897 /// Creates a copy of the QueryChannelRange
3898 pub extern "C" fn QueryChannelRange_clone(orig: &QueryChannelRange) -> QueryChannelRange {
3902 use lightning::ln::msgs::ReplyChannelRange as nativeReplyChannelRangeImport;
3903 type nativeReplyChannelRange = nativeReplyChannelRangeImport;
3905 /// A reply_channel_range message is a reply to a query_channel_range
3906 /// message. Multiple reply_channel_range messages can be sent in reply
3907 /// to a single query_channel_range message. The query recipient makes a
3908 /// best effort to respond based on their local network view which may
3909 /// not be a perfect view of the network. The short_channel_ids in the
3910 /// reply are encoded. We only support encoding_type=0 uncompressed
3911 /// serialization and do not support encoding_type=1 zlib serialization.
3914 pub struct ReplyChannelRange {
3915 /// A pointer to the opaque Rust object.
3917 /// Nearly everywhere, inner must be non-null, however in places where
3918 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3919 pub inner: *mut nativeReplyChannelRange,
3920 /// Indicates that this is the only struct which contains the same pointer.
3922 /// Rust functions which take ownership of an object provided via an argument require
3923 /// this to be true and invalidate the object pointed to by inner.
3927 impl Drop for ReplyChannelRange {
3928 fn drop(&mut self) {
3929 if self.is_owned && !<*mut nativeReplyChannelRange>::is_null(self.inner) {
3930 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3934 /// Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL.
3936 pub extern "C" fn ReplyChannelRange_free(this_obj: ReplyChannelRange) { }
3938 /// Used only if an object of this type is returned as a trait impl by a method
3939 extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) {
3940 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyChannelRange); }
3943 impl ReplyChannelRange {
3944 pub(crate) fn get_native_ref(&self) -> &'static nativeReplyChannelRange {
3945 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3947 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyChannelRange {
3948 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3950 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3951 pub(crate) fn take_inner(mut self) -> *mut nativeReplyChannelRange {
3952 assert!(self.is_owned);
3953 let ret = ObjOps::untweak_ptr(self.inner);
3954 self.inner = std::ptr::null_mut();
3958 /// The genesis hash of the blockchain being queried
3960 pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *const [u8; 32] {
3961 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
3962 inner_val.as_inner()
3964 /// The genesis hash of the blockchain being queried
3966 pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
3967 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3969 /// The height of the first block in the range of the reply
3971 pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 {
3972 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_blocknum;
3975 /// The height of the first block in the range of the reply
3977 pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChannelRange, mut val: u32) {
3978 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_blocknum = val;
3980 /// The number of blocks included in the range of the reply
3982 pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 {
3983 let mut inner_val = &mut this_ptr.get_native_mut_ref().number_of_blocks;
3986 /// The number of blocks included in the range of the reply
3988 pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyChannelRange, mut val: u32) {
3989 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.number_of_blocks = val;
3991 /// True when this is the final reply for a query
3993 pub extern "C" fn ReplyChannelRange_get_sync_complete(this_ptr: &ReplyChannelRange) -> bool {
3994 let mut inner_val = &mut this_ptr.get_native_mut_ref().sync_complete;
3997 /// True when this is the final reply for a query
3999 pub extern "C" fn ReplyChannelRange_set_sync_complete(this_ptr: &mut ReplyChannelRange, mut val: bool) {
4000 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sync_complete = val;
4002 /// The short_channel_ids in the channel range
4004 pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::derived::CVec_u64Z) {
4005 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
4006 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
4008 /// Constructs a new ReplyChannelRange given each field
4011 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 {
4012 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 }); };
4013 ReplyChannelRange { inner: ObjOps::heap_alloc(nativeReplyChannelRange {
4014 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4015 first_blocknum: first_blocknum_arg,
4016 number_of_blocks: number_of_blocks_arg,
4017 sync_complete: sync_complete_arg,
4018 short_channel_ids: local_short_channel_ids_arg,
4019 }), is_owned: true }
4021 impl Clone for ReplyChannelRange {
4022 fn clone(&self) -> Self {
4024 inner: if <*mut nativeReplyChannelRange>::is_null(self.inner) { std::ptr::null_mut() } else {
4025 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4031 /// Used only if an object of this type is returned as a trait impl by a method
4032 pub(crate) extern "C" fn ReplyChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
4033 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyChannelRange)).clone() })) as *mut c_void
4036 /// Creates a copy of the ReplyChannelRange
4037 pub extern "C" fn ReplyChannelRange_clone(orig: &ReplyChannelRange) -> ReplyChannelRange {
4041 use lightning::ln::msgs::QueryShortChannelIds as nativeQueryShortChannelIdsImport;
4042 type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport;
4044 /// A query_short_channel_ids message is used to query a peer for
4045 /// routing gossip messages related to one or more short_channel_ids.
4046 /// The query recipient will reply with the latest, if available,
4047 /// channel_announcement, channel_update and node_announcement messages
4048 /// it maintains for the requested short_channel_ids followed by a
4049 /// reply_short_channel_ids_end message. The short_channel_ids sent in
4050 /// this query are encoded. We only support encoding_type=0 uncompressed
4051 /// serialization and do not support encoding_type=1 zlib serialization.
4054 pub struct QueryShortChannelIds {
4055 /// A pointer to the opaque Rust object.
4057 /// Nearly everywhere, inner must be non-null, however in places where
4058 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4059 pub inner: *mut nativeQueryShortChannelIds,
4060 /// Indicates that this is the only struct which contains the same pointer.
4062 /// Rust functions which take ownership of an object provided via an argument require
4063 /// this to be true and invalidate the object pointed to by inner.
4067 impl Drop for QueryShortChannelIds {
4068 fn drop(&mut self) {
4069 if self.is_owned && !<*mut nativeQueryShortChannelIds>::is_null(self.inner) {
4070 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4074 /// Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL.
4076 pub extern "C" fn QueryShortChannelIds_free(this_obj: QueryShortChannelIds) { }
4078 /// Used only if an object of this type is returned as a trait impl by a method
4079 extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) {
4080 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryShortChannelIds); }
4083 impl QueryShortChannelIds {
4084 pub(crate) fn get_native_ref(&self) -> &'static nativeQueryShortChannelIds {
4085 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4087 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQueryShortChannelIds {
4088 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4090 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4091 pub(crate) fn take_inner(mut self) -> *mut nativeQueryShortChannelIds {
4092 assert!(self.is_owned);
4093 let ret = ObjOps::untweak_ptr(self.inner);
4094 self.inner = std::ptr::null_mut();
4098 /// The genesis hash of the blockchain being queried
4100 pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *const [u8; 32] {
4101 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4102 inner_val.as_inner()
4104 /// The genesis hash of the blockchain being queried
4106 pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::ThirtyTwoBytes) {
4107 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4109 /// The short_channel_ids that are being queried
4111 pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::derived::CVec_u64Z) {
4112 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
4113 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_ids = local_val;
4115 /// Constructs a new QueryShortChannelIds given each field
4118 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 {
4119 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 }); };
4120 QueryShortChannelIds { inner: ObjOps::heap_alloc(nativeQueryShortChannelIds {
4121 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4122 short_channel_ids: local_short_channel_ids_arg,
4123 }), is_owned: true }
4125 impl Clone for QueryShortChannelIds {
4126 fn clone(&self) -> Self {
4128 inner: if <*mut nativeQueryShortChannelIds>::is_null(self.inner) { std::ptr::null_mut() } else {
4129 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4135 /// Used only if an object of this type is returned as a trait impl by a method
4136 pub(crate) extern "C" fn QueryShortChannelIds_clone_void(this_ptr: *const c_void) -> *mut c_void {
4137 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryShortChannelIds)).clone() })) as *mut c_void
4140 /// Creates a copy of the QueryShortChannelIds
4141 pub extern "C" fn QueryShortChannelIds_clone(orig: &QueryShortChannelIds) -> QueryShortChannelIds {
4145 use lightning::ln::msgs::ReplyShortChannelIdsEnd as nativeReplyShortChannelIdsEndImport;
4146 type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport;
4148 /// A reply_short_channel_ids_end message is sent as a reply to a
4149 /// query_short_channel_ids message. The query recipient makes a best
4150 /// effort to respond based on their local network view which may not be
4151 /// a perfect view of the network.
4154 pub struct ReplyShortChannelIdsEnd {
4155 /// A pointer to the opaque Rust object.
4157 /// Nearly everywhere, inner must be non-null, however in places where
4158 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4159 pub inner: *mut nativeReplyShortChannelIdsEnd,
4160 /// Indicates that this is the only struct which contains the same pointer.
4162 /// Rust functions which take ownership of an object provided via an argument require
4163 /// this to be true and invalidate the object pointed to by inner.
4167 impl Drop for ReplyShortChannelIdsEnd {
4168 fn drop(&mut self) {
4169 if self.is_owned && !<*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) {
4170 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4174 /// Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL.
4176 pub extern "C" fn ReplyShortChannelIdsEnd_free(this_obj: ReplyShortChannelIdsEnd) { }
4178 /// Used only if an object of this type is returned as a trait impl by a method
4179 extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) {
4180 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyShortChannelIdsEnd); }
4183 impl ReplyShortChannelIdsEnd {
4184 pub(crate) fn get_native_ref(&self) -> &'static nativeReplyShortChannelIdsEnd {
4185 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4187 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplyShortChannelIdsEnd {
4188 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4190 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4191 pub(crate) fn take_inner(mut self) -> *mut nativeReplyShortChannelIdsEnd {
4192 assert!(self.is_owned);
4193 let ret = ObjOps::untweak_ptr(self.inner);
4194 self.inner = std::ptr::null_mut();
4198 /// The genesis hash of the blockchain that was queried
4200 pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *const [u8; 32] {
4201 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4202 inner_val.as_inner()
4204 /// The genesis hash of the blockchain that was queried
4206 pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) {
4207 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4209 /// Indicates if the query recipient maintains up-to-date channel
4210 /// information for the chain_hash
4212 pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool {
4213 let mut inner_val = &mut this_ptr.get_native_mut_ref().full_information;
4216 /// Indicates if the query recipient maintains up-to-date channel
4217 /// information for the chain_hash
4219 pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: bool) {
4220 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.full_information = val;
4222 /// Constructs a new ReplyShortChannelIdsEnd given each field
4225 pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd {
4226 ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(nativeReplyShortChannelIdsEnd {
4227 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4228 full_information: full_information_arg,
4229 }), is_owned: true }
4231 impl Clone for ReplyShortChannelIdsEnd {
4232 fn clone(&self) -> Self {
4234 inner: if <*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) { std::ptr::null_mut() } else {
4235 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4241 /// Used only if an object of this type is returned as a trait impl by a method
4242 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_void) -> *mut c_void {
4243 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyShortChannelIdsEnd)).clone() })) as *mut c_void
4246 /// Creates a copy of the ReplyShortChannelIdsEnd
4247 pub extern "C" fn ReplyShortChannelIdsEnd_clone(orig: &ReplyShortChannelIdsEnd) -> ReplyShortChannelIdsEnd {
4251 use lightning::ln::msgs::GossipTimestampFilter as nativeGossipTimestampFilterImport;
4252 type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport;
4254 /// A gossip_timestamp_filter message is used by a node to request
4255 /// gossip relay for messages in the requested time range when the
4256 /// gossip_queries feature has been negotiated.
4259 pub struct GossipTimestampFilter {
4260 /// A pointer to the opaque Rust object.
4262 /// Nearly everywhere, inner must be non-null, however in places where
4263 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4264 pub inner: *mut nativeGossipTimestampFilter,
4265 /// Indicates that this is the only struct which contains the same pointer.
4267 /// Rust functions which take ownership of an object provided via an argument require
4268 /// this to be true and invalidate the object pointed to by inner.
4272 impl Drop for GossipTimestampFilter {
4273 fn drop(&mut self) {
4274 if self.is_owned && !<*mut nativeGossipTimestampFilter>::is_null(self.inner) {
4275 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4279 /// Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL.
4281 pub extern "C" fn GossipTimestampFilter_free(this_obj: GossipTimestampFilter) { }
4283 /// Used only if an object of this type is returned as a trait impl by a method
4284 extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) {
4285 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeGossipTimestampFilter); }
4288 impl GossipTimestampFilter {
4289 pub(crate) fn get_native_ref(&self) -> &'static nativeGossipTimestampFilter {
4290 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4292 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeGossipTimestampFilter {
4293 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4295 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4296 pub(crate) fn take_inner(mut self) -> *mut nativeGossipTimestampFilter {
4297 assert!(self.is_owned);
4298 let ret = ObjOps::untweak_ptr(self.inner);
4299 self.inner = std::ptr::null_mut();
4303 /// The genesis hash of the blockchain for channel and node information
4305 pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *const [u8; 32] {
4306 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash;
4307 inner_val.as_inner()
4309 /// The genesis hash of the blockchain for channel and node information
4311 pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) {
4312 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
4314 /// The starting unix timestamp
4316 pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 {
4317 let mut inner_val = &mut this_ptr.get_native_mut_ref().first_timestamp;
4320 /// The starting unix timestamp
4322 pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
4323 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_timestamp = val;
4325 /// The range of information in seconds
4327 pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 {
4328 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp_range;
4331 /// The range of information in seconds
4333 pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
4334 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp_range = val;
4336 /// Constructs a new GossipTimestampFilter given each field
4339 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 {
4340 GossipTimestampFilter { inner: ObjOps::heap_alloc(nativeGossipTimestampFilter {
4341 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
4342 first_timestamp: first_timestamp_arg,
4343 timestamp_range: timestamp_range_arg,
4344 }), is_owned: true }
4346 impl Clone for GossipTimestampFilter {
4347 fn clone(&self) -> Self {
4349 inner: if <*mut nativeGossipTimestampFilter>::is_null(self.inner) { std::ptr::null_mut() } else {
4350 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4356 /// Used only if an object of this type is returned as a trait impl by a method
4357 pub(crate) extern "C" fn GossipTimestampFilter_clone_void(this_ptr: *const c_void) -> *mut c_void {
4358 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeGossipTimestampFilter)).clone() })) as *mut c_void
4361 /// Creates a copy of the GossipTimestampFilter
4362 pub extern "C" fn GossipTimestampFilter_clone(orig: &GossipTimestampFilter) -> GossipTimestampFilter {
4365 /// Used to put an error message in a LightningError
4369 pub enum ErrorAction {
4370 /// The peer took some action which made us think they were useless. Disconnect them.
4372 /// An error message which we should make an effort to send before we disconnect.
4374 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
4375 msg: crate::lightning::ln::msgs::ErrorMessage,
4377 /// The peer did something harmless that we weren't able to process, just log and ignore
4379 /// The peer did something harmless that we weren't able to meaningfully process.
4380 /// If the error is logged, log it at the given level.
4381 IgnoreAndLog(crate::lightning::util::logger::Level),
4382 /// The peer did something incorrect. Tell them.
4384 /// The message to send.
4385 msg: crate::lightning::ln::msgs::ErrorMessage,
4388 use lightning::ln::msgs::ErrorAction as nativeErrorAction;
4391 pub(crate) fn to_native(&self) -> nativeErrorAction {
4393 ErrorAction::DisconnectPeer {ref msg, } => {
4394 let mut msg_nonref = (*msg).clone();
4395 let mut local_msg_nonref = if msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg_nonref.take_inner()) } }) };
4396 nativeErrorAction::DisconnectPeer {
4397 msg: local_msg_nonref,
4400 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
4401 ErrorAction::IgnoreAndLog (ref a, ) => {
4402 let mut a_nonref = (*a).clone();
4403 nativeErrorAction::IgnoreAndLog (
4404 a_nonref.into_native(),
4407 ErrorAction::SendErrorMessage {ref msg, } => {
4408 let mut msg_nonref = (*msg).clone();
4409 nativeErrorAction::SendErrorMessage {
4410 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
4416 pub(crate) fn into_native(self) -> nativeErrorAction {
4418 ErrorAction::DisconnectPeer {mut msg, } => {
4419 let mut local_msg = if msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg.take_inner()) } }) };
4420 nativeErrorAction::DisconnectPeer {
4424 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
4425 ErrorAction::IgnoreAndLog (mut a, ) => {
4426 nativeErrorAction::IgnoreAndLog (
4430 ErrorAction::SendErrorMessage {mut msg, } => {
4431 nativeErrorAction::SendErrorMessage {
4432 msg: *unsafe { Box::from_raw(msg.take_inner()) },
4438 pub(crate) fn from_native(native: &nativeErrorAction) -> Self {
4440 nativeErrorAction::DisconnectPeer {ref msg, } => {
4441 let mut msg_nonref = (*msg).clone();
4442 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 };
4443 ErrorAction::DisconnectPeer {
4444 msg: local_msg_nonref,
4447 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
4448 nativeErrorAction::IgnoreAndLog (ref a, ) => {
4449 let mut a_nonref = (*a).clone();
4450 ErrorAction::IgnoreAndLog (
4451 crate::lightning::util::logger::Level::native_into(a_nonref),
4454 nativeErrorAction::SendErrorMessage {ref msg, } => {
4455 let mut msg_nonref = (*msg).clone();
4456 ErrorAction::SendErrorMessage {
4457 msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
4463 pub(crate) fn native_into(native: nativeErrorAction) -> Self {
4465 nativeErrorAction::DisconnectPeer {mut msg, } => {
4466 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 };
4467 ErrorAction::DisconnectPeer {
4471 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
4472 nativeErrorAction::IgnoreAndLog (mut a, ) => {
4473 ErrorAction::IgnoreAndLog (
4474 crate::lightning::util::logger::Level::native_into(a),
4477 nativeErrorAction::SendErrorMessage {mut msg, } => {
4478 ErrorAction::SendErrorMessage {
4479 msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
4485 /// Frees any resources used by the ErrorAction
4487 pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { }
4488 /// Creates a copy of the ErrorAction
4490 pub extern "C" fn ErrorAction_clone(orig: &ErrorAction) -> ErrorAction {
4494 /// Utility method to constructs a new DisconnectPeer-variant ErrorAction
4495 pub extern "C" fn ErrorAction_disconnect_peer(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
4496 ErrorAction::DisconnectPeer {
4501 /// Utility method to constructs a new IgnoreError-variant ErrorAction
4502 pub extern "C" fn ErrorAction_ignore_error() -> ErrorAction {
4503 ErrorAction::IgnoreError}
4505 /// Utility method to constructs a new IgnoreAndLog-variant ErrorAction
4506 pub extern "C" fn ErrorAction_ignore_and_log(a: crate::lightning::util::logger::Level) -> ErrorAction {
4507 ErrorAction::IgnoreAndLog(a, )
4510 /// Utility method to constructs a new SendErrorMessage-variant ErrorAction
4511 pub extern "C" fn ErrorAction_send_error_message(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
4512 ErrorAction::SendErrorMessage {
4517 use lightning::ln::msgs::LightningError as nativeLightningErrorImport;
4518 type nativeLightningError = nativeLightningErrorImport;
4520 /// An Err type for failure to process messages.
4523 pub struct LightningError {
4524 /// A pointer to the opaque Rust object.
4526 /// Nearly everywhere, inner must be non-null, however in places where
4527 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4528 pub inner: *mut nativeLightningError,
4529 /// Indicates that this is the only struct which contains the same pointer.
4531 /// Rust functions which take ownership of an object provided via an argument require
4532 /// this to be true and invalidate the object pointed to by inner.
4536 impl Drop for LightningError {
4537 fn drop(&mut self) {
4538 if self.is_owned && !<*mut nativeLightningError>::is_null(self.inner) {
4539 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4543 /// Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL.
4545 pub extern "C" fn LightningError_free(this_obj: LightningError) { }
4547 /// Used only if an object of this type is returned as a trait impl by a method
4548 extern "C" fn LightningError_free_void(this_ptr: *mut c_void) {
4549 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeLightningError); }
4552 impl LightningError {
4553 pub(crate) fn get_native_ref(&self) -> &'static nativeLightningError {
4554 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4556 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLightningError {
4557 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4559 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4560 pub(crate) fn take_inner(mut self) -> *mut nativeLightningError {
4561 assert!(self.is_owned);
4562 let ret = ObjOps::untweak_ptr(self.inner);
4563 self.inner = std::ptr::null_mut();
4567 /// A human-readable message describing the error
4569 pub extern "C" fn LightningError_get_err(this_ptr: &LightningError) -> crate::c_types::Str {
4570 let mut inner_val = &mut this_ptr.get_native_mut_ref().err;
4571 inner_val.as_str().into()
4573 /// A human-readable message describing the error
4575 pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: crate::c_types::Str) {
4576 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.err = val.into_string();
4578 /// The action which should be taken against the offending peer.
4580 pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate::lightning::ln::msgs::ErrorAction {
4581 let mut inner_val = &mut this_ptr.get_native_mut_ref().action;
4582 crate::lightning::ln::msgs::ErrorAction::from_native(inner_val)
4584 /// The action which should be taken against the offending peer.
4586 pub extern "C" fn LightningError_set_action(this_ptr: &mut LightningError, mut val: crate::lightning::ln::msgs::ErrorAction) {
4587 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.action = val.into_native();
4589 /// Constructs a new LightningError given each field
4592 pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::Str, mut action_arg: crate::lightning::ln::msgs::ErrorAction) -> LightningError {
4593 LightningError { inner: ObjOps::heap_alloc(nativeLightningError {
4594 err: err_arg.into_string(),
4595 action: action_arg.into_native(),
4596 }), is_owned: true }
4598 impl Clone for LightningError {
4599 fn clone(&self) -> Self {
4601 inner: if <*mut nativeLightningError>::is_null(self.inner) { std::ptr::null_mut() } else {
4602 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4608 /// Used only if an object of this type is returned as a trait impl by a method
4609 pub(crate) extern "C" fn LightningError_clone_void(this_ptr: *const c_void) -> *mut c_void {
4610 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeLightningError)).clone() })) as *mut c_void
4613 /// Creates a copy of the LightningError
4614 pub extern "C" fn LightningError_clone(orig: &LightningError) -> LightningError {
4618 use lightning::ln::msgs::CommitmentUpdate as nativeCommitmentUpdateImport;
4619 type nativeCommitmentUpdate = nativeCommitmentUpdateImport;
4621 /// Struct used to return values from revoke_and_ack messages, containing a bunch of commitment
4622 /// transaction updates if they were pending.
4625 pub struct CommitmentUpdate {
4626 /// A pointer to the opaque Rust object.
4628 /// Nearly everywhere, inner must be non-null, however in places where
4629 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
4630 pub inner: *mut nativeCommitmentUpdate,
4631 /// Indicates that this is the only struct which contains the same pointer.
4633 /// Rust functions which take ownership of an object provided via an argument require
4634 /// this to be true and invalidate the object pointed to by inner.
4638 impl Drop for CommitmentUpdate {
4639 fn drop(&mut self) {
4640 if self.is_owned && !<*mut nativeCommitmentUpdate>::is_null(self.inner) {
4641 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
4645 /// Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL.
4647 pub extern "C" fn CommitmentUpdate_free(this_obj: CommitmentUpdate) { }
4649 /// Used only if an object of this type is returned as a trait impl by a method
4650 extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) {
4651 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentUpdate); }
4654 impl CommitmentUpdate {
4655 pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentUpdate {
4656 unsafe { &*ObjOps::untweak_ptr(self.inner) }
4658 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentUpdate {
4659 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
4661 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
4662 pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentUpdate {
4663 assert!(self.is_owned);
4664 let ret = ObjOps::untweak_ptr(self.inner);
4665 self.inner = std::ptr::null_mut();
4669 /// update_add_htlc messages which should be sent
4671 pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) {
4672 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4673 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_add_htlcs = local_val;
4675 /// update_fulfill_htlc messages which should be sent
4677 pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) {
4678 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4679 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fulfill_htlcs = local_val;
4681 /// update_fail_htlc messages which should be sent
4683 pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) {
4684 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4685 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_htlcs = local_val;
4687 /// update_fail_malformed_htlc messages which should be sent
4689 pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) {
4690 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4691 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_malformed_htlcs = local_val;
4693 /// An update_fee message which should be sent
4695 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
4697 pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::UpdateFee {
4698 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fee;
4699 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 };
4702 /// An update_fee message which should be sent
4704 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
4706 pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::UpdateFee) {
4707 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
4708 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fee = local_val;
4710 /// Finally, the commitment_signed message which should be sent
4712 pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::CommitmentSigned {
4713 let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_signed;
4714 crate::lightning::ln::msgs::CommitmentSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false }
4716 /// Finally, the commitment_signed message which should be sent
4718 pub extern "C" fn CommitmentUpdate_set_commitment_signed(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::CommitmentSigned) {
4719 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_signed = *unsafe { Box::from_raw(val.take_inner()) };
4721 /// Constructs a new CommitmentUpdate given each field
4724 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 {
4725 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()) } }); };
4726 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()) } }); };
4727 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()) } }); };
4728 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()) } }); };
4729 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()) } }) };
4730 CommitmentUpdate { inner: ObjOps::heap_alloc(nativeCommitmentUpdate {
4731 update_add_htlcs: local_update_add_htlcs_arg,
4732 update_fulfill_htlcs: local_update_fulfill_htlcs_arg,
4733 update_fail_htlcs: local_update_fail_htlcs_arg,
4734 update_fail_malformed_htlcs: local_update_fail_malformed_htlcs_arg,
4735 update_fee: local_update_fee_arg,
4736 commitment_signed: *unsafe { Box::from_raw(commitment_signed_arg.take_inner()) },
4737 }), is_owned: true }
4739 impl Clone for CommitmentUpdate {
4740 fn clone(&self) -> Self {
4742 inner: if <*mut nativeCommitmentUpdate>::is_null(self.inner) { std::ptr::null_mut() } else {
4743 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
4749 /// Used only if an object of this type is returned as a trait impl by a method
4750 pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
4751 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentUpdate)).clone() })) as *mut c_void
4754 /// Creates a copy of the CommitmentUpdate
4755 pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentUpdate {
4758 /// The information we received from a peer along the route of a payment we originated. This is
4759 /// returned by ChannelMessageHandler::handle_update_fail_htlc to be passed into
4760 /// RoutingMessageHandler::handle_htlc_fail_channel_update to update our network map.
4764 pub enum HTLCFailChannelUpdate {
4765 /// We received an error which included a full ChannelUpdate message.
4766 ChannelUpdateMessage {
4767 /// The unwrapped message we received
4768 msg: crate::lightning::ln::msgs::ChannelUpdate,
4770 /// We received an error which indicated only that a channel has been closed
4772 /// The short_channel_id which has now closed.
4773 short_channel_id: u64,
4774 /// when this true, this channel should be permanently removed from the
4775 /// consideration. Otherwise, this channel can be restored as new channel_update is received
4778 /// We received an error which indicated only that a node has failed
4780 /// The node_id that has failed.
4781 node_id: crate::c_types::PublicKey,
4782 /// when this true, node should be permanently removed from the
4783 /// consideration. Otherwise, the channels connected to this node can be
4784 /// restored as new channel_update is received
4788 use lightning::ln::msgs::HTLCFailChannelUpdate as nativeHTLCFailChannelUpdate;
4789 impl HTLCFailChannelUpdate {
4791 pub(crate) fn to_native(&self) -> nativeHTLCFailChannelUpdate {
4793 HTLCFailChannelUpdate::ChannelUpdateMessage {ref msg, } => {
4794 let mut msg_nonref = (*msg).clone();
4795 nativeHTLCFailChannelUpdate::ChannelUpdateMessage {
4796 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
4799 HTLCFailChannelUpdate::ChannelClosed {ref short_channel_id, ref is_permanent, } => {
4800 let mut short_channel_id_nonref = (*short_channel_id).clone();
4801 let mut is_permanent_nonref = (*is_permanent).clone();
4802 nativeHTLCFailChannelUpdate::ChannelClosed {
4803 short_channel_id: short_channel_id_nonref,
4804 is_permanent: is_permanent_nonref,
4807 HTLCFailChannelUpdate::NodeFailure {ref node_id, ref is_permanent, } => {
4808 let mut node_id_nonref = (*node_id).clone();
4809 let mut is_permanent_nonref = (*is_permanent).clone();
4810 nativeHTLCFailChannelUpdate::NodeFailure {
4811 node_id: node_id_nonref.into_rust(),
4812 is_permanent: is_permanent_nonref,
4818 pub(crate) fn into_native(self) -> nativeHTLCFailChannelUpdate {
4820 HTLCFailChannelUpdate::ChannelUpdateMessage {mut msg, } => {
4821 nativeHTLCFailChannelUpdate::ChannelUpdateMessage {
4822 msg: *unsafe { Box::from_raw(msg.take_inner()) },
4825 HTLCFailChannelUpdate::ChannelClosed {mut short_channel_id, mut is_permanent, } => {
4826 nativeHTLCFailChannelUpdate::ChannelClosed {
4827 short_channel_id: short_channel_id,
4828 is_permanent: is_permanent,
4831 HTLCFailChannelUpdate::NodeFailure {mut node_id, mut is_permanent, } => {
4832 nativeHTLCFailChannelUpdate::NodeFailure {
4833 node_id: node_id.into_rust(),
4834 is_permanent: is_permanent,
4840 pub(crate) fn from_native(native: &nativeHTLCFailChannelUpdate) -> Self {
4842 nativeHTLCFailChannelUpdate::ChannelUpdateMessage {ref msg, } => {
4843 let mut msg_nonref = (*msg).clone();
4844 HTLCFailChannelUpdate::ChannelUpdateMessage {
4845 msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
4848 nativeHTLCFailChannelUpdate::ChannelClosed {ref short_channel_id, ref is_permanent, } => {
4849 let mut short_channel_id_nonref = (*short_channel_id).clone();
4850 let mut is_permanent_nonref = (*is_permanent).clone();
4851 HTLCFailChannelUpdate::ChannelClosed {
4852 short_channel_id: short_channel_id_nonref,
4853 is_permanent: is_permanent_nonref,
4856 nativeHTLCFailChannelUpdate::NodeFailure {ref node_id, ref is_permanent, } => {
4857 let mut node_id_nonref = (*node_id).clone();
4858 let mut is_permanent_nonref = (*is_permanent).clone();
4859 HTLCFailChannelUpdate::NodeFailure {
4860 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
4861 is_permanent: is_permanent_nonref,
4867 pub(crate) fn native_into(native: nativeHTLCFailChannelUpdate) -> Self {
4869 nativeHTLCFailChannelUpdate::ChannelUpdateMessage {mut msg, } => {
4870 HTLCFailChannelUpdate::ChannelUpdateMessage {
4871 msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg), is_owned: true },
4874 nativeHTLCFailChannelUpdate::ChannelClosed {mut short_channel_id, mut is_permanent, } => {
4875 HTLCFailChannelUpdate::ChannelClosed {
4876 short_channel_id: short_channel_id,
4877 is_permanent: is_permanent,
4880 nativeHTLCFailChannelUpdate::NodeFailure {mut node_id, mut is_permanent, } => {
4881 HTLCFailChannelUpdate::NodeFailure {
4882 node_id: crate::c_types::PublicKey::from_rust(&node_id),
4883 is_permanent: is_permanent,
4889 /// Frees any resources used by the HTLCFailChannelUpdate
4891 pub extern "C" fn HTLCFailChannelUpdate_free(this_ptr: HTLCFailChannelUpdate) { }
4892 /// Creates a copy of the HTLCFailChannelUpdate
4894 pub extern "C" fn HTLCFailChannelUpdate_clone(orig: &HTLCFailChannelUpdate) -> HTLCFailChannelUpdate {
4898 /// Utility method to constructs a new ChannelUpdateMessage-variant HTLCFailChannelUpdate
4899 pub extern "C" fn HTLCFailChannelUpdate_channel_update_message(msg: crate::lightning::ln::msgs::ChannelUpdate) -> HTLCFailChannelUpdate {
4900 HTLCFailChannelUpdate::ChannelUpdateMessage {
4905 /// Utility method to constructs a new ChannelClosed-variant HTLCFailChannelUpdate
4906 pub extern "C" fn HTLCFailChannelUpdate_channel_closed(short_channel_id: u64, is_permanent: bool) -> HTLCFailChannelUpdate {
4907 HTLCFailChannelUpdate::ChannelClosed {
4913 /// Utility method to constructs a new NodeFailure-variant HTLCFailChannelUpdate
4914 pub extern "C" fn HTLCFailChannelUpdate_node_failure(node_id: crate::c_types::PublicKey, is_permanent: bool) -> HTLCFailChannelUpdate {
4915 HTLCFailChannelUpdate::NodeFailure {
4920 /// A trait to describe an object which can receive channel messages.
4922 /// Messages MAY be called in parallel when they originate from different their_node_ids, however
4923 /// they MUST NOT be called in parallel when the two calls have the same their_node_id.
4925 pub struct ChannelMessageHandler {
4926 /// An opaque pointer which is passed to your function implementations as an argument.
4927 /// This has no meaning in the LDK, and can be NULL or any other value.
4928 pub this_arg: *mut c_void,
4929 /// Handle an incoming open_channel message from the given peer.
4930 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),
4931 /// Handle an incoming accept_channel message from the given peer.
4932 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),
4933 /// Handle an incoming funding_created message from the given peer.
4934 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),
4935 /// Handle an incoming funding_signed message from the given peer.
4936 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),
4937 /// Handle an incoming funding_locked message from the given peer.
4938 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),
4939 /// Handle an incoming shutdown message from the given peer.
4940 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),
4941 /// Handle an incoming closing_signed message from the given peer.
4942 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),
4943 /// Handle an incoming update_add_htlc message from the given peer.
4944 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),
4945 /// Handle an incoming update_fulfill_htlc message from the given peer.
4946 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),
4947 /// Handle an incoming update_fail_htlc message from the given peer.
4948 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),
4949 /// Handle an incoming update_fail_malformed_htlc message from the given peer.
4950 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),
4951 /// Handle an incoming commitment_signed message from the given peer.
4952 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),
4953 /// Handle an incoming revoke_and_ack message from the given peer.
4954 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),
4955 /// Handle an incoming update_fee message from the given peer.
4956 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),
4957 /// Handle an incoming announcement_signatures message from the given peer.
4958 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),
4959 /// Indicates a connection to the peer failed/an existing connection was lost. If no connection
4960 /// is believed to be possible in the future (eg they're sending us messages we don't
4961 /// understand or indicate they require unknown feature bits), no_connection_possible is set
4962 /// and any outstanding channels should be failed.
4963 pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, no_connection_possible: bool),
4964 /// Handle a peer reconnecting, possibly generating channel_reestablish message(s).
4965 pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Init),
4966 /// Handle an incoming channel_reestablish message from the given peer.
4967 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),
4968 /// Handle an incoming channel update from the given peer.
4969 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),
4970 /// Handle an incoming error message from the given peer.
4971 pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ErrorMessage),
4972 /// Implementation of MessageSendEventsProvider for this object.
4973 pub MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider,
4974 /// Frees any resources associated with this object given its this_arg pointer.
4975 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
4976 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
4978 unsafe impl Send for ChannelMessageHandler {}
4979 unsafe impl Sync for ChannelMessageHandler {}
4981 pub(crate) extern "C" fn ChannelMessageHandler_clone_fields(orig: &ChannelMessageHandler) -> ChannelMessageHandler {
4982 ChannelMessageHandler {
4983 this_arg: orig.this_arg,
4984 handle_open_channel: Clone::clone(&orig.handle_open_channel),
4985 handle_accept_channel: Clone::clone(&orig.handle_accept_channel),
4986 handle_funding_created: Clone::clone(&orig.handle_funding_created),
4987 handle_funding_signed: Clone::clone(&orig.handle_funding_signed),
4988 handle_funding_locked: Clone::clone(&orig.handle_funding_locked),
4989 handle_shutdown: Clone::clone(&orig.handle_shutdown),
4990 handle_closing_signed: Clone::clone(&orig.handle_closing_signed),
4991 handle_update_add_htlc: Clone::clone(&orig.handle_update_add_htlc),
4992 handle_update_fulfill_htlc: Clone::clone(&orig.handle_update_fulfill_htlc),
4993 handle_update_fail_htlc: Clone::clone(&orig.handle_update_fail_htlc),
4994 handle_update_fail_malformed_htlc: Clone::clone(&orig.handle_update_fail_malformed_htlc),
4995 handle_commitment_signed: Clone::clone(&orig.handle_commitment_signed),
4996 handle_revoke_and_ack: Clone::clone(&orig.handle_revoke_and_ack),
4997 handle_update_fee: Clone::clone(&orig.handle_update_fee),
4998 handle_announcement_signatures: Clone::clone(&orig.handle_announcement_signatures),
4999 peer_disconnected: Clone::clone(&orig.peer_disconnected),
5000 peer_connected: Clone::clone(&orig.peer_connected),
5001 handle_channel_reestablish: Clone::clone(&orig.handle_channel_reestablish),
5002 handle_channel_update: Clone::clone(&orig.handle_channel_update),
5003 handle_error: Clone::clone(&orig.handle_error),
5004 MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
5005 free: Clone::clone(&orig.free),
5008 impl lightning::util::events::MessageSendEventsProvider for ChannelMessageHandler {
5009 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
5010 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
5011 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
5016 use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler;
5017 impl rustChannelMessageHandler for ChannelMessageHandler {
5018 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) {
5019 (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 })
5021 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) {
5022 (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 })
5024 fn handle_funding_created(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::FundingCreated) {
5025 (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 })
5027 fn handle_funding_signed(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::FundingSigned) {
5028 (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 })
5030 fn handle_funding_locked(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::FundingLocked) {
5031 (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 })
5033 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) {
5034 (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 })
5036 fn handle_closing_signed(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ClosingSigned) {
5037 (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 })
5039 fn handle_update_add_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateAddHTLC) {
5040 (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 })
5042 fn handle_update_fulfill_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFulfillHTLC) {
5043 (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 })
5045 fn handle_update_fail_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailHTLC) {
5046 (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 })
5048 fn handle_update_fail_malformed_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) {
5049 (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 })
5051 fn handle_commitment_signed(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::CommitmentSigned) {
5052 (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 })
5054 fn handle_revoke_and_ack(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::RevokeAndACK) {
5055 (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 })
5057 fn handle_update_fee(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFee) {
5058 (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 })
5060 fn handle_announcement_signatures(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::AnnouncementSignatures) {
5061 (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 })
5063 fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut no_connection_possible: bool) {
5064 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), no_connection_possible)
5066 fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::Init) {
5067 (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 })
5069 fn handle_channel_reestablish(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ChannelReestablish) {
5070 (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 })
5072 fn handle_channel_update(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ChannelUpdate) {
5073 (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 })
5075 fn handle_error(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ErrorMessage) {
5076 (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 })
5080 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
5081 // directly as a Deref trait in higher-level structs:
5082 impl std::ops::Deref for ChannelMessageHandler {
5084 fn deref(&self) -> &Self {
5088 /// Calls the free function if one is set
5090 pub extern "C" fn ChannelMessageHandler_free(this_ptr: ChannelMessageHandler) { }
5091 impl Drop for ChannelMessageHandler {
5092 fn drop(&mut self) {
5093 if let Some(f) = self.free {
5098 /// A trait to describe an object which can receive routing messages.
5100 /// # Implementor DoS Warnings
5102 /// For `gossip_queries` messages there are potential DoS vectors when handling
5103 /// inbound queries. Implementors using an on-disk network graph should be aware of
5104 /// repeated disk I/O for queries accessing different parts of the network graph.
5106 pub struct RoutingMessageHandler {
5107 /// An opaque pointer which is passed to your function implementations as an argument.
5108 /// This has no meaning in the LDK, and can be NULL or any other value.
5109 pub this_arg: *mut c_void,
5110 /// Handle an incoming node_announcement message, returning true if it should be forwarded on,
5111 /// false or returning an Err otherwise.
5113 pub handle_node_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
5114 /// Handle a channel_announcement message, returning true if it should be forwarded on, false
5115 /// or returning an Err otherwise.
5117 pub handle_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
5118 /// Handle an incoming channel_update message, returning true if it should be forwarded on,
5119 /// false or returning an Err otherwise.
5121 pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ,
5122 /// Handle some updates to the route graph that we learned due to an outbound failed payment.
5123 pub handle_htlc_fail_channel_update: extern "C" fn (this_arg: *const c_void, update: &crate::lightning::ln::msgs::HTLCFailChannelUpdate),
5124 /// Gets a subset of the channel announcements and updates required to dump our routing table
5125 /// to a remote node, starting at the short_channel_id indicated by starting_point and
5126 /// including the batch_amount entries immediately higher in numerical value than starting_point.
5128 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,
5129 /// Gets a subset of the node announcements required to dump our routing table to a remote node,
5130 /// starting at the node *after* the provided publickey and including batch_amount entries
5131 /// immediately higher (as defined by <PublicKey as Ord>::cmp) than starting_point.
5132 /// If None is provided for starting_point, we start at the first node.
5134 /// Note that starting_point (or a relevant inner pointer) may be NULL or all-0s to represent None
5136 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,
5137 /// Called when a connection is established with a peer. This can be used to
5138 /// perform routing table synchronization using a strategy defined by the
5140 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),
5141 /// Handles the reply of a query we initiated to learn about channels
5142 /// for a given range of blocks. We can expect to receive one or more
5143 /// replies to a single query.
5145 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,
5146 /// Handles the reply of a query we initiated asking for routing gossip
5147 /// messages for a list of channels. We should receive this message when
5148 /// a node has completed its best effort to send us the pertaining routing
5149 /// gossip messages.
5151 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,
5152 /// Handles when a peer asks us to send a list of short_channel_ids
5153 /// for the requested range of blocks.
5155 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,
5156 /// Handles when a peer asks us to send routing gossip messages for a
5157 /// list of short_channel_ids.
5159 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,
5160 /// Implementation of MessageSendEventsProvider for this object.
5161 pub MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider,
5162 /// Frees any resources associated with this object given its this_arg pointer.
5163 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
5164 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
5166 unsafe impl Send for RoutingMessageHandler {}
5167 unsafe impl Sync for RoutingMessageHandler {}
5169 pub(crate) extern "C" fn RoutingMessageHandler_clone_fields(orig: &RoutingMessageHandler) -> RoutingMessageHandler {
5170 RoutingMessageHandler {
5171 this_arg: orig.this_arg,
5172 handle_node_announcement: Clone::clone(&orig.handle_node_announcement),
5173 handle_channel_announcement: Clone::clone(&orig.handle_channel_announcement),
5174 handle_channel_update: Clone::clone(&orig.handle_channel_update),
5175 handle_htlc_fail_channel_update: Clone::clone(&orig.handle_htlc_fail_channel_update),
5176 get_next_channel_announcements: Clone::clone(&orig.get_next_channel_announcements),
5177 get_next_node_announcements: Clone::clone(&orig.get_next_node_announcements),
5178 sync_routing_table: Clone::clone(&orig.sync_routing_table),
5179 handle_reply_channel_range: Clone::clone(&orig.handle_reply_channel_range),
5180 handle_reply_short_channel_ids_end: Clone::clone(&orig.handle_reply_short_channel_ids_end),
5181 handle_query_channel_range: Clone::clone(&orig.handle_query_channel_range),
5182 handle_query_short_channel_ids: Clone::clone(&orig.handle_query_short_channel_ids),
5183 MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider),
5184 free: Clone::clone(&orig.free),
5187 impl lightning::util::events::MessageSendEventsProvider for RoutingMessageHandler {
5188 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
5189 let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg);
5190 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
5195 use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler;
5196 impl rustRoutingMessageHandler for RoutingMessageHandler {
5197 fn handle_node_announcement(&self, mut msg: &lightning::ln::msgs::NodeAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
5198 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 });
5199 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()) } })};
5202 fn handle_channel_announcement(&self, mut msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
5203 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 });
5204 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()) } })};
5207 fn handle_channel_update(&self, mut msg: &lightning::ln::msgs::ChannelUpdate) -> Result<bool, lightning::ln::msgs::LightningError> {
5208 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 });
5209 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()) } })};
5212 fn handle_htlc_fail_channel_update(&self, mut update: &lightning::ln::msgs::HTLCFailChannelUpdate) {
5213 (self.handle_htlc_fail_channel_update)(self.this_arg, &crate::lightning::ln::msgs::HTLCFailChannelUpdate::from_native(update))
5215 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>)> {
5216 let mut ret = (self.get_next_channel_announcements)(self.this_arg, starting_point, batch_amount);
5217 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 }); };
5220 fn get_next_node_announcements(&self, mut starting_point: Option<&bitcoin::secp256k1::key::PublicKey>, mut batch_amount: u8) -> Vec<lightning::ln::msgs::NodeAnnouncement> {
5221 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())) } };
5222 let mut ret = (self.get_next_node_announcements)(self.this_arg, local_starting_point, batch_amount);
5223 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
5226 fn sync_routing_table(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut init: &lightning::ln::msgs::Init) {
5227 (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 })
5229 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> {
5230 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 });
5231 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()) } })};
5234 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> {
5235 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 });
5236 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()) } })};
5239 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> {
5240 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 });
5241 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()) } })};
5244 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> {
5245 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 });
5246 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()) } })};
5251 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
5252 // directly as a Deref trait in higher-level structs:
5253 impl std::ops::Deref for RoutingMessageHandler {
5255 fn deref(&self) -> &Self {
5259 /// Calls the free function if one is set
5261 pub extern "C" fn RoutingMessageHandler_free(this_ptr: RoutingMessageHandler) { }
5262 impl Drop for RoutingMessageHandler {
5263 fn drop(&mut self) {
5264 if let Some(f) = self.free {
5269 mod fuzzy_internal_msgs {
5271 use std::str::FromStr;
5272 use std::ffi::c_void;
5273 use bitcoin::hashes::Hash;
5274 use crate::c_types::*;
5278 /// Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read
5279 pub extern "C" fn AcceptChannel_write(obj: &AcceptChannel) -> crate::c_types::derived::CVec_u8Z {
5280 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5283 pub(crate) extern "C" fn AcceptChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5284 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannel) })
5287 /// Read a AcceptChannel from a byte array, created by AcceptChannel_write
5288 pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelDecodeErrorZ {
5289 let res = crate::c_types::deserialize_obj(ser);
5290 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() };
5294 /// Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read
5295 pub extern "C" fn AnnouncementSignatures_write(obj: &AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z {
5296 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5299 pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5300 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAnnouncementSignatures) })
5303 /// Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write
5304 pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AnnouncementSignaturesDecodeErrorZ {
5305 let res = crate::c_types::deserialize_obj(ser);
5306 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() };
5310 /// Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read
5311 pub extern "C" fn ChannelReestablish_write(obj: &ChannelReestablish) -> crate::c_types::derived::CVec_u8Z {
5312 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5315 pub(crate) extern "C" fn ChannelReestablish_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5316 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReestablish) })
5319 /// Read a ChannelReestablish from a byte array, created by ChannelReestablish_write
5320 pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReestablishDecodeErrorZ {
5321 let res = crate::c_types::deserialize_obj(ser);
5322 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() };
5326 /// Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read
5327 pub extern "C" fn ClosingSigned_write(obj: &ClosingSigned) -> crate::c_types::derived::CVec_u8Z {
5328 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5331 pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5332 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSigned) })
5335 /// Read a ClosingSigned from a byte array, created by ClosingSigned_write
5336 pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedDecodeErrorZ {
5337 let res = crate::c_types::deserialize_obj(ser);
5338 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() };
5342 /// Serialize the ClosingSignedFeeRange object into a byte array which can be read by ClosingSignedFeeRange_read
5343 pub extern "C" fn ClosingSignedFeeRange_write(obj: &ClosingSignedFeeRange) -> crate::c_types::derived::CVec_u8Z {
5344 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5347 pub(crate) extern "C" fn ClosingSignedFeeRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5348 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSignedFeeRange) })
5351 /// Read a ClosingSignedFeeRange from a byte array, created by ClosingSignedFeeRange_write
5352 pub extern "C" fn ClosingSignedFeeRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedFeeRangeDecodeErrorZ {
5353 let res = crate::c_types::deserialize_obj(ser);
5354 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() };
5358 /// Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read
5359 pub extern "C" fn CommitmentSigned_write(obj: &CommitmentSigned) -> crate::c_types::derived::CVec_u8Z {
5360 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5363 pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5364 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentSigned) })
5367 /// Read a CommitmentSigned from a byte array, created by CommitmentSigned_write
5368 pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CommitmentSignedDecodeErrorZ {
5369 let res = crate::c_types::deserialize_obj(ser);
5370 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() };
5374 /// Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read
5375 pub extern "C" fn FundingCreated_write(obj: &FundingCreated) -> crate::c_types::derived::CVec_u8Z {
5376 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5379 pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5380 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingCreated) })
5383 /// Read a FundingCreated from a byte array, created by FundingCreated_write
5384 pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingCreatedDecodeErrorZ {
5385 let res = crate::c_types::deserialize_obj(ser);
5386 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() };
5390 /// Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read
5391 pub extern "C" fn FundingSigned_write(obj: &FundingSigned) -> crate::c_types::derived::CVec_u8Z {
5392 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5395 pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5396 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingSigned) })
5399 /// Read a FundingSigned from a byte array, created by FundingSigned_write
5400 pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingSignedDecodeErrorZ {
5401 let res = crate::c_types::deserialize_obj(ser);
5402 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() };
5406 /// Serialize the FundingLocked object into a byte array which can be read by FundingLocked_read
5407 pub extern "C" fn FundingLocked_write(obj: &FundingLocked) -> crate::c_types::derived::CVec_u8Z {
5408 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5411 pub(crate) extern "C" fn FundingLocked_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5412 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingLocked) })
5415 /// Read a FundingLocked from a byte array, created by FundingLocked_write
5416 pub extern "C" fn FundingLocked_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingLockedDecodeErrorZ {
5417 let res = crate::c_types::deserialize_obj(ser);
5418 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() };
5422 /// Serialize the Init object into a byte array which can be read by Init_read
5423 pub extern "C" fn Init_write(obj: &Init) -> crate::c_types::derived::CVec_u8Z {
5424 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5427 pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5428 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInit) })
5431 /// Read a Init from a byte array, created by Init_write
5432 pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitDecodeErrorZ {
5433 let res = crate::c_types::deserialize_obj(ser);
5434 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() };
5438 /// Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read
5439 pub extern "C" fn OpenChannel_write(obj: &OpenChannel) -> crate::c_types::derived::CVec_u8Z {
5440 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5443 pub(crate) extern "C" fn OpenChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5444 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannel) })
5447 /// Read a OpenChannel from a byte array, created by OpenChannel_write
5448 pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelDecodeErrorZ {
5449 let res = crate::c_types::deserialize_obj(ser);
5450 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() };
5454 /// Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read
5455 pub extern "C" fn RevokeAndACK_write(obj: &RevokeAndACK) -> crate::c_types::derived::CVec_u8Z {
5456 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5459 pub(crate) extern "C" fn RevokeAndACK_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5460 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevokeAndACK) })
5463 /// Read a RevokeAndACK from a byte array, created by RevokeAndACK_write
5464 pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RevokeAndACKDecodeErrorZ {
5465 let res = crate::c_types::deserialize_obj(ser);
5466 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() };
5470 /// Serialize the Shutdown object into a byte array which can be read by Shutdown_read
5471 pub extern "C" fn Shutdown_write(obj: &Shutdown) -> crate::c_types::derived::CVec_u8Z {
5472 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5475 pub(crate) extern "C" fn Shutdown_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5476 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeShutdown) })
5479 /// Read a Shutdown from a byte array, created by Shutdown_write
5480 pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ShutdownDecodeErrorZ {
5481 let res = crate::c_types::deserialize_obj(ser);
5482 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() };
5486 /// Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read
5487 pub extern "C" fn UpdateFailHTLC_write(obj: &UpdateFailHTLC) -> crate::c_types::derived::CVec_u8Z {
5488 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5491 pub(crate) extern "C" fn UpdateFailHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5492 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailHTLC) })
5495 /// Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write
5496 pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailHTLCDecodeErrorZ {
5497 let res = crate::c_types::deserialize_obj(ser);
5498 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() };
5502 /// Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read
5503 pub extern "C" fn UpdateFailMalformedHTLC_write(obj: &UpdateFailMalformedHTLC) -> crate::c_types::derived::CVec_u8Z {
5504 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5507 pub(crate) extern "C" fn UpdateFailMalformedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5508 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailMalformedHTLC) })
5511 /// Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write
5512 pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailMalformedHTLCDecodeErrorZ {
5513 let res = crate::c_types::deserialize_obj(ser);
5514 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() };
5518 /// Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read
5519 pub extern "C" fn UpdateFee_write(obj: &UpdateFee) -> crate::c_types::derived::CVec_u8Z {
5520 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5523 pub(crate) extern "C" fn UpdateFee_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5524 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFee) })
5527 /// Read a UpdateFee from a byte array, created by UpdateFee_write
5528 pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFeeDecodeErrorZ {
5529 let res = crate::c_types::deserialize_obj(ser);
5530 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() };
5534 /// Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read
5535 pub extern "C" fn UpdateFulfillHTLC_write(obj: &UpdateFulfillHTLC) -> crate::c_types::derived::CVec_u8Z {
5536 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5539 pub(crate) extern "C" fn UpdateFulfillHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5540 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFulfillHTLC) })
5543 /// Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write
5544 pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFulfillHTLCDecodeErrorZ {
5545 let res = crate::c_types::deserialize_obj(ser);
5546 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() };
5550 /// Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read
5551 pub extern "C" fn UpdateAddHTLC_write(obj: &UpdateAddHTLC) -> crate::c_types::derived::CVec_u8Z {
5552 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5555 pub(crate) extern "C" fn UpdateAddHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5556 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateAddHTLC) })
5559 /// Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write
5560 pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateAddHTLCDecodeErrorZ {
5561 let res = crate::c_types::deserialize_obj(ser);
5562 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() };
5566 /// Serialize the Ping object into a byte array which can be read by Ping_read
5567 pub extern "C" fn Ping_write(obj: &Ping) -> crate::c_types::derived::CVec_u8Z {
5568 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5571 pub(crate) extern "C" fn Ping_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5572 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePing) })
5575 /// Read a Ping from a byte array, created by Ping_write
5576 pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PingDecodeErrorZ {
5577 let res = crate::c_types::deserialize_obj(ser);
5578 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() };
5582 /// Serialize the Pong object into a byte array which can be read by Pong_read
5583 pub extern "C" fn Pong_write(obj: &Pong) -> crate::c_types::derived::CVec_u8Z {
5584 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5587 pub(crate) extern "C" fn Pong_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5588 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePong) })
5591 /// Read a Pong from a byte array, created by Pong_write
5592 pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PongDecodeErrorZ {
5593 let res = crate::c_types::deserialize_obj(ser);
5594 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::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() };
5598 /// Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read
5599 pub extern "C" fn UnsignedChannelAnnouncement_write(obj: &UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
5600 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5603 pub(crate) extern "C" fn UnsignedChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5604 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelAnnouncement) })
5607 /// Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write
5608 pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelAnnouncementDecodeErrorZ {
5609 let res = crate::c_types::deserialize_obj(ser);
5610 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() };
5614 /// Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read
5615 pub extern "C" fn ChannelAnnouncement_write(obj: &ChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
5616 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5619 pub(crate) extern "C" fn ChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5620 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelAnnouncement) })
5623 /// Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write
5624 pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelAnnouncementDecodeErrorZ {
5625 let res = crate::c_types::deserialize_obj(ser);
5626 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() };
5630 /// Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read
5631 pub extern "C" fn UnsignedChannelUpdate_write(obj: &UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
5632 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5635 pub(crate) extern "C" fn UnsignedChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5636 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelUpdate) })
5639 /// Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write
5640 pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelUpdateDecodeErrorZ {
5641 let res = crate::c_types::deserialize_obj(ser);
5642 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() };
5646 /// Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read
5647 pub extern "C" fn ChannelUpdate_write(obj: &ChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
5648 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5651 pub(crate) extern "C" fn ChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5652 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdate) })
5655 /// Read a ChannelUpdate from a byte array, created by ChannelUpdate_write
5656 pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelUpdateDecodeErrorZ {
5657 let res = crate::c_types::deserialize_obj(ser);
5658 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() };
5662 /// Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read
5663 pub extern "C" fn ErrorMessage_write(obj: &ErrorMessage) -> crate::c_types::derived::CVec_u8Z {
5664 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5667 pub(crate) extern "C" fn ErrorMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5668 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeErrorMessage) })
5671 /// Read a ErrorMessage from a byte array, created by ErrorMessage_write
5672 pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ErrorMessageDecodeErrorZ {
5673 let res = crate::c_types::deserialize_obj(ser);
5674 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() };
5678 /// Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read
5679 pub extern "C" fn UnsignedNodeAnnouncement_write(obj: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
5680 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5683 pub(crate) extern "C" fn UnsignedNodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5684 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedNodeAnnouncement) })
5687 /// Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write
5688 pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedNodeAnnouncementDecodeErrorZ {
5689 let res = crate::c_types::deserialize_obj(ser);
5690 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() };
5694 /// Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read
5695 pub extern "C" fn NodeAnnouncement_write(obj: &NodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
5696 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5699 pub(crate) extern "C" fn NodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5700 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncement) })
5703 /// Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write
5704 pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementDecodeErrorZ {
5705 let res = crate::c_types::deserialize_obj(ser);
5706 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() };
5710 /// Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write
5711 pub extern "C" fn QueryShortChannelIds_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryShortChannelIdsDecodeErrorZ {
5712 let res = crate::c_types::deserialize_obj(ser);
5713 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() };
5717 /// Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read
5718 pub extern "C" fn QueryShortChannelIds_write(obj: &QueryShortChannelIds) -> crate::c_types::derived::CVec_u8Z {
5719 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5722 pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5723 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) })
5726 /// Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write
5727 pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyShortChannelIdsEndDecodeErrorZ {
5728 let res = crate::c_types::deserialize_obj(ser);
5729 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() };
5733 /// Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read
5734 pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z {
5735 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5738 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5739 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) })
5741 ///\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
5744 pub extern "C" fn QueryChannelRange_end_blocknum(this_arg: &QueryChannelRange) -> u32 {
5745 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.end_blocknum();
5750 /// Read a QueryChannelRange from a byte array, created by QueryChannelRange_write
5751 pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ {
5752 let res = crate::c_types::deserialize_obj(ser);
5753 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::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() };
5757 /// Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read
5758 pub extern "C" fn QueryChannelRange_write(obj: &QueryChannelRange) -> crate::c_types::derived::CVec_u8Z {
5759 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5762 pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5763 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) })
5766 /// Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write
5767 pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyChannelRangeDecodeErrorZ {
5768 let res = crate::c_types::deserialize_obj(ser);
5769 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::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() };
5773 /// Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read
5774 pub extern "C" fn ReplyChannelRange_write(obj: &ReplyChannelRange) -> crate::c_types::derived::CVec_u8Z {
5775 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5778 pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5779 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) })
5782 /// Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write
5783 pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_GossipTimestampFilterDecodeErrorZ {
5784 let res = crate::c_types::deserialize_obj(ser);
5785 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::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() };
5789 /// Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read
5790 pub extern "C" fn GossipTimestampFilter_write(obj: &GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z {
5791 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
5794 pub(crate) extern "C" fn GossipTimestampFilter_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
5795 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeGossipTimestampFilter) })