1 //! Wire messages, traits representing wire message handlers, and a few error types live here.
3 //! For a normal node you probably don't need to use anything here, however, if you wish to split a
4 //! node into an internet-facing route/message socket handling daemon and a separate daemon (or
5 //! server entirely) which handles only channel-related messages you may wish to implement
6 //! ChannelMessageHandler yourself and use it to re-serialize messages and pass them across
9 //! Note that if you go with such an architecture (instead of passing raw socket events to a
10 //! non-internet-facing system) you trust the frontend internet-facing system to not lie about the
11 //! source node_id of the message, however this does allow you to significantly reduce bandwidth
12 //! between the systems as routing messages can represent a significant chunk of bandwidth usage
13 //! (especially for non-channel-publicly-announcing nodes). As an alternate design which avoids
14 //! this issue, if you have sufficient bidirectional bandwidth between your systems, you may send
15 //! raw socket events into your non-internet-facing system and then send routing events back to
16 //! track the network on the less-secure system.
19 use bitcoin::hashes::Hash;
20 use crate::c_types::*;
23 use lightning::ln::msgs::DecodeError as nativeDecodeErrorImport;
24 type nativeDecodeError = nativeDecodeErrorImport;
26 /// An error in decoding a message or struct.
29 pub struct DecodeError {
30 /// Nearly everywhere, inner must be non-null, however in places where
31 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
32 pub inner: *mut nativeDecodeError,
36 impl Drop for DecodeError {
38 if self.is_owned && !self.inner.is_null() {
39 let _ = unsafe { Box::from_raw(self.inner) };
44 pub extern "C" fn DecodeError_free(this_ptr: DecodeError) { }
46 /// Used only if an object of this type is returned as a trait impl by a method
47 extern "C" fn DecodeError_free_void(this_ptr: *mut c_void) {
48 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDecodeError); }
51 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
53 pub(crate) fn take_inner(mut self) -> *mut nativeDecodeError {
54 assert!(self.is_owned);
56 self.inner = std::ptr::null_mut();
60 impl Clone for DecodeError {
61 fn clone(&self) -> Self {
63 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
64 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
70 /// Used only if an object of this type is returned as a trait impl by a method
71 pub(crate) extern "C" fn DecodeError_clone_void(this_ptr: *const c_void) -> *mut c_void {
72 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDecodeError)).clone() })) as *mut c_void
75 pub extern "C" fn DecodeError_clone(orig: &DecodeError) -> DecodeError {
79 use lightning::ln::msgs::Init as nativeInitImport;
80 type nativeInit = nativeInitImport;
82 /// An init message to be sent or received from a peer
86 /// Nearly everywhere, inner must be non-null, however in places where
87 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
88 pub inner: *mut nativeInit,
94 if self.is_owned && !self.inner.is_null() {
95 let _ = unsafe { Box::from_raw(self.inner) };
100 pub extern "C" fn Init_free(this_ptr: Init) { }
102 /// Used only if an object of this type is returned as a trait impl by a method
103 extern "C" fn Init_free_void(this_ptr: *mut c_void) {
104 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeInit); }
107 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
109 pub(crate) fn take_inner(mut self) -> *mut nativeInit {
110 assert!(self.is_owned);
111 let ret = self.inner;
112 self.inner = std::ptr::null_mut();
116 /// The relevant features which the sender supports
118 pub extern "C" fn Init_get_features(this_ptr: &Init) -> crate::ln::features::InitFeatures {
119 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features;
120 crate::ln::features::InitFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
122 /// The relevant features which the sender supports
124 pub extern "C" fn Init_set_features(this_ptr: &mut Init, mut val: crate::ln::features::InitFeatures) {
125 unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_inner()) };
129 pub extern "C" fn Init_new(mut features_arg: crate::ln::features::InitFeatures) -> Init {
130 Init { inner: Box::into_raw(Box::new(nativeInit {
131 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
132 })), is_owned: true }
134 impl Clone for Init {
135 fn clone(&self) -> Self {
137 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
138 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
144 /// Used only if an object of this type is returned as a trait impl by a method
145 pub(crate) extern "C" fn Init_clone_void(this_ptr: *const c_void) -> *mut c_void {
146 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInit)).clone() })) as *mut c_void
149 pub extern "C" fn Init_clone(orig: &Init) -> Init {
153 use lightning::ln::msgs::ErrorMessage as nativeErrorMessageImport;
154 type nativeErrorMessage = nativeErrorMessageImport;
156 /// An error message to be sent or received from a peer
159 pub struct ErrorMessage {
160 /// Nearly everywhere, inner must be non-null, however in places where
161 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
162 pub inner: *mut nativeErrorMessage,
166 impl Drop for ErrorMessage {
168 if self.is_owned && !self.inner.is_null() {
169 let _ = unsafe { Box::from_raw(self.inner) };
174 pub extern "C" fn ErrorMessage_free(this_ptr: ErrorMessage) { }
176 /// Used only if an object of this type is returned as a trait impl by a method
177 extern "C" fn ErrorMessage_free_void(this_ptr: *mut c_void) {
178 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeErrorMessage); }
181 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
183 pub(crate) fn take_inner(mut self) -> *mut nativeErrorMessage {
184 assert!(self.is_owned);
185 let ret = self.inner;
186 self.inner = std::ptr::null_mut();
190 /// The channel ID involved in the error
192 pub extern "C" fn ErrorMessage_get_channel_id(this_ptr: &ErrorMessage) -> *const [u8; 32] {
193 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
196 /// The channel ID involved in the error
198 pub extern "C" fn ErrorMessage_set_channel_id(this_ptr: &mut ErrorMessage, mut val: crate::c_types::ThirtyTwoBytes) {
199 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
201 /// A possibly human-readable error description.
202 /// The string should be sanitized before it is used (e.g. emitted to logs
203 /// or printed to stdout). Otherwise, a well crafted error message may trigger a security
204 /// vulnerability in the terminal emulator or the logging subsystem.
206 pub extern "C" fn ErrorMessage_get_data(this_ptr: &ErrorMessage) -> crate::c_types::Str {
207 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.data;
208 (*inner_val).as_str().into()
210 /// A possibly human-readable error description.
211 /// The string should be sanitized before it is used (e.g. emitted to logs
212 /// or printed to stdout). Otherwise, a well crafted error message may trigger a security
213 /// vulnerability in the terminal emulator or the logging subsystem.
215 pub extern "C" fn ErrorMessage_set_data(this_ptr: &mut ErrorMessage, mut val: crate::c_types::derived::CVec_u8Z) {
216 unsafe { &mut *this_ptr.inner }.data = String::from_utf8(val.into_rust()).unwrap();
220 pub extern "C" fn ErrorMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::derived::CVec_u8Z) -> ErrorMessage {
221 ErrorMessage { inner: Box::into_raw(Box::new(nativeErrorMessage {
222 channel_id: channel_id_arg.data,
223 data: String::from_utf8(data_arg.into_rust()).unwrap(),
224 })), is_owned: true }
226 impl Clone for ErrorMessage {
227 fn clone(&self) -> Self {
229 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
230 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
236 /// Used only if an object of this type is returned as a trait impl by a method
237 pub(crate) extern "C" fn ErrorMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
238 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeErrorMessage)).clone() })) as *mut c_void
241 pub extern "C" fn ErrorMessage_clone(orig: &ErrorMessage) -> ErrorMessage {
245 use lightning::ln::msgs::Ping as nativePingImport;
246 type nativePing = nativePingImport;
248 /// A ping message to be sent or received from a peer
252 /// Nearly everywhere, inner must be non-null, however in places where
253 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
254 pub inner: *mut nativePing,
260 if self.is_owned && !self.inner.is_null() {
261 let _ = unsafe { Box::from_raw(self.inner) };
266 pub extern "C" fn Ping_free(this_ptr: Ping) { }
268 /// Used only if an object of this type is returned as a trait impl by a method
269 extern "C" fn Ping_free_void(this_ptr: *mut c_void) {
270 unsafe { let _ = Box::from_raw(this_ptr as *mut nativePing); }
273 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
275 pub(crate) fn take_inner(mut self) -> *mut nativePing {
276 assert!(self.is_owned);
277 let ret = self.inner;
278 self.inner = std::ptr::null_mut();
282 /// The desired response length
284 pub extern "C" fn Ping_get_ponglen(this_ptr: &Ping) -> u16 {
285 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.ponglen;
288 /// The desired response length
290 pub extern "C" fn Ping_set_ponglen(this_ptr: &mut Ping, mut val: u16) {
291 unsafe { &mut *this_ptr.inner }.ponglen = val;
293 /// The ping packet size.
294 /// This field is not sent on the wire. byteslen zeros are sent.
296 pub extern "C" fn Ping_get_byteslen(this_ptr: &Ping) -> u16 {
297 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.byteslen;
300 /// The ping packet size.
301 /// This field is not sent on the wire. byteslen zeros are sent.
303 pub extern "C" fn Ping_set_byteslen(this_ptr: &mut Ping, mut val: u16) {
304 unsafe { &mut *this_ptr.inner }.byteslen = val;
308 pub extern "C" fn Ping_new(mut ponglen_arg: u16, mut byteslen_arg: u16) -> Ping {
309 Ping { inner: Box::into_raw(Box::new(nativePing {
310 ponglen: ponglen_arg,
311 byteslen: byteslen_arg,
312 })), is_owned: true }
314 impl Clone for Ping {
315 fn clone(&self) -> Self {
317 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
318 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
324 /// Used only if an object of this type is returned as a trait impl by a method
325 pub(crate) extern "C" fn Ping_clone_void(this_ptr: *const c_void) -> *mut c_void {
326 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePing)).clone() })) as *mut c_void
329 pub extern "C" fn Ping_clone(orig: &Ping) -> Ping {
333 use lightning::ln::msgs::Pong as nativePongImport;
334 type nativePong = nativePongImport;
336 /// A pong message to be sent or received from a peer
340 /// Nearly everywhere, inner must be non-null, however in places where
341 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
342 pub inner: *mut nativePong,
348 if self.is_owned && !self.inner.is_null() {
349 let _ = unsafe { Box::from_raw(self.inner) };
354 pub extern "C" fn Pong_free(this_ptr: Pong) { }
356 /// Used only if an object of this type is returned as a trait impl by a method
357 extern "C" fn Pong_free_void(this_ptr: *mut c_void) {
358 unsafe { let _ = Box::from_raw(this_ptr as *mut nativePong); }
361 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
363 pub(crate) fn take_inner(mut self) -> *mut nativePong {
364 assert!(self.is_owned);
365 let ret = self.inner;
366 self.inner = std::ptr::null_mut();
370 /// The pong packet size.
371 /// This field is not sent on the wire. byteslen zeros are sent.
373 pub extern "C" fn Pong_get_byteslen(this_ptr: &Pong) -> u16 {
374 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.byteslen;
377 /// The pong packet size.
378 /// This field is not sent on the wire. byteslen zeros are sent.
380 pub extern "C" fn Pong_set_byteslen(this_ptr: &mut Pong, mut val: u16) {
381 unsafe { &mut *this_ptr.inner }.byteslen = val;
385 pub extern "C" fn Pong_new(mut byteslen_arg: u16) -> Pong {
386 Pong { inner: Box::into_raw(Box::new(nativePong {
387 byteslen: byteslen_arg,
388 })), is_owned: true }
390 impl Clone for Pong {
391 fn clone(&self) -> Self {
393 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
394 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
400 /// Used only if an object of this type is returned as a trait impl by a method
401 pub(crate) extern "C" fn Pong_clone_void(this_ptr: *const c_void) -> *mut c_void {
402 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePong)).clone() })) as *mut c_void
405 pub extern "C" fn Pong_clone(orig: &Pong) -> Pong {
409 use lightning::ln::msgs::OpenChannel as nativeOpenChannelImport;
410 type nativeOpenChannel = nativeOpenChannelImport;
412 /// An open_channel message to be sent or received from a peer
415 pub struct OpenChannel {
416 /// Nearly everywhere, inner must be non-null, however in places where
417 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
418 pub inner: *mut nativeOpenChannel,
422 impl Drop for OpenChannel {
424 if self.is_owned && !self.inner.is_null() {
425 let _ = unsafe { Box::from_raw(self.inner) };
430 pub extern "C" fn OpenChannel_free(this_ptr: OpenChannel) { }
432 /// Used only if an object of this type is returned as a trait impl by a method
433 extern "C" fn OpenChannel_free_void(this_ptr: *mut c_void) {
434 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeOpenChannel); }
437 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
439 pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannel {
440 assert!(self.is_owned);
441 let ret = self.inner;
442 self.inner = std::ptr::null_mut();
446 /// The genesis hash of the blockchain where the channel is to be opened
448 pub extern "C" fn OpenChannel_get_chain_hash(this_ptr: &OpenChannel) -> *const [u8; 32] {
449 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
450 (*inner_val).as_inner()
452 /// The genesis hash of the blockchain where the channel is to be opened
454 pub extern "C" fn OpenChannel_set_chain_hash(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
455 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
457 /// A temporary channel ID, until the funding outpoint is announced
459 pub extern "C" fn OpenChannel_get_temporary_channel_id(this_ptr: &OpenChannel) -> *const [u8; 32] {
460 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.temporary_channel_id;
463 /// A temporary channel ID, until the funding outpoint is announced
465 pub extern "C" fn OpenChannel_set_temporary_channel_id(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
466 unsafe { &mut *this_ptr.inner }.temporary_channel_id = val.data;
468 /// The channel value
470 pub extern "C" fn OpenChannel_get_funding_satoshis(this_ptr: &OpenChannel) -> u64 {
471 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_satoshis;
474 /// The channel value
476 pub extern "C" fn OpenChannel_set_funding_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
477 unsafe { &mut *this_ptr.inner }.funding_satoshis = val;
479 /// The amount to push to the counterparty as part of the open, in milli-satoshi
481 pub extern "C" fn OpenChannel_get_push_msat(this_ptr: &OpenChannel) -> u64 {
482 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.push_msat;
485 /// The amount to push to the counterparty as part of the open, in milli-satoshi
487 pub extern "C" fn OpenChannel_set_push_msat(this_ptr: &mut OpenChannel, mut val: u64) {
488 unsafe { &mut *this_ptr.inner }.push_msat = val;
490 /// The threshold below which outputs on transactions broadcast by sender will be omitted
492 pub extern "C" fn OpenChannel_get_dust_limit_satoshis(this_ptr: &OpenChannel) -> u64 {
493 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.dust_limit_satoshis;
496 /// The threshold below which outputs on transactions broadcast by sender will be omitted
498 pub extern "C" fn OpenChannel_set_dust_limit_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
499 unsafe { &mut *this_ptr.inner }.dust_limit_satoshis = val;
501 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
503 pub extern "C" fn OpenChannel_get_max_htlc_value_in_flight_msat(this_ptr: &OpenChannel) -> u64 {
504 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_htlc_value_in_flight_msat;
507 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
509 pub extern "C" fn OpenChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut OpenChannel, mut val: u64) {
510 unsafe { &mut *this_ptr.inner }.max_htlc_value_in_flight_msat = val;
512 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
514 pub extern "C" fn OpenChannel_get_channel_reserve_satoshis(this_ptr: &OpenChannel) -> u64 {
515 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_reserve_satoshis;
518 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
520 pub extern "C" fn OpenChannel_set_channel_reserve_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
521 unsafe { &mut *this_ptr.inner }.channel_reserve_satoshis = val;
523 /// The minimum HTLC size incoming to sender, in milli-satoshi
525 pub extern "C" fn OpenChannel_get_htlc_minimum_msat(this_ptr: &OpenChannel) -> u64 {
526 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_minimum_msat;
529 /// The minimum HTLC size incoming to sender, in milli-satoshi
531 pub extern "C" fn OpenChannel_set_htlc_minimum_msat(this_ptr: &mut OpenChannel, mut val: u64) {
532 unsafe { &mut *this_ptr.inner }.htlc_minimum_msat = val;
534 /// The feerate per 1000-weight of sender generated transactions, until updated by update_fee
536 pub extern "C" fn OpenChannel_get_feerate_per_kw(this_ptr: &OpenChannel) -> u32 {
537 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.feerate_per_kw;
540 /// The feerate per 1000-weight of sender generated transactions, until updated by update_fee
542 pub extern "C" fn OpenChannel_set_feerate_per_kw(this_ptr: &mut OpenChannel, mut val: u32) {
543 unsafe { &mut *this_ptr.inner }.feerate_per_kw = val;
545 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
547 pub extern "C" fn OpenChannel_get_to_self_delay(this_ptr: &OpenChannel) -> u16 {
548 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.to_self_delay;
551 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
553 pub extern "C" fn OpenChannel_set_to_self_delay(this_ptr: &mut OpenChannel, mut val: u16) {
554 unsafe { &mut *this_ptr.inner }.to_self_delay = val;
556 /// The maximum number of inbound HTLCs towards sender
558 pub extern "C" fn OpenChannel_get_max_accepted_htlcs(this_ptr: &OpenChannel) -> u16 {
559 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_accepted_htlcs;
562 /// The maximum number of inbound HTLCs towards sender
564 pub extern "C" fn OpenChannel_set_max_accepted_htlcs(this_ptr: &mut OpenChannel, mut val: u16) {
565 unsafe { &mut *this_ptr.inner }.max_accepted_htlcs = val;
567 /// The sender's key controlling the funding transaction
569 pub extern "C" fn OpenChannel_get_funding_pubkey(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
570 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_pubkey;
571 crate::c_types::PublicKey::from_rust(&(*inner_val))
573 /// The sender's key controlling the funding transaction
575 pub extern "C" fn OpenChannel_set_funding_pubkey(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
576 unsafe { &mut *this_ptr.inner }.funding_pubkey = val.into_rust();
578 /// Used to derive a revocation key for transactions broadcast by counterparty
580 pub extern "C" fn OpenChannel_get_revocation_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
581 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.revocation_basepoint;
582 crate::c_types::PublicKey::from_rust(&(*inner_val))
584 /// Used to derive a revocation key for transactions broadcast by counterparty
586 pub extern "C" fn OpenChannel_set_revocation_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
587 unsafe { &mut *this_ptr.inner }.revocation_basepoint = val.into_rust();
589 /// A payment key to sender for transactions broadcast by counterparty
591 pub extern "C" fn OpenChannel_get_payment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
592 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_point;
593 crate::c_types::PublicKey::from_rust(&(*inner_val))
595 /// A payment key to sender for transactions broadcast by counterparty
597 pub extern "C" fn OpenChannel_set_payment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
598 unsafe { &mut *this_ptr.inner }.payment_point = val.into_rust();
600 /// Used to derive a payment key to sender for transactions broadcast by sender
602 pub extern "C" fn OpenChannel_get_delayed_payment_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
603 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.delayed_payment_basepoint;
604 crate::c_types::PublicKey::from_rust(&(*inner_val))
606 /// Used to derive a payment key to sender for transactions broadcast by sender
608 pub extern "C" fn OpenChannel_set_delayed_payment_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
609 unsafe { &mut *this_ptr.inner }.delayed_payment_basepoint = val.into_rust();
611 /// Used to derive an HTLC payment key to sender
613 pub extern "C" fn OpenChannel_get_htlc_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
614 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_basepoint;
615 crate::c_types::PublicKey::from_rust(&(*inner_val))
617 /// Used to derive an HTLC payment key to sender
619 pub extern "C" fn OpenChannel_set_htlc_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
620 unsafe { &mut *this_ptr.inner }.htlc_basepoint = val.into_rust();
622 /// The first to-be-broadcast-by-sender transaction's per commitment point
624 pub extern "C" fn OpenChannel_get_first_per_commitment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
625 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_per_commitment_point;
626 crate::c_types::PublicKey::from_rust(&(*inner_val))
628 /// The first to-be-broadcast-by-sender transaction's per commitment point
630 pub extern "C" fn OpenChannel_set_first_per_commitment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
631 unsafe { &mut *this_ptr.inner }.first_per_commitment_point = val.into_rust();
635 pub extern "C" fn OpenChannel_get_channel_flags(this_ptr: &OpenChannel) -> u8 {
636 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_flags;
641 pub extern "C" fn OpenChannel_set_channel_flags(this_ptr: &mut OpenChannel, mut val: u8) {
642 unsafe { &mut *this_ptr.inner }.channel_flags = val;
644 impl Clone for OpenChannel {
645 fn clone(&self) -> Self {
647 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
648 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
654 /// Used only if an object of this type is returned as a trait impl by a method
655 pub(crate) extern "C" fn OpenChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
656 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOpenChannel)).clone() })) as *mut c_void
659 pub extern "C" fn OpenChannel_clone(orig: &OpenChannel) -> OpenChannel {
663 use lightning::ln::msgs::AcceptChannel as nativeAcceptChannelImport;
664 type nativeAcceptChannel = nativeAcceptChannelImport;
666 /// An accept_channel message to be sent or received from a peer
669 pub struct AcceptChannel {
670 /// Nearly everywhere, inner must be non-null, however in places where
671 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
672 pub inner: *mut nativeAcceptChannel,
676 impl Drop for AcceptChannel {
678 if self.is_owned && !self.inner.is_null() {
679 let _ = unsafe { Box::from_raw(self.inner) };
684 pub extern "C" fn AcceptChannel_free(this_ptr: AcceptChannel) { }
686 /// Used only if an object of this type is returned as a trait impl by a method
687 extern "C" fn AcceptChannel_free_void(this_ptr: *mut c_void) {
688 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeAcceptChannel); }
691 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
693 pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannel {
694 assert!(self.is_owned);
695 let ret = self.inner;
696 self.inner = std::ptr::null_mut();
700 /// A temporary channel ID, until the funding outpoint is announced
702 pub extern "C" fn AcceptChannel_get_temporary_channel_id(this_ptr: &AcceptChannel) -> *const [u8; 32] {
703 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.temporary_channel_id;
706 /// A temporary channel ID, until the funding outpoint is announced
708 pub extern "C" fn AcceptChannel_set_temporary_channel_id(this_ptr: &mut AcceptChannel, mut val: crate::c_types::ThirtyTwoBytes) {
709 unsafe { &mut *this_ptr.inner }.temporary_channel_id = val.data;
711 /// The threshold below which outputs on transactions broadcast by sender will be omitted
713 pub extern "C" fn AcceptChannel_get_dust_limit_satoshis(this_ptr: &AcceptChannel) -> u64 {
714 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.dust_limit_satoshis;
717 /// The threshold below which outputs on transactions broadcast by sender will be omitted
719 pub extern "C" fn AcceptChannel_set_dust_limit_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
720 unsafe { &mut *this_ptr.inner }.dust_limit_satoshis = val;
722 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
724 pub extern "C" fn AcceptChannel_get_max_htlc_value_in_flight_msat(this_ptr: &AcceptChannel) -> u64 {
725 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_htlc_value_in_flight_msat;
728 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
730 pub extern "C" fn AcceptChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
731 unsafe { &mut *this_ptr.inner }.max_htlc_value_in_flight_msat = val;
733 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
735 pub extern "C" fn AcceptChannel_get_channel_reserve_satoshis(this_ptr: &AcceptChannel) -> u64 {
736 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_reserve_satoshis;
739 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
741 pub extern "C" fn AcceptChannel_set_channel_reserve_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
742 unsafe { &mut *this_ptr.inner }.channel_reserve_satoshis = val;
744 /// The minimum HTLC size incoming to sender, in milli-satoshi
746 pub extern "C" fn AcceptChannel_get_htlc_minimum_msat(this_ptr: &AcceptChannel) -> u64 {
747 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_minimum_msat;
750 /// The minimum HTLC size incoming to sender, in milli-satoshi
752 pub extern "C" fn AcceptChannel_set_htlc_minimum_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
753 unsafe { &mut *this_ptr.inner }.htlc_minimum_msat = val;
755 /// Minimum depth of the funding transaction before the channel is considered open
757 pub extern "C" fn AcceptChannel_get_minimum_depth(this_ptr: &AcceptChannel) -> u32 {
758 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.minimum_depth;
761 /// Minimum depth of the funding transaction before the channel is considered open
763 pub extern "C" fn AcceptChannel_set_minimum_depth(this_ptr: &mut AcceptChannel, mut val: u32) {
764 unsafe { &mut *this_ptr.inner }.minimum_depth = val;
766 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
768 pub extern "C" fn AcceptChannel_get_to_self_delay(this_ptr: &AcceptChannel) -> u16 {
769 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.to_self_delay;
772 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
774 pub extern "C" fn AcceptChannel_set_to_self_delay(this_ptr: &mut AcceptChannel, mut val: u16) {
775 unsafe { &mut *this_ptr.inner }.to_self_delay = val;
777 /// The maximum number of inbound HTLCs towards sender
779 pub extern "C" fn AcceptChannel_get_max_accepted_htlcs(this_ptr: &AcceptChannel) -> u16 {
780 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_accepted_htlcs;
783 /// The maximum number of inbound HTLCs towards sender
785 pub extern "C" fn AcceptChannel_set_max_accepted_htlcs(this_ptr: &mut AcceptChannel, mut val: u16) {
786 unsafe { &mut *this_ptr.inner }.max_accepted_htlcs = val;
788 /// The sender's key controlling the funding transaction
790 pub extern "C" fn AcceptChannel_get_funding_pubkey(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
791 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_pubkey;
792 crate::c_types::PublicKey::from_rust(&(*inner_val))
794 /// The sender's key controlling the funding transaction
796 pub extern "C" fn AcceptChannel_set_funding_pubkey(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
797 unsafe { &mut *this_ptr.inner }.funding_pubkey = val.into_rust();
799 /// Used to derive a revocation key for transactions broadcast by counterparty
801 pub extern "C" fn AcceptChannel_get_revocation_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
802 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.revocation_basepoint;
803 crate::c_types::PublicKey::from_rust(&(*inner_val))
805 /// Used to derive a revocation key for transactions broadcast by counterparty
807 pub extern "C" fn AcceptChannel_set_revocation_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
808 unsafe { &mut *this_ptr.inner }.revocation_basepoint = val.into_rust();
810 /// A payment key to sender for transactions broadcast by counterparty
812 pub extern "C" fn AcceptChannel_get_payment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
813 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_point;
814 crate::c_types::PublicKey::from_rust(&(*inner_val))
816 /// A payment key to sender for transactions broadcast by counterparty
818 pub extern "C" fn AcceptChannel_set_payment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
819 unsafe { &mut *this_ptr.inner }.payment_point = val.into_rust();
821 /// Used to derive a payment key to sender for transactions broadcast by sender
823 pub extern "C" fn AcceptChannel_get_delayed_payment_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
824 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.delayed_payment_basepoint;
825 crate::c_types::PublicKey::from_rust(&(*inner_val))
827 /// Used to derive a payment key to sender for transactions broadcast by sender
829 pub extern "C" fn AcceptChannel_set_delayed_payment_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
830 unsafe { &mut *this_ptr.inner }.delayed_payment_basepoint = val.into_rust();
832 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
834 pub extern "C" fn AcceptChannel_get_htlc_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
835 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_basepoint;
836 crate::c_types::PublicKey::from_rust(&(*inner_val))
838 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
840 pub extern "C" fn AcceptChannel_set_htlc_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
841 unsafe { &mut *this_ptr.inner }.htlc_basepoint = val.into_rust();
843 /// The first to-be-broadcast-by-sender transaction's per commitment point
845 pub extern "C" fn AcceptChannel_get_first_per_commitment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
846 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_per_commitment_point;
847 crate::c_types::PublicKey::from_rust(&(*inner_val))
849 /// The first to-be-broadcast-by-sender transaction's per commitment point
851 pub extern "C" fn AcceptChannel_set_first_per_commitment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
852 unsafe { &mut *this_ptr.inner }.first_per_commitment_point = val.into_rust();
854 impl Clone for AcceptChannel {
855 fn clone(&self) -> Self {
857 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
858 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
864 /// Used only if an object of this type is returned as a trait impl by a method
865 pub(crate) extern "C" fn AcceptChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
866 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAcceptChannel)).clone() })) as *mut c_void
869 pub extern "C" fn AcceptChannel_clone(orig: &AcceptChannel) -> AcceptChannel {
873 use lightning::ln::msgs::FundingCreated as nativeFundingCreatedImport;
874 type nativeFundingCreated = nativeFundingCreatedImport;
876 /// A funding_created message to be sent or received from a peer
879 pub struct FundingCreated {
880 /// Nearly everywhere, inner must be non-null, however in places where
881 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
882 pub inner: *mut nativeFundingCreated,
886 impl Drop for FundingCreated {
888 if self.is_owned && !self.inner.is_null() {
889 let _ = unsafe { Box::from_raw(self.inner) };
894 pub extern "C" fn FundingCreated_free(this_ptr: FundingCreated) { }
896 /// Used only if an object of this type is returned as a trait impl by a method
897 extern "C" fn FundingCreated_free_void(this_ptr: *mut c_void) {
898 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingCreated); }
901 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
902 impl FundingCreated {
903 pub(crate) fn take_inner(mut self) -> *mut nativeFundingCreated {
904 assert!(self.is_owned);
905 let ret = self.inner;
906 self.inner = std::ptr::null_mut();
910 /// A temporary channel ID, until the funding is established
912 pub extern "C" fn FundingCreated_get_temporary_channel_id(this_ptr: &FundingCreated) -> *const [u8; 32] {
913 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.temporary_channel_id;
916 /// A temporary channel ID, until the funding is established
918 pub extern "C" fn FundingCreated_set_temporary_channel_id(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
919 unsafe { &mut *this_ptr.inner }.temporary_channel_id = val.data;
921 /// The funding transaction ID
923 pub extern "C" fn FundingCreated_get_funding_txid(this_ptr: &FundingCreated) -> *const [u8; 32] {
924 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_txid;
925 (*inner_val).as_inner()
927 /// The funding transaction ID
929 pub extern "C" fn FundingCreated_set_funding_txid(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
930 unsafe { &mut *this_ptr.inner }.funding_txid = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
932 /// The specific output index funding this channel
934 pub extern "C" fn FundingCreated_get_funding_output_index(this_ptr: &FundingCreated) -> u16 {
935 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_output_index;
938 /// The specific output index funding this channel
940 pub extern "C" fn FundingCreated_set_funding_output_index(this_ptr: &mut FundingCreated, mut val: u16) {
941 unsafe { &mut *this_ptr.inner }.funding_output_index = val;
943 /// The signature of the channel initiator (funder) on the funding transaction
945 pub extern "C" fn FundingCreated_get_signature(this_ptr: &FundingCreated) -> crate::c_types::Signature {
946 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
947 crate::c_types::Signature::from_rust(&(*inner_val))
949 /// The signature of the channel initiator (funder) on the funding transaction
951 pub extern "C" fn FundingCreated_set_signature(this_ptr: &mut FundingCreated, mut val: crate::c_types::Signature) {
952 unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
956 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 {
957 FundingCreated { inner: Box::into_raw(Box::new(nativeFundingCreated {
958 temporary_channel_id: temporary_channel_id_arg.data,
959 funding_txid: ::bitcoin::hash_types::Txid::from_slice(&funding_txid_arg.data[..]).unwrap(),
960 funding_output_index: funding_output_index_arg,
961 signature: signature_arg.into_rust(),
962 })), is_owned: true }
964 impl Clone for FundingCreated {
965 fn clone(&self) -> Self {
967 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
968 Box::into_raw(Box::new(unsafe { &*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 FundingCreated_clone_void(this_ptr: *const c_void) -> *mut c_void {
976 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingCreated)).clone() })) as *mut c_void
979 pub extern "C" fn FundingCreated_clone(orig: &FundingCreated) -> FundingCreated {
983 use lightning::ln::msgs::FundingSigned as nativeFundingSignedImport;
984 type nativeFundingSigned = nativeFundingSignedImport;
986 /// A funding_signed message to be sent or received from a peer
989 pub struct FundingSigned {
990 /// Nearly everywhere, inner must be non-null, however in places where
991 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
992 pub inner: *mut nativeFundingSigned,
996 impl Drop for FundingSigned {
998 if self.is_owned && !self.inner.is_null() {
999 let _ = unsafe { Box::from_raw(self.inner) };
1004 pub extern "C" fn FundingSigned_free(this_ptr: FundingSigned) { }
1006 /// Used only if an object of this type is returned as a trait impl by a method
1007 extern "C" fn FundingSigned_free_void(this_ptr: *mut c_void) {
1008 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingSigned); }
1011 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1012 impl FundingSigned {
1013 pub(crate) fn take_inner(mut self) -> *mut nativeFundingSigned {
1014 assert!(self.is_owned);
1015 let ret = self.inner;
1016 self.inner = std::ptr::null_mut();
1022 pub extern "C" fn FundingSigned_get_channel_id(this_ptr: &FundingSigned) -> *const [u8; 32] {
1023 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1028 pub extern "C" fn FundingSigned_set_channel_id(this_ptr: &mut FundingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
1029 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1031 /// The signature of the channel acceptor (fundee) on the funding transaction
1033 pub extern "C" fn FundingSigned_get_signature(this_ptr: &FundingSigned) -> crate::c_types::Signature {
1034 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
1035 crate::c_types::Signature::from_rust(&(*inner_val))
1037 /// The signature of the channel acceptor (fundee) on the funding transaction
1039 pub extern "C" fn FundingSigned_set_signature(this_ptr: &mut FundingSigned, mut val: crate::c_types::Signature) {
1040 unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
1044 pub extern "C" fn FundingSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut signature_arg: crate::c_types::Signature) -> FundingSigned {
1045 FundingSigned { inner: Box::into_raw(Box::new(nativeFundingSigned {
1046 channel_id: channel_id_arg.data,
1047 signature: signature_arg.into_rust(),
1048 })), is_owned: true }
1050 impl Clone for FundingSigned {
1051 fn clone(&self) -> Self {
1053 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1054 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1060 /// Used only if an object of this type is returned as a trait impl by a method
1061 pub(crate) extern "C" fn FundingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
1062 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingSigned)).clone() })) as *mut c_void
1065 pub extern "C" fn FundingSigned_clone(orig: &FundingSigned) -> FundingSigned {
1069 use lightning::ln::msgs::FundingLocked as nativeFundingLockedImport;
1070 type nativeFundingLocked = nativeFundingLockedImport;
1072 /// A funding_locked message to be sent or received from a peer
1075 pub struct FundingLocked {
1076 /// Nearly everywhere, inner must be non-null, however in places where
1077 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1078 pub inner: *mut nativeFundingLocked,
1082 impl Drop for FundingLocked {
1083 fn drop(&mut self) {
1084 if self.is_owned && !self.inner.is_null() {
1085 let _ = unsafe { Box::from_raw(self.inner) };
1090 pub extern "C" fn FundingLocked_free(this_ptr: FundingLocked) { }
1092 /// Used only if an object of this type is returned as a trait impl by a method
1093 extern "C" fn FundingLocked_free_void(this_ptr: *mut c_void) {
1094 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingLocked); }
1097 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1098 impl FundingLocked {
1099 pub(crate) fn take_inner(mut self) -> *mut nativeFundingLocked {
1100 assert!(self.is_owned);
1101 let ret = self.inner;
1102 self.inner = std::ptr::null_mut();
1108 pub extern "C" fn FundingLocked_get_channel_id(this_ptr: &FundingLocked) -> *const [u8; 32] {
1109 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1114 pub extern "C" fn FundingLocked_set_channel_id(this_ptr: &mut FundingLocked, mut val: crate::c_types::ThirtyTwoBytes) {
1115 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1117 /// The per-commitment point of the second commitment transaction
1119 pub extern "C" fn FundingLocked_get_next_per_commitment_point(this_ptr: &FundingLocked) -> crate::c_types::PublicKey {
1120 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.next_per_commitment_point;
1121 crate::c_types::PublicKey::from_rust(&(*inner_val))
1123 /// The per-commitment point of the second commitment transaction
1125 pub extern "C" fn FundingLocked_set_next_per_commitment_point(this_ptr: &mut FundingLocked, mut val: crate::c_types::PublicKey) {
1126 unsafe { &mut *this_ptr.inner }.next_per_commitment_point = val.into_rust();
1130 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 {
1131 FundingLocked { inner: Box::into_raw(Box::new(nativeFundingLocked {
1132 channel_id: channel_id_arg.data,
1133 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
1134 })), is_owned: true }
1136 impl Clone for FundingLocked {
1137 fn clone(&self) -> Self {
1139 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1140 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1146 /// Used only if an object of this type is returned as a trait impl by a method
1147 pub(crate) extern "C" fn FundingLocked_clone_void(this_ptr: *const c_void) -> *mut c_void {
1148 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingLocked)).clone() })) as *mut c_void
1151 pub extern "C" fn FundingLocked_clone(orig: &FundingLocked) -> FundingLocked {
1155 use lightning::ln::msgs::Shutdown as nativeShutdownImport;
1156 type nativeShutdown = nativeShutdownImport;
1158 /// A shutdown message to be sent or received from a peer
1161 pub struct Shutdown {
1162 /// Nearly everywhere, inner must be non-null, however in places where
1163 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1164 pub inner: *mut nativeShutdown,
1168 impl Drop for Shutdown {
1169 fn drop(&mut self) {
1170 if self.is_owned && !self.inner.is_null() {
1171 let _ = unsafe { Box::from_raw(self.inner) };
1176 pub extern "C" fn Shutdown_free(this_ptr: Shutdown) { }
1178 /// Used only if an object of this type is returned as a trait impl by a method
1179 extern "C" fn Shutdown_free_void(this_ptr: *mut c_void) {
1180 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeShutdown); }
1183 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1185 pub(crate) fn take_inner(mut self) -> *mut nativeShutdown {
1186 assert!(self.is_owned);
1187 let ret = self.inner;
1188 self.inner = std::ptr::null_mut();
1194 pub extern "C" fn Shutdown_get_channel_id(this_ptr: &Shutdown) -> *const [u8; 32] {
1195 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1200 pub extern "C" fn Shutdown_set_channel_id(this_ptr: &mut Shutdown, mut val: crate::c_types::ThirtyTwoBytes) {
1201 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1203 /// The destination of this peer's funds on closing.
1204 /// Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
1206 pub extern "C" fn Shutdown_get_scriptpubkey(this_ptr: &Shutdown) -> crate::c_types::u8slice {
1207 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.scriptpubkey;
1208 crate::c_types::u8slice::from_slice(&(*inner_val)[..])
1210 /// The destination of this peer's funds on closing.
1211 /// Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
1213 pub extern "C" fn Shutdown_set_scriptpubkey(this_ptr: &mut Shutdown, mut val: crate::c_types::derived::CVec_u8Z) {
1214 unsafe { &mut *this_ptr.inner }.scriptpubkey = ::bitcoin::blockdata::script::Script::from(val.into_rust());
1218 pub extern "C" fn Shutdown_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut scriptpubkey_arg: crate::c_types::derived::CVec_u8Z) -> Shutdown {
1219 Shutdown { inner: Box::into_raw(Box::new(nativeShutdown {
1220 channel_id: channel_id_arg.data,
1221 scriptpubkey: ::bitcoin::blockdata::script::Script::from(scriptpubkey_arg.into_rust()),
1222 })), is_owned: true }
1224 impl Clone for Shutdown {
1225 fn clone(&self) -> Self {
1227 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1228 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1234 /// Used only if an object of this type is returned as a trait impl by a method
1235 pub(crate) extern "C" fn Shutdown_clone_void(this_ptr: *const c_void) -> *mut c_void {
1236 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeShutdown)).clone() })) as *mut c_void
1239 pub extern "C" fn Shutdown_clone(orig: &Shutdown) -> Shutdown {
1243 use lightning::ln::msgs::ClosingSigned as nativeClosingSignedImport;
1244 type nativeClosingSigned = nativeClosingSignedImport;
1246 /// A closing_signed message to be sent or received from a peer
1249 pub struct ClosingSigned {
1250 /// Nearly everywhere, inner must be non-null, however in places where
1251 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1252 pub inner: *mut nativeClosingSigned,
1256 impl Drop for ClosingSigned {
1257 fn drop(&mut self) {
1258 if self.is_owned && !self.inner.is_null() {
1259 let _ = unsafe { Box::from_raw(self.inner) };
1264 pub extern "C" fn ClosingSigned_free(this_ptr: ClosingSigned) { }
1266 /// Used only if an object of this type is returned as a trait impl by a method
1267 extern "C" fn ClosingSigned_free_void(this_ptr: *mut c_void) {
1268 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeClosingSigned); }
1271 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1272 impl ClosingSigned {
1273 pub(crate) fn take_inner(mut self) -> *mut nativeClosingSigned {
1274 assert!(self.is_owned);
1275 let ret = self.inner;
1276 self.inner = std::ptr::null_mut();
1282 pub extern "C" fn ClosingSigned_get_channel_id(this_ptr: &ClosingSigned) -> *const [u8; 32] {
1283 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1288 pub extern "C" fn ClosingSigned_set_channel_id(this_ptr: &mut ClosingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
1289 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1291 /// The proposed total fee for the closing transaction
1293 pub extern "C" fn ClosingSigned_get_fee_satoshis(this_ptr: &ClosingSigned) -> u64 {
1294 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_satoshis;
1297 /// The proposed total fee for the closing transaction
1299 pub extern "C" fn ClosingSigned_set_fee_satoshis(this_ptr: &mut ClosingSigned, mut val: u64) {
1300 unsafe { &mut *this_ptr.inner }.fee_satoshis = val;
1302 /// A signature on the closing transaction
1304 pub extern "C" fn ClosingSigned_get_signature(this_ptr: &ClosingSigned) -> crate::c_types::Signature {
1305 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
1306 crate::c_types::Signature::from_rust(&(*inner_val))
1308 /// A signature on the closing transaction
1310 pub extern "C" fn ClosingSigned_set_signature(this_ptr: &mut ClosingSigned, mut val: crate::c_types::Signature) {
1311 unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
1315 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) -> ClosingSigned {
1316 ClosingSigned { inner: Box::into_raw(Box::new(nativeClosingSigned {
1317 channel_id: channel_id_arg.data,
1318 fee_satoshis: fee_satoshis_arg,
1319 signature: signature_arg.into_rust(),
1320 })), is_owned: true }
1322 impl Clone for ClosingSigned {
1323 fn clone(&self) -> Self {
1325 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1326 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1332 /// Used only if an object of this type is returned as a trait impl by a method
1333 pub(crate) extern "C" fn ClosingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
1334 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClosingSigned)).clone() })) as *mut c_void
1337 pub extern "C" fn ClosingSigned_clone(orig: &ClosingSigned) -> ClosingSigned {
1341 use lightning::ln::msgs::UpdateAddHTLC as nativeUpdateAddHTLCImport;
1342 type nativeUpdateAddHTLC = nativeUpdateAddHTLCImport;
1344 /// An update_add_htlc message to be sent or received from a peer
1347 pub struct UpdateAddHTLC {
1348 /// Nearly everywhere, inner must be non-null, however in places where
1349 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1350 pub inner: *mut nativeUpdateAddHTLC,
1354 impl Drop for UpdateAddHTLC {
1355 fn drop(&mut self) {
1356 if self.is_owned && !self.inner.is_null() {
1357 let _ = unsafe { Box::from_raw(self.inner) };
1362 pub extern "C" fn UpdateAddHTLC_free(this_ptr: UpdateAddHTLC) { }
1364 /// Used only if an object of this type is returned as a trait impl by a method
1365 extern "C" fn UpdateAddHTLC_free_void(this_ptr: *mut c_void) {
1366 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateAddHTLC); }
1369 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1370 impl UpdateAddHTLC {
1371 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateAddHTLC {
1372 assert!(self.is_owned);
1373 let ret = self.inner;
1374 self.inner = std::ptr::null_mut();
1380 pub extern "C" fn UpdateAddHTLC_get_channel_id(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
1381 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1386 pub extern "C" fn UpdateAddHTLC_set_channel_id(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1387 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1391 pub extern "C" fn UpdateAddHTLC_get_htlc_id(this_ptr: &UpdateAddHTLC) -> u64 {
1392 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_id;
1397 pub extern "C" fn UpdateAddHTLC_set_htlc_id(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
1398 unsafe { &mut *this_ptr.inner }.htlc_id = val;
1400 /// The HTLC value in milli-satoshi
1402 pub extern "C" fn UpdateAddHTLC_get_amount_msat(this_ptr: &UpdateAddHTLC) -> u64 {
1403 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.amount_msat;
1406 /// The HTLC value in milli-satoshi
1408 pub extern "C" fn UpdateAddHTLC_set_amount_msat(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
1409 unsafe { &mut *this_ptr.inner }.amount_msat = val;
1411 /// The payment hash, the pre-image of which controls HTLC redemption
1413 pub extern "C" fn UpdateAddHTLC_get_payment_hash(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
1414 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_hash;
1417 /// The payment hash, the pre-image of which controls HTLC redemption
1419 pub extern "C" fn UpdateAddHTLC_set_payment_hash(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1420 unsafe { &mut *this_ptr.inner }.payment_hash = ::lightning::ln::channelmanager::PaymentHash(val.data);
1422 /// The expiry height of the HTLC
1424 pub extern "C" fn UpdateAddHTLC_get_cltv_expiry(this_ptr: &UpdateAddHTLC) -> u32 {
1425 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry;
1428 /// The expiry height of the HTLC
1430 pub extern "C" fn UpdateAddHTLC_set_cltv_expiry(this_ptr: &mut UpdateAddHTLC, mut val: u32) {
1431 unsafe { &mut *this_ptr.inner }.cltv_expiry = val;
1433 impl Clone for UpdateAddHTLC {
1434 fn clone(&self) -> Self {
1436 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1437 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1443 /// Used only if an object of this type is returned as a trait impl by a method
1444 pub(crate) extern "C" fn UpdateAddHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1445 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateAddHTLC)).clone() })) as *mut c_void
1448 pub extern "C" fn UpdateAddHTLC_clone(orig: &UpdateAddHTLC) -> UpdateAddHTLC {
1452 use lightning::ln::msgs::UpdateFulfillHTLC as nativeUpdateFulfillHTLCImport;
1453 type nativeUpdateFulfillHTLC = nativeUpdateFulfillHTLCImport;
1455 /// An update_fulfill_htlc message to be sent or received from a peer
1458 pub struct UpdateFulfillHTLC {
1459 /// Nearly everywhere, inner must be non-null, however in places where
1460 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1461 pub inner: *mut nativeUpdateFulfillHTLC,
1465 impl Drop for UpdateFulfillHTLC {
1466 fn drop(&mut self) {
1467 if self.is_owned && !self.inner.is_null() {
1468 let _ = unsafe { Box::from_raw(self.inner) };
1473 pub extern "C" fn UpdateFulfillHTLC_free(this_ptr: UpdateFulfillHTLC) { }
1475 /// Used only if an object of this type is returned as a trait impl by a method
1476 extern "C" fn UpdateFulfillHTLC_free_void(this_ptr: *mut c_void) {
1477 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFulfillHTLC); }
1480 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1481 impl UpdateFulfillHTLC {
1482 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFulfillHTLC {
1483 assert!(self.is_owned);
1484 let ret = self.inner;
1485 self.inner = std::ptr::null_mut();
1491 pub extern "C" fn UpdateFulfillHTLC_get_channel_id(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
1492 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1497 pub extern "C" fn UpdateFulfillHTLC_set_channel_id(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1498 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1502 pub extern "C" fn UpdateFulfillHTLC_get_htlc_id(this_ptr: &UpdateFulfillHTLC) -> u64 {
1503 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_id;
1508 pub extern "C" fn UpdateFulfillHTLC_set_htlc_id(this_ptr: &mut UpdateFulfillHTLC, mut val: u64) {
1509 unsafe { &mut *this_ptr.inner }.htlc_id = val;
1511 /// The pre-image of the payment hash, allowing HTLC redemption
1513 pub extern "C" fn UpdateFulfillHTLC_get_payment_preimage(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
1514 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_preimage;
1517 /// The pre-image of the payment hash, allowing HTLC redemption
1519 pub extern "C" fn UpdateFulfillHTLC_set_payment_preimage(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1520 unsafe { &mut *this_ptr.inner }.payment_preimage = ::lightning::ln::channelmanager::PaymentPreimage(val.data);
1524 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 {
1525 UpdateFulfillHTLC { inner: Box::into_raw(Box::new(nativeUpdateFulfillHTLC {
1526 channel_id: channel_id_arg.data,
1527 htlc_id: htlc_id_arg,
1528 payment_preimage: ::lightning::ln::channelmanager::PaymentPreimage(payment_preimage_arg.data),
1529 })), is_owned: true }
1531 impl Clone for UpdateFulfillHTLC {
1532 fn clone(&self) -> Self {
1534 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1535 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1541 /// Used only if an object of this type is returned as a trait impl by a method
1542 pub(crate) extern "C" fn UpdateFulfillHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1543 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFulfillHTLC)).clone() })) as *mut c_void
1546 pub extern "C" fn UpdateFulfillHTLC_clone(orig: &UpdateFulfillHTLC) -> UpdateFulfillHTLC {
1550 use lightning::ln::msgs::UpdateFailHTLC as nativeUpdateFailHTLCImport;
1551 type nativeUpdateFailHTLC = nativeUpdateFailHTLCImport;
1553 /// An update_fail_htlc message to be sent or received from a peer
1556 pub struct UpdateFailHTLC {
1557 /// Nearly everywhere, inner must be non-null, however in places where
1558 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1559 pub inner: *mut nativeUpdateFailHTLC,
1563 impl Drop for UpdateFailHTLC {
1564 fn drop(&mut self) {
1565 if self.is_owned && !self.inner.is_null() {
1566 let _ = unsafe { Box::from_raw(self.inner) };
1571 pub extern "C" fn UpdateFailHTLC_free(this_ptr: UpdateFailHTLC) { }
1573 /// Used only if an object of this type is returned as a trait impl by a method
1574 extern "C" fn UpdateFailHTLC_free_void(this_ptr: *mut c_void) {
1575 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFailHTLC); }
1578 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1579 impl UpdateFailHTLC {
1580 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailHTLC {
1581 assert!(self.is_owned);
1582 let ret = self.inner;
1583 self.inner = std::ptr::null_mut();
1589 pub extern "C" fn UpdateFailHTLC_get_channel_id(this_ptr: &UpdateFailHTLC) -> *const [u8; 32] {
1590 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1595 pub extern "C" fn UpdateFailHTLC_set_channel_id(this_ptr: &mut UpdateFailHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1596 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1600 pub extern "C" fn UpdateFailHTLC_get_htlc_id(this_ptr: &UpdateFailHTLC) -> u64 {
1601 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_id;
1606 pub extern "C" fn UpdateFailHTLC_set_htlc_id(this_ptr: &mut UpdateFailHTLC, mut val: u64) {
1607 unsafe { &mut *this_ptr.inner }.htlc_id = val;
1609 impl Clone for UpdateFailHTLC {
1610 fn clone(&self) -> Self {
1612 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1613 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1619 /// Used only if an object of this type is returned as a trait impl by a method
1620 pub(crate) extern "C" fn UpdateFailHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1621 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailHTLC)).clone() })) as *mut c_void
1624 pub extern "C" fn UpdateFailHTLC_clone(orig: &UpdateFailHTLC) -> UpdateFailHTLC {
1628 use lightning::ln::msgs::UpdateFailMalformedHTLC as nativeUpdateFailMalformedHTLCImport;
1629 type nativeUpdateFailMalformedHTLC = nativeUpdateFailMalformedHTLCImport;
1631 /// An update_fail_malformed_htlc message to be sent or received from a peer
1634 pub struct UpdateFailMalformedHTLC {
1635 /// Nearly everywhere, inner must be non-null, however in places where
1636 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1637 pub inner: *mut nativeUpdateFailMalformedHTLC,
1641 impl Drop for UpdateFailMalformedHTLC {
1642 fn drop(&mut self) {
1643 if self.is_owned && !self.inner.is_null() {
1644 let _ = unsafe { Box::from_raw(self.inner) };
1649 pub extern "C" fn UpdateFailMalformedHTLC_free(this_ptr: UpdateFailMalformedHTLC) { }
1651 /// Used only if an object of this type is returned as a trait impl by a method
1652 extern "C" fn UpdateFailMalformedHTLC_free_void(this_ptr: *mut c_void) {
1653 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFailMalformedHTLC); }
1656 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1657 impl UpdateFailMalformedHTLC {
1658 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailMalformedHTLC {
1659 assert!(self.is_owned);
1660 let ret = self.inner;
1661 self.inner = std::ptr::null_mut();
1667 pub extern "C" fn UpdateFailMalformedHTLC_get_channel_id(this_ptr: &UpdateFailMalformedHTLC) -> *const [u8; 32] {
1668 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1673 pub extern "C" fn UpdateFailMalformedHTLC_set_channel_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1674 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1678 pub extern "C" fn UpdateFailMalformedHTLC_get_htlc_id(this_ptr: &UpdateFailMalformedHTLC) -> u64 {
1679 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_id;
1684 pub extern "C" fn UpdateFailMalformedHTLC_set_htlc_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u64) {
1685 unsafe { &mut *this_ptr.inner }.htlc_id = val;
1687 /// The failure code
1689 pub extern "C" fn UpdateFailMalformedHTLC_get_failure_code(this_ptr: &UpdateFailMalformedHTLC) -> u16 {
1690 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.failure_code;
1693 /// The failure code
1695 pub extern "C" fn UpdateFailMalformedHTLC_set_failure_code(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u16) {
1696 unsafe { &mut *this_ptr.inner }.failure_code = val;
1698 impl Clone for UpdateFailMalformedHTLC {
1699 fn clone(&self) -> Self {
1701 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1702 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1708 /// Used only if an object of this type is returned as a trait impl by a method
1709 pub(crate) extern "C" fn UpdateFailMalformedHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1710 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailMalformedHTLC)).clone() })) as *mut c_void
1713 pub extern "C" fn UpdateFailMalformedHTLC_clone(orig: &UpdateFailMalformedHTLC) -> UpdateFailMalformedHTLC {
1717 use lightning::ln::msgs::CommitmentSigned as nativeCommitmentSignedImport;
1718 type nativeCommitmentSigned = nativeCommitmentSignedImport;
1720 /// A commitment_signed message to be sent or received from a peer
1723 pub struct CommitmentSigned {
1724 /// Nearly everywhere, inner must be non-null, however in places where
1725 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1726 pub inner: *mut nativeCommitmentSigned,
1730 impl Drop for CommitmentSigned {
1731 fn drop(&mut self) {
1732 if self.is_owned && !self.inner.is_null() {
1733 let _ = unsafe { Box::from_raw(self.inner) };
1738 pub extern "C" fn CommitmentSigned_free(this_ptr: CommitmentSigned) { }
1740 /// Used only if an object of this type is returned as a trait impl by a method
1741 extern "C" fn CommitmentSigned_free_void(this_ptr: *mut c_void) {
1742 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentSigned); }
1745 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1746 impl CommitmentSigned {
1747 pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentSigned {
1748 assert!(self.is_owned);
1749 let ret = self.inner;
1750 self.inner = std::ptr::null_mut();
1756 pub extern "C" fn CommitmentSigned_get_channel_id(this_ptr: &CommitmentSigned) -> *const [u8; 32] {
1757 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1762 pub extern "C" fn CommitmentSigned_set_channel_id(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::ThirtyTwoBytes) {
1763 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1765 /// A signature on the commitment transaction
1767 pub extern "C" fn CommitmentSigned_get_signature(this_ptr: &CommitmentSigned) -> crate::c_types::Signature {
1768 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
1769 crate::c_types::Signature::from_rust(&(*inner_val))
1771 /// A signature on the commitment transaction
1773 pub extern "C" fn CommitmentSigned_set_signature(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::Signature) {
1774 unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
1776 /// Signatures on the HTLC transactions
1778 pub extern "C" fn CommitmentSigned_set_htlc_signatures(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::derived::CVec_SignatureZ) {
1779 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_rust() }); };
1780 unsafe { &mut *this_ptr.inner }.htlc_signatures = local_val;
1784 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 {
1785 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() }); };
1786 CommitmentSigned { inner: Box::into_raw(Box::new(nativeCommitmentSigned {
1787 channel_id: channel_id_arg.data,
1788 signature: signature_arg.into_rust(),
1789 htlc_signatures: local_htlc_signatures_arg,
1790 })), is_owned: true }
1792 impl Clone for CommitmentSigned {
1793 fn clone(&self) -> Self {
1795 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1796 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1802 /// Used only if an object of this type is returned as a trait impl by a method
1803 pub(crate) extern "C" fn CommitmentSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
1804 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentSigned)).clone() })) as *mut c_void
1807 pub extern "C" fn CommitmentSigned_clone(orig: &CommitmentSigned) -> CommitmentSigned {
1811 use lightning::ln::msgs::RevokeAndACK as nativeRevokeAndACKImport;
1812 type nativeRevokeAndACK = nativeRevokeAndACKImport;
1814 /// A revoke_and_ack message to be sent or received from a peer
1817 pub struct RevokeAndACK {
1818 /// Nearly everywhere, inner must be non-null, however in places where
1819 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1820 pub inner: *mut nativeRevokeAndACK,
1824 impl Drop for RevokeAndACK {
1825 fn drop(&mut self) {
1826 if self.is_owned && !self.inner.is_null() {
1827 let _ = unsafe { Box::from_raw(self.inner) };
1832 pub extern "C" fn RevokeAndACK_free(this_ptr: RevokeAndACK) { }
1834 /// Used only if an object of this type is returned as a trait impl by a method
1835 extern "C" fn RevokeAndACK_free_void(this_ptr: *mut c_void) {
1836 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRevokeAndACK); }
1839 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1841 pub(crate) fn take_inner(mut self) -> *mut nativeRevokeAndACK {
1842 assert!(self.is_owned);
1843 let ret = self.inner;
1844 self.inner = std::ptr::null_mut();
1850 pub extern "C" fn RevokeAndACK_get_channel_id(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
1851 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1856 pub extern "C" fn RevokeAndACK_set_channel_id(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
1857 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1859 /// The secret corresponding to the per-commitment point
1861 pub extern "C" fn RevokeAndACK_get_per_commitment_secret(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
1862 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.per_commitment_secret;
1865 /// The secret corresponding to the per-commitment point
1867 pub extern "C" fn RevokeAndACK_set_per_commitment_secret(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
1868 unsafe { &mut *this_ptr.inner }.per_commitment_secret = val.data;
1870 /// The next sender-broadcast commitment transaction's per-commitment point
1872 pub extern "C" fn RevokeAndACK_get_next_per_commitment_point(this_ptr: &RevokeAndACK) -> crate::c_types::PublicKey {
1873 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.next_per_commitment_point;
1874 crate::c_types::PublicKey::from_rust(&(*inner_val))
1876 /// The next sender-broadcast commitment transaction's per-commitment point
1878 pub extern "C" fn RevokeAndACK_set_next_per_commitment_point(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::PublicKey) {
1879 unsafe { &mut *this_ptr.inner }.next_per_commitment_point = val.into_rust();
1883 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 {
1884 RevokeAndACK { inner: Box::into_raw(Box::new(nativeRevokeAndACK {
1885 channel_id: channel_id_arg.data,
1886 per_commitment_secret: per_commitment_secret_arg.data,
1887 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
1888 })), is_owned: true }
1890 impl Clone for RevokeAndACK {
1891 fn clone(&self) -> Self {
1893 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1894 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1900 /// Used only if an object of this type is returned as a trait impl by a method
1901 pub(crate) extern "C" fn RevokeAndACK_clone_void(this_ptr: *const c_void) -> *mut c_void {
1902 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRevokeAndACK)).clone() })) as *mut c_void
1905 pub extern "C" fn RevokeAndACK_clone(orig: &RevokeAndACK) -> RevokeAndACK {
1909 use lightning::ln::msgs::UpdateFee as nativeUpdateFeeImport;
1910 type nativeUpdateFee = nativeUpdateFeeImport;
1912 /// An update_fee message to be sent or received from a peer
1915 pub struct UpdateFee {
1916 /// Nearly everywhere, inner must be non-null, however in places where
1917 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1918 pub inner: *mut nativeUpdateFee,
1922 impl Drop for UpdateFee {
1923 fn drop(&mut self) {
1924 if self.is_owned && !self.inner.is_null() {
1925 let _ = unsafe { Box::from_raw(self.inner) };
1930 pub extern "C" fn UpdateFee_free(this_ptr: UpdateFee) { }
1932 /// Used only if an object of this type is returned as a trait impl by a method
1933 extern "C" fn UpdateFee_free_void(this_ptr: *mut c_void) {
1934 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFee); }
1937 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1939 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFee {
1940 assert!(self.is_owned);
1941 let ret = self.inner;
1942 self.inner = std::ptr::null_mut();
1948 pub extern "C" fn UpdateFee_get_channel_id(this_ptr: &UpdateFee) -> *const [u8; 32] {
1949 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1954 pub extern "C" fn UpdateFee_set_channel_id(this_ptr: &mut UpdateFee, mut val: crate::c_types::ThirtyTwoBytes) {
1955 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1957 /// Fee rate per 1000-weight of the transaction
1959 pub extern "C" fn UpdateFee_get_feerate_per_kw(this_ptr: &UpdateFee) -> u32 {
1960 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.feerate_per_kw;
1963 /// Fee rate per 1000-weight of the transaction
1965 pub extern "C" fn UpdateFee_set_feerate_per_kw(this_ptr: &mut UpdateFee, mut val: u32) {
1966 unsafe { &mut *this_ptr.inner }.feerate_per_kw = val;
1970 pub extern "C" fn UpdateFee_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut feerate_per_kw_arg: u32) -> UpdateFee {
1971 UpdateFee { inner: Box::into_raw(Box::new(nativeUpdateFee {
1972 channel_id: channel_id_arg.data,
1973 feerate_per_kw: feerate_per_kw_arg,
1974 })), is_owned: true }
1976 impl Clone for UpdateFee {
1977 fn clone(&self) -> Self {
1979 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1980 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1986 /// Used only if an object of this type is returned as a trait impl by a method
1987 pub(crate) extern "C" fn UpdateFee_clone_void(this_ptr: *const c_void) -> *mut c_void {
1988 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFee)).clone() })) as *mut c_void
1991 pub extern "C" fn UpdateFee_clone(orig: &UpdateFee) -> UpdateFee {
1995 use lightning::ln::msgs::DataLossProtect as nativeDataLossProtectImport;
1996 type nativeDataLossProtect = nativeDataLossProtectImport;
1998 /// Proof that the sender knows the per-commitment secret of the previous commitment transaction.
1999 /// This is used to convince the recipient that the channel is at a certain commitment
2000 /// number even if they lost that data due to a local failure. Of course, the peer may lie
2001 /// and even later commitments may have been revoked.
2004 pub struct DataLossProtect {
2005 /// Nearly everywhere, inner must be non-null, however in places where
2006 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2007 pub inner: *mut nativeDataLossProtect,
2011 impl Drop for DataLossProtect {
2012 fn drop(&mut self) {
2013 if self.is_owned && !self.inner.is_null() {
2014 let _ = unsafe { Box::from_raw(self.inner) };
2019 pub extern "C" fn DataLossProtect_free(this_ptr: DataLossProtect) { }
2021 /// Used only if an object of this type is returned as a trait impl by a method
2022 extern "C" fn DataLossProtect_free_void(this_ptr: *mut c_void) {
2023 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDataLossProtect); }
2026 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2027 impl DataLossProtect {
2028 pub(crate) fn take_inner(mut self) -> *mut nativeDataLossProtect {
2029 assert!(self.is_owned);
2030 let ret = self.inner;
2031 self.inner = std::ptr::null_mut();
2035 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
2036 /// belonging to the recipient
2038 pub extern "C" fn DataLossProtect_get_your_last_per_commitment_secret(this_ptr: &DataLossProtect) -> *const [u8; 32] {
2039 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.your_last_per_commitment_secret;
2042 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
2043 /// belonging to the recipient
2045 pub extern "C" fn DataLossProtect_set_your_last_per_commitment_secret(this_ptr: &mut DataLossProtect, mut val: crate::c_types::ThirtyTwoBytes) {
2046 unsafe { &mut *this_ptr.inner }.your_last_per_commitment_secret = val.data;
2048 /// The sender's per-commitment point for their current commitment transaction
2050 pub extern "C" fn DataLossProtect_get_my_current_per_commitment_point(this_ptr: &DataLossProtect) -> crate::c_types::PublicKey {
2051 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.my_current_per_commitment_point;
2052 crate::c_types::PublicKey::from_rust(&(*inner_val))
2054 /// The sender's per-commitment point for their current commitment transaction
2056 pub extern "C" fn DataLossProtect_set_my_current_per_commitment_point(this_ptr: &mut DataLossProtect, mut val: crate::c_types::PublicKey) {
2057 unsafe { &mut *this_ptr.inner }.my_current_per_commitment_point = val.into_rust();
2061 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 {
2062 DataLossProtect { inner: Box::into_raw(Box::new(nativeDataLossProtect {
2063 your_last_per_commitment_secret: your_last_per_commitment_secret_arg.data,
2064 my_current_per_commitment_point: my_current_per_commitment_point_arg.into_rust(),
2065 })), is_owned: true }
2067 impl Clone for DataLossProtect {
2068 fn clone(&self) -> Self {
2070 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
2071 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2077 /// Used only if an object of this type is returned as a trait impl by a method
2078 pub(crate) extern "C" fn DataLossProtect_clone_void(this_ptr: *const c_void) -> *mut c_void {
2079 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDataLossProtect)).clone() })) as *mut c_void
2082 pub extern "C" fn DataLossProtect_clone(orig: &DataLossProtect) -> DataLossProtect {
2086 use lightning::ln::msgs::ChannelReestablish as nativeChannelReestablishImport;
2087 type nativeChannelReestablish = nativeChannelReestablishImport;
2089 /// A channel_reestablish message to be sent or received from a peer
2092 pub struct ChannelReestablish {
2093 /// Nearly everywhere, inner must be non-null, however in places where
2094 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2095 pub inner: *mut nativeChannelReestablish,
2099 impl Drop for ChannelReestablish {
2100 fn drop(&mut self) {
2101 if self.is_owned && !self.inner.is_null() {
2102 let _ = unsafe { Box::from_raw(self.inner) };
2107 pub extern "C" fn ChannelReestablish_free(this_ptr: ChannelReestablish) { }
2109 /// Used only if an object of this type is returned as a trait impl by a method
2110 extern "C" fn ChannelReestablish_free_void(this_ptr: *mut c_void) {
2111 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelReestablish); }
2114 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2115 impl ChannelReestablish {
2116 pub(crate) fn take_inner(mut self) -> *mut nativeChannelReestablish {
2117 assert!(self.is_owned);
2118 let ret = self.inner;
2119 self.inner = std::ptr::null_mut();
2125 pub extern "C" fn ChannelReestablish_get_channel_id(this_ptr: &ChannelReestablish) -> *const [u8; 32] {
2126 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
2131 pub extern "C" fn ChannelReestablish_set_channel_id(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) {
2132 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
2134 /// The next commitment number for the sender
2136 pub extern "C" fn ChannelReestablish_get_next_local_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
2137 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.next_local_commitment_number;
2140 /// The next commitment number for the sender
2142 pub extern "C" fn ChannelReestablish_set_next_local_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
2143 unsafe { &mut *this_ptr.inner }.next_local_commitment_number = val;
2145 /// The next commitment number for the recipient
2147 pub extern "C" fn ChannelReestablish_get_next_remote_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
2148 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.next_remote_commitment_number;
2151 /// The next commitment number for the recipient
2153 pub extern "C" fn ChannelReestablish_set_next_remote_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
2154 unsafe { &mut *this_ptr.inner }.next_remote_commitment_number = val;
2156 impl Clone for ChannelReestablish {
2157 fn clone(&self) -> Self {
2159 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
2160 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2166 /// Used only if an object of this type is returned as a trait impl by a method
2167 pub(crate) extern "C" fn ChannelReestablish_clone_void(this_ptr: *const c_void) -> *mut c_void {
2168 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelReestablish)).clone() })) as *mut c_void
2171 pub extern "C" fn ChannelReestablish_clone(orig: &ChannelReestablish) -> ChannelReestablish {
2175 use lightning::ln::msgs::AnnouncementSignatures as nativeAnnouncementSignaturesImport;
2176 type nativeAnnouncementSignatures = nativeAnnouncementSignaturesImport;
2178 /// An announcement_signatures message to be sent or received from a peer
2181 pub struct AnnouncementSignatures {
2182 /// Nearly everywhere, inner must be non-null, however in places where
2183 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2184 pub inner: *mut nativeAnnouncementSignatures,
2188 impl Drop for AnnouncementSignatures {
2189 fn drop(&mut self) {
2190 if self.is_owned && !self.inner.is_null() {
2191 let _ = unsafe { Box::from_raw(self.inner) };
2196 pub extern "C" fn AnnouncementSignatures_free(this_ptr: AnnouncementSignatures) { }
2198 /// Used only if an object of this type is returned as a trait impl by a method
2199 extern "C" fn AnnouncementSignatures_free_void(this_ptr: *mut c_void) {
2200 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeAnnouncementSignatures); }
2203 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2204 impl AnnouncementSignatures {
2205 pub(crate) fn take_inner(mut self) -> *mut nativeAnnouncementSignatures {
2206 assert!(self.is_owned);
2207 let ret = self.inner;
2208 self.inner = std::ptr::null_mut();
2214 pub extern "C" fn AnnouncementSignatures_get_channel_id(this_ptr: &AnnouncementSignatures) -> *const [u8; 32] {
2215 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
2220 pub extern "C" fn AnnouncementSignatures_set_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
2221 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
2223 /// The short channel ID
2225 pub extern "C" fn AnnouncementSignatures_get_short_channel_id(this_ptr: &AnnouncementSignatures) -> u64 {
2226 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id;
2229 /// The short channel ID
2231 pub extern "C" fn AnnouncementSignatures_set_short_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: u64) {
2232 unsafe { &mut *this_ptr.inner }.short_channel_id = val;
2234 /// A signature by the node key
2236 pub extern "C" fn AnnouncementSignatures_get_node_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
2237 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_signature;
2238 crate::c_types::Signature::from_rust(&(*inner_val))
2240 /// A signature by the node key
2242 pub extern "C" fn AnnouncementSignatures_set_node_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
2243 unsafe { &mut *this_ptr.inner }.node_signature = val.into_rust();
2245 /// A signature by the funding key
2247 pub extern "C" fn AnnouncementSignatures_get_bitcoin_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
2248 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_signature;
2249 crate::c_types::Signature::from_rust(&(*inner_val))
2251 /// A signature by the funding key
2253 pub extern "C" fn AnnouncementSignatures_set_bitcoin_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
2254 unsafe { &mut *this_ptr.inner }.bitcoin_signature = val.into_rust();
2258 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 {
2259 AnnouncementSignatures { inner: Box::into_raw(Box::new(nativeAnnouncementSignatures {
2260 channel_id: channel_id_arg.data,
2261 short_channel_id: short_channel_id_arg,
2262 node_signature: node_signature_arg.into_rust(),
2263 bitcoin_signature: bitcoin_signature_arg.into_rust(),
2264 })), is_owned: true }
2266 impl Clone for AnnouncementSignatures {
2267 fn clone(&self) -> Self {
2269 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
2270 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2276 /// Used only if an object of this type is returned as a trait impl by a method
2277 pub(crate) extern "C" fn AnnouncementSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
2278 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAnnouncementSignatures)).clone() })) as *mut c_void
2281 pub extern "C" fn AnnouncementSignatures_clone(orig: &AnnouncementSignatures) -> AnnouncementSignatures {
2284 /// An address which can be used to connect to a remote peer
2288 pub enum NetAddress {
2289 /// An IPv4 address/port on which the peer is listening.
2291 addr: crate::c_types::FourBytes,
2294 /// An IPv6 address/port on which the peer is listening.
2296 addr: crate::c_types::SixteenBytes,
2299 /// An old-style Tor onion address/port on which the peer is listening.
2301 addr: crate::c_types::TenBytes,
2304 /// A new-style Tor onion address/port on which the peer is listening.
2305 /// To create the human-readable \"hostname\", concatenate ed25519_pubkey, checksum, and version,
2306 /// wrap as base32 and append \".onion\".
2308 ed25519_pubkey: crate::c_types::ThirtyTwoBytes,
2314 use lightning::ln::msgs::NetAddress as nativeNetAddress;
2317 pub(crate) fn to_native(&self) -> nativeNetAddress {
2319 NetAddress::IPv4 {ref addr, ref port, } => {
2320 let mut addr_nonref = (*addr).clone();
2321 let mut port_nonref = (*port).clone();
2322 nativeNetAddress::IPv4 {
2323 addr: addr_nonref.data,
2327 NetAddress::IPv6 {ref addr, ref port, } => {
2328 let mut addr_nonref = (*addr).clone();
2329 let mut port_nonref = (*port).clone();
2330 nativeNetAddress::IPv6 {
2331 addr: addr_nonref.data,
2335 NetAddress::OnionV2 {ref addr, ref port, } => {
2336 let mut addr_nonref = (*addr).clone();
2337 let mut port_nonref = (*port).clone();
2338 nativeNetAddress::OnionV2 {
2339 addr: addr_nonref.data,
2343 NetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
2344 let mut ed25519_pubkey_nonref = (*ed25519_pubkey).clone();
2345 let mut checksum_nonref = (*checksum).clone();
2346 let mut version_nonref = (*version).clone();
2347 let mut port_nonref = (*port).clone();
2348 nativeNetAddress::OnionV3 {
2349 ed25519_pubkey: ed25519_pubkey_nonref.data,
2350 checksum: checksum_nonref,
2351 version: version_nonref,
2358 pub(crate) fn into_native(self) -> nativeNetAddress {
2360 NetAddress::IPv4 {mut addr, mut port, } => {
2361 nativeNetAddress::IPv4 {
2366 NetAddress::IPv6 {mut addr, mut port, } => {
2367 nativeNetAddress::IPv6 {
2372 NetAddress::OnionV2 {mut addr, mut port, } => {
2373 nativeNetAddress::OnionV2 {
2378 NetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
2379 nativeNetAddress::OnionV3 {
2380 ed25519_pubkey: ed25519_pubkey.data,
2389 pub(crate) fn from_native(native: &nativeNetAddress) -> Self {
2391 nativeNetAddress::IPv4 {ref addr, ref port, } => {
2392 let mut addr_nonref = (*addr).clone();
2393 let mut port_nonref = (*port).clone();
2395 addr: crate::c_types::FourBytes { data: addr_nonref },
2399 nativeNetAddress::IPv6 {ref addr, ref port, } => {
2400 let mut addr_nonref = (*addr).clone();
2401 let mut port_nonref = (*port).clone();
2403 addr: crate::c_types::SixteenBytes { data: addr_nonref },
2407 nativeNetAddress::OnionV2 {ref addr, ref port, } => {
2408 let mut addr_nonref = (*addr).clone();
2409 let mut port_nonref = (*port).clone();
2410 NetAddress::OnionV2 {
2411 addr: crate::c_types::TenBytes { data: addr_nonref },
2415 nativeNetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
2416 let mut ed25519_pubkey_nonref = (*ed25519_pubkey).clone();
2417 let mut checksum_nonref = (*checksum).clone();
2418 let mut version_nonref = (*version).clone();
2419 let mut port_nonref = (*port).clone();
2420 NetAddress::OnionV3 {
2421 ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey_nonref },
2422 checksum: checksum_nonref,
2423 version: version_nonref,
2430 pub(crate) fn native_into(native: nativeNetAddress) -> Self {
2432 nativeNetAddress::IPv4 {mut addr, mut port, } => {
2434 addr: crate::c_types::FourBytes { data: addr },
2438 nativeNetAddress::IPv6 {mut addr, mut port, } => {
2440 addr: crate::c_types::SixteenBytes { data: addr },
2444 nativeNetAddress::OnionV2 {mut addr, mut port, } => {
2445 NetAddress::OnionV2 {
2446 addr: crate::c_types::TenBytes { data: addr },
2450 nativeNetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
2451 NetAddress::OnionV3 {
2452 ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey },
2462 pub extern "C" fn NetAddress_free(this_ptr: NetAddress) { }
2464 pub extern "C" fn NetAddress_clone(orig: &NetAddress) -> NetAddress {
2468 pub extern "C" fn NetAddress_write(obj: &NetAddress) -> crate::c_types::derived::CVec_u8Z {
2469 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
2472 pub extern "C" fn Result_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CResult_NetAddressu8ZDecodeErrorZ {
2473 let res = crate::c_types::deserialize_obj(ser);
2474 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::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::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
2478 use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport;
2479 type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport;
2481 /// The unsigned part of a node_announcement
2484 pub struct UnsignedNodeAnnouncement {
2485 /// Nearly everywhere, inner must be non-null, however in places where
2486 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2487 pub inner: *mut nativeUnsignedNodeAnnouncement,
2491 impl Drop for UnsignedNodeAnnouncement {
2492 fn drop(&mut self) {
2493 if self.is_owned && !self.inner.is_null() {
2494 let _ = unsafe { Box::from_raw(self.inner) };
2499 pub extern "C" fn UnsignedNodeAnnouncement_free(this_ptr: UnsignedNodeAnnouncement) { }
2501 /// Used only if an object of this type is returned as a trait impl by a method
2502 extern "C" fn UnsignedNodeAnnouncement_free_void(this_ptr: *mut c_void) {
2503 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedNodeAnnouncement); }
2506 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2507 impl UnsignedNodeAnnouncement {
2508 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedNodeAnnouncement {
2509 assert!(self.is_owned);
2510 let ret = self.inner;
2511 self.inner = std::ptr::null_mut();
2515 /// The advertised features
2517 pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::ln::features::NodeFeatures {
2518 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features;
2519 crate::ln::features::NodeFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
2521 /// The advertised features
2523 pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::ln::features::NodeFeatures) {
2524 unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_inner()) };
2526 /// A strictly monotonic announcement counter, with gaps allowed
2528 pub extern "C" fn UnsignedNodeAnnouncement_get_timestamp(this_ptr: &UnsignedNodeAnnouncement) -> u32 {
2529 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp;
2532 /// A strictly monotonic announcement counter, with gaps allowed
2534 pub extern "C" fn UnsignedNodeAnnouncement_set_timestamp(this_ptr: &mut UnsignedNodeAnnouncement, mut val: u32) {
2535 unsafe { &mut *this_ptr.inner }.timestamp = val;
2537 /// The node_id this announcement originated from (don't rebroadcast the node_announcement back
2540 pub extern "C" fn UnsignedNodeAnnouncement_get_node_id(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::PublicKey {
2541 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_id;
2542 crate::c_types::PublicKey::from_rust(&(*inner_val))
2544 /// The node_id this announcement originated from (don't rebroadcast the node_announcement back
2547 pub extern "C" fn UnsignedNodeAnnouncement_set_node_id(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::PublicKey) {
2548 unsafe { &mut *this_ptr.inner }.node_id = val.into_rust();
2550 /// An RGB color for UI purposes
2552 pub extern "C" fn UnsignedNodeAnnouncement_get_rgb(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 3] {
2553 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.rgb;
2556 /// An RGB color for UI purposes
2558 pub extern "C" fn UnsignedNodeAnnouncement_set_rgb(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThreeBytes) {
2559 unsafe { &mut *this_ptr.inner }.rgb = val.data;
2561 /// An alias, for UI purposes. This should be sanitized before use. There is no guarantee
2564 pub extern "C" fn UnsignedNodeAnnouncement_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 32] {
2565 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.alias;
2568 /// An alias, for UI purposes. This should be sanitized before use. There is no guarantee
2571 pub extern "C" fn UnsignedNodeAnnouncement_set_alias(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
2572 unsafe { &mut *this_ptr.inner }.alias = val.data;
2574 /// List of addresses on which this node is reachable
2576 pub extern "C" fn UnsignedNodeAnnouncement_set_addresses(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_NetAddressZ) {
2577 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
2578 unsafe { &mut *this_ptr.inner }.addresses = local_val;
2580 impl Clone for UnsignedNodeAnnouncement {
2581 fn clone(&self) -> Self {
2583 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
2584 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2590 /// Used only if an object of this type is returned as a trait impl by a method
2591 pub(crate) extern "C" fn UnsignedNodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
2592 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedNodeAnnouncement)).clone() })) as *mut c_void
2595 pub extern "C" fn UnsignedNodeAnnouncement_clone(orig: &UnsignedNodeAnnouncement) -> UnsignedNodeAnnouncement {
2599 use lightning::ln::msgs::NodeAnnouncement as nativeNodeAnnouncementImport;
2600 type nativeNodeAnnouncement = nativeNodeAnnouncementImport;
2602 /// A node_announcement message to be sent or received from a peer
2605 pub struct NodeAnnouncement {
2606 /// Nearly everywhere, inner must be non-null, however in places where
2607 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2608 pub inner: *mut nativeNodeAnnouncement,
2612 impl Drop for NodeAnnouncement {
2613 fn drop(&mut self) {
2614 if self.is_owned && !self.inner.is_null() {
2615 let _ = unsafe { Box::from_raw(self.inner) };
2620 pub extern "C" fn NodeAnnouncement_free(this_ptr: NodeAnnouncement) { }
2622 /// Used only if an object of this type is returned as a trait impl by a method
2623 extern "C" fn NodeAnnouncement_free_void(this_ptr: *mut c_void) {
2624 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeAnnouncement); }
2627 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2628 impl NodeAnnouncement {
2629 pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncement {
2630 assert!(self.is_owned);
2631 let ret = self.inner;
2632 self.inner = std::ptr::null_mut();
2636 /// The signature by the node key
2638 pub extern "C" fn NodeAnnouncement_get_signature(this_ptr: &NodeAnnouncement) -> crate::c_types::Signature {
2639 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
2640 crate::c_types::Signature::from_rust(&(*inner_val))
2642 /// The signature by the node key
2644 pub extern "C" fn NodeAnnouncement_set_signature(this_ptr: &mut NodeAnnouncement, mut val: crate::c_types::Signature) {
2645 unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
2647 /// The actual content of the announcement
2649 pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> crate::ln::msgs::UnsignedNodeAnnouncement {
2650 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents;
2651 crate::ln::msgs::UnsignedNodeAnnouncement { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
2653 /// The actual content of the announcement
2655 pub extern "C" fn NodeAnnouncement_set_contents(this_ptr: &mut NodeAnnouncement, mut val: crate::ln::msgs::UnsignedNodeAnnouncement) {
2656 unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_inner()) };
2660 pub extern "C" fn NodeAnnouncement_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::ln::msgs::UnsignedNodeAnnouncement) -> NodeAnnouncement {
2661 NodeAnnouncement { inner: Box::into_raw(Box::new(nativeNodeAnnouncement {
2662 signature: signature_arg.into_rust(),
2663 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
2664 })), is_owned: true }
2666 impl Clone for NodeAnnouncement {
2667 fn clone(&self) -> Self {
2669 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
2670 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2676 /// Used only if an object of this type is returned as a trait impl by a method
2677 pub(crate) extern "C" fn NodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
2678 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeAnnouncement)).clone() })) as *mut c_void
2681 pub extern "C" fn NodeAnnouncement_clone(orig: &NodeAnnouncement) -> NodeAnnouncement {
2685 use lightning::ln::msgs::UnsignedChannelAnnouncement as nativeUnsignedChannelAnnouncementImport;
2686 type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport;
2688 /// The unsigned part of a channel_announcement
2691 pub struct UnsignedChannelAnnouncement {
2692 /// Nearly everywhere, inner must be non-null, however in places where
2693 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2694 pub inner: *mut nativeUnsignedChannelAnnouncement,
2698 impl Drop for UnsignedChannelAnnouncement {
2699 fn drop(&mut self) {
2700 if self.is_owned && !self.inner.is_null() {
2701 let _ = unsafe { Box::from_raw(self.inner) };
2706 pub extern "C" fn UnsignedChannelAnnouncement_free(this_ptr: UnsignedChannelAnnouncement) { }
2708 /// Used only if an object of this type is returned as a trait impl by a method
2709 extern "C" fn UnsignedChannelAnnouncement_free_void(this_ptr: *mut c_void) {
2710 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelAnnouncement); }
2713 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2714 impl UnsignedChannelAnnouncement {
2715 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelAnnouncement {
2716 assert!(self.is_owned);
2717 let ret = self.inner;
2718 self.inner = std::ptr::null_mut();
2722 /// The advertised channel features
2724 pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::ln::features::ChannelFeatures {
2725 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features;
2726 crate::ln::features::ChannelFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
2728 /// The advertised channel features
2730 pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::ln::features::ChannelFeatures) {
2731 unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_inner()) };
2733 /// The genesis hash of the blockchain where the channel is to be opened
2735 pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &UnsignedChannelAnnouncement) -> *const [u8; 32] {
2736 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
2737 (*inner_val).as_inner()
2739 /// The genesis hash of the blockchain where the channel is to be opened
2741 pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
2742 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
2744 /// The short channel ID
2746 pub extern "C" fn UnsignedChannelAnnouncement_get_short_channel_id(this_ptr: &UnsignedChannelAnnouncement) -> u64 {
2747 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id;
2750 /// The short channel ID
2752 pub extern "C" fn UnsignedChannelAnnouncement_set_short_channel_id(this_ptr: &mut UnsignedChannelAnnouncement, mut val: u64) {
2753 unsafe { &mut *this_ptr.inner }.short_channel_id = val;
2755 /// One of the two node_ids which are endpoints of this channel
2757 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
2758 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_id_1;
2759 crate::c_types::PublicKey::from_rust(&(*inner_val))
2761 /// One of the two node_ids which are endpoints of this channel
2763 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
2764 unsafe { &mut *this_ptr.inner }.node_id_1 = val.into_rust();
2766 /// The other of the two node_ids which are endpoints of this channel
2768 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
2769 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_id_2;
2770 crate::c_types::PublicKey::from_rust(&(*inner_val))
2772 /// The other of the two node_ids which are endpoints of this channel
2774 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
2775 unsafe { &mut *this_ptr.inner }.node_id_2 = val.into_rust();
2777 /// The funding key for the first node
2779 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
2780 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_key_1;
2781 crate::c_types::PublicKey::from_rust(&(*inner_val))
2783 /// The funding key for the first node
2785 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
2786 unsafe { &mut *this_ptr.inner }.bitcoin_key_1 = val.into_rust();
2788 /// The funding key for the second node
2790 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
2791 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_key_2;
2792 crate::c_types::PublicKey::from_rust(&(*inner_val))
2794 /// The funding key for the second node
2796 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
2797 unsafe { &mut *this_ptr.inner }.bitcoin_key_2 = val.into_rust();
2799 impl Clone for UnsignedChannelAnnouncement {
2800 fn clone(&self) -> Self {
2802 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
2803 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2809 /// Used only if an object of this type is returned as a trait impl by a method
2810 pub(crate) extern "C" fn UnsignedChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
2811 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelAnnouncement)).clone() })) as *mut c_void
2814 pub extern "C" fn UnsignedChannelAnnouncement_clone(orig: &UnsignedChannelAnnouncement) -> UnsignedChannelAnnouncement {
2818 use lightning::ln::msgs::ChannelAnnouncement as nativeChannelAnnouncementImport;
2819 type nativeChannelAnnouncement = nativeChannelAnnouncementImport;
2821 /// A channel_announcement message to be sent or received from a peer
2824 pub struct ChannelAnnouncement {
2825 /// Nearly everywhere, inner must be non-null, however in places where
2826 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2827 pub inner: *mut nativeChannelAnnouncement,
2831 impl Drop for ChannelAnnouncement {
2832 fn drop(&mut self) {
2833 if self.is_owned && !self.inner.is_null() {
2834 let _ = unsafe { Box::from_raw(self.inner) };
2839 pub extern "C" fn ChannelAnnouncement_free(this_ptr: ChannelAnnouncement) { }
2841 /// Used only if an object of this type is returned as a trait impl by a method
2842 extern "C" fn ChannelAnnouncement_free_void(this_ptr: *mut c_void) {
2843 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelAnnouncement); }
2846 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2847 impl ChannelAnnouncement {
2848 pub(crate) fn take_inner(mut self) -> *mut nativeChannelAnnouncement {
2849 assert!(self.is_owned);
2850 let ret = self.inner;
2851 self.inner = std::ptr::null_mut();
2855 /// Authentication of the announcement by the first public node
2857 pub extern "C" fn ChannelAnnouncement_get_node_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
2858 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_signature_1;
2859 crate::c_types::Signature::from_rust(&(*inner_val))
2861 /// Authentication of the announcement by the first public node
2863 pub extern "C" fn ChannelAnnouncement_set_node_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
2864 unsafe { &mut *this_ptr.inner }.node_signature_1 = val.into_rust();
2866 /// Authentication of the announcement by the second public node
2868 pub extern "C" fn ChannelAnnouncement_get_node_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
2869 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_signature_2;
2870 crate::c_types::Signature::from_rust(&(*inner_val))
2872 /// Authentication of the announcement by the second public node
2874 pub extern "C" fn ChannelAnnouncement_set_node_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
2875 unsafe { &mut *this_ptr.inner }.node_signature_2 = val.into_rust();
2877 /// Proof of funding UTXO ownership by the first public node
2879 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
2880 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_signature_1;
2881 crate::c_types::Signature::from_rust(&(*inner_val))
2883 /// Proof of funding UTXO ownership by the first public node
2885 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
2886 unsafe { &mut *this_ptr.inner }.bitcoin_signature_1 = val.into_rust();
2888 /// Proof of funding UTXO ownership by the second public node
2890 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
2891 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_signature_2;
2892 crate::c_types::Signature::from_rust(&(*inner_val))
2894 /// Proof of funding UTXO ownership by the second public node
2896 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
2897 unsafe { &mut *this_ptr.inner }.bitcoin_signature_2 = val.into_rust();
2899 /// The actual announcement
2901 pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncement) -> crate::ln::msgs::UnsignedChannelAnnouncement {
2902 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents;
2903 crate::ln::msgs::UnsignedChannelAnnouncement { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
2905 /// The actual announcement
2907 pub extern "C" fn ChannelAnnouncement_set_contents(this_ptr: &mut ChannelAnnouncement, mut val: crate::ln::msgs::UnsignedChannelAnnouncement) {
2908 unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_inner()) };
2912 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::ln::msgs::UnsignedChannelAnnouncement) -> ChannelAnnouncement {
2913 ChannelAnnouncement { inner: Box::into_raw(Box::new(nativeChannelAnnouncement {
2914 node_signature_1: node_signature_1_arg.into_rust(),
2915 node_signature_2: node_signature_2_arg.into_rust(),
2916 bitcoin_signature_1: bitcoin_signature_1_arg.into_rust(),
2917 bitcoin_signature_2: bitcoin_signature_2_arg.into_rust(),
2918 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
2919 })), is_owned: true }
2921 impl Clone for ChannelAnnouncement {
2922 fn clone(&self) -> Self {
2924 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
2925 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2931 /// Used only if an object of this type is returned as a trait impl by a method
2932 pub(crate) extern "C" fn ChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
2933 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelAnnouncement)).clone() })) as *mut c_void
2936 pub extern "C" fn ChannelAnnouncement_clone(orig: &ChannelAnnouncement) -> ChannelAnnouncement {
2940 use lightning::ln::msgs::UnsignedChannelUpdate as nativeUnsignedChannelUpdateImport;
2941 type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport;
2943 /// The unsigned part of a channel_update
2946 pub struct UnsignedChannelUpdate {
2947 /// Nearly everywhere, inner must be non-null, however in places where
2948 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2949 pub inner: *mut nativeUnsignedChannelUpdate,
2953 impl Drop for UnsignedChannelUpdate {
2954 fn drop(&mut self) {
2955 if self.is_owned && !self.inner.is_null() {
2956 let _ = unsafe { Box::from_raw(self.inner) };
2961 pub extern "C" fn UnsignedChannelUpdate_free(this_ptr: UnsignedChannelUpdate) { }
2963 /// Used only if an object of this type is returned as a trait impl by a method
2964 extern "C" fn UnsignedChannelUpdate_free_void(this_ptr: *mut c_void) {
2965 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelUpdate); }
2968 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2969 impl UnsignedChannelUpdate {
2970 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelUpdate {
2971 assert!(self.is_owned);
2972 let ret = self.inner;
2973 self.inner = std::ptr::null_mut();
2977 /// The genesis hash of the blockchain where the channel is to be opened
2979 pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChannelUpdate) -> *const [u8; 32] {
2980 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
2981 (*inner_val).as_inner()
2983 /// The genesis hash of the blockchain where the channel is to be opened
2985 pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::ThirtyTwoBytes) {
2986 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
2988 /// The short channel ID
2990 pub extern "C" fn UnsignedChannelUpdate_get_short_channel_id(this_ptr: &UnsignedChannelUpdate) -> u64 {
2991 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id;
2994 /// The short channel ID
2996 pub extern "C" fn UnsignedChannelUpdate_set_short_channel_id(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
2997 unsafe { &mut *this_ptr.inner }.short_channel_id = val;
2999 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
3001 pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannelUpdate) -> u32 {
3002 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp;
3005 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
3007 pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3008 unsafe { &mut *this_ptr.inner }.timestamp = val;
3012 pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 {
3013 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.flags;
3018 pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) {
3019 unsafe { &mut *this_ptr.inner }.flags = val;
3021 /// The number of blocks to subtract from incoming HTLC cltv_expiry values
3023 pub extern "C" fn UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr: &UnsignedChannelUpdate) -> u16 {
3024 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry_delta;
3027 /// The number of blocks to subtract from incoming HTLC cltv_expiry values
3029 pub extern "C" fn UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr: &mut UnsignedChannelUpdate, mut val: u16) {
3030 unsafe { &mut *this_ptr.inner }.cltv_expiry_delta = val;
3032 /// The minimum HTLC size incoming to sender, in milli-satoshi
3034 pub extern "C" fn UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
3035 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_minimum_msat;
3038 /// The minimum HTLC size incoming to sender, in milli-satoshi
3040 pub extern "C" fn UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
3041 unsafe { &mut *this_ptr.inner }.htlc_minimum_msat = val;
3043 /// The base HTLC fee charged by sender, in milli-satoshi
3045 pub extern "C" fn UnsignedChannelUpdate_get_fee_base_msat(this_ptr: &UnsignedChannelUpdate) -> u32 {
3046 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_base_msat;
3049 /// The base HTLC fee charged by sender, in milli-satoshi
3051 pub extern "C" fn UnsignedChannelUpdate_set_fee_base_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3052 unsafe { &mut *this_ptr.inner }.fee_base_msat = val;
3054 /// The amount to fee multiplier, in micro-satoshi
3056 pub extern "C" fn UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr: &UnsignedChannelUpdate) -> u32 {
3057 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_proportional_millionths;
3060 /// The amount to fee multiplier, in micro-satoshi
3062 pub extern "C" fn UnsignedChannelUpdate_set_fee_proportional_millionths(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3063 unsafe { &mut *this_ptr.inner }.fee_proportional_millionths = val;
3065 impl Clone for UnsignedChannelUpdate {
3066 fn clone(&self) -> Self {
3068 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
3069 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3075 /// Used only if an object of this type is returned as a trait impl by a method
3076 pub(crate) extern "C" fn UnsignedChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
3077 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelUpdate)).clone() })) as *mut c_void
3080 pub extern "C" fn UnsignedChannelUpdate_clone(orig: &UnsignedChannelUpdate) -> UnsignedChannelUpdate {
3084 use lightning::ln::msgs::ChannelUpdate as nativeChannelUpdateImport;
3085 type nativeChannelUpdate = nativeChannelUpdateImport;
3087 /// A channel_update message to be sent or received from a peer
3090 pub struct ChannelUpdate {
3091 /// Nearly everywhere, inner must be non-null, however in places where
3092 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3093 pub inner: *mut nativeChannelUpdate,
3097 impl Drop for ChannelUpdate {
3098 fn drop(&mut self) {
3099 if self.is_owned && !self.inner.is_null() {
3100 let _ = unsafe { Box::from_raw(self.inner) };
3105 pub extern "C" fn ChannelUpdate_free(this_ptr: ChannelUpdate) { }
3107 /// Used only if an object of this type is returned as a trait impl by a method
3108 extern "C" fn ChannelUpdate_free_void(this_ptr: *mut c_void) {
3109 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelUpdate); }
3112 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3113 impl ChannelUpdate {
3114 pub(crate) fn take_inner(mut self) -> *mut nativeChannelUpdate {
3115 assert!(self.is_owned);
3116 let ret = self.inner;
3117 self.inner = std::ptr::null_mut();
3121 /// A signature of the channel update
3123 pub extern "C" fn ChannelUpdate_get_signature(this_ptr: &ChannelUpdate) -> crate::c_types::Signature {
3124 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
3125 crate::c_types::Signature::from_rust(&(*inner_val))
3127 /// A signature of the channel update
3129 pub extern "C" fn ChannelUpdate_set_signature(this_ptr: &mut ChannelUpdate, mut val: crate::c_types::Signature) {
3130 unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
3132 /// The actual channel update
3134 pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate::ln::msgs::UnsignedChannelUpdate {
3135 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents;
3136 crate::ln::msgs::UnsignedChannelUpdate { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
3138 /// The actual channel update
3140 pub extern "C" fn ChannelUpdate_set_contents(this_ptr: &mut ChannelUpdate, mut val: crate::ln::msgs::UnsignedChannelUpdate) {
3141 unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_inner()) };
3145 pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::ln::msgs::UnsignedChannelUpdate) -> ChannelUpdate {
3146 ChannelUpdate { inner: Box::into_raw(Box::new(nativeChannelUpdate {
3147 signature: signature_arg.into_rust(),
3148 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
3149 })), is_owned: true }
3151 impl Clone for ChannelUpdate {
3152 fn clone(&self) -> Self {
3154 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
3155 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3161 /// Used only if an object of this type is returned as a trait impl by a method
3162 pub(crate) extern "C" fn ChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
3163 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelUpdate)).clone() })) as *mut c_void
3166 pub extern "C" fn ChannelUpdate_clone(orig: &ChannelUpdate) -> ChannelUpdate {
3170 use lightning::ln::msgs::QueryChannelRange as nativeQueryChannelRangeImport;
3171 type nativeQueryChannelRange = nativeQueryChannelRangeImport;
3173 /// A query_channel_range message is used to query a peer for channel
3174 /// UTXOs in a range of blocks. The recipient of a query makes a best
3175 /// effort to reply to the query using one or more reply_channel_range
3179 pub struct QueryChannelRange {
3180 /// Nearly everywhere, inner must be non-null, however in places where
3181 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3182 pub inner: *mut nativeQueryChannelRange,
3186 impl Drop for QueryChannelRange {
3187 fn drop(&mut self) {
3188 if self.is_owned && !self.inner.is_null() {
3189 let _ = unsafe { Box::from_raw(self.inner) };
3194 pub extern "C" fn QueryChannelRange_free(this_ptr: QueryChannelRange) { }
3196 /// Used only if an object of this type is returned as a trait impl by a method
3197 extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) {
3198 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryChannelRange); }
3201 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3202 impl QueryChannelRange {
3203 pub(crate) fn take_inner(mut self) -> *mut nativeQueryChannelRange {
3204 assert!(self.is_owned);
3205 let ret = self.inner;
3206 self.inner = std::ptr::null_mut();
3210 /// The genesis hash of the blockchain being queried
3212 pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *const [u8; 32] {
3213 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3214 (*inner_val).as_inner()
3216 /// The genesis hash of the blockchain being queried
3218 pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
3219 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3221 /// The height of the first block for the channel UTXOs being queried
3223 pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 {
3224 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_blocknum;
3227 /// The height of the first block for the channel UTXOs being queried
3229 pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChannelRange, mut val: u32) {
3230 unsafe { &mut *this_ptr.inner }.first_blocknum = val;
3232 /// The number of blocks to include in the query results
3234 pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 {
3235 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.number_of_blocks;
3238 /// The number of blocks to include in the query results
3240 pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryChannelRange, mut val: u32) {
3241 unsafe { &mut *this_ptr.inner }.number_of_blocks = val;
3245 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 {
3246 QueryChannelRange { inner: Box::into_raw(Box::new(nativeQueryChannelRange {
3247 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3248 first_blocknum: first_blocknum_arg,
3249 number_of_blocks: number_of_blocks_arg,
3250 })), is_owned: true }
3252 impl Clone for QueryChannelRange {
3253 fn clone(&self) -> Self {
3255 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
3256 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3262 /// Used only if an object of this type is returned as a trait impl by a method
3263 pub(crate) extern "C" fn QueryChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
3264 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryChannelRange)).clone() })) as *mut c_void
3267 pub extern "C" fn QueryChannelRange_clone(orig: &QueryChannelRange) -> QueryChannelRange {
3271 use lightning::ln::msgs::ReplyChannelRange as nativeReplyChannelRangeImport;
3272 type nativeReplyChannelRange = nativeReplyChannelRangeImport;
3274 /// A reply_channel_range message is a reply to a query_channel_range
3275 /// message. Multiple reply_channel_range messages can be sent in reply
3276 /// to a single query_channel_range message. The query recipient makes a
3277 /// best effort to respond based on their local network view which may
3278 /// not be a perfect view of the network. The short_channel_ids in the
3279 /// reply are encoded. We only support encoding_type=0 uncompressed
3280 /// serialization and do not support encoding_type=1 zlib serialization.
3283 pub struct ReplyChannelRange {
3284 /// Nearly everywhere, inner must be non-null, however in places where
3285 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3286 pub inner: *mut nativeReplyChannelRange,
3290 impl Drop for ReplyChannelRange {
3291 fn drop(&mut self) {
3292 if self.is_owned && !self.inner.is_null() {
3293 let _ = unsafe { Box::from_raw(self.inner) };
3298 pub extern "C" fn ReplyChannelRange_free(this_ptr: ReplyChannelRange) { }
3300 /// Used only if an object of this type is returned as a trait impl by a method
3301 extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) {
3302 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyChannelRange); }
3305 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3306 impl ReplyChannelRange {
3307 pub(crate) fn take_inner(mut self) -> *mut nativeReplyChannelRange {
3308 assert!(self.is_owned);
3309 let ret = self.inner;
3310 self.inner = std::ptr::null_mut();
3314 /// The genesis hash of the blockchain being queried
3316 pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *const [u8; 32] {
3317 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3318 (*inner_val).as_inner()
3320 /// The genesis hash of the blockchain being queried
3322 pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
3323 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3325 /// The height of the first block in the range of the reply
3327 pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 {
3328 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_blocknum;
3331 /// The height of the first block in the range of the reply
3333 pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChannelRange, mut val: u32) {
3334 unsafe { &mut *this_ptr.inner }.first_blocknum = val;
3336 /// The number of blocks included in the range of the reply
3338 pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 {
3339 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.number_of_blocks;
3342 /// The number of blocks included in the range of the reply
3344 pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyChannelRange, mut val: u32) {
3345 unsafe { &mut *this_ptr.inner }.number_of_blocks = val;
3347 /// True when this is the final reply for a query
3349 pub extern "C" fn ReplyChannelRange_get_sync_complete(this_ptr: &ReplyChannelRange) -> bool {
3350 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.sync_complete;
3353 /// True when this is the final reply for a query
3355 pub extern "C" fn ReplyChannelRange_set_sync_complete(this_ptr: &mut ReplyChannelRange, mut val: bool) {
3356 unsafe { &mut *this_ptr.inner }.sync_complete = val;
3358 /// The short_channel_ids in the channel range
3360 pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::derived::CVec_u64Z) {
3361 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
3362 unsafe { &mut *this_ptr.inner }.short_channel_ids = local_val;
3366 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 {
3367 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 }); };
3368 ReplyChannelRange { inner: Box::into_raw(Box::new(nativeReplyChannelRange {
3369 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3370 first_blocknum: first_blocknum_arg,
3371 number_of_blocks: number_of_blocks_arg,
3372 sync_complete: sync_complete_arg,
3373 short_channel_ids: local_short_channel_ids_arg,
3374 })), is_owned: true }
3376 impl Clone for ReplyChannelRange {
3377 fn clone(&self) -> Self {
3379 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
3380 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3386 /// Used only if an object of this type is returned as a trait impl by a method
3387 pub(crate) extern "C" fn ReplyChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
3388 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyChannelRange)).clone() })) as *mut c_void
3391 pub extern "C" fn ReplyChannelRange_clone(orig: &ReplyChannelRange) -> ReplyChannelRange {
3395 use lightning::ln::msgs::QueryShortChannelIds as nativeQueryShortChannelIdsImport;
3396 type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport;
3398 /// A query_short_channel_ids message is used to query a peer for
3399 /// routing gossip messages related to one or more short_channel_ids.
3400 /// The query recipient will reply with the latest, if available,
3401 /// channel_announcement, channel_update and node_announcement messages
3402 /// it maintains for the requested short_channel_ids followed by a
3403 /// reply_short_channel_ids_end message. The short_channel_ids sent in
3404 /// this query are encoded. We only support encoding_type=0 uncompressed
3405 /// serialization and do not support encoding_type=1 zlib serialization.
3408 pub struct QueryShortChannelIds {
3409 /// Nearly everywhere, inner must be non-null, however in places where
3410 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3411 pub inner: *mut nativeQueryShortChannelIds,
3415 impl Drop for QueryShortChannelIds {
3416 fn drop(&mut self) {
3417 if self.is_owned && !self.inner.is_null() {
3418 let _ = unsafe { Box::from_raw(self.inner) };
3423 pub extern "C" fn QueryShortChannelIds_free(this_ptr: QueryShortChannelIds) { }
3425 /// Used only if an object of this type is returned as a trait impl by a method
3426 extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) {
3427 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryShortChannelIds); }
3430 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3431 impl QueryShortChannelIds {
3432 pub(crate) fn take_inner(mut self) -> *mut nativeQueryShortChannelIds {
3433 assert!(self.is_owned);
3434 let ret = self.inner;
3435 self.inner = std::ptr::null_mut();
3439 /// The genesis hash of the blockchain being queried
3441 pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *const [u8; 32] {
3442 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3443 (*inner_val).as_inner()
3445 /// The genesis hash of the blockchain being queried
3447 pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::ThirtyTwoBytes) {
3448 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3450 /// The short_channel_ids that are being queried
3452 pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::derived::CVec_u64Z) {
3453 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
3454 unsafe { &mut *this_ptr.inner }.short_channel_ids = local_val;
3458 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 {
3459 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 }); };
3460 QueryShortChannelIds { inner: Box::into_raw(Box::new(nativeQueryShortChannelIds {
3461 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3462 short_channel_ids: local_short_channel_ids_arg,
3463 })), is_owned: true }
3465 impl Clone for QueryShortChannelIds {
3466 fn clone(&self) -> Self {
3468 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
3469 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3475 /// Used only if an object of this type is returned as a trait impl by a method
3476 pub(crate) extern "C" fn QueryShortChannelIds_clone_void(this_ptr: *const c_void) -> *mut c_void {
3477 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryShortChannelIds)).clone() })) as *mut c_void
3480 pub extern "C" fn QueryShortChannelIds_clone(orig: &QueryShortChannelIds) -> QueryShortChannelIds {
3484 use lightning::ln::msgs::ReplyShortChannelIdsEnd as nativeReplyShortChannelIdsEndImport;
3485 type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport;
3487 /// A reply_short_channel_ids_end message is sent as a reply to a
3488 /// query_short_channel_ids message. The query recipient makes a best
3489 /// effort to respond based on their local network view which may not be
3490 /// a perfect view of the network.
3493 pub struct ReplyShortChannelIdsEnd {
3494 /// Nearly everywhere, inner must be non-null, however in places where
3495 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3496 pub inner: *mut nativeReplyShortChannelIdsEnd,
3500 impl Drop for ReplyShortChannelIdsEnd {
3501 fn drop(&mut self) {
3502 if self.is_owned && !self.inner.is_null() {
3503 let _ = unsafe { Box::from_raw(self.inner) };
3508 pub extern "C" fn ReplyShortChannelIdsEnd_free(this_ptr: ReplyShortChannelIdsEnd) { }
3510 /// Used only if an object of this type is returned as a trait impl by a method
3511 extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) {
3512 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyShortChannelIdsEnd); }
3515 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3516 impl ReplyShortChannelIdsEnd {
3517 pub(crate) fn take_inner(mut self) -> *mut nativeReplyShortChannelIdsEnd {
3518 assert!(self.is_owned);
3519 let ret = self.inner;
3520 self.inner = std::ptr::null_mut();
3524 /// The genesis hash of the blockchain that was queried
3526 pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *const [u8; 32] {
3527 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3528 (*inner_val).as_inner()
3530 /// The genesis hash of the blockchain that was queried
3532 pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) {
3533 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3535 /// Indicates if the query recipient maintains up-to-date channel
3536 /// information for the chain_hash
3538 pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool {
3539 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.full_information;
3542 /// Indicates if the query recipient maintains up-to-date channel
3543 /// information for the chain_hash
3545 pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: bool) {
3546 unsafe { &mut *this_ptr.inner }.full_information = val;
3550 pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd {
3551 ReplyShortChannelIdsEnd { inner: Box::into_raw(Box::new(nativeReplyShortChannelIdsEnd {
3552 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3553 full_information: full_information_arg,
3554 })), is_owned: true }
3556 impl Clone for ReplyShortChannelIdsEnd {
3557 fn clone(&self) -> Self {
3559 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
3560 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3566 /// Used only if an object of this type is returned as a trait impl by a method
3567 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_void) -> *mut c_void {
3568 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyShortChannelIdsEnd)).clone() })) as *mut c_void
3571 pub extern "C" fn ReplyShortChannelIdsEnd_clone(orig: &ReplyShortChannelIdsEnd) -> ReplyShortChannelIdsEnd {
3575 use lightning::ln::msgs::GossipTimestampFilter as nativeGossipTimestampFilterImport;
3576 type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport;
3578 /// A gossip_timestamp_filter message is used by a node to request
3579 /// gossip relay for messages in the requested time range when the
3580 /// gossip_queries feature has been negotiated.
3583 pub struct GossipTimestampFilter {
3584 /// Nearly everywhere, inner must be non-null, however in places where
3585 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3586 pub inner: *mut nativeGossipTimestampFilter,
3590 impl Drop for GossipTimestampFilter {
3591 fn drop(&mut self) {
3592 if self.is_owned && !self.inner.is_null() {
3593 let _ = unsafe { Box::from_raw(self.inner) };
3598 pub extern "C" fn GossipTimestampFilter_free(this_ptr: GossipTimestampFilter) { }
3600 /// Used only if an object of this type is returned as a trait impl by a method
3601 extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) {
3602 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeGossipTimestampFilter); }
3605 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3606 impl GossipTimestampFilter {
3607 pub(crate) fn take_inner(mut self) -> *mut nativeGossipTimestampFilter {
3608 assert!(self.is_owned);
3609 let ret = self.inner;
3610 self.inner = std::ptr::null_mut();
3614 /// The genesis hash of the blockchain for channel and node information
3616 pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *const [u8; 32] {
3617 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3618 (*inner_val).as_inner()
3620 /// The genesis hash of the blockchain for channel and node information
3622 pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) {
3623 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3625 /// The starting unix timestamp
3627 pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 {
3628 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_timestamp;
3631 /// The starting unix timestamp
3633 pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
3634 unsafe { &mut *this_ptr.inner }.first_timestamp = val;
3636 /// The range of information in seconds
3638 pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 {
3639 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp_range;
3642 /// The range of information in seconds
3644 pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
3645 unsafe { &mut *this_ptr.inner }.timestamp_range = val;
3649 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 {
3650 GossipTimestampFilter { inner: Box::into_raw(Box::new(nativeGossipTimestampFilter {
3651 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3652 first_timestamp: first_timestamp_arg,
3653 timestamp_range: timestamp_range_arg,
3654 })), is_owned: true }
3656 impl Clone for GossipTimestampFilter {
3657 fn clone(&self) -> Self {
3659 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
3660 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3666 /// Used only if an object of this type is returned as a trait impl by a method
3667 pub(crate) extern "C" fn GossipTimestampFilter_clone_void(this_ptr: *const c_void) -> *mut c_void {
3668 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeGossipTimestampFilter)).clone() })) as *mut c_void
3671 pub extern "C" fn GossipTimestampFilter_clone(orig: &GossipTimestampFilter) -> GossipTimestampFilter {
3674 /// Used to put an error message in a LightningError
3678 pub enum ErrorAction {
3679 /// The peer took some action which made us think they were useless. Disconnect them.
3681 msg: crate::ln::msgs::ErrorMessage,
3683 /// The peer did something harmless that we weren't able to process, just log and ignore
3685 /// The peer did something incorrect. Tell them.
3687 msg: crate::ln::msgs::ErrorMessage,
3690 use lightning::ln::msgs::ErrorAction as nativeErrorAction;
3693 pub(crate) fn to_native(&self) -> nativeErrorAction {
3695 ErrorAction::DisconnectPeer {ref msg, } => {
3696 let mut msg_nonref = (*msg).clone();
3697 let mut local_msg_nonref = if msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg_nonref.take_inner()) } }) };
3698 nativeErrorAction::DisconnectPeer {
3699 msg: local_msg_nonref,
3702 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
3703 ErrorAction::SendErrorMessage {ref msg, } => {
3704 let mut msg_nonref = (*msg).clone();
3705 nativeErrorAction::SendErrorMessage {
3706 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3712 pub(crate) fn into_native(self) -> nativeErrorAction {
3714 ErrorAction::DisconnectPeer {mut msg, } => {
3715 let mut local_msg = if msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg.take_inner()) } }) };
3716 nativeErrorAction::DisconnectPeer {
3720 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
3721 ErrorAction::SendErrorMessage {mut msg, } => {
3722 nativeErrorAction::SendErrorMessage {
3723 msg: *unsafe { Box::from_raw(msg.take_inner()) },
3729 pub(crate) fn from_native(native: &nativeErrorAction) -> Self {
3731 nativeErrorAction::DisconnectPeer {ref msg, } => {
3732 let mut msg_nonref = (*msg).clone();
3733 let mut local_msg_nonref = crate::ln::msgs::ErrorMessage { inner: if msg_nonref.is_none() { std::ptr::null_mut() } else { { Box::into_raw(Box::new((msg_nonref.unwrap()))) } }, is_owned: true };
3734 ErrorAction::DisconnectPeer {
3735 msg: local_msg_nonref,
3738 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
3739 nativeErrorAction::SendErrorMessage {ref msg, } => {
3740 let mut msg_nonref = (*msg).clone();
3741 ErrorAction::SendErrorMessage {
3742 msg: crate::ln::msgs::ErrorMessage { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
3748 pub(crate) fn native_into(native: nativeErrorAction) -> Self {
3750 nativeErrorAction::DisconnectPeer {mut msg, } => {
3751 let mut local_msg = crate::ln::msgs::ErrorMessage { inner: if msg.is_none() { std::ptr::null_mut() } else { { Box::into_raw(Box::new((msg.unwrap()))) } }, is_owned: true };
3752 ErrorAction::DisconnectPeer {
3756 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
3757 nativeErrorAction::SendErrorMessage {mut msg, } => {
3758 ErrorAction::SendErrorMessage {
3759 msg: crate::ln::msgs::ErrorMessage { inner: Box::into_raw(Box::new(msg)), is_owned: true },
3766 pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { }
3768 pub extern "C" fn ErrorAction_clone(orig: &ErrorAction) -> ErrorAction {
3772 use lightning::ln::msgs::LightningError as nativeLightningErrorImport;
3773 type nativeLightningError = nativeLightningErrorImport;
3775 /// An Err type for failure to process messages.
3778 pub struct LightningError {
3779 /// Nearly everywhere, inner must be non-null, however in places where
3780 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3781 pub inner: *mut nativeLightningError,
3785 impl Drop for LightningError {
3786 fn drop(&mut self) {
3787 if self.is_owned && !self.inner.is_null() {
3788 let _ = unsafe { Box::from_raw(self.inner) };
3793 pub extern "C" fn LightningError_free(this_ptr: LightningError) { }
3795 /// Used only if an object of this type is returned as a trait impl by a method
3796 extern "C" fn LightningError_free_void(this_ptr: *mut c_void) {
3797 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeLightningError); }
3800 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3801 impl LightningError {
3802 pub(crate) fn take_inner(mut self) -> *mut nativeLightningError {
3803 assert!(self.is_owned);
3804 let ret = self.inner;
3805 self.inner = std::ptr::null_mut();
3809 /// A human-readable message describing the error
3811 pub extern "C" fn LightningError_get_err(this_ptr: &LightningError) -> crate::c_types::Str {
3812 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.err;
3813 (*inner_val).as_str().into()
3815 /// A human-readable message describing the error
3817 pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: crate::c_types::derived::CVec_u8Z) {
3818 unsafe { &mut *this_ptr.inner }.err = String::from_utf8(val.into_rust()).unwrap();
3820 /// The action which should be taken against the offending peer.
3822 pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate::ln::msgs::ErrorAction {
3823 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.action;
3824 crate::ln::msgs::ErrorAction::from_native(&(*inner_val))
3826 /// The action which should be taken against the offending peer.
3828 pub extern "C" fn LightningError_set_action(this_ptr: &mut LightningError, mut val: crate::ln::msgs::ErrorAction) {
3829 unsafe { &mut *this_ptr.inner }.action = val.into_native();
3833 pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::derived::CVec_u8Z, mut action_arg: crate::ln::msgs::ErrorAction) -> LightningError {
3834 LightningError { inner: Box::into_raw(Box::new(nativeLightningError {
3835 err: String::from_utf8(err_arg.into_rust()).unwrap(),
3836 action: action_arg.into_native(),
3837 })), is_owned: true }
3839 impl Clone for LightningError {
3840 fn clone(&self) -> Self {
3842 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
3843 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3849 /// Used only if an object of this type is returned as a trait impl by a method
3850 pub(crate) extern "C" fn LightningError_clone_void(this_ptr: *const c_void) -> *mut c_void {
3851 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeLightningError)).clone() })) as *mut c_void
3854 pub extern "C" fn LightningError_clone(orig: &LightningError) -> LightningError {
3858 use lightning::ln::msgs::CommitmentUpdate as nativeCommitmentUpdateImport;
3859 type nativeCommitmentUpdate = nativeCommitmentUpdateImport;
3861 /// Struct used to return values from revoke_and_ack messages, containing a bunch of commitment
3862 /// transaction updates if they were pending.
3865 pub struct CommitmentUpdate {
3866 /// Nearly everywhere, inner must be non-null, however in places where
3867 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3868 pub inner: *mut nativeCommitmentUpdate,
3872 impl Drop for CommitmentUpdate {
3873 fn drop(&mut self) {
3874 if self.is_owned && !self.inner.is_null() {
3875 let _ = unsafe { Box::from_raw(self.inner) };
3880 pub extern "C" fn CommitmentUpdate_free(this_ptr: CommitmentUpdate) { }
3882 /// Used only if an object of this type is returned as a trait impl by a method
3883 extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) {
3884 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentUpdate); }
3887 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3888 impl CommitmentUpdate {
3889 pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentUpdate {
3890 assert!(self.is_owned);
3891 let ret = self.inner;
3892 self.inner = std::ptr::null_mut();
3896 /// update_add_htlc messages which should be sent
3898 pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) {
3899 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
3900 unsafe { &mut *this_ptr.inner }.update_add_htlcs = local_val;
3902 /// update_fulfill_htlc messages which should be sent
3904 pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) {
3905 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
3906 unsafe { &mut *this_ptr.inner }.update_fulfill_htlcs = local_val;
3908 /// update_fail_htlc messages which should be sent
3910 pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) {
3911 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
3912 unsafe { &mut *this_ptr.inner }.update_fail_htlcs = local_val;
3914 /// update_fail_malformed_htlc messages which should be sent
3916 pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) {
3917 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
3918 unsafe { &mut *this_ptr.inner }.update_fail_malformed_htlcs = local_val;
3920 /// An update_fee message which should be sent
3922 pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::ln::msgs::UpdateFee {
3923 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.update_fee;
3924 let mut local_inner_val = crate::ln::msgs::UpdateFee { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { { (inner_val.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false };
3927 /// An update_fee message which should be sent
3929 pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdate, mut val: crate::ln::msgs::UpdateFee) {
3930 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
3931 unsafe { &mut *this_ptr.inner }.update_fee = local_val;
3933 /// Finally, the commitment_signed message which should be sent
3935 pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::ln::msgs::CommitmentSigned {
3936 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.commitment_signed;
3937 crate::ln::msgs::CommitmentSigned { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
3939 /// Finally, the commitment_signed message which should be sent
3941 pub extern "C" fn CommitmentUpdate_set_commitment_signed(this_ptr: &mut CommitmentUpdate, mut val: crate::ln::msgs::CommitmentSigned) {
3942 unsafe { &mut *this_ptr.inner }.commitment_signed = *unsafe { Box::from_raw(val.take_inner()) };
3946 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::ln::msgs::UpdateFee, mut commitment_signed_arg: crate::ln::msgs::CommitmentSigned) -> CommitmentUpdate {
3947 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()) } }); };
3948 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()) } }); };
3949 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()) } }); };
3950 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()) } }); };
3951 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()) } }) };
3952 CommitmentUpdate { inner: Box::into_raw(Box::new(nativeCommitmentUpdate {
3953 update_add_htlcs: local_update_add_htlcs_arg,
3954 update_fulfill_htlcs: local_update_fulfill_htlcs_arg,
3955 update_fail_htlcs: local_update_fail_htlcs_arg,
3956 update_fail_malformed_htlcs: local_update_fail_malformed_htlcs_arg,
3957 update_fee: local_update_fee_arg,
3958 commitment_signed: *unsafe { Box::from_raw(commitment_signed_arg.take_inner()) },
3959 })), is_owned: true }
3961 impl Clone for CommitmentUpdate {
3962 fn clone(&self) -> Self {
3964 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
3965 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3971 /// Used only if an object of this type is returned as a trait impl by a method
3972 pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
3973 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentUpdate)).clone() })) as *mut c_void
3976 pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentUpdate {
3979 /// The information we received from a peer along the route of a payment we originated. This is
3980 /// returned by ChannelMessageHandler::handle_update_fail_htlc to be passed into
3981 /// RoutingMessageHandler::handle_htlc_fail_channel_update to update our network map.
3985 pub enum HTLCFailChannelUpdate {
3986 /// We received an error which included a full ChannelUpdate message.
3987 ChannelUpdateMessage {
3988 msg: crate::ln::msgs::ChannelUpdate,
3990 /// We received an error which indicated only that a channel has been closed
3992 short_channel_id: u64,
3995 /// We received an error which indicated only that a node has failed
3997 node_id: crate::c_types::PublicKey,
4001 use lightning::ln::msgs::HTLCFailChannelUpdate as nativeHTLCFailChannelUpdate;
4002 impl HTLCFailChannelUpdate {
4004 pub(crate) fn to_native(&self) -> nativeHTLCFailChannelUpdate {
4006 HTLCFailChannelUpdate::ChannelUpdateMessage {ref msg, } => {
4007 let mut msg_nonref = (*msg).clone();
4008 nativeHTLCFailChannelUpdate::ChannelUpdateMessage {
4009 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
4012 HTLCFailChannelUpdate::ChannelClosed {ref short_channel_id, ref is_permanent, } => {
4013 let mut short_channel_id_nonref = (*short_channel_id).clone();
4014 let mut is_permanent_nonref = (*is_permanent).clone();
4015 nativeHTLCFailChannelUpdate::ChannelClosed {
4016 short_channel_id: short_channel_id_nonref,
4017 is_permanent: is_permanent_nonref,
4020 HTLCFailChannelUpdate::NodeFailure {ref node_id, ref is_permanent, } => {
4021 let mut node_id_nonref = (*node_id).clone();
4022 let mut is_permanent_nonref = (*is_permanent).clone();
4023 nativeHTLCFailChannelUpdate::NodeFailure {
4024 node_id: node_id_nonref.into_rust(),
4025 is_permanent: is_permanent_nonref,
4031 pub(crate) fn into_native(self) -> nativeHTLCFailChannelUpdate {
4033 HTLCFailChannelUpdate::ChannelUpdateMessage {mut msg, } => {
4034 nativeHTLCFailChannelUpdate::ChannelUpdateMessage {
4035 msg: *unsafe { Box::from_raw(msg.take_inner()) },
4038 HTLCFailChannelUpdate::ChannelClosed {mut short_channel_id, mut is_permanent, } => {
4039 nativeHTLCFailChannelUpdate::ChannelClosed {
4040 short_channel_id: short_channel_id,
4041 is_permanent: is_permanent,
4044 HTLCFailChannelUpdate::NodeFailure {mut node_id, mut is_permanent, } => {
4045 nativeHTLCFailChannelUpdate::NodeFailure {
4046 node_id: node_id.into_rust(),
4047 is_permanent: is_permanent,
4053 pub(crate) fn from_native(native: &nativeHTLCFailChannelUpdate) -> Self {
4055 nativeHTLCFailChannelUpdate::ChannelUpdateMessage {ref msg, } => {
4056 let mut msg_nonref = (*msg).clone();
4057 HTLCFailChannelUpdate::ChannelUpdateMessage {
4058 msg: crate::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
4061 nativeHTLCFailChannelUpdate::ChannelClosed {ref short_channel_id, ref is_permanent, } => {
4062 let mut short_channel_id_nonref = (*short_channel_id).clone();
4063 let mut is_permanent_nonref = (*is_permanent).clone();
4064 HTLCFailChannelUpdate::ChannelClosed {
4065 short_channel_id: short_channel_id_nonref,
4066 is_permanent: is_permanent_nonref,
4069 nativeHTLCFailChannelUpdate::NodeFailure {ref node_id, ref is_permanent, } => {
4070 let mut node_id_nonref = (*node_id).clone();
4071 let mut is_permanent_nonref = (*is_permanent).clone();
4072 HTLCFailChannelUpdate::NodeFailure {
4073 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
4074 is_permanent: is_permanent_nonref,
4080 pub(crate) fn native_into(native: nativeHTLCFailChannelUpdate) -> Self {
4082 nativeHTLCFailChannelUpdate::ChannelUpdateMessage {mut msg, } => {
4083 HTLCFailChannelUpdate::ChannelUpdateMessage {
4084 msg: crate::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(msg)), is_owned: true },
4087 nativeHTLCFailChannelUpdate::ChannelClosed {mut short_channel_id, mut is_permanent, } => {
4088 HTLCFailChannelUpdate::ChannelClosed {
4089 short_channel_id: short_channel_id,
4090 is_permanent: is_permanent,
4093 nativeHTLCFailChannelUpdate::NodeFailure {mut node_id, mut is_permanent, } => {
4094 HTLCFailChannelUpdate::NodeFailure {
4095 node_id: crate::c_types::PublicKey::from_rust(&node_id),
4096 is_permanent: is_permanent,
4103 pub extern "C" fn HTLCFailChannelUpdate_free(this_ptr: HTLCFailChannelUpdate) { }
4105 pub extern "C" fn HTLCFailChannelUpdate_clone(orig: &HTLCFailChannelUpdate) -> HTLCFailChannelUpdate {
4108 /// A trait to describe an object which can receive channel messages.
4110 /// Messages MAY be called in parallel when they originate from different their_node_ids, however
4111 /// they MUST NOT be called in parallel when the two calls have the same their_node_id.
4113 pub struct ChannelMessageHandler {
4114 pub this_arg: *mut c_void,
4115 /// Handle an incoming open_channel message from the given peer.
4116 pub handle_open_channel: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, their_features: crate::ln::features::InitFeatures, msg: &crate::ln::msgs::OpenChannel),
4117 /// Handle an incoming accept_channel message from the given peer.
4118 pub handle_accept_channel: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, their_features: crate::ln::features::InitFeatures, msg: &crate::ln::msgs::AcceptChannel),
4119 /// Handle an incoming funding_created message from the given peer.
4120 pub handle_funding_created: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingCreated),
4121 /// Handle an incoming funding_signed message from the given peer.
4122 pub handle_funding_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingSigned),
4123 /// Handle an incoming funding_locked message from the given peer.
4124 pub handle_funding_locked: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingLocked),
4125 /// Handle an incoming shutdown message from the given peer.
4126 pub handle_shutdown: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, their_features: &crate::ln::features::InitFeatures, msg: &crate::ln::msgs::Shutdown),
4127 /// Handle an incoming closing_signed message from the given peer.
4128 pub handle_closing_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ClosingSigned),
4129 /// Handle an incoming update_add_htlc message from the given peer.
4130 pub handle_update_add_htlc: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateAddHTLC),
4131 /// Handle an incoming update_fulfill_htlc message from the given peer.
4132 pub handle_update_fulfill_htlc: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFulfillHTLC),
4133 /// Handle an incoming update_fail_htlc message from the given peer.
4134 pub handle_update_fail_htlc: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFailHTLC),
4135 /// Handle an incoming update_fail_malformed_htlc message from the given peer.
4136 pub handle_update_fail_malformed_htlc: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFailMalformedHTLC),
4137 /// Handle an incoming commitment_signed message from the given peer.
4138 pub handle_commitment_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::CommitmentSigned),
4139 /// Handle an incoming revoke_and_ack message from the given peer.
4140 pub handle_revoke_and_ack: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::RevokeAndACK),
4141 /// Handle an incoming update_fee message from the given peer.
4142 pub handle_update_fee: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFee),
4143 /// Handle an incoming announcement_signatures message from the given peer.
4144 pub handle_announcement_signatures: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::AnnouncementSignatures),
4145 /// Indicates a connection to the peer failed/an existing connection was lost. If no connection
4146 /// is believed to be possible in the future (eg they're sending us messages we don't
4147 /// understand or indicate they require unknown feature bits), no_connection_possible is set
4148 /// and any outstanding channels should be failed.
4149 pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, no_connection_possible: bool),
4150 /// Handle a peer reconnecting, possibly generating channel_reestablish message(s).
4151 pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::Init),
4152 /// Handle an incoming channel_reestablish message from the given peer.
4153 pub handle_channel_reestablish: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ChannelReestablish),
4154 /// Handle an incoming error message from the given peer.
4155 pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ErrorMessage),
4156 pub MessageSendEventsProvider: crate::util::events::MessageSendEventsProvider,
4157 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
4159 impl lightning::util::events::MessageSendEventsProvider for ChannelMessageHandler {
4160 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
4161 <crate::util::events::MessageSendEventsProvider as lightning::util::events::MessageSendEventsProvider>::get_and_clear_pending_msg_events(&self.MessageSendEventsProvider)
4164 unsafe impl Send for ChannelMessageHandler {}
4165 unsafe impl Sync for ChannelMessageHandler {}
4167 use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler;
4168 impl rustChannelMessageHandler for ChannelMessageHandler {
4169 fn handle_open_channel(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, their_features: lightning::ln::features::InitFeatures, msg: &lightning::ln::msgs::OpenChannel) {
4170 (self.handle_open_channel)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::ln::features::InitFeatures { inner: Box::into_raw(Box::new(their_features)), is_owned: true }, &crate::ln::msgs::OpenChannel { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false })
4172 fn handle_accept_channel(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, their_features: lightning::ln::features::InitFeatures, msg: &lightning::ln::msgs::AcceptChannel) {
4173 (self.handle_accept_channel)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::ln::features::InitFeatures { inner: Box::into_raw(Box::new(their_features)), is_owned: true }, &crate::ln::msgs::AcceptChannel { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false })
4175 fn handle_funding_created(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::FundingCreated) {
4176 (self.handle_funding_created)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::FundingCreated { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false })
4178 fn handle_funding_signed(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::FundingSigned) {
4179 (self.handle_funding_signed)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::FundingSigned { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false })
4181 fn handle_funding_locked(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::FundingLocked) {
4182 (self.handle_funding_locked)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::FundingLocked { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false })
4184 fn handle_shutdown(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, their_features: &lightning::ln::features::InitFeatures, msg: &lightning::ln::msgs::Shutdown) {
4185 (self.handle_shutdown)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::features::InitFeatures { inner: unsafe { (their_features as *const _) as *mut _ }, is_owned: false }, &crate::ln::msgs::Shutdown { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false })
4187 fn handle_closing_signed(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::ClosingSigned) {
4188 (self.handle_closing_signed)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::ClosingSigned { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false })
4190 fn handle_update_add_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateAddHTLC) {
4191 (self.handle_update_add_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::UpdateAddHTLC { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false })
4193 fn handle_update_fulfill_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFulfillHTLC) {
4194 (self.handle_update_fulfill_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::UpdateFulfillHTLC { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false })
4196 fn handle_update_fail_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFailHTLC) {
4197 (self.handle_update_fail_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::UpdateFailHTLC { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false })
4199 fn handle_update_fail_malformed_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) {
4200 (self.handle_update_fail_malformed_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::UpdateFailMalformedHTLC { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false })
4202 fn handle_commitment_signed(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::CommitmentSigned) {
4203 (self.handle_commitment_signed)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::CommitmentSigned { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false })
4205 fn handle_revoke_and_ack(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::RevokeAndACK) {
4206 (self.handle_revoke_and_ack)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::RevokeAndACK { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false })
4208 fn handle_update_fee(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFee) {
4209 (self.handle_update_fee)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::UpdateFee { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false })
4211 fn handle_announcement_signatures(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::AnnouncementSignatures) {
4212 (self.handle_announcement_signatures)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::AnnouncementSignatures { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false })
4214 fn peer_disconnected(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, no_connection_possible: bool) {
4215 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), no_connection_possible)
4217 fn peer_connected(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::Init) {
4218 (self.peer_connected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::Init { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false })
4220 fn handle_channel_reestablish(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::ChannelReestablish) {
4221 (self.handle_channel_reestablish)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::ChannelReestablish { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false })
4223 fn handle_error(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::ErrorMessage) {
4224 (self.handle_error)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::ErrorMessage { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false })
4228 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
4229 // directly as a Deref trait in higher-level structs:
4230 impl std::ops::Deref for ChannelMessageHandler {
4232 fn deref(&self) -> &Self {
4236 /// Calls the free function if one is set
4238 pub extern "C" fn ChannelMessageHandler_free(this_ptr: ChannelMessageHandler) { }
4239 impl Drop for ChannelMessageHandler {
4240 fn drop(&mut self) {
4241 if let Some(f) = self.free {
4246 /// A trait to describe an object which can receive routing messages.
4248 /// # Implementor DoS Warnings
4250 /// For `gossip_queries` messages there are potential DoS vectors when handling
4251 /// inbound queries. Implementors using an on-disk network graph should be aware of
4252 /// repeated disk I/O for queries accessing different parts of the network graph.
4254 pub struct RoutingMessageHandler {
4255 pub this_arg: *mut c_void,
4256 /// Handle an incoming node_announcement message, returning true if it should be forwarded on,
4257 /// false or returning an Err otherwise.
4259 pub handle_node_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
4260 /// Handle a channel_announcement message, returning true if it should be forwarded on, false
4261 /// or returning an Err otherwise.
4263 pub handle_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
4264 /// Handle an incoming channel_update message, returning true if it should be forwarded on,
4265 /// false or returning an Err otherwise.
4267 pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ,
4268 /// Handle some updates to the route graph that we learned due to an outbound failed payment.
4269 pub handle_htlc_fail_channel_update: extern "C" fn (this_arg: *const c_void, update: &crate::ln::msgs::HTLCFailChannelUpdate),
4270 /// Gets a subset of the channel announcements and updates required to dump our routing table
4271 /// to a remote node, starting at the short_channel_id indicated by starting_point and
4272 /// including the batch_amount entries immediately higher in numerical value than starting_point.
4274 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,
4275 /// Gets a subset of the node announcements required to dump our routing table to a remote node,
4276 /// starting at the node *after* the provided publickey and including batch_amount entries
4277 /// immediately higher (as defined by <PublicKey as Ord>::cmp) than starting_point.
4278 /// If None is provided for starting_point, we start at the first node.
4280 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,
4281 /// Called when a connection is established with a peer. This can be used to
4282 /// perform routing table synchronization using a strategy defined by the
4284 pub sync_routing_table: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, init: &crate::ln::msgs::Init),
4285 /// Handles the reply of a query we initiated to learn about channels
4286 /// for a given range of blocks. We can expect to receive one or more
4287 /// replies to a single query.
4289 pub handle_reply_channel_range: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ,
4290 /// Handles the reply of a query we initiated asking for routing gossip
4291 /// messages for a list of channels. We should receive this message when
4292 /// a node has completed its best effort to send us the pertaining routing
4293 /// gossip messages.
4295 pub handle_reply_short_channel_ids_end: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CResult_NoneLightningErrorZ,
4296 /// Handles when a peer asks us to send a list of short_channel_ids
4297 /// for the requested range of blocks.
4299 pub handle_query_channel_range: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ,
4300 /// Handles when a peer asks us to send routing gossip messages for a
4301 /// list of short_channel_ids.
4303 pub handle_query_short_channel_ids: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CResult_NoneLightningErrorZ,
4304 pub MessageSendEventsProvider: crate::util::events::MessageSendEventsProvider,
4305 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
4307 unsafe impl Send for RoutingMessageHandler {}
4308 unsafe impl Sync for RoutingMessageHandler {}
4309 impl lightning::util::events::MessageSendEventsProvider for RoutingMessageHandler {
4310 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
4311 <crate::util::events::MessageSendEventsProvider as lightning::util::events::MessageSendEventsProvider>::get_and_clear_pending_msg_events(&self.MessageSendEventsProvider)
4315 use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler;
4316 impl rustRoutingMessageHandler for RoutingMessageHandler {
4317 fn handle_node_announcement(&self, msg: &lightning::ln::msgs::NodeAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
4318 let mut ret = (self.handle_node_announcement)(self.this_arg, &crate::ln::msgs::NodeAnnouncement { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false });
4319 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()) } })};
4322 fn handle_channel_announcement(&self, msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
4323 let mut ret = (self.handle_channel_announcement)(self.this_arg, &crate::ln::msgs::ChannelAnnouncement { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false });
4324 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()) } })};
4327 fn handle_channel_update(&self, msg: &lightning::ln::msgs::ChannelUpdate) -> Result<bool, lightning::ln::msgs::LightningError> {
4328 let mut ret = (self.handle_channel_update)(self.this_arg, &crate::ln::msgs::ChannelUpdate { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false });
4329 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()) } })};
4332 fn handle_htlc_fail_channel_update(&self, update: &lightning::ln::msgs::HTLCFailChannelUpdate) {
4333 (self.handle_htlc_fail_channel_update)(self.this_arg, &crate::ln::msgs::HTLCFailChannelUpdate::from_native(&update))
4335 fn get_next_channel_announcements(&self, starting_point: u64, batch_amount: u8) -> Vec<(lightning::ln::msgs::ChannelAnnouncement, Option<lightning::ln::msgs::ChannelUpdate>, Option<lightning::ln::msgs::ChannelUpdate>)> {
4336 let mut ret = (self.get_next_channel_announcements)(self.this_arg, starting_point, batch_amount);
4337 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 }); };
4340 fn get_next_node_announcements(&self, starting_point: Option<&bitcoin::secp256k1::key::PublicKey>, batch_amount: u8) -> Vec<lightning::ln::msgs::NodeAnnouncement> {
4341 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())) } };
4342 let mut ret = (self.get_next_node_announcements)(self.this_arg, local_starting_point, batch_amount);
4343 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4346 fn sync_routing_table(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, init: &lightning::ln::msgs::Init) {
4347 (self.sync_routing_table)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::Init { inner: unsafe { (init as *const _) as *mut _ }, is_owned: false })
4349 fn handle_reply_channel_range(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: lightning::ln::msgs::ReplyChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
4350 let mut ret = (self.handle_reply_channel_range)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::ln::msgs::ReplyChannelRange { inner: Box::into_raw(Box::new(msg)), is_owned: true });
4351 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()) } })};
4354 fn handle_reply_short_channel_ids_end(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: lightning::ln::msgs::ReplyShortChannelIdsEnd) -> Result<(), lightning::ln::msgs::LightningError> {
4355 let mut ret = (self.handle_reply_short_channel_ids_end)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::ln::msgs::ReplyShortChannelIdsEnd { inner: Box::into_raw(Box::new(msg)), is_owned: true });
4356 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()) } })};
4359 fn handle_query_channel_range(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: lightning::ln::msgs::QueryChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
4360 let mut ret = (self.handle_query_channel_range)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::ln::msgs::QueryChannelRange { inner: Box::into_raw(Box::new(msg)), is_owned: true });
4361 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()) } })};
4364 fn handle_query_short_channel_ids(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: lightning::ln::msgs::QueryShortChannelIds) -> Result<(), lightning::ln::msgs::LightningError> {
4365 let mut ret = (self.handle_query_short_channel_ids)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::ln::msgs::QueryShortChannelIds { inner: Box::into_raw(Box::new(msg)), is_owned: true });
4366 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()) } })};
4371 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
4372 // directly as a Deref trait in higher-level structs:
4373 impl std::ops::Deref for RoutingMessageHandler {
4375 fn deref(&self) -> &Self {
4379 /// Calls the free function if one is set
4381 pub extern "C" fn RoutingMessageHandler_free(this_ptr: RoutingMessageHandler) { }
4382 impl Drop for RoutingMessageHandler {
4383 fn drop(&mut self) {
4384 if let Some(f) = self.free {
4390 pub extern "C" fn AcceptChannel_write(obj: &AcceptChannel) -> crate::c_types::derived::CVec_u8Z {
4391 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4394 pub(crate) extern "C" fn AcceptChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4395 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannel) })
4398 pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelDecodeErrorZ {
4399 let res = crate::c_types::deserialize_obj(ser);
4400 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::AcceptChannel { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4404 pub extern "C" fn AnnouncementSignatures_write(obj: &AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z {
4405 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4408 pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4409 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAnnouncementSignatures) })
4412 pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AnnouncementSignaturesDecodeErrorZ {
4413 let res = crate::c_types::deserialize_obj(ser);
4414 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::AnnouncementSignatures { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4418 pub extern "C" fn ChannelReestablish_write(obj: &ChannelReestablish) -> crate::c_types::derived::CVec_u8Z {
4419 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4422 pub(crate) extern "C" fn ChannelReestablish_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4423 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReestablish) })
4426 pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReestablishDecodeErrorZ {
4427 let res = crate::c_types::deserialize_obj(ser);
4428 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::ChannelReestablish { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4432 pub extern "C" fn ClosingSigned_write(obj: &ClosingSigned) -> crate::c_types::derived::CVec_u8Z {
4433 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4436 pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4437 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSigned) })
4440 pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedDecodeErrorZ {
4441 let res = crate::c_types::deserialize_obj(ser);
4442 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::ClosingSigned { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4446 pub extern "C" fn CommitmentSigned_write(obj: &CommitmentSigned) -> crate::c_types::derived::CVec_u8Z {
4447 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4450 pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4451 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentSigned) })
4454 pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CommitmentSignedDecodeErrorZ {
4455 let res = crate::c_types::deserialize_obj(ser);
4456 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::CommitmentSigned { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4460 pub extern "C" fn FundingCreated_write(obj: &FundingCreated) -> crate::c_types::derived::CVec_u8Z {
4461 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4464 pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4465 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingCreated) })
4468 pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingCreatedDecodeErrorZ {
4469 let res = crate::c_types::deserialize_obj(ser);
4470 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::FundingCreated { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4474 pub extern "C" fn FundingSigned_write(obj: &FundingSigned) -> crate::c_types::derived::CVec_u8Z {
4475 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4478 pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4479 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingSigned) })
4482 pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingSignedDecodeErrorZ {
4483 let res = crate::c_types::deserialize_obj(ser);
4484 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::FundingSigned { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4488 pub extern "C" fn FundingLocked_write(obj: &FundingLocked) -> crate::c_types::derived::CVec_u8Z {
4489 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4492 pub(crate) extern "C" fn FundingLocked_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4493 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingLocked) })
4496 pub extern "C" fn FundingLocked_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingLockedDecodeErrorZ {
4497 let res = crate::c_types::deserialize_obj(ser);
4498 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::FundingLocked { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4502 pub extern "C" fn Init_write(obj: &Init) -> crate::c_types::derived::CVec_u8Z {
4503 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4506 pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4507 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInit) })
4510 pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitDecodeErrorZ {
4511 let res = crate::c_types::deserialize_obj(ser);
4512 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::Init { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4516 pub extern "C" fn OpenChannel_write(obj: &OpenChannel) -> crate::c_types::derived::CVec_u8Z {
4517 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4520 pub(crate) extern "C" fn OpenChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4521 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannel) })
4524 pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelDecodeErrorZ {
4525 let res = crate::c_types::deserialize_obj(ser);
4526 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::OpenChannel { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4530 pub extern "C" fn RevokeAndACK_write(obj: &RevokeAndACK) -> crate::c_types::derived::CVec_u8Z {
4531 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4534 pub(crate) extern "C" fn RevokeAndACK_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4535 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevokeAndACK) })
4538 pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RevokeAndACKDecodeErrorZ {
4539 let res = crate::c_types::deserialize_obj(ser);
4540 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::RevokeAndACK { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4544 pub extern "C" fn Shutdown_write(obj: &Shutdown) -> crate::c_types::derived::CVec_u8Z {
4545 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4548 pub(crate) extern "C" fn Shutdown_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4549 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeShutdown) })
4552 pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ShutdownDecodeErrorZ {
4553 let res = crate::c_types::deserialize_obj(ser);
4554 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::Shutdown { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4558 pub extern "C" fn UpdateFailHTLC_write(obj: &UpdateFailHTLC) -> crate::c_types::derived::CVec_u8Z {
4559 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4562 pub(crate) extern "C" fn UpdateFailHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4563 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailHTLC) })
4566 pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailHTLCDecodeErrorZ {
4567 let res = crate::c_types::deserialize_obj(ser);
4568 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::UpdateFailHTLC { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4572 pub extern "C" fn UpdateFailMalformedHTLC_write(obj: &UpdateFailMalformedHTLC) -> crate::c_types::derived::CVec_u8Z {
4573 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4576 pub(crate) extern "C" fn UpdateFailMalformedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4577 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailMalformedHTLC) })
4580 pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailMalformedHTLCDecodeErrorZ {
4581 let res = crate::c_types::deserialize_obj(ser);
4582 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::UpdateFailMalformedHTLC { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4586 pub extern "C" fn UpdateFee_write(obj: &UpdateFee) -> crate::c_types::derived::CVec_u8Z {
4587 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4590 pub(crate) extern "C" fn UpdateFee_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4591 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFee) })
4594 pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFeeDecodeErrorZ {
4595 let res = crate::c_types::deserialize_obj(ser);
4596 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::UpdateFee { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4600 pub extern "C" fn UpdateFulfillHTLC_write(obj: &UpdateFulfillHTLC) -> crate::c_types::derived::CVec_u8Z {
4601 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4604 pub(crate) extern "C" fn UpdateFulfillHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4605 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFulfillHTLC) })
4608 pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFulfillHTLCDecodeErrorZ {
4609 let res = crate::c_types::deserialize_obj(ser);
4610 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::UpdateFulfillHTLC { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4614 pub extern "C" fn UpdateAddHTLC_write(obj: &UpdateAddHTLC) -> crate::c_types::derived::CVec_u8Z {
4615 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4618 pub(crate) extern "C" fn UpdateAddHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4619 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateAddHTLC) })
4622 pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateAddHTLCDecodeErrorZ {
4623 let res = crate::c_types::deserialize_obj(ser);
4624 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::UpdateAddHTLC { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4628 pub extern "C" fn Ping_write(obj: &Ping) -> crate::c_types::derived::CVec_u8Z {
4629 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4632 pub(crate) extern "C" fn Ping_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4633 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePing) })
4636 pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PingDecodeErrorZ {
4637 let res = crate::c_types::deserialize_obj(ser);
4638 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::Ping { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4642 pub extern "C" fn Pong_write(obj: &Pong) -> crate::c_types::derived::CVec_u8Z {
4643 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4646 pub(crate) extern "C" fn Pong_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4647 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePong) })
4650 pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PongDecodeErrorZ {
4651 let res = crate::c_types::deserialize_obj(ser);
4652 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::Pong { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4656 pub extern "C" fn UnsignedChannelAnnouncement_write(obj: &UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
4657 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4660 pub(crate) extern "C" fn UnsignedChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4661 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelAnnouncement) })
4664 pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelAnnouncementDecodeErrorZ {
4665 let res = crate::c_types::deserialize_obj(ser);
4666 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::UnsignedChannelAnnouncement { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4670 pub extern "C" fn ChannelAnnouncement_write(obj: &ChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
4671 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4674 pub(crate) extern "C" fn ChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4675 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelAnnouncement) })
4678 pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelAnnouncementDecodeErrorZ {
4679 let res = crate::c_types::deserialize_obj(ser);
4680 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::ChannelAnnouncement { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4684 pub extern "C" fn UnsignedChannelUpdate_write(obj: &UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
4685 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4688 pub(crate) extern "C" fn UnsignedChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4689 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelUpdate) })
4692 pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelUpdateDecodeErrorZ {
4693 let res = crate::c_types::deserialize_obj(ser);
4694 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::UnsignedChannelUpdate { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4698 pub extern "C" fn ChannelUpdate_write(obj: &ChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
4699 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4702 pub(crate) extern "C" fn ChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4703 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdate) })
4706 pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelUpdateDecodeErrorZ {
4707 let res = crate::c_types::deserialize_obj(ser);
4708 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4712 pub extern "C" fn ErrorMessage_write(obj: &ErrorMessage) -> crate::c_types::derived::CVec_u8Z {
4713 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4716 pub(crate) extern "C" fn ErrorMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4717 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeErrorMessage) })
4720 pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ErrorMessageDecodeErrorZ {
4721 let res = crate::c_types::deserialize_obj(ser);
4722 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::ErrorMessage { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4726 pub extern "C" fn UnsignedNodeAnnouncement_write(obj: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
4727 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4730 pub(crate) extern "C" fn UnsignedNodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4731 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedNodeAnnouncement) })
4734 pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedNodeAnnouncementDecodeErrorZ {
4735 let res = crate::c_types::deserialize_obj(ser);
4736 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::UnsignedNodeAnnouncement { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4740 pub extern "C" fn NodeAnnouncement_write(obj: &NodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
4741 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4744 pub(crate) extern "C" fn NodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4745 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncement) })
4748 pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementDecodeErrorZ {
4749 let res = crate::c_types::deserialize_obj(ser);
4750 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::NodeAnnouncement { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4754 pub extern "C" fn QueryShortChannelIds_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryShortChannelIdsDecodeErrorZ {
4755 let res = crate::c_types::deserialize_obj(ser);
4756 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::QueryShortChannelIds { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4760 pub extern "C" fn QueryShortChannelIds_write(obj: &QueryShortChannelIds) -> crate::c_types::derived::CVec_u8Z {
4761 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4764 pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4765 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) })
4768 pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyShortChannelIdsEndDecodeErrorZ {
4769 let res = crate::c_types::deserialize_obj(ser);
4770 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::ReplyShortChannelIdsEnd { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4774 pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z {
4775 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4778 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4779 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) })
4782 pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ {
4783 let res = crate::c_types::deserialize_obj(ser);
4784 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::QueryChannelRange { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4788 pub extern "C" fn QueryChannelRange_write(obj: &QueryChannelRange) -> crate::c_types::derived::CVec_u8Z {
4789 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4792 pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4793 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) })
4796 pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyChannelRangeDecodeErrorZ {
4797 let res = crate::c_types::deserialize_obj(ser);
4798 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::ReplyChannelRange { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4802 pub extern "C" fn ReplyChannelRange_write(obj: &ReplyChannelRange) -> crate::c_types::derived::CVec_u8Z {
4803 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4806 pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4807 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) })
4810 pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_GossipTimestampFilterDecodeErrorZ {
4811 let res = crate::c_types::deserialize_obj(ser);
4812 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::GossipTimestampFilter { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4816 pub extern "C" fn GossipTimestampFilter_write(obj: &GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z {
4817 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4820 pub(crate) extern "C" fn GossipTimestampFilter_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4821 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeGossipTimestampFilter) })