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 everyhwere, 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_ptr(mut self) -> *mut nativeDecodeError {
54 assert!(self.is_owned);
56 self.inner = std::ptr::null_mut();
61 use lightning::ln::msgs::Init as nativeInitImport;
62 type nativeInit = nativeInitImport;
64 /// An init message to be sent or received from a peer
68 /// Nearly everyhwere, inner must be non-null, however in places where
69 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
70 pub inner: *mut nativeInit,
76 if self.is_owned && !self.inner.is_null() {
77 let _ = unsafe { Box::from_raw(self.inner) };
82 pub extern "C" fn Init_free(this_ptr: Init) { }
84 /// Used only if an object of this type is returned as a trait impl by a method
85 extern "C" fn Init_free_void(this_ptr: *mut c_void) {
86 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeInit); }
89 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
91 pub(crate) fn take_ptr(mut self) -> *mut nativeInit {
92 assert!(self.is_owned);
94 self.inner = std::ptr::null_mut();
99 use lightning::ln::msgs::ErrorMessage as nativeErrorMessageImport;
100 type nativeErrorMessage = nativeErrorMessageImport;
102 /// An error message to be sent or received from a peer
105 pub struct ErrorMessage {
106 /// Nearly everyhwere, inner must be non-null, however in places where
107 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
108 pub inner: *mut nativeErrorMessage,
112 impl Drop for ErrorMessage {
114 if self.is_owned && !self.inner.is_null() {
115 let _ = unsafe { Box::from_raw(self.inner) };
120 pub extern "C" fn ErrorMessage_free(this_ptr: ErrorMessage) { }
122 /// Used only if an object of this type is returned as a trait impl by a method
123 extern "C" fn ErrorMessage_free_void(this_ptr: *mut c_void) {
124 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeErrorMessage); }
127 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
129 pub(crate) fn take_ptr(mut self) -> *mut nativeErrorMessage {
130 assert!(self.is_owned);
131 let ret = self.inner;
132 self.inner = std::ptr::null_mut();
136 impl Clone for ErrorMessage {
137 fn clone(&self) -> Self {
139 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
145 /// Used only if an object of this type is returned as a trait impl by a method
146 pub(crate) extern "C" fn ErrorMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
147 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeErrorMessage)).clone() })) as *mut c_void
149 /// The channel ID involved in the error
151 pub extern "C" fn ErrorMessage_get_channel_id(this_ptr: &ErrorMessage) -> *const [u8; 32] {
152 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
155 /// The channel ID involved in the error
157 pub extern "C" fn ErrorMessage_set_channel_id(this_ptr: &mut ErrorMessage, mut val: crate::c_types::ThirtyTwoBytes) {
158 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
160 /// A possibly human-readable error description.
161 /// The string should be sanitized before it is used (e.g. emitted to logs
162 /// or printed to stdout). Otherwise, a well crafted error message may trigger a security
163 /// vulnerability in the terminal emulator or the logging subsystem.
165 pub extern "C" fn ErrorMessage_get_data(this_ptr: &ErrorMessage) -> crate::c_types::Str {
166 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.data;
167 (*inner_val).as_str().into()
169 /// A possibly human-readable error description.
170 /// The string should be sanitized before it is used (e.g. emitted to logs
171 /// or printed to stdout). Otherwise, a well crafted error message may trigger a security
172 /// vulnerability in the terminal emulator or the logging subsystem.
174 pub extern "C" fn ErrorMessage_set_data(this_ptr: &mut ErrorMessage, mut val: crate::c_types::derived::CVec_u8Z) {
175 unsafe { &mut *this_ptr.inner }.data = String::from_utf8(val.into_rust()).unwrap();
179 pub extern "C" fn ErrorMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::derived::CVec_u8Z) -> ErrorMessage {
180 ErrorMessage { inner: Box::into_raw(Box::new(nativeErrorMessage {
181 channel_id: channel_id_arg.data,
182 data: String::from_utf8(data_arg.into_rust()).unwrap(),
183 })), is_owned: true }
186 use lightning::ln::msgs::Ping as nativePingImport;
187 type nativePing = nativePingImport;
189 /// A ping message to be sent or received from a peer
193 /// Nearly everyhwere, inner must be non-null, however in places where
194 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
195 pub inner: *mut nativePing,
201 if self.is_owned && !self.inner.is_null() {
202 let _ = unsafe { Box::from_raw(self.inner) };
207 pub extern "C" fn Ping_free(this_ptr: Ping) { }
209 /// Used only if an object of this type is returned as a trait impl by a method
210 extern "C" fn Ping_free_void(this_ptr: *mut c_void) {
211 unsafe { let _ = Box::from_raw(this_ptr as *mut nativePing); }
214 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
216 pub(crate) fn take_ptr(mut self) -> *mut nativePing {
217 assert!(self.is_owned);
218 let ret = self.inner;
219 self.inner = std::ptr::null_mut();
223 /// The desired response length
225 pub extern "C" fn Ping_get_ponglen(this_ptr: &Ping) -> u16 {
226 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.ponglen;
229 /// The desired response length
231 pub extern "C" fn Ping_set_ponglen(this_ptr: &mut Ping, mut val: u16) {
232 unsafe { &mut *this_ptr.inner }.ponglen = val;
234 /// The ping packet size.
235 /// This field is not sent on the wire. byteslen zeros are sent.
237 pub extern "C" fn Ping_get_byteslen(this_ptr: &Ping) -> u16 {
238 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.byteslen;
241 /// The ping packet size.
242 /// This field is not sent on the wire. byteslen zeros are sent.
244 pub extern "C" fn Ping_set_byteslen(this_ptr: &mut Ping, mut val: u16) {
245 unsafe { &mut *this_ptr.inner }.byteslen = val;
249 pub extern "C" fn Ping_new(mut ponglen_arg: u16, mut byteslen_arg: u16) -> Ping {
250 Ping { inner: Box::into_raw(Box::new(nativePing {
251 ponglen: ponglen_arg,
252 byteslen: byteslen_arg,
253 })), is_owned: true }
256 use lightning::ln::msgs::Pong as nativePongImport;
257 type nativePong = nativePongImport;
259 /// A pong message to be sent or received from a peer
263 /// Nearly everyhwere, inner must be non-null, however in places where
264 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
265 pub inner: *mut nativePong,
271 if self.is_owned && !self.inner.is_null() {
272 let _ = unsafe { Box::from_raw(self.inner) };
277 pub extern "C" fn Pong_free(this_ptr: Pong) { }
279 /// Used only if an object of this type is returned as a trait impl by a method
280 extern "C" fn Pong_free_void(this_ptr: *mut c_void) {
281 unsafe { let _ = Box::from_raw(this_ptr as *mut nativePong); }
284 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
286 pub(crate) fn take_ptr(mut self) -> *mut nativePong {
287 assert!(self.is_owned);
288 let ret = self.inner;
289 self.inner = std::ptr::null_mut();
293 /// The pong packet size.
294 /// This field is not sent on the wire. byteslen zeros are sent.
296 pub extern "C" fn Pong_get_byteslen(this_ptr: &Pong) -> u16 {
297 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.byteslen;
300 /// The pong packet size.
301 /// This field is not sent on the wire. byteslen zeros are sent.
303 pub extern "C" fn Pong_set_byteslen(this_ptr: &mut Pong, mut val: u16) {
304 unsafe { &mut *this_ptr.inner }.byteslen = val;
308 pub extern "C" fn Pong_new(mut byteslen_arg: u16) -> Pong {
309 Pong { inner: Box::into_raw(Box::new(nativePong {
310 byteslen: byteslen_arg,
311 })), is_owned: true }
314 use lightning::ln::msgs::OpenChannel as nativeOpenChannelImport;
315 type nativeOpenChannel = nativeOpenChannelImport;
317 /// An open_channel message to be sent or received from a peer
320 pub struct OpenChannel {
321 /// Nearly everyhwere, inner must be non-null, however in places where
322 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
323 pub inner: *mut nativeOpenChannel,
327 impl Drop for OpenChannel {
329 if self.is_owned && !self.inner.is_null() {
330 let _ = unsafe { Box::from_raw(self.inner) };
335 pub extern "C" fn OpenChannel_free(this_ptr: OpenChannel) { }
337 /// Used only if an object of this type is returned as a trait impl by a method
338 extern "C" fn OpenChannel_free_void(this_ptr: *mut c_void) {
339 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeOpenChannel); }
342 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
344 pub(crate) fn take_ptr(mut self) -> *mut nativeOpenChannel {
345 assert!(self.is_owned);
346 let ret = self.inner;
347 self.inner = std::ptr::null_mut();
351 impl Clone for OpenChannel {
352 fn clone(&self) -> Self {
354 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
360 /// Used only if an object of this type is returned as a trait impl by a method
361 pub(crate) extern "C" fn OpenChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
362 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOpenChannel)).clone() })) as *mut c_void
364 /// The genesis hash of the blockchain where the channel is to be opened
366 pub extern "C" fn OpenChannel_get_chain_hash(this_ptr: &OpenChannel) -> *const [u8; 32] {
367 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
368 (*inner_val).as_inner()
370 /// The genesis hash of the blockchain where the channel is to be opened
372 pub extern "C" fn OpenChannel_set_chain_hash(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
373 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
375 /// A temporary channel ID, until the funding outpoint is announced
377 pub extern "C" fn OpenChannel_get_temporary_channel_id(this_ptr: &OpenChannel) -> *const [u8; 32] {
378 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.temporary_channel_id;
381 /// A temporary channel ID, until the funding outpoint is announced
383 pub extern "C" fn OpenChannel_set_temporary_channel_id(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
384 unsafe { &mut *this_ptr.inner }.temporary_channel_id = val.data;
386 /// The channel value
388 pub extern "C" fn OpenChannel_get_funding_satoshis(this_ptr: &OpenChannel) -> u64 {
389 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_satoshis;
392 /// The channel value
394 pub extern "C" fn OpenChannel_set_funding_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
395 unsafe { &mut *this_ptr.inner }.funding_satoshis = val;
397 /// The amount to push to the counterparty as part of the open, in milli-satoshi
399 pub extern "C" fn OpenChannel_get_push_msat(this_ptr: &OpenChannel) -> u64 {
400 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.push_msat;
403 /// The amount to push to the counterparty as part of the open, in milli-satoshi
405 pub extern "C" fn OpenChannel_set_push_msat(this_ptr: &mut OpenChannel, mut val: u64) {
406 unsafe { &mut *this_ptr.inner }.push_msat = val;
408 /// The threshold below which outputs on transactions broadcast by sender will be omitted
410 pub extern "C" fn OpenChannel_get_dust_limit_satoshis(this_ptr: &OpenChannel) -> u64 {
411 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.dust_limit_satoshis;
414 /// The threshold below which outputs on transactions broadcast by sender will be omitted
416 pub extern "C" fn OpenChannel_set_dust_limit_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
417 unsafe { &mut *this_ptr.inner }.dust_limit_satoshis = val;
419 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
421 pub extern "C" fn OpenChannel_get_max_htlc_value_in_flight_msat(this_ptr: &OpenChannel) -> u64 {
422 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_htlc_value_in_flight_msat;
425 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
427 pub extern "C" fn OpenChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut OpenChannel, mut val: u64) {
428 unsafe { &mut *this_ptr.inner }.max_htlc_value_in_flight_msat = val;
430 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
432 pub extern "C" fn OpenChannel_get_channel_reserve_satoshis(this_ptr: &OpenChannel) -> u64 {
433 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_reserve_satoshis;
436 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
438 pub extern "C" fn OpenChannel_set_channel_reserve_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
439 unsafe { &mut *this_ptr.inner }.channel_reserve_satoshis = val;
441 /// The minimum HTLC size incoming to sender, in milli-satoshi
443 pub extern "C" fn OpenChannel_get_htlc_minimum_msat(this_ptr: &OpenChannel) -> u64 {
444 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_minimum_msat;
447 /// The minimum HTLC size incoming to sender, in milli-satoshi
449 pub extern "C" fn OpenChannel_set_htlc_minimum_msat(this_ptr: &mut OpenChannel, mut val: u64) {
450 unsafe { &mut *this_ptr.inner }.htlc_minimum_msat = val;
452 /// The feerate per 1000-weight of sender generated transactions, until updated by update_fee
454 pub extern "C" fn OpenChannel_get_feerate_per_kw(this_ptr: &OpenChannel) -> u32 {
455 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.feerate_per_kw;
458 /// The feerate per 1000-weight of sender generated transactions, until updated by update_fee
460 pub extern "C" fn OpenChannel_set_feerate_per_kw(this_ptr: &mut OpenChannel, mut val: u32) {
461 unsafe { &mut *this_ptr.inner }.feerate_per_kw = val;
463 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
465 pub extern "C" fn OpenChannel_get_to_self_delay(this_ptr: &OpenChannel) -> u16 {
466 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.to_self_delay;
469 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
471 pub extern "C" fn OpenChannel_set_to_self_delay(this_ptr: &mut OpenChannel, mut val: u16) {
472 unsafe { &mut *this_ptr.inner }.to_self_delay = val;
474 /// The maximum number of inbound HTLCs towards sender
476 pub extern "C" fn OpenChannel_get_max_accepted_htlcs(this_ptr: &OpenChannel) -> u16 {
477 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_accepted_htlcs;
480 /// The maximum number of inbound HTLCs towards sender
482 pub extern "C" fn OpenChannel_set_max_accepted_htlcs(this_ptr: &mut OpenChannel, mut val: u16) {
483 unsafe { &mut *this_ptr.inner }.max_accepted_htlcs = val;
485 /// The sender's key controlling the funding transaction
487 pub extern "C" fn OpenChannel_get_funding_pubkey(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
488 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_pubkey;
489 crate::c_types::PublicKey::from_rust(&(*inner_val))
491 /// The sender's key controlling the funding transaction
493 pub extern "C" fn OpenChannel_set_funding_pubkey(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
494 unsafe { &mut *this_ptr.inner }.funding_pubkey = val.into_rust();
496 /// Used to derive a revocation key for transactions broadcast by counterparty
498 pub extern "C" fn OpenChannel_get_revocation_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
499 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.revocation_basepoint;
500 crate::c_types::PublicKey::from_rust(&(*inner_val))
502 /// Used to derive a revocation key for transactions broadcast by counterparty
504 pub extern "C" fn OpenChannel_set_revocation_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
505 unsafe { &mut *this_ptr.inner }.revocation_basepoint = val.into_rust();
507 /// A payment key to sender for transactions broadcast by counterparty
509 pub extern "C" fn OpenChannel_get_payment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
510 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_point;
511 crate::c_types::PublicKey::from_rust(&(*inner_val))
513 /// A payment key to sender for transactions broadcast by counterparty
515 pub extern "C" fn OpenChannel_set_payment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
516 unsafe { &mut *this_ptr.inner }.payment_point = val.into_rust();
518 /// Used to derive a payment key to sender for transactions broadcast by sender
520 pub extern "C" fn OpenChannel_get_delayed_payment_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
521 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.delayed_payment_basepoint;
522 crate::c_types::PublicKey::from_rust(&(*inner_val))
524 /// Used to derive a payment key to sender for transactions broadcast by sender
526 pub extern "C" fn OpenChannel_set_delayed_payment_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
527 unsafe { &mut *this_ptr.inner }.delayed_payment_basepoint = val.into_rust();
529 /// Used to derive an HTLC payment key to sender
531 pub extern "C" fn OpenChannel_get_htlc_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
532 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_basepoint;
533 crate::c_types::PublicKey::from_rust(&(*inner_val))
535 /// Used to derive an HTLC payment key to sender
537 pub extern "C" fn OpenChannel_set_htlc_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
538 unsafe { &mut *this_ptr.inner }.htlc_basepoint = val.into_rust();
540 /// The first to-be-broadcast-by-sender transaction's per commitment point
542 pub extern "C" fn OpenChannel_get_first_per_commitment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
543 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_per_commitment_point;
544 crate::c_types::PublicKey::from_rust(&(*inner_val))
546 /// The first to-be-broadcast-by-sender transaction's per commitment point
548 pub extern "C" fn OpenChannel_set_first_per_commitment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
549 unsafe { &mut *this_ptr.inner }.first_per_commitment_point = val.into_rust();
553 pub extern "C" fn OpenChannel_get_channel_flags(this_ptr: &OpenChannel) -> u8 {
554 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_flags;
559 pub extern "C" fn OpenChannel_set_channel_flags(this_ptr: &mut OpenChannel, mut val: u8) {
560 unsafe { &mut *this_ptr.inner }.channel_flags = val;
563 use lightning::ln::msgs::AcceptChannel as nativeAcceptChannelImport;
564 type nativeAcceptChannel = nativeAcceptChannelImport;
566 /// An accept_channel message to be sent or received from a peer
569 pub struct AcceptChannel {
570 /// Nearly everyhwere, inner must be non-null, however in places where
571 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
572 pub inner: *mut nativeAcceptChannel,
576 impl Drop for AcceptChannel {
578 if self.is_owned && !self.inner.is_null() {
579 let _ = unsafe { Box::from_raw(self.inner) };
584 pub extern "C" fn AcceptChannel_free(this_ptr: AcceptChannel) { }
586 /// Used only if an object of this type is returned as a trait impl by a method
587 extern "C" fn AcceptChannel_free_void(this_ptr: *mut c_void) {
588 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeAcceptChannel); }
591 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
593 pub(crate) fn take_ptr(mut self) -> *mut nativeAcceptChannel {
594 assert!(self.is_owned);
595 let ret = self.inner;
596 self.inner = std::ptr::null_mut();
600 impl Clone for AcceptChannel {
601 fn clone(&self) -> Self {
603 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
609 /// Used only if an object of this type is returned as a trait impl by a method
610 pub(crate) extern "C" fn AcceptChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
611 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAcceptChannel)).clone() })) as *mut c_void
613 /// A temporary channel ID, until the funding outpoint is announced
615 pub extern "C" fn AcceptChannel_get_temporary_channel_id(this_ptr: &AcceptChannel) -> *const [u8; 32] {
616 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.temporary_channel_id;
619 /// A temporary channel ID, until the funding outpoint is announced
621 pub extern "C" fn AcceptChannel_set_temporary_channel_id(this_ptr: &mut AcceptChannel, mut val: crate::c_types::ThirtyTwoBytes) {
622 unsafe { &mut *this_ptr.inner }.temporary_channel_id = val.data;
624 /// The threshold below which outputs on transactions broadcast by sender will be omitted
626 pub extern "C" fn AcceptChannel_get_dust_limit_satoshis(this_ptr: &AcceptChannel) -> u64 {
627 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.dust_limit_satoshis;
630 /// The threshold below which outputs on transactions broadcast by sender will be omitted
632 pub extern "C" fn AcceptChannel_set_dust_limit_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
633 unsafe { &mut *this_ptr.inner }.dust_limit_satoshis = val;
635 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
637 pub extern "C" fn AcceptChannel_get_max_htlc_value_in_flight_msat(this_ptr: &AcceptChannel) -> u64 {
638 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_htlc_value_in_flight_msat;
641 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
643 pub extern "C" fn AcceptChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
644 unsafe { &mut *this_ptr.inner }.max_htlc_value_in_flight_msat = val;
646 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
648 pub extern "C" fn AcceptChannel_get_channel_reserve_satoshis(this_ptr: &AcceptChannel) -> u64 {
649 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_reserve_satoshis;
652 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
654 pub extern "C" fn AcceptChannel_set_channel_reserve_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
655 unsafe { &mut *this_ptr.inner }.channel_reserve_satoshis = val;
657 /// The minimum HTLC size incoming to sender, in milli-satoshi
659 pub extern "C" fn AcceptChannel_get_htlc_minimum_msat(this_ptr: &AcceptChannel) -> u64 {
660 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_minimum_msat;
663 /// The minimum HTLC size incoming to sender, in milli-satoshi
665 pub extern "C" fn AcceptChannel_set_htlc_minimum_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
666 unsafe { &mut *this_ptr.inner }.htlc_minimum_msat = val;
668 /// Minimum depth of the funding transaction before the channel is considered open
670 pub extern "C" fn AcceptChannel_get_minimum_depth(this_ptr: &AcceptChannel) -> u32 {
671 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.minimum_depth;
674 /// Minimum depth of the funding transaction before the channel is considered open
676 pub extern "C" fn AcceptChannel_set_minimum_depth(this_ptr: &mut AcceptChannel, mut val: u32) {
677 unsafe { &mut *this_ptr.inner }.minimum_depth = val;
679 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
681 pub extern "C" fn AcceptChannel_get_to_self_delay(this_ptr: &AcceptChannel) -> u16 {
682 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.to_self_delay;
685 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
687 pub extern "C" fn AcceptChannel_set_to_self_delay(this_ptr: &mut AcceptChannel, mut val: u16) {
688 unsafe { &mut *this_ptr.inner }.to_self_delay = val;
690 /// The maximum number of inbound HTLCs towards sender
692 pub extern "C" fn AcceptChannel_get_max_accepted_htlcs(this_ptr: &AcceptChannel) -> u16 {
693 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_accepted_htlcs;
696 /// The maximum number of inbound HTLCs towards sender
698 pub extern "C" fn AcceptChannel_set_max_accepted_htlcs(this_ptr: &mut AcceptChannel, mut val: u16) {
699 unsafe { &mut *this_ptr.inner }.max_accepted_htlcs = val;
701 /// The sender's key controlling the funding transaction
703 pub extern "C" fn AcceptChannel_get_funding_pubkey(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
704 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_pubkey;
705 crate::c_types::PublicKey::from_rust(&(*inner_val))
707 /// The sender's key controlling the funding transaction
709 pub extern "C" fn AcceptChannel_set_funding_pubkey(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
710 unsafe { &mut *this_ptr.inner }.funding_pubkey = val.into_rust();
712 /// Used to derive a revocation key for transactions broadcast by counterparty
714 pub extern "C" fn AcceptChannel_get_revocation_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
715 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.revocation_basepoint;
716 crate::c_types::PublicKey::from_rust(&(*inner_val))
718 /// Used to derive a revocation key for transactions broadcast by counterparty
720 pub extern "C" fn AcceptChannel_set_revocation_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
721 unsafe { &mut *this_ptr.inner }.revocation_basepoint = val.into_rust();
723 /// A payment key to sender for transactions broadcast by counterparty
725 pub extern "C" fn AcceptChannel_get_payment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
726 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_point;
727 crate::c_types::PublicKey::from_rust(&(*inner_val))
729 /// A payment key to sender for transactions broadcast by counterparty
731 pub extern "C" fn AcceptChannel_set_payment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
732 unsafe { &mut *this_ptr.inner }.payment_point = val.into_rust();
734 /// Used to derive a payment key to sender for transactions broadcast by sender
736 pub extern "C" fn AcceptChannel_get_delayed_payment_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
737 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.delayed_payment_basepoint;
738 crate::c_types::PublicKey::from_rust(&(*inner_val))
740 /// Used to derive a payment key to sender for transactions broadcast by sender
742 pub extern "C" fn AcceptChannel_set_delayed_payment_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
743 unsafe { &mut *this_ptr.inner }.delayed_payment_basepoint = val.into_rust();
745 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
747 pub extern "C" fn AcceptChannel_get_htlc_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
748 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_basepoint;
749 crate::c_types::PublicKey::from_rust(&(*inner_val))
751 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
753 pub extern "C" fn AcceptChannel_set_htlc_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
754 unsafe { &mut *this_ptr.inner }.htlc_basepoint = val.into_rust();
756 /// The first to-be-broadcast-by-sender transaction's per commitment point
758 pub extern "C" fn AcceptChannel_get_first_per_commitment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
759 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_per_commitment_point;
760 crate::c_types::PublicKey::from_rust(&(*inner_val))
762 /// The first to-be-broadcast-by-sender transaction's per commitment point
764 pub extern "C" fn AcceptChannel_set_first_per_commitment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
765 unsafe { &mut *this_ptr.inner }.first_per_commitment_point = val.into_rust();
768 use lightning::ln::msgs::FundingCreated as nativeFundingCreatedImport;
769 type nativeFundingCreated = nativeFundingCreatedImport;
771 /// A funding_created message to be sent or received from a peer
774 pub struct FundingCreated {
775 /// Nearly everyhwere, inner must be non-null, however in places where
776 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
777 pub inner: *mut nativeFundingCreated,
781 impl Drop for FundingCreated {
783 if self.is_owned && !self.inner.is_null() {
784 let _ = unsafe { Box::from_raw(self.inner) };
789 pub extern "C" fn FundingCreated_free(this_ptr: FundingCreated) { }
791 /// Used only if an object of this type is returned as a trait impl by a method
792 extern "C" fn FundingCreated_free_void(this_ptr: *mut c_void) {
793 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingCreated); }
796 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
797 impl FundingCreated {
798 pub(crate) fn take_ptr(mut self) -> *mut nativeFundingCreated {
799 assert!(self.is_owned);
800 let ret = self.inner;
801 self.inner = std::ptr::null_mut();
805 impl Clone for FundingCreated {
806 fn clone(&self) -> Self {
808 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
814 /// Used only if an object of this type is returned as a trait impl by a method
815 pub(crate) extern "C" fn FundingCreated_clone_void(this_ptr: *const c_void) -> *mut c_void {
816 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingCreated)).clone() })) as *mut c_void
818 /// A temporary channel ID, until the funding is established
820 pub extern "C" fn FundingCreated_get_temporary_channel_id(this_ptr: &FundingCreated) -> *const [u8; 32] {
821 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.temporary_channel_id;
824 /// A temporary channel ID, until the funding is established
826 pub extern "C" fn FundingCreated_set_temporary_channel_id(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
827 unsafe { &mut *this_ptr.inner }.temporary_channel_id = val.data;
829 /// The funding transaction ID
831 pub extern "C" fn FundingCreated_get_funding_txid(this_ptr: &FundingCreated) -> *const [u8; 32] {
832 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_txid;
833 (*inner_val).as_inner()
835 /// The funding transaction ID
837 pub extern "C" fn FundingCreated_set_funding_txid(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
838 unsafe { &mut *this_ptr.inner }.funding_txid = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
840 /// The specific output index funding this channel
842 pub extern "C" fn FundingCreated_get_funding_output_index(this_ptr: &FundingCreated) -> u16 {
843 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_output_index;
846 /// The specific output index funding this channel
848 pub extern "C" fn FundingCreated_set_funding_output_index(this_ptr: &mut FundingCreated, mut val: u16) {
849 unsafe { &mut *this_ptr.inner }.funding_output_index = val;
851 /// The signature of the channel initiator (funder) on the funding transaction
853 pub extern "C" fn FundingCreated_get_signature(this_ptr: &FundingCreated) -> crate::c_types::Signature {
854 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
855 crate::c_types::Signature::from_rust(&(*inner_val))
857 /// The signature of the channel initiator (funder) on the funding transaction
859 pub extern "C" fn FundingCreated_set_signature(this_ptr: &mut FundingCreated, mut val: crate::c_types::Signature) {
860 unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
864 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 {
865 FundingCreated { inner: Box::into_raw(Box::new(nativeFundingCreated {
866 temporary_channel_id: temporary_channel_id_arg.data,
867 funding_txid: ::bitcoin::hash_types::Txid::from_slice(&funding_txid_arg.data[..]).unwrap(),
868 funding_output_index: funding_output_index_arg,
869 signature: signature_arg.into_rust(),
870 })), is_owned: true }
873 use lightning::ln::msgs::FundingSigned as nativeFundingSignedImport;
874 type nativeFundingSigned = nativeFundingSignedImport;
876 /// A funding_signed message to be sent or received from a peer
879 pub struct FundingSigned {
880 /// Nearly everyhwere, 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 nativeFundingSigned,
886 impl Drop for FundingSigned {
888 if self.is_owned && !self.inner.is_null() {
889 let _ = unsafe { Box::from_raw(self.inner) };
894 pub extern "C" fn FundingSigned_free(this_ptr: FundingSigned) { }
896 /// Used only if an object of this type is returned as a trait impl by a method
897 extern "C" fn FundingSigned_free_void(this_ptr: *mut c_void) {
898 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingSigned); }
901 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
903 pub(crate) fn take_ptr(mut self) -> *mut nativeFundingSigned {
904 assert!(self.is_owned);
905 let ret = self.inner;
906 self.inner = std::ptr::null_mut();
910 impl Clone for FundingSigned {
911 fn clone(&self) -> Self {
913 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
919 /// Used only if an object of this type is returned as a trait impl by a method
920 pub(crate) extern "C" fn FundingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
921 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingSigned)).clone() })) as *mut c_void
925 pub extern "C" fn FundingSigned_get_channel_id(this_ptr: &FundingSigned) -> *const [u8; 32] {
926 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
931 pub extern "C" fn FundingSigned_set_channel_id(this_ptr: &mut FundingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
932 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
934 /// The signature of the channel acceptor (fundee) on the funding transaction
936 pub extern "C" fn FundingSigned_get_signature(this_ptr: &FundingSigned) -> crate::c_types::Signature {
937 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
938 crate::c_types::Signature::from_rust(&(*inner_val))
940 /// The signature of the channel acceptor (fundee) on the funding transaction
942 pub extern "C" fn FundingSigned_set_signature(this_ptr: &mut FundingSigned, mut val: crate::c_types::Signature) {
943 unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
947 pub extern "C" fn FundingSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut signature_arg: crate::c_types::Signature) -> FundingSigned {
948 FundingSigned { inner: Box::into_raw(Box::new(nativeFundingSigned {
949 channel_id: channel_id_arg.data,
950 signature: signature_arg.into_rust(),
951 })), is_owned: true }
954 use lightning::ln::msgs::FundingLocked as nativeFundingLockedImport;
955 type nativeFundingLocked = nativeFundingLockedImport;
957 /// A funding_locked message to be sent or received from a peer
960 pub struct FundingLocked {
961 /// Nearly everyhwere, inner must be non-null, however in places where
962 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
963 pub inner: *mut nativeFundingLocked,
967 impl Drop for FundingLocked {
969 if self.is_owned && !self.inner.is_null() {
970 let _ = unsafe { Box::from_raw(self.inner) };
975 pub extern "C" fn FundingLocked_free(this_ptr: FundingLocked) { }
977 /// Used only if an object of this type is returned as a trait impl by a method
978 extern "C" fn FundingLocked_free_void(this_ptr: *mut c_void) {
979 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingLocked); }
982 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
984 pub(crate) fn take_ptr(mut self) -> *mut nativeFundingLocked {
985 assert!(self.is_owned);
986 let ret = self.inner;
987 self.inner = std::ptr::null_mut();
991 impl Clone for FundingLocked {
992 fn clone(&self) -> Self {
994 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
1000 /// Used only if an object of this type is returned as a trait impl by a method
1001 pub(crate) extern "C" fn FundingLocked_clone_void(this_ptr: *const c_void) -> *mut c_void {
1002 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingLocked)).clone() })) as *mut c_void
1006 pub extern "C" fn FundingLocked_get_channel_id(this_ptr: &FundingLocked) -> *const [u8; 32] {
1007 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1012 pub extern "C" fn FundingLocked_set_channel_id(this_ptr: &mut FundingLocked, mut val: crate::c_types::ThirtyTwoBytes) {
1013 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1015 /// The per-commitment point of the second commitment transaction
1017 pub extern "C" fn FundingLocked_get_next_per_commitment_point(this_ptr: &FundingLocked) -> crate::c_types::PublicKey {
1018 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.next_per_commitment_point;
1019 crate::c_types::PublicKey::from_rust(&(*inner_val))
1021 /// The per-commitment point of the second commitment transaction
1023 pub extern "C" fn FundingLocked_set_next_per_commitment_point(this_ptr: &mut FundingLocked, mut val: crate::c_types::PublicKey) {
1024 unsafe { &mut *this_ptr.inner }.next_per_commitment_point = val.into_rust();
1028 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 {
1029 FundingLocked { inner: Box::into_raw(Box::new(nativeFundingLocked {
1030 channel_id: channel_id_arg.data,
1031 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
1032 })), is_owned: true }
1035 use lightning::ln::msgs::Shutdown as nativeShutdownImport;
1036 type nativeShutdown = nativeShutdownImport;
1038 /// A shutdown message to be sent or received from a peer
1041 pub struct Shutdown {
1042 /// Nearly everyhwere, inner must be non-null, however in places where
1043 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1044 pub inner: *mut nativeShutdown,
1048 impl Drop for Shutdown {
1049 fn drop(&mut self) {
1050 if self.is_owned && !self.inner.is_null() {
1051 let _ = unsafe { Box::from_raw(self.inner) };
1056 pub extern "C" fn Shutdown_free(this_ptr: Shutdown) { }
1058 /// Used only if an object of this type is returned as a trait impl by a method
1059 extern "C" fn Shutdown_free_void(this_ptr: *mut c_void) {
1060 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeShutdown); }
1063 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1065 pub(crate) fn take_ptr(mut self) -> *mut nativeShutdown {
1066 assert!(self.is_owned);
1067 let ret = self.inner;
1068 self.inner = std::ptr::null_mut();
1072 impl Clone for Shutdown {
1073 fn clone(&self) -> Self {
1075 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
1081 /// Used only if an object of this type is returned as a trait impl by a method
1082 pub(crate) extern "C" fn Shutdown_clone_void(this_ptr: *const c_void) -> *mut c_void {
1083 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeShutdown)).clone() })) as *mut c_void
1087 pub extern "C" fn Shutdown_get_channel_id(this_ptr: &Shutdown) -> *const [u8; 32] {
1088 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1093 pub extern "C" fn Shutdown_set_channel_id(this_ptr: &mut Shutdown, mut val: crate::c_types::ThirtyTwoBytes) {
1094 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1096 /// The destination of this peer's funds on closing.
1097 /// Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
1099 pub extern "C" fn Shutdown_get_scriptpubkey(this_ptr: &Shutdown) -> crate::c_types::u8slice {
1100 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.scriptpubkey;
1101 crate::c_types::u8slice::from_slice(&(*inner_val)[..])
1103 /// The destination of this peer's funds on closing.
1104 /// Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
1106 pub extern "C" fn Shutdown_set_scriptpubkey(this_ptr: &mut Shutdown, mut val: crate::c_types::derived::CVec_u8Z) {
1107 unsafe { &mut *this_ptr.inner }.scriptpubkey = ::bitcoin::blockdata::script::Script::from(val.into_rust());
1111 pub extern "C" fn Shutdown_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut scriptpubkey_arg: crate::c_types::derived::CVec_u8Z) -> Shutdown {
1112 Shutdown { inner: Box::into_raw(Box::new(nativeShutdown {
1113 channel_id: channel_id_arg.data,
1114 scriptpubkey: ::bitcoin::blockdata::script::Script::from(scriptpubkey_arg.into_rust()),
1115 })), is_owned: true }
1118 use lightning::ln::msgs::ClosingSigned as nativeClosingSignedImport;
1119 type nativeClosingSigned = nativeClosingSignedImport;
1121 /// A closing_signed message to be sent or received from a peer
1124 pub struct ClosingSigned {
1125 /// Nearly everyhwere, inner must be non-null, however in places where
1126 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1127 pub inner: *mut nativeClosingSigned,
1131 impl Drop for ClosingSigned {
1132 fn drop(&mut self) {
1133 if self.is_owned && !self.inner.is_null() {
1134 let _ = unsafe { Box::from_raw(self.inner) };
1139 pub extern "C" fn ClosingSigned_free(this_ptr: ClosingSigned) { }
1141 /// Used only if an object of this type is returned as a trait impl by a method
1142 extern "C" fn ClosingSigned_free_void(this_ptr: *mut c_void) {
1143 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeClosingSigned); }
1146 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1147 impl ClosingSigned {
1148 pub(crate) fn take_ptr(mut self) -> *mut nativeClosingSigned {
1149 assert!(self.is_owned);
1150 let ret = self.inner;
1151 self.inner = std::ptr::null_mut();
1155 impl Clone for ClosingSigned {
1156 fn clone(&self) -> Self {
1158 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
1164 /// Used only if an object of this type is returned as a trait impl by a method
1165 pub(crate) extern "C" fn ClosingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
1166 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClosingSigned)).clone() })) as *mut c_void
1170 pub extern "C" fn ClosingSigned_get_channel_id(this_ptr: &ClosingSigned) -> *const [u8; 32] {
1171 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1176 pub extern "C" fn ClosingSigned_set_channel_id(this_ptr: &mut ClosingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
1177 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1179 /// The proposed total fee for the closing transaction
1181 pub extern "C" fn ClosingSigned_get_fee_satoshis(this_ptr: &ClosingSigned) -> u64 {
1182 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_satoshis;
1185 /// The proposed total fee for the closing transaction
1187 pub extern "C" fn ClosingSigned_set_fee_satoshis(this_ptr: &mut ClosingSigned, mut val: u64) {
1188 unsafe { &mut *this_ptr.inner }.fee_satoshis = val;
1190 /// A signature on the closing transaction
1192 pub extern "C" fn ClosingSigned_get_signature(this_ptr: &ClosingSigned) -> crate::c_types::Signature {
1193 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
1194 crate::c_types::Signature::from_rust(&(*inner_val))
1196 /// A signature on the closing transaction
1198 pub extern "C" fn ClosingSigned_set_signature(this_ptr: &mut ClosingSigned, mut val: crate::c_types::Signature) {
1199 unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
1203 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 {
1204 ClosingSigned { inner: Box::into_raw(Box::new(nativeClosingSigned {
1205 channel_id: channel_id_arg.data,
1206 fee_satoshis: fee_satoshis_arg,
1207 signature: signature_arg.into_rust(),
1208 })), is_owned: true }
1211 use lightning::ln::msgs::UpdateAddHTLC as nativeUpdateAddHTLCImport;
1212 type nativeUpdateAddHTLC = nativeUpdateAddHTLCImport;
1214 /// An update_add_htlc message to be sent or received from a peer
1217 pub struct UpdateAddHTLC {
1218 /// Nearly everyhwere, inner must be non-null, however in places where
1219 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1220 pub inner: *mut nativeUpdateAddHTLC,
1224 impl Drop for UpdateAddHTLC {
1225 fn drop(&mut self) {
1226 if self.is_owned && !self.inner.is_null() {
1227 let _ = unsafe { Box::from_raw(self.inner) };
1232 pub extern "C" fn UpdateAddHTLC_free(this_ptr: UpdateAddHTLC) { }
1234 /// Used only if an object of this type is returned as a trait impl by a method
1235 extern "C" fn UpdateAddHTLC_free_void(this_ptr: *mut c_void) {
1236 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateAddHTLC); }
1239 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1240 impl UpdateAddHTLC {
1241 pub(crate) fn take_ptr(mut self) -> *mut nativeUpdateAddHTLC {
1242 assert!(self.is_owned);
1243 let ret = self.inner;
1244 self.inner = std::ptr::null_mut();
1248 impl Clone for UpdateAddHTLC {
1249 fn clone(&self) -> Self {
1251 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
1257 /// Used only if an object of this type is returned as a trait impl by a method
1258 pub(crate) extern "C" fn UpdateAddHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1259 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateAddHTLC)).clone() })) as *mut c_void
1263 pub extern "C" fn UpdateAddHTLC_get_channel_id(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
1264 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1269 pub extern "C" fn UpdateAddHTLC_set_channel_id(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1270 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1274 pub extern "C" fn UpdateAddHTLC_get_htlc_id(this_ptr: &UpdateAddHTLC) -> u64 {
1275 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_id;
1280 pub extern "C" fn UpdateAddHTLC_set_htlc_id(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
1281 unsafe { &mut *this_ptr.inner }.htlc_id = val;
1283 /// The HTLC value in milli-satoshi
1285 pub extern "C" fn UpdateAddHTLC_get_amount_msat(this_ptr: &UpdateAddHTLC) -> u64 {
1286 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.amount_msat;
1289 /// The HTLC value in milli-satoshi
1291 pub extern "C" fn UpdateAddHTLC_set_amount_msat(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
1292 unsafe { &mut *this_ptr.inner }.amount_msat = val;
1294 /// The payment hash, the pre-image of which controls HTLC redemption
1296 pub extern "C" fn UpdateAddHTLC_get_payment_hash(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
1297 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_hash;
1300 /// The payment hash, the pre-image of which controls HTLC redemption
1302 pub extern "C" fn UpdateAddHTLC_set_payment_hash(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1303 unsafe { &mut *this_ptr.inner }.payment_hash = ::lightning::ln::channelmanager::PaymentHash(val.data);
1305 /// The expiry height of the HTLC
1307 pub extern "C" fn UpdateAddHTLC_get_cltv_expiry(this_ptr: &UpdateAddHTLC) -> u32 {
1308 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry;
1311 /// The expiry height of the HTLC
1313 pub extern "C" fn UpdateAddHTLC_set_cltv_expiry(this_ptr: &mut UpdateAddHTLC, mut val: u32) {
1314 unsafe { &mut *this_ptr.inner }.cltv_expiry = val;
1317 use lightning::ln::msgs::UpdateFulfillHTLC as nativeUpdateFulfillHTLCImport;
1318 type nativeUpdateFulfillHTLC = nativeUpdateFulfillHTLCImport;
1320 /// An update_fulfill_htlc message to be sent or received from a peer
1323 pub struct UpdateFulfillHTLC {
1324 /// Nearly everyhwere, inner must be non-null, however in places where
1325 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1326 pub inner: *mut nativeUpdateFulfillHTLC,
1330 impl Drop for UpdateFulfillHTLC {
1331 fn drop(&mut self) {
1332 if self.is_owned && !self.inner.is_null() {
1333 let _ = unsafe { Box::from_raw(self.inner) };
1338 pub extern "C" fn UpdateFulfillHTLC_free(this_ptr: UpdateFulfillHTLC) { }
1340 /// Used only if an object of this type is returned as a trait impl by a method
1341 extern "C" fn UpdateFulfillHTLC_free_void(this_ptr: *mut c_void) {
1342 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFulfillHTLC); }
1345 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1346 impl UpdateFulfillHTLC {
1347 pub(crate) fn take_ptr(mut self) -> *mut nativeUpdateFulfillHTLC {
1348 assert!(self.is_owned);
1349 let ret = self.inner;
1350 self.inner = std::ptr::null_mut();
1354 impl Clone for UpdateFulfillHTLC {
1355 fn clone(&self) -> Self {
1357 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
1363 /// Used only if an object of this type is returned as a trait impl by a method
1364 pub(crate) extern "C" fn UpdateFulfillHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1365 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFulfillHTLC)).clone() })) as *mut c_void
1369 pub extern "C" fn UpdateFulfillHTLC_get_channel_id(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
1370 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1375 pub extern "C" fn UpdateFulfillHTLC_set_channel_id(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1376 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1380 pub extern "C" fn UpdateFulfillHTLC_get_htlc_id(this_ptr: &UpdateFulfillHTLC) -> u64 {
1381 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_id;
1386 pub extern "C" fn UpdateFulfillHTLC_set_htlc_id(this_ptr: &mut UpdateFulfillHTLC, mut val: u64) {
1387 unsafe { &mut *this_ptr.inner }.htlc_id = val;
1389 /// The pre-image of the payment hash, allowing HTLC redemption
1391 pub extern "C" fn UpdateFulfillHTLC_get_payment_preimage(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
1392 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_preimage;
1395 /// The pre-image of the payment hash, allowing HTLC redemption
1397 pub extern "C" fn UpdateFulfillHTLC_set_payment_preimage(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1398 unsafe { &mut *this_ptr.inner }.payment_preimage = ::lightning::ln::channelmanager::PaymentPreimage(val.data);
1402 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 {
1403 UpdateFulfillHTLC { inner: Box::into_raw(Box::new(nativeUpdateFulfillHTLC {
1404 channel_id: channel_id_arg.data,
1405 htlc_id: htlc_id_arg,
1406 payment_preimage: ::lightning::ln::channelmanager::PaymentPreimage(payment_preimage_arg.data),
1407 })), is_owned: true }
1410 use lightning::ln::msgs::UpdateFailHTLC as nativeUpdateFailHTLCImport;
1411 type nativeUpdateFailHTLC = nativeUpdateFailHTLCImport;
1413 /// An update_fail_htlc message to be sent or received from a peer
1416 pub struct UpdateFailHTLC {
1417 /// Nearly everyhwere, inner must be non-null, however in places where
1418 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1419 pub inner: *mut nativeUpdateFailHTLC,
1423 impl Drop for UpdateFailHTLC {
1424 fn drop(&mut self) {
1425 if self.is_owned && !self.inner.is_null() {
1426 let _ = unsafe { Box::from_raw(self.inner) };
1431 pub extern "C" fn UpdateFailHTLC_free(this_ptr: UpdateFailHTLC) { }
1433 /// Used only if an object of this type is returned as a trait impl by a method
1434 extern "C" fn UpdateFailHTLC_free_void(this_ptr: *mut c_void) {
1435 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFailHTLC); }
1438 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1439 impl UpdateFailHTLC {
1440 pub(crate) fn take_ptr(mut self) -> *mut nativeUpdateFailHTLC {
1441 assert!(self.is_owned);
1442 let ret = self.inner;
1443 self.inner = std::ptr::null_mut();
1447 impl Clone for UpdateFailHTLC {
1448 fn clone(&self) -> Self {
1450 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
1456 /// Used only if an object of this type is returned as a trait impl by a method
1457 pub(crate) extern "C" fn UpdateFailHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1458 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailHTLC)).clone() })) as *mut c_void
1462 pub extern "C" fn UpdateFailHTLC_get_channel_id(this_ptr: &UpdateFailHTLC) -> *const [u8; 32] {
1463 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1468 pub extern "C" fn UpdateFailHTLC_set_channel_id(this_ptr: &mut UpdateFailHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1469 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1473 pub extern "C" fn UpdateFailHTLC_get_htlc_id(this_ptr: &UpdateFailHTLC) -> u64 {
1474 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_id;
1479 pub extern "C" fn UpdateFailHTLC_set_htlc_id(this_ptr: &mut UpdateFailHTLC, mut val: u64) {
1480 unsafe { &mut *this_ptr.inner }.htlc_id = val;
1483 use lightning::ln::msgs::UpdateFailMalformedHTLC as nativeUpdateFailMalformedHTLCImport;
1484 type nativeUpdateFailMalformedHTLC = nativeUpdateFailMalformedHTLCImport;
1486 /// An update_fail_malformed_htlc message to be sent or received from a peer
1489 pub struct UpdateFailMalformedHTLC {
1490 /// Nearly everyhwere, inner must be non-null, however in places where
1491 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1492 pub inner: *mut nativeUpdateFailMalformedHTLC,
1496 impl Drop for UpdateFailMalformedHTLC {
1497 fn drop(&mut self) {
1498 if self.is_owned && !self.inner.is_null() {
1499 let _ = unsafe { Box::from_raw(self.inner) };
1504 pub extern "C" fn UpdateFailMalformedHTLC_free(this_ptr: UpdateFailMalformedHTLC) { }
1506 /// Used only if an object of this type is returned as a trait impl by a method
1507 extern "C" fn UpdateFailMalformedHTLC_free_void(this_ptr: *mut c_void) {
1508 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFailMalformedHTLC); }
1511 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1512 impl UpdateFailMalformedHTLC {
1513 pub(crate) fn take_ptr(mut self) -> *mut nativeUpdateFailMalformedHTLC {
1514 assert!(self.is_owned);
1515 let ret = self.inner;
1516 self.inner = std::ptr::null_mut();
1520 impl Clone for UpdateFailMalformedHTLC {
1521 fn clone(&self) -> Self {
1523 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
1529 /// Used only if an object of this type is returned as a trait impl by a method
1530 pub(crate) extern "C" fn UpdateFailMalformedHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1531 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailMalformedHTLC)).clone() })) as *mut c_void
1535 pub extern "C" fn UpdateFailMalformedHTLC_get_channel_id(this_ptr: &UpdateFailMalformedHTLC) -> *const [u8; 32] {
1536 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1541 pub extern "C" fn UpdateFailMalformedHTLC_set_channel_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1542 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1546 pub extern "C" fn UpdateFailMalformedHTLC_get_htlc_id(this_ptr: &UpdateFailMalformedHTLC) -> u64 {
1547 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_id;
1552 pub extern "C" fn UpdateFailMalformedHTLC_set_htlc_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u64) {
1553 unsafe { &mut *this_ptr.inner }.htlc_id = val;
1555 /// The failure code
1557 pub extern "C" fn UpdateFailMalformedHTLC_get_failure_code(this_ptr: &UpdateFailMalformedHTLC) -> u16 {
1558 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.failure_code;
1561 /// The failure code
1563 pub extern "C" fn UpdateFailMalformedHTLC_set_failure_code(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u16) {
1564 unsafe { &mut *this_ptr.inner }.failure_code = val;
1567 use lightning::ln::msgs::CommitmentSigned as nativeCommitmentSignedImport;
1568 type nativeCommitmentSigned = nativeCommitmentSignedImport;
1570 /// A commitment_signed message to be sent or received from a peer
1573 pub struct CommitmentSigned {
1574 /// Nearly everyhwere, inner must be non-null, however in places where
1575 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1576 pub inner: *mut nativeCommitmentSigned,
1580 impl Drop for CommitmentSigned {
1581 fn drop(&mut self) {
1582 if self.is_owned && !self.inner.is_null() {
1583 let _ = unsafe { Box::from_raw(self.inner) };
1588 pub extern "C" fn CommitmentSigned_free(this_ptr: CommitmentSigned) { }
1590 /// Used only if an object of this type is returned as a trait impl by a method
1591 extern "C" fn CommitmentSigned_free_void(this_ptr: *mut c_void) {
1592 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentSigned); }
1595 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1596 impl CommitmentSigned {
1597 pub(crate) fn take_ptr(mut self) -> *mut nativeCommitmentSigned {
1598 assert!(self.is_owned);
1599 let ret = self.inner;
1600 self.inner = std::ptr::null_mut();
1604 impl Clone for CommitmentSigned {
1605 fn clone(&self) -> Self {
1607 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
1613 /// Used only if an object of this type is returned as a trait impl by a method
1614 pub(crate) extern "C" fn CommitmentSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
1615 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentSigned)).clone() })) as *mut c_void
1619 pub extern "C" fn CommitmentSigned_get_channel_id(this_ptr: &CommitmentSigned) -> *const [u8; 32] {
1620 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1625 pub extern "C" fn CommitmentSigned_set_channel_id(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::ThirtyTwoBytes) {
1626 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1628 /// A signature on the commitment transaction
1630 pub extern "C" fn CommitmentSigned_get_signature(this_ptr: &CommitmentSigned) -> crate::c_types::Signature {
1631 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
1632 crate::c_types::Signature::from_rust(&(*inner_val))
1634 /// A signature on the commitment transaction
1636 pub extern "C" fn CommitmentSigned_set_signature(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::Signature) {
1637 unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
1639 /// Signatures on the HTLC transactions
1641 pub extern "C" fn CommitmentSigned_set_htlc_signatures(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::derived::CVec_SignatureZ) {
1642 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_rust() }); };
1643 unsafe { &mut *this_ptr.inner }.htlc_signatures = local_val;
1647 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 {
1648 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() }); };
1649 CommitmentSigned { inner: Box::into_raw(Box::new(nativeCommitmentSigned {
1650 channel_id: channel_id_arg.data,
1651 signature: signature_arg.into_rust(),
1652 htlc_signatures: local_htlc_signatures_arg,
1653 })), is_owned: true }
1656 use lightning::ln::msgs::RevokeAndACK as nativeRevokeAndACKImport;
1657 type nativeRevokeAndACK = nativeRevokeAndACKImport;
1659 /// A revoke_and_ack message to be sent or received from a peer
1662 pub struct RevokeAndACK {
1663 /// Nearly everyhwere, inner must be non-null, however in places where
1664 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1665 pub inner: *mut nativeRevokeAndACK,
1669 impl Drop for RevokeAndACK {
1670 fn drop(&mut self) {
1671 if self.is_owned && !self.inner.is_null() {
1672 let _ = unsafe { Box::from_raw(self.inner) };
1677 pub extern "C" fn RevokeAndACK_free(this_ptr: RevokeAndACK) { }
1679 /// Used only if an object of this type is returned as a trait impl by a method
1680 extern "C" fn RevokeAndACK_free_void(this_ptr: *mut c_void) {
1681 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRevokeAndACK); }
1684 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1686 pub(crate) fn take_ptr(mut self) -> *mut nativeRevokeAndACK {
1687 assert!(self.is_owned);
1688 let ret = self.inner;
1689 self.inner = std::ptr::null_mut();
1693 impl Clone for RevokeAndACK {
1694 fn clone(&self) -> Self {
1696 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
1702 /// Used only if an object of this type is returned as a trait impl by a method
1703 pub(crate) extern "C" fn RevokeAndACK_clone_void(this_ptr: *const c_void) -> *mut c_void {
1704 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRevokeAndACK)).clone() })) as *mut c_void
1708 pub extern "C" fn RevokeAndACK_get_channel_id(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
1709 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1714 pub extern "C" fn RevokeAndACK_set_channel_id(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
1715 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1717 /// The secret corresponding to the per-commitment point
1719 pub extern "C" fn RevokeAndACK_get_per_commitment_secret(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
1720 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.per_commitment_secret;
1723 /// The secret corresponding to the per-commitment point
1725 pub extern "C" fn RevokeAndACK_set_per_commitment_secret(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
1726 unsafe { &mut *this_ptr.inner }.per_commitment_secret = val.data;
1728 /// The next sender-broadcast commitment transaction's per-commitment point
1730 pub extern "C" fn RevokeAndACK_get_next_per_commitment_point(this_ptr: &RevokeAndACK) -> crate::c_types::PublicKey {
1731 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.next_per_commitment_point;
1732 crate::c_types::PublicKey::from_rust(&(*inner_val))
1734 /// The next sender-broadcast commitment transaction's per-commitment point
1736 pub extern "C" fn RevokeAndACK_set_next_per_commitment_point(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::PublicKey) {
1737 unsafe { &mut *this_ptr.inner }.next_per_commitment_point = val.into_rust();
1741 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 {
1742 RevokeAndACK { inner: Box::into_raw(Box::new(nativeRevokeAndACK {
1743 channel_id: channel_id_arg.data,
1744 per_commitment_secret: per_commitment_secret_arg.data,
1745 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
1746 })), is_owned: true }
1749 use lightning::ln::msgs::UpdateFee as nativeUpdateFeeImport;
1750 type nativeUpdateFee = nativeUpdateFeeImport;
1752 /// An update_fee message to be sent or received from a peer
1755 pub struct UpdateFee {
1756 /// Nearly everyhwere, inner must be non-null, however in places where
1757 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1758 pub inner: *mut nativeUpdateFee,
1762 impl Drop for UpdateFee {
1763 fn drop(&mut self) {
1764 if self.is_owned && !self.inner.is_null() {
1765 let _ = unsafe { Box::from_raw(self.inner) };
1770 pub extern "C" fn UpdateFee_free(this_ptr: UpdateFee) { }
1772 /// Used only if an object of this type is returned as a trait impl by a method
1773 extern "C" fn UpdateFee_free_void(this_ptr: *mut c_void) {
1774 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFee); }
1777 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1779 pub(crate) fn take_ptr(mut self) -> *mut nativeUpdateFee {
1780 assert!(self.is_owned);
1781 let ret = self.inner;
1782 self.inner = std::ptr::null_mut();
1786 impl Clone for UpdateFee {
1787 fn clone(&self) -> Self {
1789 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
1795 /// Used only if an object of this type is returned as a trait impl by a method
1796 pub(crate) extern "C" fn UpdateFee_clone_void(this_ptr: *const c_void) -> *mut c_void {
1797 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFee)).clone() })) as *mut c_void
1801 pub extern "C" fn UpdateFee_get_channel_id(this_ptr: &UpdateFee) -> *const [u8; 32] {
1802 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1807 pub extern "C" fn UpdateFee_set_channel_id(this_ptr: &mut UpdateFee, mut val: crate::c_types::ThirtyTwoBytes) {
1808 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1810 /// Fee rate per 1000-weight of the transaction
1812 pub extern "C" fn UpdateFee_get_feerate_per_kw(this_ptr: &UpdateFee) -> u32 {
1813 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.feerate_per_kw;
1816 /// Fee rate per 1000-weight of the transaction
1818 pub extern "C" fn UpdateFee_set_feerate_per_kw(this_ptr: &mut UpdateFee, mut val: u32) {
1819 unsafe { &mut *this_ptr.inner }.feerate_per_kw = val;
1823 pub extern "C" fn UpdateFee_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut feerate_per_kw_arg: u32) -> UpdateFee {
1824 UpdateFee { inner: Box::into_raw(Box::new(nativeUpdateFee {
1825 channel_id: channel_id_arg.data,
1826 feerate_per_kw: feerate_per_kw_arg,
1827 })), is_owned: true }
1830 use lightning::ln::msgs::DataLossProtect as nativeDataLossProtectImport;
1831 type nativeDataLossProtect = nativeDataLossProtectImport;
1833 /// Proof that the sender knows the per-commitment secret of the previous commitment transaction.
1834 /// This is used to convince the recipient that the channel is at a certain commitment
1835 /// number even if they lost that data due to a local failure. Of course, the peer may lie
1836 /// and even later commitments may have been revoked.
1839 pub struct DataLossProtect {
1840 /// Nearly everyhwere, inner must be non-null, however in places where
1841 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1842 pub inner: *mut nativeDataLossProtect,
1846 impl Drop for DataLossProtect {
1847 fn drop(&mut self) {
1848 if self.is_owned && !self.inner.is_null() {
1849 let _ = unsafe { Box::from_raw(self.inner) };
1854 pub extern "C" fn DataLossProtect_free(this_ptr: DataLossProtect) { }
1856 /// Used only if an object of this type is returned as a trait impl by a method
1857 extern "C" fn DataLossProtect_free_void(this_ptr: *mut c_void) {
1858 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDataLossProtect); }
1861 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1862 impl DataLossProtect {
1863 pub(crate) fn take_ptr(mut self) -> *mut nativeDataLossProtect {
1864 assert!(self.is_owned);
1865 let ret = self.inner;
1866 self.inner = std::ptr::null_mut();
1870 impl Clone for DataLossProtect {
1871 fn clone(&self) -> Self {
1873 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
1879 /// Used only if an object of this type is returned as a trait impl by a method
1880 pub(crate) extern "C" fn DataLossProtect_clone_void(this_ptr: *const c_void) -> *mut c_void {
1881 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDataLossProtect)).clone() })) as *mut c_void
1883 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
1884 /// belonging to the recipient
1886 pub extern "C" fn DataLossProtect_get_your_last_per_commitment_secret(this_ptr: &DataLossProtect) -> *const [u8; 32] {
1887 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.your_last_per_commitment_secret;
1890 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
1891 /// belonging to the recipient
1893 pub extern "C" fn DataLossProtect_set_your_last_per_commitment_secret(this_ptr: &mut DataLossProtect, mut val: crate::c_types::ThirtyTwoBytes) {
1894 unsafe { &mut *this_ptr.inner }.your_last_per_commitment_secret = val.data;
1896 /// The sender's per-commitment point for their current commitment transaction
1898 pub extern "C" fn DataLossProtect_get_my_current_per_commitment_point(this_ptr: &DataLossProtect) -> crate::c_types::PublicKey {
1899 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.my_current_per_commitment_point;
1900 crate::c_types::PublicKey::from_rust(&(*inner_val))
1902 /// The sender's per-commitment point for their current commitment transaction
1904 pub extern "C" fn DataLossProtect_set_my_current_per_commitment_point(this_ptr: &mut DataLossProtect, mut val: crate::c_types::PublicKey) {
1905 unsafe { &mut *this_ptr.inner }.my_current_per_commitment_point = val.into_rust();
1909 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 {
1910 DataLossProtect { inner: Box::into_raw(Box::new(nativeDataLossProtect {
1911 your_last_per_commitment_secret: your_last_per_commitment_secret_arg.data,
1912 my_current_per_commitment_point: my_current_per_commitment_point_arg.into_rust(),
1913 })), is_owned: true }
1916 use lightning::ln::msgs::ChannelReestablish as nativeChannelReestablishImport;
1917 type nativeChannelReestablish = nativeChannelReestablishImport;
1919 /// A channel_reestablish message to be sent or received from a peer
1922 pub struct ChannelReestablish {
1923 /// Nearly everyhwere, inner must be non-null, however in places where
1924 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1925 pub inner: *mut nativeChannelReestablish,
1929 impl Drop for ChannelReestablish {
1930 fn drop(&mut self) {
1931 if self.is_owned && !self.inner.is_null() {
1932 let _ = unsafe { Box::from_raw(self.inner) };
1937 pub extern "C" fn ChannelReestablish_free(this_ptr: ChannelReestablish) { }
1939 /// Used only if an object of this type is returned as a trait impl by a method
1940 extern "C" fn ChannelReestablish_free_void(this_ptr: *mut c_void) {
1941 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelReestablish); }
1944 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1945 impl ChannelReestablish {
1946 pub(crate) fn take_ptr(mut self) -> *mut nativeChannelReestablish {
1947 assert!(self.is_owned);
1948 let ret = self.inner;
1949 self.inner = std::ptr::null_mut();
1953 impl Clone for ChannelReestablish {
1954 fn clone(&self) -> Self {
1956 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
1962 /// Used only if an object of this type is returned as a trait impl by a method
1963 pub(crate) extern "C" fn ChannelReestablish_clone_void(this_ptr: *const c_void) -> *mut c_void {
1964 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelReestablish)).clone() })) as *mut c_void
1968 pub extern "C" fn ChannelReestablish_get_channel_id(this_ptr: &ChannelReestablish) -> *const [u8; 32] {
1969 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1974 pub extern "C" fn ChannelReestablish_set_channel_id(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) {
1975 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1977 /// The next commitment number for the sender
1979 pub extern "C" fn ChannelReestablish_get_next_local_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
1980 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.next_local_commitment_number;
1983 /// The next commitment number for the sender
1985 pub extern "C" fn ChannelReestablish_set_next_local_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
1986 unsafe { &mut *this_ptr.inner }.next_local_commitment_number = val;
1988 /// The next commitment number for the recipient
1990 pub extern "C" fn ChannelReestablish_get_next_remote_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
1991 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.next_remote_commitment_number;
1994 /// The next commitment number for the recipient
1996 pub extern "C" fn ChannelReestablish_set_next_remote_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
1997 unsafe { &mut *this_ptr.inner }.next_remote_commitment_number = val;
2000 use lightning::ln::msgs::AnnouncementSignatures as nativeAnnouncementSignaturesImport;
2001 type nativeAnnouncementSignatures = nativeAnnouncementSignaturesImport;
2003 /// An announcement_signatures message to be sent or received from a peer
2006 pub struct AnnouncementSignatures {
2007 /// Nearly everyhwere, inner must be non-null, however in places where
2008 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2009 pub inner: *mut nativeAnnouncementSignatures,
2013 impl Drop for AnnouncementSignatures {
2014 fn drop(&mut self) {
2015 if self.is_owned && !self.inner.is_null() {
2016 let _ = unsafe { Box::from_raw(self.inner) };
2021 pub extern "C" fn AnnouncementSignatures_free(this_ptr: AnnouncementSignatures) { }
2023 /// Used only if an object of this type is returned as a trait impl by a method
2024 extern "C" fn AnnouncementSignatures_free_void(this_ptr: *mut c_void) {
2025 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeAnnouncementSignatures); }
2028 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2029 impl AnnouncementSignatures {
2030 pub(crate) fn take_ptr(mut self) -> *mut nativeAnnouncementSignatures {
2031 assert!(self.is_owned);
2032 let ret = self.inner;
2033 self.inner = std::ptr::null_mut();
2037 impl Clone for AnnouncementSignatures {
2038 fn clone(&self) -> Self {
2040 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
2046 /// Used only if an object of this type is returned as a trait impl by a method
2047 pub(crate) extern "C" fn AnnouncementSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
2048 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAnnouncementSignatures)).clone() })) as *mut c_void
2052 pub extern "C" fn AnnouncementSignatures_get_channel_id(this_ptr: &AnnouncementSignatures) -> *const [u8; 32] {
2053 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
2058 pub extern "C" fn AnnouncementSignatures_set_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
2059 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
2061 /// The short channel ID
2063 pub extern "C" fn AnnouncementSignatures_get_short_channel_id(this_ptr: &AnnouncementSignatures) -> u64 {
2064 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id;
2067 /// The short channel ID
2069 pub extern "C" fn AnnouncementSignatures_set_short_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: u64) {
2070 unsafe { &mut *this_ptr.inner }.short_channel_id = val;
2072 /// A signature by the node key
2074 pub extern "C" fn AnnouncementSignatures_get_node_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
2075 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_signature;
2076 crate::c_types::Signature::from_rust(&(*inner_val))
2078 /// A signature by the node key
2080 pub extern "C" fn AnnouncementSignatures_set_node_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
2081 unsafe { &mut *this_ptr.inner }.node_signature = val.into_rust();
2083 /// A signature by the funding key
2085 pub extern "C" fn AnnouncementSignatures_get_bitcoin_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
2086 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_signature;
2087 crate::c_types::Signature::from_rust(&(*inner_val))
2089 /// A signature by the funding key
2091 pub extern "C" fn AnnouncementSignatures_set_bitcoin_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
2092 unsafe { &mut *this_ptr.inner }.bitcoin_signature = val.into_rust();
2096 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 {
2097 AnnouncementSignatures { inner: Box::into_raw(Box::new(nativeAnnouncementSignatures {
2098 channel_id: channel_id_arg.data,
2099 short_channel_id: short_channel_id_arg,
2100 node_signature: node_signature_arg.into_rust(),
2101 bitcoin_signature: bitcoin_signature_arg.into_rust(),
2102 })), is_owned: true }
2104 /// An address which can be used to connect to a remote peer
2108 pub enum NetAddress {
2109 /// An IPv4 address/port on which the peer is listening.
2111 addr: crate::c_types::FourBytes,
2114 /// An IPv6 address/port on which the peer is listening.
2116 addr: crate::c_types::SixteenBytes,
2119 /// An old-style Tor onion address/port on which the peer is listening.
2121 addr: crate::c_types::TenBytes,
2124 /// A new-style Tor onion address/port on which the peer is listening.
2125 /// To create the human-readable \"hostname\", concatenate ed25519_pubkey, checksum, and version,
2126 /// wrap as base32 and append \".onion\".
2128 ed25519_pubkey: crate::c_types::ThirtyTwoBytes,
2134 use lightning::ln::msgs::NetAddress as nativeNetAddress;
2137 pub(crate) fn to_native(&self) -> nativeNetAddress {
2139 NetAddress::IPv4 {ref addr, ref port, } => {
2140 let mut addr_nonref = (*addr).clone();
2141 let mut port_nonref = (*port).clone();
2142 nativeNetAddress::IPv4 {
2143 addr: addr_nonref.data,
2147 NetAddress::IPv6 {ref addr, ref port, } => {
2148 let mut addr_nonref = (*addr).clone();
2149 let mut port_nonref = (*port).clone();
2150 nativeNetAddress::IPv6 {
2151 addr: addr_nonref.data,
2155 NetAddress::OnionV2 {ref addr, ref port, } => {
2156 let mut addr_nonref = (*addr).clone();
2157 let mut port_nonref = (*port).clone();
2158 nativeNetAddress::OnionV2 {
2159 addr: addr_nonref.data,
2163 NetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
2164 let mut ed25519_pubkey_nonref = (*ed25519_pubkey).clone();
2165 let mut checksum_nonref = (*checksum).clone();
2166 let mut version_nonref = (*version).clone();
2167 let mut port_nonref = (*port).clone();
2168 nativeNetAddress::OnionV3 {
2169 ed25519_pubkey: ed25519_pubkey_nonref.data,
2170 checksum: checksum_nonref,
2171 version: version_nonref,
2178 pub(crate) fn into_native(self) -> nativeNetAddress {
2180 NetAddress::IPv4 {mut addr, mut port, } => {
2181 nativeNetAddress::IPv4 {
2186 NetAddress::IPv6 {mut addr, mut port, } => {
2187 nativeNetAddress::IPv6 {
2192 NetAddress::OnionV2 {mut addr, mut port, } => {
2193 nativeNetAddress::OnionV2 {
2198 NetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
2199 nativeNetAddress::OnionV3 {
2200 ed25519_pubkey: ed25519_pubkey.data,
2209 pub(crate) fn from_native(native: &nativeNetAddress) -> Self {
2211 nativeNetAddress::IPv4 {ref addr, ref port, } => {
2212 let mut addr_nonref = (*addr).clone();
2213 let mut port_nonref = (*port).clone();
2215 addr: crate::c_types::FourBytes { data: addr_nonref },
2219 nativeNetAddress::IPv6 {ref addr, ref port, } => {
2220 let mut addr_nonref = (*addr).clone();
2221 let mut port_nonref = (*port).clone();
2223 addr: crate::c_types::SixteenBytes { data: addr_nonref },
2227 nativeNetAddress::OnionV2 {ref addr, ref port, } => {
2228 let mut addr_nonref = (*addr).clone();
2229 let mut port_nonref = (*port).clone();
2230 NetAddress::OnionV2 {
2231 addr: crate::c_types::TenBytes { data: addr_nonref },
2235 nativeNetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
2236 let mut ed25519_pubkey_nonref = (*ed25519_pubkey).clone();
2237 let mut checksum_nonref = (*checksum).clone();
2238 let mut version_nonref = (*version).clone();
2239 let mut port_nonref = (*port).clone();
2240 NetAddress::OnionV3 {
2241 ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey_nonref },
2242 checksum: checksum_nonref,
2243 version: version_nonref,
2250 pub(crate) fn native_into(native: nativeNetAddress) -> Self {
2252 nativeNetAddress::IPv4 {mut addr, mut port, } => {
2254 addr: crate::c_types::FourBytes { data: addr },
2258 nativeNetAddress::IPv6 {mut addr, mut port, } => {
2260 addr: crate::c_types::SixteenBytes { data: addr },
2264 nativeNetAddress::OnionV2 {mut addr, mut port, } => {
2265 NetAddress::OnionV2 {
2266 addr: crate::c_types::TenBytes { data: addr },
2270 nativeNetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
2271 NetAddress::OnionV3 {
2272 ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey },
2282 pub extern "C" fn NetAddress_free(this_ptr: NetAddress) { }
2284 use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport;
2285 type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport;
2287 /// The unsigned part of a node_announcement
2290 pub struct UnsignedNodeAnnouncement {
2291 /// Nearly everyhwere, inner must be non-null, however in places where
2292 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2293 pub inner: *mut nativeUnsignedNodeAnnouncement,
2297 impl Drop for UnsignedNodeAnnouncement {
2298 fn drop(&mut self) {
2299 if self.is_owned && !self.inner.is_null() {
2300 let _ = unsafe { Box::from_raw(self.inner) };
2305 pub extern "C" fn UnsignedNodeAnnouncement_free(this_ptr: UnsignedNodeAnnouncement) { }
2307 /// Used only if an object of this type is returned as a trait impl by a method
2308 extern "C" fn UnsignedNodeAnnouncement_free_void(this_ptr: *mut c_void) {
2309 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedNodeAnnouncement); }
2312 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2313 impl UnsignedNodeAnnouncement {
2314 pub(crate) fn take_ptr(mut self) -> *mut nativeUnsignedNodeAnnouncement {
2315 assert!(self.is_owned);
2316 let ret = self.inner;
2317 self.inner = std::ptr::null_mut();
2321 impl Clone for UnsignedNodeAnnouncement {
2322 fn clone(&self) -> Self {
2324 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
2330 /// Used only if an object of this type is returned as a trait impl by a method
2331 pub(crate) extern "C" fn UnsignedNodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
2332 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedNodeAnnouncement)).clone() })) as *mut c_void
2334 /// The advertised features
2336 pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::ln::features::NodeFeatures {
2337 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features;
2338 crate::ln::features::NodeFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
2340 /// The advertised features
2342 pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::ln::features::NodeFeatures) {
2343 unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_ptr()) };
2345 /// A strictly monotonic announcement counter, with gaps allowed
2347 pub extern "C" fn UnsignedNodeAnnouncement_get_timestamp(this_ptr: &UnsignedNodeAnnouncement) -> u32 {
2348 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp;
2351 /// A strictly monotonic announcement counter, with gaps allowed
2353 pub extern "C" fn UnsignedNodeAnnouncement_set_timestamp(this_ptr: &mut UnsignedNodeAnnouncement, mut val: u32) {
2354 unsafe { &mut *this_ptr.inner }.timestamp = val;
2356 /// The node_id this announcement originated from (don't rebroadcast the node_announcement back
2359 pub extern "C" fn UnsignedNodeAnnouncement_get_node_id(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::PublicKey {
2360 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_id;
2361 crate::c_types::PublicKey::from_rust(&(*inner_val))
2363 /// The node_id this announcement originated from (don't rebroadcast the node_announcement back
2366 pub extern "C" fn UnsignedNodeAnnouncement_set_node_id(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::PublicKey) {
2367 unsafe { &mut *this_ptr.inner }.node_id = val.into_rust();
2369 /// An RGB color for UI purposes
2371 pub extern "C" fn UnsignedNodeAnnouncement_get_rgb(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 3] {
2372 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.rgb;
2375 /// An RGB color for UI purposes
2377 pub extern "C" fn UnsignedNodeAnnouncement_set_rgb(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThreeBytes) {
2378 unsafe { &mut *this_ptr.inner }.rgb = val.data;
2380 /// An alias, for UI purposes. This should be sanitized before use. There is no guarantee
2383 pub extern "C" fn UnsignedNodeAnnouncement_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 32] {
2384 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.alias;
2387 /// An alias, for UI purposes. This should be sanitized before use. There is no guarantee
2390 pub extern "C" fn UnsignedNodeAnnouncement_set_alias(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
2391 unsafe { &mut *this_ptr.inner }.alias = val.data;
2393 /// List of addresses on which this node is reachable
2395 pub extern "C" fn UnsignedNodeAnnouncement_set_addresses(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_NetAddressZ) {
2396 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
2397 unsafe { &mut *this_ptr.inner }.addresses = local_val;
2400 use lightning::ln::msgs::NodeAnnouncement as nativeNodeAnnouncementImport;
2401 type nativeNodeAnnouncement = nativeNodeAnnouncementImport;
2403 /// A node_announcement message to be sent or received from a peer
2406 pub struct NodeAnnouncement {
2407 /// Nearly everyhwere, inner must be non-null, however in places where
2408 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2409 pub inner: *mut nativeNodeAnnouncement,
2413 impl Drop for NodeAnnouncement {
2414 fn drop(&mut self) {
2415 if self.is_owned && !self.inner.is_null() {
2416 let _ = unsafe { Box::from_raw(self.inner) };
2421 pub extern "C" fn NodeAnnouncement_free(this_ptr: NodeAnnouncement) { }
2423 /// Used only if an object of this type is returned as a trait impl by a method
2424 extern "C" fn NodeAnnouncement_free_void(this_ptr: *mut c_void) {
2425 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeAnnouncement); }
2428 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2429 impl NodeAnnouncement {
2430 pub(crate) fn take_ptr(mut self) -> *mut nativeNodeAnnouncement {
2431 assert!(self.is_owned);
2432 let ret = self.inner;
2433 self.inner = std::ptr::null_mut();
2437 impl Clone for NodeAnnouncement {
2438 fn clone(&self) -> Self {
2440 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
2446 /// Used only if an object of this type is returned as a trait impl by a method
2447 pub(crate) extern "C" fn NodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
2448 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeAnnouncement)).clone() })) as *mut c_void
2450 /// The signature by the node key
2452 pub extern "C" fn NodeAnnouncement_get_signature(this_ptr: &NodeAnnouncement) -> crate::c_types::Signature {
2453 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
2454 crate::c_types::Signature::from_rust(&(*inner_val))
2456 /// The signature by the node key
2458 pub extern "C" fn NodeAnnouncement_set_signature(this_ptr: &mut NodeAnnouncement, mut val: crate::c_types::Signature) {
2459 unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
2461 /// The actual content of the announcement
2463 pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> crate::ln::msgs::UnsignedNodeAnnouncement {
2464 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents;
2465 crate::ln::msgs::UnsignedNodeAnnouncement { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
2467 /// The actual content of the announcement
2469 pub extern "C" fn NodeAnnouncement_set_contents(this_ptr: &mut NodeAnnouncement, mut val: crate::ln::msgs::UnsignedNodeAnnouncement) {
2470 unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_ptr()) };
2474 pub extern "C" fn NodeAnnouncement_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::ln::msgs::UnsignedNodeAnnouncement) -> NodeAnnouncement {
2475 NodeAnnouncement { inner: Box::into_raw(Box::new(nativeNodeAnnouncement {
2476 signature: signature_arg.into_rust(),
2477 contents: *unsafe { Box::from_raw(contents_arg.take_ptr()) },
2478 })), is_owned: true }
2481 use lightning::ln::msgs::UnsignedChannelAnnouncement as nativeUnsignedChannelAnnouncementImport;
2482 type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport;
2484 /// The unsigned part of a channel_announcement
2487 pub struct UnsignedChannelAnnouncement {
2488 /// Nearly everyhwere, inner must be non-null, however in places where
2489 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2490 pub inner: *mut nativeUnsignedChannelAnnouncement,
2494 impl Drop for UnsignedChannelAnnouncement {
2495 fn drop(&mut self) {
2496 if self.is_owned && !self.inner.is_null() {
2497 let _ = unsafe { Box::from_raw(self.inner) };
2502 pub extern "C" fn UnsignedChannelAnnouncement_free(this_ptr: UnsignedChannelAnnouncement) { }
2504 /// Used only if an object of this type is returned as a trait impl by a method
2505 extern "C" fn UnsignedChannelAnnouncement_free_void(this_ptr: *mut c_void) {
2506 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelAnnouncement); }
2509 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2510 impl UnsignedChannelAnnouncement {
2511 pub(crate) fn take_ptr(mut self) -> *mut nativeUnsignedChannelAnnouncement {
2512 assert!(self.is_owned);
2513 let ret = self.inner;
2514 self.inner = std::ptr::null_mut();
2518 impl Clone for UnsignedChannelAnnouncement {
2519 fn clone(&self) -> Self {
2521 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
2527 /// Used only if an object of this type is returned as a trait impl by a method
2528 pub(crate) extern "C" fn UnsignedChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
2529 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelAnnouncement)).clone() })) as *mut c_void
2531 /// The advertised channel features
2533 pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::ln::features::ChannelFeatures {
2534 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features;
2535 crate::ln::features::ChannelFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
2537 /// The advertised channel features
2539 pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::ln::features::ChannelFeatures) {
2540 unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_ptr()) };
2542 /// The genesis hash of the blockchain where the channel is to be opened
2544 pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &UnsignedChannelAnnouncement) -> *const [u8; 32] {
2545 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
2546 (*inner_val).as_inner()
2548 /// The genesis hash of the blockchain where the channel is to be opened
2550 pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
2551 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
2553 /// The short channel ID
2555 pub extern "C" fn UnsignedChannelAnnouncement_get_short_channel_id(this_ptr: &UnsignedChannelAnnouncement) -> u64 {
2556 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id;
2559 /// The short channel ID
2561 pub extern "C" fn UnsignedChannelAnnouncement_set_short_channel_id(this_ptr: &mut UnsignedChannelAnnouncement, mut val: u64) {
2562 unsafe { &mut *this_ptr.inner }.short_channel_id = val;
2564 /// One of the two node_ids which are endpoints of this channel
2566 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
2567 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_id_1;
2568 crate::c_types::PublicKey::from_rust(&(*inner_val))
2570 /// One of the two node_ids which are endpoints of this channel
2572 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
2573 unsafe { &mut *this_ptr.inner }.node_id_1 = val.into_rust();
2575 /// The other of the two node_ids which are endpoints of this channel
2577 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
2578 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_id_2;
2579 crate::c_types::PublicKey::from_rust(&(*inner_val))
2581 /// The other of the two node_ids which are endpoints of this channel
2583 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
2584 unsafe { &mut *this_ptr.inner }.node_id_2 = val.into_rust();
2586 /// The funding key for the first node
2588 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
2589 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_key_1;
2590 crate::c_types::PublicKey::from_rust(&(*inner_val))
2592 /// The funding key for the first node
2594 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
2595 unsafe { &mut *this_ptr.inner }.bitcoin_key_1 = val.into_rust();
2597 /// The funding key for the second node
2599 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
2600 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_key_2;
2601 crate::c_types::PublicKey::from_rust(&(*inner_val))
2603 /// The funding key for the second node
2605 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
2606 unsafe { &mut *this_ptr.inner }.bitcoin_key_2 = val.into_rust();
2609 use lightning::ln::msgs::ChannelAnnouncement as nativeChannelAnnouncementImport;
2610 type nativeChannelAnnouncement = nativeChannelAnnouncementImport;
2612 /// A channel_announcement message to be sent or received from a peer
2615 pub struct ChannelAnnouncement {
2616 /// Nearly everyhwere, inner must be non-null, however in places where
2617 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2618 pub inner: *mut nativeChannelAnnouncement,
2622 impl Drop for ChannelAnnouncement {
2623 fn drop(&mut self) {
2624 if self.is_owned && !self.inner.is_null() {
2625 let _ = unsafe { Box::from_raw(self.inner) };
2630 pub extern "C" fn ChannelAnnouncement_free(this_ptr: ChannelAnnouncement) { }
2632 /// Used only if an object of this type is returned as a trait impl by a method
2633 extern "C" fn ChannelAnnouncement_free_void(this_ptr: *mut c_void) {
2634 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelAnnouncement); }
2637 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2638 impl ChannelAnnouncement {
2639 pub(crate) fn take_ptr(mut self) -> *mut nativeChannelAnnouncement {
2640 assert!(self.is_owned);
2641 let ret = self.inner;
2642 self.inner = std::ptr::null_mut();
2646 impl Clone for ChannelAnnouncement {
2647 fn clone(&self) -> Self {
2649 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
2655 /// Used only if an object of this type is returned as a trait impl by a method
2656 pub(crate) extern "C" fn ChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
2657 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelAnnouncement)).clone() })) as *mut c_void
2659 /// Authentication of the announcement by the first public node
2661 pub extern "C" fn ChannelAnnouncement_get_node_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
2662 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_signature_1;
2663 crate::c_types::Signature::from_rust(&(*inner_val))
2665 /// Authentication of the announcement by the first public node
2667 pub extern "C" fn ChannelAnnouncement_set_node_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
2668 unsafe { &mut *this_ptr.inner }.node_signature_1 = val.into_rust();
2670 /// Authentication of the announcement by the second public node
2672 pub extern "C" fn ChannelAnnouncement_get_node_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
2673 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_signature_2;
2674 crate::c_types::Signature::from_rust(&(*inner_val))
2676 /// Authentication of the announcement by the second public node
2678 pub extern "C" fn ChannelAnnouncement_set_node_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
2679 unsafe { &mut *this_ptr.inner }.node_signature_2 = val.into_rust();
2681 /// Proof of funding UTXO ownership by the first public node
2683 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
2684 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_signature_1;
2685 crate::c_types::Signature::from_rust(&(*inner_val))
2687 /// Proof of funding UTXO ownership by the first public node
2689 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
2690 unsafe { &mut *this_ptr.inner }.bitcoin_signature_1 = val.into_rust();
2692 /// Proof of funding UTXO ownership by the second public node
2694 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
2695 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_signature_2;
2696 crate::c_types::Signature::from_rust(&(*inner_val))
2698 /// Proof of funding UTXO ownership by the second public node
2700 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
2701 unsafe { &mut *this_ptr.inner }.bitcoin_signature_2 = val.into_rust();
2703 /// The actual announcement
2705 pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncement) -> crate::ln::msgs::UnsignedChannelAnnouncement {
2706 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents;
2707 crate::ln::msgs::UnsignedChannelAnnouncement { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
2709 /// The actual announcement
2711 pub extern "C" fn ChannelAnnouncement_set_contents(this_ptr: &mut ChannelAnnouncement, mut val: crate::ln::msgs::UnsignedChannelAnnouncement) {
2712 unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_ptr()) };
2716 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 {
2717 ChannelAnnouncement { inner: Box::into_raw(Box::new(nativeChannelAnnouncement {
2718 node_signature_1: node_signature_1_arg.into_rust(),
2719 node_signature_2: node_signature_2_arg.into_rust(),
2720 bitcoin_signature_1: bitcoin_signature_1_arg.into_rust(),
2721 bitcoin_signature_2: bitcoin_signature_2_arg.into_rust(),
2722 contents: *unsafe { Box::from_raw(contents_arg.take_ptr()) },
2723 })), is_owned: true }
2726 use lightning::ln::msgs::UnsignedChannelUpdate as nativeUnsignedChannelUpdateImport;
2727 type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport;
2729 /// The unsigned part of a channel_update
2732 pub struct UnsignedChannelUpdate {
2733 /// Nearly everyhwere, inner must be non-null, however in places where
2734 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2735 pub inner: *mut nativeUnsignedChannelUpdate,
2739 impl Drop for UnsignedChannelUpdate {
2740 fn drop(&mut self) {
2741 if self.is_owned && !self.inner.is_null() {
2742 let _ = unsafe { Box::from_raw(self.inner) };
2747 pub extern "C" fn UnsignedChannelUpdate_free(this_ptr: UnsignedChannelUpdate) { }
2749 /// Used only if an object of this type is returned as a trait impl by a method
2750 extern "C" fn UnsignedChannelUpdate_free_void(this_ptr: *mut c_void) {
2751 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelUpdate); }
2754 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2755 impl UnsignedChannelUpdate {
2756 pub(crate) fn take_ptr(mut self) -> *mut nativeUnsignedChannelUpdate {
2757 assert!(self.is_owned);
2758 let ret = self.inner;
2759 self.inner = std::ptr::null_mut();
2763 impl Clone for UnsignedChannelUpdate {
2764 fn clone(&self) -> Self {
2766 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
2772 /// Used only if an object of this type is returned as a trait impl by a method
2773 pub(crate) extern "C" fn UnsignedChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
2774 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelUpdate)).clone() })) as *mut c_void
2776 /// The genesis hash of the blockchain where the channel is to be opened
2778 pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChannelUpdate) -> *const [u8; 32] {
2779 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
2780 (*inner_val).as_inner()
2782 /// The genesis hash of the blockchain where the channel is to be opened
2784 pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::ThirtyTwoBytes) {
2785 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
2787 /// The short channel ID
2789 pub extern "C" fn UnsignedChannelUpdate_get_short_channel_id(this_ptr: &UnsignedChannelUpdate) -> u64 {
2790 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id;
2793 /// The short channel ID
2795 pub extern "C" fn UnsignedChannelUpdate_set_short_channel_id(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
2796 unsafe { &mut *this_ptr.inner }.short_channel_id = val;
2798 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
2800 pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannelUpdate) -> u32 {
2801 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp;
2804 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
2806 pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
2807 unsafe { &mut *this_ptr.inner }.timestamp = val;
2811 pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 {
2812 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.flags;
2817 pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) {
2818 unsafe { &mut *this_ptr.inner }.flags = val;
2820 /// The number of blocks to subtract from incoming HTLC cltv_expiry values
2822 pub extern "C" fn UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr: &UnsignedChannelUpdate) -> u16 {
2823 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry_delta;
2826 /// The number of blocks to subtract from incoming HTLC cltv_expiry values
2828 pub extern "C" fn UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr: &mut UnsignedChannelUpdate, mut val: u16) {
2829 unsafe { &mut *this_ptr.inner }.cltv_expiry_delta = val;
2831 /// The minimum HTLC size incoming to sender, in milli-satoshi
2833 pub extern "C" fn UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
2834 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_minimum_msat;
2837 /// The minimum HTLC size incoming to sender, in milli-satoshi
2839 pub extern "C" fn UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
2840 unsafe { &mut *this_ptr.inner }.htlc_minimum_msat = val;
2842 /// The base HTLC fee charged by sender, in milli-satoshi
2844 pub extern "C" fn UnsignedChannelUpdate_get_fee_base_msat(this_ptr: &UnsignedChannelUpdate) -> u32 {
2845 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_base_msat;
2848 /// The base HTLC fee charged by sender, in milli-satoshi
2850 pub extern "C" fn UnsignedChannelUpdate_set_fee_base_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
2851 unsafe { &mut *this_ptr.inner }.fee_base_msat = val;
2853 /// The amount to fee multiplier, in micro-satoshi
2855 pub extern "C" fn UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr: &UnsignedChannelUpdate) -> u32 {
2856 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_proportional_millionths;
2859 /// The amount to fee multiplier, in micro-satoshi
2861 pub extern "C" fn UnsignedChannelUpdate_set_fee_proportional_millionths(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
2862 unsafe { &mut *this_ptr.inner }.fee_proportional_millionths = val;
2865 use lightning::ln::msgs::ChannelUpdate as nativeChannelUpdateImport;
2866 type nativeChannelUpdate = nativeChannelUpdateImport;
2868 /// A channel_update message to be sent or received from a peer
2871 pub struct ChannelUpdate {
2872 /// Nearly everyhwere, inner must be non-null, however in places where
2873 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2874 pub inner: *mut nativeChannelUpdate,
2878 impl Drop for ChannelUpdate {
2879 fn drop(&mut self) {
2880 if self.is_owned && !self.inner.is_null() {
2881 let _ = unsafe { Box::from_raw(self.inner) };
2886 pub extern "C" fn ChannelUpdate_free(this_ptr: ChannelUpdate) { }
2888 /// Used only if an object of this type is returned as a trait impl by a method
2889 extern "C" fn ChannelUpdate_free_void(this_ptr: *mut c_void) {
2890 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelUpdate); }
2893 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2894 impl ChannelUpdate {
2895 pub(crate) fn take_ptr(mut self) -> *mut nativeChannelUpdate {
2896 assert!(self.is_owned);
2897 let ret = self.inner;
2898 self.inner = std::ptr::null_mut();
2902 impl Clone for ChannelUpdate {
2903 fn clone(&self) -> Self {
2905 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
2911 /// Used only if an object of this type is returned as a trait impl by a method
2912 pub(crate) extern "C" fn ChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
2913 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelUpdate)).clone() })) as *mut c_void
2915 /// A signature of the channel update
2917 pub extern "C" fn ChannelUpdate_get_signature(this_ptr: &ChannelUpdate) -> crate::c_types::Signature {
2918 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
2919 crate::c_types::Signature::from_rust(&(*inner_val))
2921 /// A signature of the channel update
2923 pub extern "C" fn ChannelUpdate_set_signature(this_ptr: &mut ChannelUpdate, mut val: crate::c_types::Signature) {
2924 unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
2926 /// The actual channel update
2928 pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate::ln::msgs::UnsignedChannelUpdate {
2929 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents;
2930 crate::ln::msgs::UnsignedChannelUpdate { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
2932 /// The actual channel update
2934 pub extern "C" fn ChannelUpdate_set_contents(this_ptr: &mut ChannelUpdate, mut val: crate::ln::msgs::UnsignedChannelUpdate) {
2935 unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_ptr()) };
2939 pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::ln::msgs::UnsignedChannelUpdate) -> ChannelUpdate {
2940 ChannelUpdate { inner: Box::into_raw(Box::new(nativeChannelUpdate {
2941 signature: signature_arg.into_rust(),
2942 contents: *unsafe { Box::from_raw(contents_arg.take_ptr()) },
2943 })), is_owned: true }
2946 use lightning::ln::msgs::QueryChannelRange as nativeQueryChannelRangeImport;
2947 type nativeQueryChannelRange = nativeQueryChannelRangeImport;
2949 /// A query_channel_range message is used to query a peer for channel
2950 /// UTXOs in a range of blocks. The recipient of a query makes a best
2951 /// effort to reply to the query using one or more reply_channel_range
2955 pub struct QueryChannelRange {
2956 /// Nearly everyhwere, inner must be non-null, however in places where
2957 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2958 pub inner: *mut nativeQueryChannelRange,
2962 impl Drop for QueryChannelRange {
2963 fn drop(&mut self) {
2964 if self.is_owned && !self.inner.is_null() {
2965 let _ = unsafe { Box::from_raw(self.inner) };
2970 pub extern "C" fn QueryChannelRange_free(this_ptr: QueryChannelRange) { }
2972 /// Used only if an object of this type is returned as a trait impl by a method
2973 extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) {
2974 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryChannelRange); }
2977 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2978 impl QueryChannelRange {
2979 pub(crate) fn take_ptr(mut self) -> *mut nativeQueryChannelRange {
2980 assert!(self.is_owned);
2981 let ret = self.inner;
2982 self.inner = std::ptr::null_mut();
2986 impl Clone for QueryChannelRange {
2987 fn clone(&self) -> Self {
2989 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
2995 /// Used only if an object of this type is returned as a trait impl by a method
2996 pub(crate) extern "C" fn QueryChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
2997 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryChannelRange)).clone() })) as *mut c_void
2999 /// The genesis hash of the blockchain being queried
3001 pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *const [u8; 32] {
3002 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3003 (*inner_val).as_inner()
3005 /// The genesis hash of the blockchain being queried
3007 pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
3008 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3010 /// The height of the first block for the channel UTXOs being queried
3012 pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 {
3013 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_blocknum;
3016 /// The height of the first block for the channel UTXOs being queried
3018 pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChannelRange, mut val: u32) {
3019 unsafe { &mut *this_ptr.inner }.first_blocknum = val;
3021 /// The number of blocks to include in the query results
3023 pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 {
3024 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.number_of_blocks;
3027 /// The number of blocks to include in the query results
3029 pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryChannelRange, mut val: u32) {
3030 unsafe { &mut *this_ptr.inner }.number_of_blocks = val;
3034 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 {
3035 QueryChannelRange { inner: Box::into_raw(Box::new(nativeQueryChannelRange {
3036 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3037 first_blocknum: first_blocknum_arg,
3038 number_of_blocks: number_of_blocks_arg,
3039 })), is_owned: true }
3042 use lightning::ln::msgs::ReplyChannelRange as nativeReplyChannelRangeImport;
3043 type nativeReplyChannelRange = nativeReplyChannelRangeImport;
3045 /// A reply_channel_range message is a reply to a query_channel_range
3046 /// message. Multiple reply_channel_range messages can be sent in reply
3047 /// to a single query_channel_range message. The query recipient makes a
3048 /// best effort to respond based on their local network view which may
3049 /// not be a perfect view of the network. The short_channel_ids in the
3050 /// reply are encoded. We only support encoding_type=0 uncompressed
3051 /// serialization and do not support encoding_type=1 zlib serialization.
3054 pub struct ReplyChannelRange {
3055 /// Nearly everyhwere, inner must be non-null, however in places where
3056 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3057 pub inner: *mut nativeReplyChannelRange,
3061 impl Drop for ReplyChannelRange {
3062 fn drop(&mut self) {
3063 if self.is_owned && !self.inner.is_null() {
3064 let _ = unsafe { Box::from_raw(self.inner) };
3069 pub extern "C" fn ReplyChannelRange_free(this_ptr: ReplyChannelRange) { }
3071 /// Used only if an object of this type is returned as a trait impl by a method
3072 extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) {
3073 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyChannelRange); }
3076 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3077 impl ReplyChannelRange {
3078 pub(crate) fn take_ptr(mut self) -> *mut nativeReplyChannelRange {
3079 assert!(self.is_owned);
3080 let ret = self.inner;
3081 self.inner = std::ptr::null_mut();
3085 impl Clone for ReplyChannelRange {
3086 fn clone(&self) -> Self {
3088 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
3094 /// Used only if an object of this type is returned as a trait impl by a method
3095 pub(crate) extern "C" fn ReplyChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
3096 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyChannelRange)).clone() })) as *mut c_void
3098 /// The genesis hash of the blockchain being queried
3100 pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *const [u8; 32] {
3101 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3102 (*inner_val).as_inner()
3104 /// The genesis hash of the blockchain being queried
3106 pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
3107 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3109 /// The height of the first block in the range of the reply
3111 pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 {
3112 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_blocknum;
3115 /// The height of the first block in the range of the reply
3117 pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChannelRange, mut val: u32) {
3118 unsafe { &mut *this_ptr.inner }.first_blocknum = val;
3120 /// The number of blocks included in the range of the reply
3122 pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 {
3123 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.number_of_blocks;
3126 /// The number of blocks included in the range of the reply
3128 pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyChannelRange, mut val: u32) {
3129 unsafe { &mut *this_ptr.inner }.number_of_blocks = val;
3131 /// Indicates if the query recipient maintains up-to-date channel
3132 /// information for the chain_hash
3134 pub extern "C" fn ReplyChannelRange_get_full_information(this_ptr: &ReplyChannelRange) -> bool {
3135 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.full_information;
3138 /// Indicates if the query recipient maintains up-to-date channel
3139 /// information for the chain_hash
3141 pub extern "C" fn ReplyChannelRange_set_full_information(this_ptr: &mut ReplyChannelRange, mut val: bool) {
3142 unsafe { &mut *this_ptr.inner }.full_information = val;
3144 /// The short_channel_ids in the channel range
3146 pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::derived::CVec_u64Z) {
3147 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
3148 unsafe { &mut *this_ptr.inner }.short_channel_ids = local_val;
3152 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 full_information_arg: bool, mut short_channel_ids_arg: crate::c_types::derived::CVec_u64Z) -> ReplyChannelRange {
3153 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 }); };
3154 ReplyChannelRange { inner: Box::into_raw(Box::new(nativeReplyChannelRange {
3155 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3156 first_blocknum: first_blocknum_arg,
3157 number_of_blocks: number_of_blocks_arg,
3158 full_information: full_information_arg,
3159 short_channel_ids: local_short_channel_ids_arg,
3160 })), is_owned: true }
3163 use lightning::ln::msgs::QueryShortChannelIds as nativeQueryShortChannelIdsImport;
3164 type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport;
3166 /// A query_short_channel_ids message is used to query a peer for
3167 /// routing gossip messages related to one or more short_channel_ids.
3168 /// The query recipient will reply with the latest, if available,
3169 /// channel_announcement, channel_update and node_announcement messages
3170 /// it maintains for the requested short_channel_ids followed by a
3171 /// reply_short_channel_ids_end message. The short_channel_ids sent in
3172 /// this query are encoded. We only support encoding_type=0 uncompressed
3173 /// serialization and do not support encoding_type=1 zlib serialization.
3176 pub struct QueryShortChannelIds {
3177 /// Nearly everyhwere, inner must be non-null, however in places where
3178 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3179 pub inner: *mut nativeQueryShortChannelIds,
3183 impl Drop for QueryShortChannelIds {
3184 fn drop(&mut self) {
3185 if self.is_owned && !self.inner.is_null() {
3186 let _ = unsafe { Box::from_raw(self.inner) };
3191 pub extern "C" fn QueryShortChannelIds_free(this_ptr: QueryShortChannelIds) { }
3193 /// Used only if an object of this type is returned as a trait impl by a method
3194 extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) {
3195 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryShortChannelIds); }
3198 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3199 impl QueryShortChannelIds {
3200 pub(crate) fn take_ptr(mut self) -> *mut nativeQueryShortChannelIds {
3201 assert!(self.is_owned);
3202 let ret = self.inner;
3203 self.inner = std::ptr::null_mut();
3207 impl Clone for QueryShortChannelIds {
3208 fn clone(&self) -> Self {
3210 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
3216 /// Used only if an object of this type is returned as a trait impl by a method
3217 pub(crate) extern "C" fn QueryShortChannelIds_clone_void(this_ptr: *const c_void) -> *mut c_void {
3218 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryShortChannelIds)).clone() })) as *mut c_void
3220 /// The genesis hash of the blockchain being queried
3222 pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *const [u8; 32] {
3223 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3224 (*inner_val).as_inner()
3226 /// The genesis hash of the blockchain being queried
3228 pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::ThirtyTwoBytes) {
3229 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3231 /// The short_channel_ids that are being queried
3233 pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::derived::CVec_u64Z) {
3234 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
3235 unsafe { &mut *this_ptr.inner }.short_channel_ids = local_val;
3239 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 {
3240 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 }); };
3241 QueryShortChannelIds { inner: Box::into_raw(Box::new(nativeQueryShortChannelIds {
3242 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3243 short_channel_ids: local_short_channel_ids_arg,
3244 })), is_owned: true }
3247 use lightning::ln::msgs::ReplyShortChannelIdsEnd as nativeReplyShortChannelIdsEndImport;
3248 type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport;
3250 /// A reply_short_channel_ids_end message is sent as a reply to a
3251 /// query_short_channel_ids message. The query recipient makes a best
3252 /// effort to respond based on their local network view which may not be
3253 /// a perfect view of the network.
3256 pub struct ReplyShortChannelIdsEnd {
3257 /// Nearly everyhwere, inner must be non-null, however in places where
3258 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3259 pub inner: *mut nativeReplyShortChannelIdsEnd,
3263 impl Drop for ReplyShortChannelIdsEnd {
3264 fn drop(&mut self) {
3265 if self.is_owned && !self.inner.is_null() {
3266 let _ = unsafe { Box::from_raw(self.inner) };
3271 pub extern "C" fn ReplyShortChannelIdsEnd_free(this_ptr: ReplyShortChannelIdsEnd) { }
3273 /// Used only if an object of this type is returned as a trait impl by a method
3274 extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) {
3275 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyShortChannelIdsEnd); }
3278 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3279 impl ReplyShortChannelIdsEnd {
3280 pub(crate) fn take_ptr(mut self) -> *mut nativeReplyShortChannelIdsEnd {
3281 assert!(self.is_owned);
3282 let ret = self.inner;
3283 self.inner = std::ptr::null_mut();
3287 impl Clone for ReplyShortChannelIdsEnd {
3288 fn clone(&self) -> Self {
3290 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
3296 /// Used only if an object of this type is returned as a trait impl by a method
3297 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_void) -> *mut c_void {
3298 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyShortChannelIdsEnd)).clone() })) as *mut c_void
3300 /// The genesis hash of the blockchain that was queried
3302 pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *const [u8; 32] {
3303 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3304 (*inner_val).as_inner()
3306 /// The genesis hash of the blockchain that was queried
3308 pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) {
3309 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3311 /// Indicates if the query recipient maintains up-to-date channel
3312 /// information for the chain_hash
3314 pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool {
3315 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.full_information;
3318 /// Indicates if the query recipient maintains up-to-date channel
3319 /// information for the chain_hash
3321 pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: bool) {
3322 unsafe { &mut *this_ptr.inner }.full_information = val;
3326 pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd {
3327 ReplyShortChannelIdsEnd { inner: Box::into_raw(Box::new(nativeReplyShortChannelIdsEnd {
3328 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3329 full_information: full_information_arg,
3330 })), is_owned: true }
3333 use lightning::ln::msgs::GossipTimestampFilter as nativeGossipTimestampFilterImport;
3334 type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport;
3336 /// A gossip_timestamp_filter message is used by a node to request
3337 /// gossip relay for messages in the requested time range when the
3338 /// gossip_queries feature has been negotiated.
3341 pub struct GossipTimestampFilter {
3342 /// Nearly everyhwere, inner must be non-null, however in places where
3343 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3344 pub inner: *mut nativeGossipTimestampFilter,
3348 impl Drop for GossipTimestampFilter {
3349 fn drop(&mut self) {
3350 if self.is_owned && !self.inner.is_null() {
3351 let _ = unsafe { Box::from_raw(self.inner) };
3356 pub extern "C" fn GossipTimestampFilter_free(this_ptr: GossipTimestampFilter) { }
3358 /// Used only if an object of this type is returned as a trait impl by a method
3359 extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) {
3360 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeGossipTimestampFilter); }
3363 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3364 impl GossipTimestampFilter {
3365 pub(crate) fn take_ptr(mut self) -> *mut nativeGossipTimestampFilter {
3366 assert!(self.is_owned);
3367 let ret = self.inner;
3368 self.inner = std::ptr::null_mut();
3372 impl Clone for GossipTimestampFilter {
3373 fn clone(&self) -> Self {
3375 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
3381 /// Used only if an object of this type is returned as a trait impl by a method
3382 pub(crate) extern "C" fn GossipTimestampFilter_clone_void(this_ptr: *const c_void) -> *mut c_void {
3383 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeGossipTimestampFilter)).clone() })) as *mut c_void
3385 /// The genesis hash of the blockchain for channel and node information
3387 pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *const [u8; 32] {
3388 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3389 (*inner_val).as_inner()
3391 /// The genesis hash of the blockchain for channel and node information
3393 pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) {
3394 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3396 /// The starting unix timestamp
3398 pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 {
3399 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_timestamp;
3402 /// The starting unix timestamp
3404 pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
3405 unsafe { &mut *this_ptr.inner }.first_timestamp = val;
3407 /// The range of information in seconds
3409 pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 {
3410 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp_range;
3413 /// The range of information in seconds
3415 pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
3416 unsafe { &mut *this_ptr.inner }.timestamp_range = val;
3420 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 {
3421 GossipTimestampFilter { inner: Box::into_raw(Box::new(nativeGossipTimestampFilter {
3422 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3423 first_timestamp: first_timestamp_arg,
3424 timestamp_range: timestamp_range_arg,
3425 })), is_owned: true }
3427 /// Used to put an error message in a LightningError
3431 pub enum ErrorAction {
3432 /// The peer took some action which made us think they were useless. Disconnect them.
3434 msg: crate::ln::msgs::ErrorMessage,
3436 /// The peer did something harmless that we weren't able to process, just log and ignore
3438 /// The peer did something incorrect. Tell them.
3440 msg: crate::ln::msgs::ErrorMessage,
3443 use lightning::ln::msgs::ErrorAction as nativeErrorAction;
3446 pub(crate) fn to_native(&self) -> nativeErrorAction {
3448 ErrorAction::DisconnectPeer {ref msg, } => {
3449 let mut msg_nonref = (*msg).clone();
3450 let mut local_msg_nonref = if msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg_nonref.take_ptr()) } }) };
3451 nativeErrorAction::DisconnectPeer {
3452 msg: local_msg_nonref,
3455 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
3456 ErrorAction::SendErrorMessage {ref msg, } => {
3457 let mut msg_nonref = (*msg).clone();
3458 nativeErrorAction::SendErrorMessage {
3459 msg: *unsafe { Box::from_raw(msg_nonref.take_ptr()) },
3465 pub(crate) fn into_native(self) -> nativeErrorAction {
3467 ErrorAction::DisconnectPeer {mut msg, } => {
3468 let mut local_msg = if msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg.take_ptr()) } }) };
3469 nativeErrorAction::DisconnectPeer {
3473 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
3474 ErrorAction::SendErrorMessage {mut msg, } => {
3475 nativeErrorAction::SendErrorMessage {
3476 msg: *unsafe { Box::from_raw(msg.take_ptr()) },
3482 pub(crate) fn from_native(native: &nativeErrorAction) -> Self {
3484 nativeErrorAction::DisconnectPeer {ref msg, } => {
3485 let mut msg_nonref = (*msg).clone();
3486 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 };
3487 ErrorAction::DisconnectPeer {
3488 msg: local_msg_nonref,
3491 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
3492 nativeErrorAction::SendErrorMessage {ref msg, } => {
3493 let mut msg_nonref = (*msg).clone();
3494 ErrorAction::SendErrorMessage {
3495 msg: crate::ln::msgs::ErrorMessage { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
3501 pub(crate) fn native_into(native: nativeErrorAction) -> Self {
3503 nativeErrorAction::DisconnectPeer {mut msg, } => {
3504 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 };
3505 ErrorAction::DisconnectPeer {
3509 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
3510 nativeErrorAction::SendErrorMessage {mut msg, } => {
3511 ErrorAction::SendErrorMessage {
3512 msg: crate::ln::msgs::ErrorMessage { inner: Box::into_raw(Box::new(msg)), is_owned: true },
3519 pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { }
3521 use lightning::ln::msgs::LightningError as nativeLightningErrorImport;
3522 type nativeLightningError = nativeLightningErrorImport;
3524 /// An Err type for failure to process messages.
3527 pub struct LightningError {
3528 /// Nearly everyhwere, inner must be non-null, however in places where
3529 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3530 pub inner: *mut nativeLightningError,
3534 impl Drop for LightningError {
3535 fn drop(&mut self) {
3536 if self.is_owned && !self.inner.is_null() {
3537 let _ = unsafe { Box::from_raw(self.inner) };
3542 pub extern "C" fn LightningError_free(this_ptr: LightningError) { }
3544 /// Used only if an object of this type is returned as a trait impl by a method
3545 extern "C" fn LightningError_free_void(this_ptr: *mut c_void) {
3546 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeLightningError); }
3549 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3550 impl LightningError {
3551 pub(crate) fn take_ptr(mut self) -> *mut nativeLightningError {
3552 assert!(self.is_owned);
3553 let ret = self.inner;
3554 self.inner = std::ptr::null_mut();
3558 /// A human-readable message describing the error
3560 pub extern "C" fn LightningError_get_err(this_ptr: &LightningError) -> crate::c_types::Str {
3561 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.err;
3562 (*inner_val).as_str().into()
3564 /// A human-readable message describing the error
3566 pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: crate::c_types::derived::CVec_u8Z) {
3567 unsafe { &mut *this_ptr.inner }.err = String::from_utf8(val.into_rust()).unwrap();
3569 /// The action which should be taken against the offending peer.
3571 pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate::ln::msgs::ErrorAction {
3572 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.action;
3573 crate::ln::msgs::ErrorAction::from_native(&(*inner_val))
3575 /// The action which should be taken against the offending peer.
3577 pub extern "C" fn LightningError_set_action(this_ptr: &mut LightningError, mut val: crate::ln::msgs::ErrorAction) {
3578 unsafe { &mut *this_ptr.inner }.action = val.into_native();
3582 pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::derived::CVec_u8Z, mut action_arg: crate::ln::msgs::ErrorAction) -> LightningError {
3583 LightningError { inner: Box::into_raw(Box::new(nativeLightningError {
3584 err: String::from_utf8(err_arg.into_rust()).unwrap(),
3585 action: action_arg.into_native(),
3586 })), is_owned: true }
3589 use lightning::ln::msgs::CommitmentUpdate as nativeCommitmentUpdateImport;
3590 type nativeCommitmentUpdate = nativeCommitmentUpdateImport;
3592 /// Struct used to return values from revoke_and_ack messages, containing a bunch of commitment
3593 /// transaction updates if they were pending.
3596 pub struct CommitmentUpdate {
3597 /// Nearly everyhwere, inner must be non-null, however in places where
3598 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3599 pub inner: *mut nativeCommitmentUpdate,
3603 impl Drop for CommitmentUpdate {
3604 fn drop(&mut self) {
3605 if self.is_owned && !self.inner.is_null() {
3606 let _ = unsafe { Box::from_raw(self.inner) };
3611 pub extern "C" fn CommitmentUpdate_free(this_ptr: CommitmentUpdate) { }
3613 /// Used only if an object of this type is returned as a trait impl by a method
3614 extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) {
3615 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentUpdate); }
3618 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3619 impl CommitmentUpdate {
3620 pub(crate) fn take_ptr(mut self) -> *mut nativeCommitmentUpdate {
3621 assert!(self.is_owned);
3622 let ret = self.inner;
3623 self.inner = std::ptr::null_mut();
3627 impl Clone for CommitmentUpdate {
3628 fn clone(&self) -> Self {
3630 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
3636 /// Used only if an object of this type is returned as a trait impl by a method
3637 pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
3638 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentUpdate)).clone() })) as *mut c_void
3640 /// update_add_htlc messages which should be sent
3642 pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) {
3643 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); };
3644 unsafe { &mut *this_ptr.inner }.update_add_htlcs = local_val;
3646 /// update_fulfill_htlc messages which should be sent
3648 pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) {
3649 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); };
3650 unsafe { &mut *this_ptr.inner }.update_fulfill_htlcs = local_val;
3652 /// update_fail_htlc messages which should be sent
3654 pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) {
3655 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); };
3656 unsafe { &mut *this_ptr.inner }.update_fail_htlcs = local_val;
3658 /// update_fail_malformed_htlc messages which should be sent
3660 pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) {
3661 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); };
3662 unsafe { &mut *this_ptr.inner }.update_fail_malformed_htlcs = local_val;
3664 /// An update_fee message which should be sent
3666 pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::ln::msgs::UpdateFee {
3667 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.update_fee;
3668 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 };
3671 /// An update_fee message which should be sent
3673 pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdate, mut val: crate::ln::msgs::UpdateFee) {
3674 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_ptr()) } }) };
3675 unsafe { &mut *this_ptr.inner }.update_fee = local_val;
3677 /// Finally, the commitment_signed message which should be sent
3679 pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::ln::msgs::CommitmentSigned {
3680 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.commitment_signed;
3681 crate::ln::msgs::CommitmentSigned { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
3683 /// Finally, the commitment_signed message which should be sent
3685 pub extern "C" fn CommitmentUpdate_set_commitment_signed(this_ptr: &mut CommitmentUpdate, mut val: crate::ln::msgs::CommitmentSigned) {
3686 unsafe { &mut *this_ptr.inner }.commitment_signed = *unsafe { Box::from_raw(val.take_ptr()) };
3690 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 {
3691 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_ptr()) } }); };
3692 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_ptr()) } }); };
3693 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_ptr()) } }); };
3694 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_ptr()) } }); };
3695 let mut local_update_fee_arg = if update_fee_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(update_fee_arg.take_ptr()) } }) };
3696 CommitmentUpdate { inner: Box::into_raw(Box::new(nativeCommitmentUpdate {
3697 update_add_htlcs: local_update_add_htlcs_arg,
3698 update_fulfill_htlcs: local_update_fulfill_htlcs_arg,
3699 update_fail_htlcs: local_update_fail_htlcs_arg,
3700 update_fail_malformed_htlcs: local_update_fail_malformed_htlcs_arg,
3701 update_fee: local_update_fee_arg,
3702 commitment_signed: *unsafe { Box::from_raw(commitment_signed_arg.take_ptr()) },
3703 })), is_owned: true }
3705 /// The information we received from a peer along the route of a payment we originated. This is
3706 /// returned by ChannelMessageHandler::handle_update_fail_htlc to be passed into
3707 /// RoutingMessageHandler::handle_htlc_fail_channel_update to update our network map.
3711 pub enum HTLCFailChannelUpdate {
3712 /// We received an error which included a full ChannelUpdate message.
3713 ChannelUpdateMessage {
3714 msg: crate::ln::msgs::ChannelUpdate,
3716 /// We received an error which indicated only that a channel has been closed
3718 short_channel_id: u64,
3721 /// We received an error which indicated only that a node has failed
3723 node_id: crate::c_types::PublicKey,
3727 use lightning::ln::msgs::HTLCFailChannelUpdate as nativeHTLCFailChannelUpdate;
3728 impl HTLCFailChannelUpdate {
3730 pub(crate) fn to_native(&self) -> nativeHTLCFailChannelUpdate {
3732 HTLCFailChannelUpdate::ChannelUpdateMessage {ref msg, } => {
3733 let mut msg_nonref = (*msg).clone();
3734 nativeHTLCFailChannelUpdate::ChannelUpdateMessage {
3735 msg: *unsafe { Box::from_raw(msg_nonref.take_ptr()) },
3738 HTLCFailChannelUpdate::ChannelClosed {ref short_channel_id, ref is_permanent, } => {
3739 let mut short_channel_id_nonref = (*short_channel_id).clone();
3740 let mut is_permanent_nonref = (*is_permanent).clone();
3741 nativeHTLCFailChannelUpdate::ChannelClosed {
3742 short_channel_id: short_channel_id_nonref,
3743 is_permanent: is_permanent_nonref,
3746 HTLCFailChannelUpdate::NodeFailure {ref node_id, ref is_permanent, } => {
3747 let mut node_id_nonref = (*node_id).clone();
3748 let mut is_permanent_nonref = (*is_permanent).clone();
3749 nativeHTLCFailChannelUpdate::NodeFailure {
3750 node_id: node_id_nonref.into_rust(),
3751 is_permanent: is_permanent_nonref,
3757 pub(crate) fn into_native(self) -> nativeHTLCFailChannelUpdate {
3759 HTLCFailChannelUpdate::ChannelUpdateMessage {mut msg, } => {
3760 nativeHTLCFailChannelUpdate::ChannelUpdateMessage {
3761 msg: *unsafe { Box::from_raw(msg.take_ptr()) },
3764 HTLCFailChannelUpdate::ChannelClosed {mut short_channel_id, mut is_permanent, } => {
3765 nativeHTLCFailChannelUpdate::ChannelClosed {
3766 short_channel_id: short_channel_id,
3767 is_permanent: is_permanent,
3770 HTLCFailChannelUpdate::NodeFailure {mut node_id, mut is_permanent, } => {
3771 nativeHTLCFailChannelUpdate::NodeFailure {
3772 node_id: node_id.into_rust(),
3773 is_permanent: is_permanent,
3779 pub(crate) fn from_native(native: &nativeHTLCFailChannelUpdate) -> Self {
3781 nativeHTLCFailChannelUpdate::ChannelUpdateMessage {ref msg, } => {
3782 let mut msg_nonref = (*msg).clone();
3783 HTLCFailChannelUpdate::ChannelUpdateMessage {
3784 msg: crate::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
3787 nativeHTLCFailChannelUpdate::ChannelClosed {ref short_channel_id, ref is_permanent, } => {
3788 let mut short_channel_id_nonref = (*short_channel_id).clone();
3789 let mut is_permanent_nonref = (*is_permanent).clone();
3790 HTLCFailChannelUpdate::ChannelClosed {
3791 short_channel_id: short_channel_id_nonref,
3792 is_permanent: is_permanent_nonref,
3795 nativeHTLCFailChannelUpdate::NodeFailure {ref node_id, ref is_permanent, } => {
3796 let mut node_id_nonref = (*node_id).clone();
3797 let mut is_permanent_nonref = (*is_permanent).clone();
3798 HTLCFailChannelUpdate::NodeFailure {
3799 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3800 is_permanent: is_permanent_nonref,
3806 pub(crate) fn native_into(native: nativeHTLCFailChannelUpdate) -> Self {
3808 nativeHTLCFailChannelUpdate::ChannelUpdateMessage {mut msg, } => {
3809 HTLCFailChannelUpdate::ChannelUpdateMessage {
3810 msg: crate::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(msg)), is_owned: true },
3813 nativeHTLCFailChannelUpdate::ChannelClosed {mut short_channel_id, mut is_permanent, } => {
3814 HTLCFailChannelUpdate::ChannelClosed {
3815 short_channel_id: short_channel_id,
3816 is_permanent: is_permanent,
3819 nativeHTLCFailChannelUpdate::NodeFailure {mut node_id, mut is_permanent, } => {
3820 HTLCFailChannelUpdate::NodeFailure {
3821 node_id: crate::c_types::PublicKey::from_rust(&node_id),
3822 is_permanent: is_permanent,
3829 pub extern "C" fn HTLCFailChannelUpdate_free(this_ptr: HTLCFailChannelUpdate) { }
3830 /// A trait to describe an object which can receive channel messages.
3832 /// Messages MAY be called in parallel when they originate from different their_node_ids, however
3833 /// they MUST NOT be called in parallel when the two calls have the same their_node_id.
3835 pub struct ChannelMessageHandler {
3836 pub this_arg: *mut c_void,
3837 /// Handle an incoming open_channel message from the given peer.
3838 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),
3839 /// Handle an incoming accept_channel message from the given peer.
3840 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),
3841 /// Handle an incoming funding_created message from the given peer.
3842 pub handle_funding_created: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingCreated),
3843 /// Handle an incoming funding_signed message from the given peer.
3844 pub handle_funding_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingSigned),
3845 /// Handle an incoming funding_locked message from the given peer.
3846 pub handle_funding_locked: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingLocked),
3847 /// Handle an incoming shutdown message from the given peer.
3848 pub handle_shutdown: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::Shutdown),
3849 /// Handle an incoming closing_signed message from the given peer.
3850 pub handle_closing_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ClosingSigned),
3851 /// Handle an incoming update_add_htlc message from the given peer.
3852 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),
3853 /// Handle an incoming update_fulfill_htlc message from the given peer.
3854 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),
3855 /// Handle an incoming update_fail_htlc message from the given peer.
3856 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),
3857 /// Handle an incoming update_fail_malformed_htlc message from the given peer.
3858 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),
3859 /// Handle an incoming commitment_signed message from the given peer.
3860 pub handle_commitment_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::CommitmentSigned),
3861 /// Handle an incoming revoke_and_ack message from the given peer.
3862 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),
3863 /// Handle an incoming update_fee message from the given peer.
3864 pub handle_update_fee: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFee),
3865 /// Handle an incoming announcement_signatures message from the given peer.
3866 pub handle_announcement_signatures: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::AnnouncementSignatures),
3867 /// Indicates a connection to the peer failed/an existing connection was lost. If no connection
3868 /// is believed to be possible in the future (eg they're sending us messages we don't
3869 /// understand or indicate they require unknown feature bits), no_connection_possible is set
3870 /// and any outstanding channels should be failed.
3871 pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, no_connection_possible: bool),
3872 /// Handle a peer reconnecting, possibly generating channel_reestablish message(s).
3873 pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::Init),
3874 /// Handle an incoming channel_reestablish message from the given peer.
3875 pub handle_channel_reestablish: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ChannelReestablish),
3876 /// Handle an incoming error message from the given peer.
3877 pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ErrorMessage),
3878 pub MessageSendEventsProvider: crate::util::events::MessageSendEventsProvider,
3879 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
3881 impl lightning::util::events::MessageSendEventsProvider for ChannelMessageHandler {
3882 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
3883 <crate::util::events::MessageSendEventsProvider as lightning::util::events::MessageSendEventsProvider>::get_and_clear_pending_msg_events(&self.MessageSendEventsProvider)
3886 unsafe impl Send for ChannelMessageHandler {}
3887 unsafe impl Sync for ChannelMessageHandler {}
3889 use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler;
3890 impl rustChannelMessageHandler for ChannelMessageHandler {
3891 fn handle_open_channel(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, their_features: lightning::ln::features::InitFeatures, msg: &lightning::ln::msgs::OpenChannel) {
3892 (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 })
3894 fn handle_accept_channel(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, their_features: lightning::ln::features::InitFeatures, msg: &lightning::ln::msgs::AcceptChannel) {
3895 (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 })
3897 fn handle_funding_created(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::FundingCreated) {
3898 (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 })
3900 fn handle_funding_signed(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::FundingSigned) {
3901 (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 })
3903 fn handle_funding_locked(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::FundingLocked) {
3904 (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 })
3906 fn handle_shutdown(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::Shutdown) {
3907 (self.handle_shutdown)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::Shutdown { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false })
3909 fn handle_closing_signed(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::ClosingSigned) {
3910 (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 })
3912 fn handle_update_add_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateAddHTLC) {
3913 (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 })
3915 fn handle_update_fulfill_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFulfillHTLC) {
3916 (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 })
3918 fn handle_update_fail_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFailHTLC) {
3919 (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 })
3921 fn handle_update_fail_malformed_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) {
3922 (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 })
3924 fn handle_commitment_signed(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::CommitmentSigned) {
3925 (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 })
3927 fn handle_revoke_and_ack(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::RevokeAndACK) {
3928 (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 })
3930 fn handle_update_fee(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFee) {
3931 (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 })
3933 fn handle_announcement_signatures(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::AnnouncementSignatures) {
3934 (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 })
3936 fn peer_disconnected(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, no_connection_possible: bool) {
3937 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), no_connection_possible)
3939 fn peer_connected(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::Init) {
3940 (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 })
3942 fn handle_channel_reestablish(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::ChannelReestablish) {
3943 (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 })
3945 fn handle_error(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::ErrorMessage) {
3946 (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 })
3950 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
3951 // directly as a Deref trait in higher-level structs:
3952 impl std::ops::Deref for ChannelMessageHandler {
3954 fn deref(&self) -> &Self {
3958 /// Calls the free function if one is set
3960 pub extern "C" fn ChannelMessageHandler_free(this_ptr: ChannelMessageHandler) { }
3961 impl Drop for ChannelMessageHandler {
3962 fn drop(&mut self) {
3963 if let Some(f) = self.free {
3968 /// A trait to describe an object which can receive routing messages.
3970 pub struct RoutingMessageHandler {
3971 pub this_arg: *mut c_void,
3972 /// Handle an incoming node_announcement message, returning true if it should be forwarded on,
3973 /// false or returning an Err otherwise.
3975 pub handle_node_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
3976 /// Handle a channel_announcement message, returning true if it should be forwarded on, false
3977 /// or returning an Err otherwise.
3979 pub handle_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
3980 /// Handle an incoming channel_update message, returning true if it should be forwarded on,
3981 /// false or returning an Err otherwise.
3983 pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ,
3984 /// Handle some updates to the route graph that we learned due to an outbound failed payment.
3985 pub handle_htlc_fail_channel_update: extern "C" fn (this_arg: *const c_void, update: &crate::ln::msgs::HTLCFailChannelUpdate),
3986 /// Gets a subset of the channel announcements and updates required to dump our routing table
3987 /// to a remote node, starting at the short_channel_id indicated by starting_point and
3988 /// including the batch_amount entries immediately higher in numerical value than starting_point.
3990 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,
3991 /// Gets a subset of the node announcements required to dump our routing table to a remote node,
3992 /// starting at the node *after* the provided publickey and including batch_amount entries
3993 /// immediately higher (as defined by <PublicKey as Ord>::cmp) than starting_point.
3994 /// If None is provided for starting_point, we start at the first node.
3996 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,
3997 /// Returns whether a full sync should be requested from a peer.
3999 pub should_request_full_sync: extern "C" fn (this_arg: *const c_void, node_id: crate::c_types::PublicKey) -> bool,
4000 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
4002 unsafe impl Send for RoutingMessageHandler {}
4003 unsafe impl Sync for RoutingMessageHandler {}
4005 use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler;
4006 impl rustRoutingMessageHandler for RoutingMessageHandler {
4007 fn handle_node_announcement(&self, msg: &lightning::ln::msgs::NodeAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
4008 let mut ret = (self.handle_node_announcement)(self.this_arg, &crate::ln::msgs::NodeAnnouncement { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false });
4009 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(ret.contents.result.take_ptr()) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(ret.contents.err.take_ptr()) }).take_ptr()) } })};
4012 fn handle_channel_announcement(&self, msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
4013 let mut ret = (self.handle_channel_announcement)(self.this_arg, &crate::ln::msgs::ChannelAnnouncement { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false });
4014 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(ret.contents.result.take_ptr()) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(ret.contents.err.take_ptr()) }).take_ptr()) } })};
4017 fn handle_channel_update(&self, msg: &lightning::ln::msgs::ChannelUpdate) -> Result<bool, lightning::ln::msgs::LightningError> {
4018 let mut ret = (self.handle_channel_update)(self.this_arg, &crate::ln::msgs::ChannelUpdate { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false });
4019 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(ret.contents.result.take_ptr()) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(ret.contents.err.take_ptr()) }).take_ptr()) } })};
4022 fn handle_htlc_fail_channel_update(&self, update: &lightning::ln::msgs::HTLCFailChannelUpdate) {
4023 (self.handle_htlc_fail_channel_update)(self.this_arg, &crate::ln::msgs::HTLCFailChannelUpdate::from_native(&update))
4025 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>)> {
4026 let mut ret = (self.get_next_channel_announcements)(self.this_arg, starting_point, batch_amount);
4027 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_ptr()) } }) }; 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_ptr()) } }) }; let mut local_ret_0 = (*unsafe { Box::from_raw(orig_ret_0_0.take_ptr()) }, local_orig_ret_0_1, local_orig_ret_0_2); local_ret_0 }); };
4030 fn get_next_node_announcements(&self, starting_point: Option<&bitcoin::secp256k1::key::PublicKey>, batch_amount: u8) -> Vec<lightning::ln::msgs::NodeAnnouncement> {
4031 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())) } };
4032 let mut ret = (self.get_next_node_announcements)(self.this_arg, local_starting_point, batch_amount);
4033 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); };
4036 fn should_request_full_sync(&self, node_id: &bitcoin::secp256k1::key::PublicKey) -> bool {
4037 let mut ret = (self.should_request_full_sync)(self.this_arg, crate::c_types::PublicKey::from_rust(&node_id));
4042 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
4043 // directly as a Deref trait in higher-level structs:
4044 impl std::ops::Deref for RoutingMessageHandler {
4046 fn deref(&self) -> &Self {
4050 /// Calls the free function if one is set
4052 pub extern "C" fn RoutingMessageHandler_free(this_ptr: RoutingMessageHandler) { }
4053 impl Drop for RoutingMessageHandler {
4054 fn drop(&mut self) {
4055 if let Some(f) = self.free {
4061 pub extern "C" fn AcceptChannel_write(obj: *const AcceptChannel) -> crate::c_types::derived::CVec_u8Z {
4062 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4065 pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> AcceptChannel {
4066 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4067 AcceptChannel { inner: Box::into_raw(Box::new(res)), is_owned: true }
4069 AcceptChannel { inner: std::ptr::null_mut(), is_owned: true }
4073 pub extern "C" fn AnnouncementSignatures_write(obj: *const AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z {
4074 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4077 pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> AnnouncementSignatures {
4078 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4079 AnnouncementSignatures { inner: Box::into_raw(Box::new(res)), is_owned: true }
4081 AnnouncementSignatures { inner: std::ptr::null_mut(), is_owned: true }
4085 pub extern "C" fn ChannelReestablish_write(obj: *const ChannelReestablish) -> crate::c_types::derived::CVec_u8Z {
4086 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4089 pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> ChannelReestablish {
4090 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4091 ChannelReestablish { inner: Box::into_raw(Box::new(res)), is_owned: true }
4093 ChannelReestablish { inner: std::ptr::null_mut(), is_owned: true }
4097 pub extern "C" fn ClosingSigned_write(obj: *const ClosingSigned) -> crate::c_types::derived::CVec_u8Z {
4098 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4101 pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> ClosingSigned {
4102 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4103 ClosingSigned { inner: Box::into_raw(Box::new(res)), is_owned: true }
4105 ClosingSigned { inner: std::ptr::null_mut(), is_owned: true }
4109 pub extern "C" fn CommitmentSigned_write(obj: *const CommitmentSigned) -> crate::c_types::derived::CVec_u8Z {
4110 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4113 pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> CommitmentSigned {
4114 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4115 CommitmentSigned { inner: Box::into_raw(Box::new(res)), is_owned: true }
4117 CommitmentSigned { inner: std::ptr::null_mut(), is_owned: true }
4121 pub extern "C" fn FundingCreated_write(obj: *const FundingCreated) -> crate::c_types::derived::CVec_u8Z {
4122 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4125 pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> FundingCreated {
4126 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4127 FundingCreated { inner: Box::into_raw(Box::new(res)), is_owned: true }
4129 FundingCreated { inner: std::ptr::null_mut(), is_owned: true }
4133 pub extern "C" fn FundingSigned_write(obj: *const FundingSigned) -> crate::c_types::derived::CVec_u8Z {
4134 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4137 pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> FundingSigned {
4138 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4139 FundingSigned { inner: Box::into_raw(Box::new(res)), is_owned: true }
4141 FundingSigned { inner: std::ptr::null_mut(), is_owned: true }
4145 pub extern "C" fn FundingLocked_write(obj: *const FundingLocked) -> crate::c_types::derived::CVec_u8Z {
4146 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4149 pub extern "C" fn FundingLocked_read(ser: crate::c_types::u8slice) -> FundingLocked {
4150 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4151 FundingLocked { inner: Box::into_raw(Box::new(res)), is_owned: true }
4153 FundingLocked { inner: std::ptr::null_mut(), is_owned: true }
4157 pub extern "C" fn Init_write(obj: *const Init) -> crate::c_types::derived::CVec_u8Z {
4158 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4161 pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> Init {
4162 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4163 Init { inner: Box::into_raw(Box::new(res)), is_owned: true }
4165 Init { inner: std::ptr::null_mut(), is_owned: true }
4169 pub extern "C" fn OpenChannel_write(obj: *const OpenChannel) -> crate::c_types::derived::CVec_u8Z {
4170 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4173 pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> OpenChannel {
4174 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4175 OpenChannel { inner: Box::into_raw(Box::new(res)), is_owned: true }
4177 OpenChannel { inner: std::ptr::null_mut(), is_owned: true }
4181 pub extern "C" fn RevokeAndACK_write(obj: *const RevokeAndACK) -> crate::c_types::derived::CVec_u8Z {
4182 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4185 pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> RevokeAndACK {
4186 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4187 RevokeAndACK { inner: Box::into_raw(Box::new(res)), is_owned: true }
4189 RevokeAndACK { inner: std::ptr::null_mut(), is_owned: true }
4193 pub extern "C" fn Shutdown_write(obj: *const Shutdown) -> crate::c_types::derived::CVec_u8Z {
4194 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4197 pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> Shutdown {
4198 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4199 Shutdown { inner: Box::into_raw(Box::new(res)), is_owned: true }
4201 Shutdown { inner: std::ptr::null_mut(), is_owned: true }
4205 pub extern "C" fn UpdateFailHTLC_write(obj: *const UpdateFailHTLC) -> crate::c_types::derived::CVec_u8Z {
4206 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4209 pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> UpdateFailHTLC {
4210 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4211 UpdateFailHTLC { inner: Box::into_raw(Box::new(res)), is_owned: true }
4213 UpdateFailHTLC { inner: std::ptr::null_mut(), is_owned: true }
4217 pub extern "C" fn UpdateFailMalformedHTLC_write(obj: *const UpdateFailMalformedHTLC) -> crate::c_types::derived::CVec_u8Z {
4218 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4221 pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> UpdateFailMalformedHTLC {
4222 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4223 UpdateFailMalformedHTLC { inner: Box::into_raw(Box::new(res)), is_owned: true }
4225 UpdateFailMalformedHTLC { inner: std::ptr::null_mut(), is_owned: true }
4229 pub extern "C" fn UpdateFee_write(obj: *const UpdateFee) -> crate::c_types::derived::CVec_u8Z {
4230 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4233 pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> UpdateFee {
4234 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4235 UpdateFee { inner: Box::into_raw(Box::new(res)), is_owned: true }
4237 UpdateFee { inner: std::ptr::null_mut(), is_owned: true }
4241 pub extern "C" fn UpdateFulfillHTLC_write(obj: *const UpdateFulfillHTLC) -> crate::c_types::derived::CVec_u8Z {
4242 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4245 pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> UpdateFulfillHTLC {
4246 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4247 UpdateFulfillHTLC { inner: Box::into_raw(Box::new(res)), is_owned: true }
4249 UpdateFulfillHTLC { inner: std::ptr::null_mut(), is_owned: true }
4253 pub extern "C" fn UpdateAddHTLC_write(obj: *const UpdateAddHTLC) -> crate::c_types::derived::CVec_u8Z {
4254 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4257 pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> UpdateAddHTLC {
4258 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4259 UpdateAddHTLC { inner: Box::into_raw(Box::new(res)), is_owned: true }
4261 UpdateAddHTLC { inner: std::ptr::null_mut(), is_owned: true }
4265 pub extern "C" fn Ping_write(obj: *const Ping) -> crate::c_types::derived::CVec_u8Z {
4266 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4269 pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> Ping {
4270 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4271 Ping { inner: Box::into_raw(Box::new(res)), is_owned: true }
4273 Ping { inner: std::ptr::null_mut(), is_owned: true }
4277 pub extern "C" fn Pong_write(obj: *const Pong) -> crate::c_types::derived::CVec_u8Z {
4278 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4281 pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> Pong {
4282 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4283 Pong { inner: Box::into_raw(Box::new(res)), is_owned: true }
4285 Pong { inner: std::ptr::null_mut(), is_owned: true }
4289 pub extern "C" fn UnsignedChannelAnnouncement_write(obj: *const UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
4290 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4293 pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> UnsignedChannelAnnouncement {
4294 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4295 UnsignedChannelAnnouncement { inner: Box::into_raw(Box::new(res)), is_owned: true }
4297 UnsignedChannelAnnouncement { inner: std::ptr::null_mut(), is_owned: true }
4301 pub extern "C" fn ChannelAnnouncement_write(obj: *const ChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
4302 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4305 pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> ChannelAnnouncement {
4306 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4307 ChannelAnnouncement { inner: Box::into_raw(Box::new(res)), is_owned: true }
4309 ChannelAnnouncement { inner: std::ptr::null_mut(), is_owned: true }
4313 pub extern "C" fn UnsignedChannelUpdate_write(obj: *const UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
4314 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4317 pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> UnsignedChannelUpdate {
4318 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4319 UnsignedChannelUpdate { inner: Box::into_raw(Box::new(res)), is_owned: true }
4321 UnsignedChannelUpdate { inner: std::ptr::null_mut(), is_owned: true }
4325 pub extern "C" fn ChannelUpdate_write(obj: *const ChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
4326 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4329 pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> ChannelUpdate {
4330 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4331 ChannelUpdate { inner: Box::into_raw(Box::new(res)), is_owned: true }
4333 ChannelUpdate { inner: std::ptr::null_mut(), is_owned: true }
4337 pub extern "C" fn ErrorMessage_write(obj: *const ErrorMessage) -> crate::c_types::derived::CVec_u8Z {
4338 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4341 pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> ErrorMessage {
4342 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4343 ErrorMessage { inner: Box::into_raw(Box::new(res)), is_owned: true }
4345 ErrorMessage { inner: std::ptr::null_mut(), is_owned: true }
4349 pub extern "C" fn UnsignedNodeAnnouncement_write(obj: *const UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
4350 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4353 pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> UnsignedNodeAnnouncement {
4354 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4355 UnsignedNodeAnnouncement { inner: Box::into_raw(Box::new(res)), is_owned: true }
4357 UnsignedNodeAnnouncement { inner: std::ptr::null_mut(), is_owned: true }
4361 pub extern "C" fn NodeAnnouncement_write(obj: *const NodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
4362 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4365 pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> NodeAnnouncement {
4366 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4367 NodeAnnouncement { inner: Box::into_raw(Box::new(res)), is_owned: true }
4369 NodeAnnouncement { inner: std::ptr::null_mut(), is_owned: true }
4373 pub extern "C" fn QueryShortChannelIds_read(ser: crate::c_types::u8slice) -> QueryShortChannelIds {
4374 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4375 QueryShortChannelIds { inner: Box::into_raw(Box::new(res)), is_owned: true }
4377 QueryShortChannelIds { inner: std::ptr::null_mut(), is_owned: true }
4381 pub extern "C" fn QueryShortChannelIds_write(obj: *const QueryShortChannelIds) -> crate::c_types::derived::CVec_u8Z {
4382 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4385 pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> ReplyShortChannelIdsEnd {
4386 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4387 ReplyShortChannelIdsEnd { inner: Box::into_raw(Box::new(res)), is_owned: true }
4389 ReplyShortChannelIdsEnd { inner: std::ptr::null_mut(), is_owned: true }
4393 pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: *const ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z {
4394 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4397 pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> QueryChannelRange {
4398 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4399 QueryChannelRange { inner: Box::into_raw(Box::new(res)), is_owned: true }
4401 QueryChannelRange { inner: std::ptr::null_mut(), is_owned: true }
4405 pub extern "C" fn QueryChannelRange_write(obj: *const QueryChannelRange) -> crate::c_types::derived::CVec_u8Z {
4406 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4409 pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> ReplyChannelRange {
4410 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4411 ReplyChannelRange { inner: Box::into_raw(Box::new(res)), is_owned: true }
4413 ReplyChannelRange { inner: std::ptr::null_mut(), is_owned: true }
4417 pub extern "C" fn ReplyChannelRange_write(obj: *const ReplyChannelRange) -> crate::c_types::derived::CVec_u8Z {
4418 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4421 pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> GossipTimestampFilter {
4422 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4423 GossipTimestampFilter { inner: Box::into_raw(Box::new(res)), is_owned: true }
4425 GossipTimestampFilter { inner: std::ptr::null_mut(), is_owned: true }
4429 pub extern "C" fn GossipTimestampFilter_write(obj: *const GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z {
4430 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })