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 /// A strictly monotonic announcement counter, with gaps allowed
2336 pub extern "C" fn UnsignedNodeAnnouncement_get_timestamp(this_ptr: &UnsignedNodeAnnouncement) -> u32 {
2337 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp;
2340 /// A strictly monotonic announcement counter, with gaps allowed
2342 pub extern "C" fn UnsignedNodeAnnouncement_set_timestamp(this_ptr: &mut UnsignedNodeAnnouncement, mut val: u32) {
2343 unsafe { &mut *this_ptr.inner }.timestamp = val;
2345 /// The node_id this announcement originated from (don't rebroadcast the node_announcement back
2348 pub extern "C" fn UnsignedNodeAnnouncement_get_node_id(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::PublicKey {
2349 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_id;
2350 crate::c_types::PublicKey::from_rust(&(*inner_val))
2352 /// The node_id this announcement originated from (don't rebroadcast the node_announcement back
2355 pub extern "C" fn UnsignedNodeAnnouncement_set_node_id(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::PublicKey) {
2356 unsafe { &mut *this_ptr.inner }.node_id = val.into_rust();
2358 /// An RGB color for UI purposes
2360 pub extern "C" fn UnsignedNodeAnnouncement_get_rgb(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 3] {
2361 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.rgb;
2364 /// An RGB color for UI purposes
2366 pub extern "C" fn UnsignedNodeAnnouncement_set_rgb(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThreeBytes) {
2367 unsafe { &mut *this_ptr.inner }.rgb = val.data;
2369 /// An alias, for UI purposes. This should be sanitized before use. There is no guarantee
2372 pub extern "C" fn UnsignedNodeAnnouncement_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 32] {
2373 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.alias;
2376 /// An alias, for UI purposes. This should be sanitized before use. There is no guarantee
2379 pub extern "C" fn UnsignedNodeAnnouncement_set_alias(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
2380 unsafe { &mut *this_ptr.inner }.alias = val.data;
2382 /// List of addresses on which this node is reachable
2384 pub extern "C" fn UnsignedNodeAnnouncement_set_addresses(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_NetAddressZ) {
2385 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
2386 unsafe { &mut *this_ptr.inner }.addresses = local_val;
2389 use lightning::ln::msgs::NodeAnnouncement as nativeNodeAnnouncementImport;
2390 type nativeNodeAnnouncement = nativeNodeAnnouncementImport;
2392 /// A node_announcement message to be sent or received from a peer
2395 pub struct NodeAnnouncement {
2396 /// Nearly everyhwere, inner must be non-null, however in places where
2397 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2398 pub inner: *mut nativeNodeAnnouncement,
2402 impl Drop for NodeAnnouncement {
2403 fn drop(&mut self) {
2404 if self.is_owned && !self.inner.is_null() {
2405 let _ = unsafe { Box::from_raw(self.inner) };
2410 pub extern "C" fn NodeAnnouncement_free(this_ptr: NodeAnnouncement) { }
2412 /// Used only if an object of this type is returned as a trait impl by a method
2413 extern "C" fn NodeAnnouncement_free_void(this_ptr: *mut c_void) {
2414 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeAnnouncement); }
2417 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2418 impl NodeAnnouncement {
2419 pub(crate) fn take_ptr(mut self) -> *mut nativeNodeAnnouncement {
2420 assert!(self.is_owned);
2421 let ret = self.inner;
2422 self.inner = std::ptr::null_mut();
2426 impl Clone for NodeAnnouncement {
2427 fn clone(&self) -> Self {
2429 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
2435 /// Used only if an object of this type is returned as a trait impl by a method
2436 pub(crate) extern "C" fn NodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
2437 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeAnnouncement)).clone() })) as *mut c_void
2439 /// The signature by the node key
2441 pub extern "C" fn NodeAnnouncement_get_signature(this_ptr: &NodeAnnouncement) -> crate::c_types::Signature {
2442 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
2443 crate::c_types::Signature::from_rust(&(*inner_val))
2445 /// The signature by the node key
2447 pub extern "C" fn NodeAnnouncement_set_signature(this_ptr: &mut NodeAnnouncement, mut val: crate::c_types::Signature) {
2448 unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
2450 /// The actual content of the announcement
2452 pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> crate::ln::msgs::UnsignedNodeAnnouncement {
2453 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents;
2454 crate::ln::msgs::UnsignedNodeAnnouncement { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
2456 /// The actual content of the announcement
2458 pub extern "C" fn NodeAnnouncement_set_contents(this_ptr: &mut NodeAnnouncement, mut val: crate::ln::msgs::UnsignedNodeAnnouncement) {
2459 unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_ptr()) };
2463 pub extern "C" fn NodeAnnouncement_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::ln::msgs::UnsignedNodeAnnouncement) -> NodeAnnouncement {
2464 NodeAnnouncement { inner: Box::into_raw(Box::new(nativeNodeAnnouncement {
2465 signature: signature_arg.into_rust(),
2466 contents: *unsafe { Box::from_raw(contents_arg.take_ptr()) },
2467 })), is_owned: true }
2470 use lightning::ln::msgs::UnsignedChannelAnnouncement as nativeUnsignedChannelAnnouncementImport;
2471 type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport;
2473 /// The unsigned part of a channel_announcement
2476 pub struct UnsignedChannelAnnouncement {
2477 /// Nearly everyhwere, inner must be non-null, however in places where
2478 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2479 pub inner: *mut nativeUnsignedChannelAnnouncement,
2483 impl Drop for UnsignedChannelAnnouncement {
2484 fn drop(&mut self) {
2485 if self.is_owned && !self.inner.is_null() {
2486 let _ = unsafe { Box::from_raw(self.inner) };
2491 pub extern "C" fn UnsignedChannelAnnouncement_free(this_ptr: UnsignedChannelAnnouncement) { }
2493 /// Used only if an object of this type is returned as a trait impl by a method
2494 extern "C" fn UnsignedChannelAnnouncement_free_void(this_ptr: *mut c_void) {
2495 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelAnnouncement); }
2498 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2499 impl UnsignedChannelAnnouncement {
2500 pub(crate) fn take_ptr(mut self) -> *mut nativeUnsignedChannelAnnouncement {
2501 assert!(self.is_owned);
2502 let ret = self.inner;
2503 self.inner = std::ptr::null_mut();
2507 impl Clone for UnsignedChannelAnnouncement {
2508 fn clone(&self) -> Self {
2510 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
2516 /// Used only if an object of this type is returned as a trait impl by a method
2517 pub(crate) extern "C" fn UnsignedChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
2518 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelAnnouncement)).clone() })) as *mut c_void
2520 /// The genesis hash of the blockchain where the channel is to be opened
2522 pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &UnsignedChannelAnnouncement) -> *const [u8; 32] {
2523 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
2524 (*inner_val).as_inner()
2526 /// The genesis hash of the blockchain where the channel is to be opened
2528 pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
2529 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
2531 /// The short channel ID
2533 pub extern "C" fn UnsignedChannelAnnouncement_get_short_channel_id(this_ptr: &UnsignedChannelAnnouncement) -> u64 {
2534 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id;
2537 /// The short channel ID
2539 pub extern "C" fn UnsignedChannelAnnouncement_set_short_channel_id(this_ptr: &mut UnsignedChannelAnnouncement, mut val: u64) {
2540 unsafe { &mut *this_ptr.inner }.short_channel_id = val;
2542 /// One of the two node_ids which are endpoints of this channel
2544 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
2545 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_id_1;
2546 crate::c_types::PublicKey::from_rust(&(*inner_val))
2548 /// One of the two node_ids which are endpoints of this channel
2550 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
2551 unsafe { &mut *this_ptr.inner }.node_id_1 = val.into_rust();
2553 /// The other of the two node_ids which are endpoints of this channel
2555 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
2556 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_id_2;
2557 crate::c_types::PublicKey::from_rust(&(*inner_val))
2559 /// The other of the two node_ids which are endpoints of this channel
2561 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
2562 unsafe { &mut *this_ptr.inner }.node_id_2 = val.into_rust();
2564 /// The funding key for the first node
2566 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
2567 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_key_1;
2568 crate::c_types::PublicKey::from_rust(&(*inner_val))
2570 /// The funding key for the first node
2572 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
2573 unsafe { &mut *this_ptr.inner }.bitcoin_key_1 = val.into_rust();
2575 /// The funding key for the second node
2577 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
2578 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_key_2;
2579 crate::c_types::PublicKey::from_rust(&(*inner_val))
2581 /// The funding key for the second node
2583 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
2584 unsafe { &mut *this_ptr.inner }.bitcoin_key_2 = val.into_rust();
2587 use lightning::ln::msgs::ChannelAnnouncement as nativeChannelAnnouncementImport;
2588 type nativeChannelAnnouncement = nativeChannelAnnouncementImport;
2590 /// A channel_announcement message to be sent or received from a peer
2593 pub struct ChannelAnnouncement {
2594 /// Nearly everyhwere, inner must be non-null, however in places where
2595 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2596 pub inner: *mut nativeChannelAnnouncement,
2600 impl Drop for ChannelAnnouncement {
2601 fn drop(&mut self) {
2602 if self.is_owned && !self.inner.is_null() {
2603 let _ = unsafe { Box::from_raw(self.inner) };
2608 pub extern "C" fn ChannelAnnouncement_free(this_ptr: ChannelAnnouncement) { }
2610 /// Used only if an object of this type is returned as a trait impl by a method
2611 extern "C" fn ChannelAnnouncement_free_void(this_ptr: *mut c_void) {
2612 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelAnnouncement); }
2615 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2616 impl ChannelAnnouncement {
2617 pub(crate) fn take_ptr(mut self) -> *mut nativeChannelAnnouncement {
2618 assert!(self.is_owned);
2619 let ret = self.inner;
2620 self.inner = std::ptr::null_mut();
2624 impl Clone for ChannelAnnouncement {
2625 fn clone(&self) -> Self {
2627 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
2633 /// Used only if an object of this type is returned as a trait impl by a method
2634 pub(crate) extern "C" fn ChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
2635 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelAnnouncement)).clone() })) as *mut c_void
2637 /// Authentication of the announcement by the first public node
2639 pub extern "C" fn ChannelAnnouncement_get_node_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
2640 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_signature_1;
2641 crate::c_types::Signature::from_rust(&(*inner_val))
2643 /// Authentication of the announcement by the first public node
2645 pub extern "C" fn ChannelAnnouncement_set_node_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
2646 unsafe { &mut *this_ptr.inner }.node_signature_1 = val.into_rust();
2648 /// Authentication of the announcement by the second public node
2650 pub extern "C" fn ChannelAnnouncement_get_node_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
2651 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_signature_2;
2652 crate::c_types::Signature::from_rust(&(*inner_val))
2654 /// Authentication of the announcement by the second public node
2656 pub extern "C" fn ChannelAnnouncement_set_node_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
2657 unsafe { &mut *this_ptr.inner }.node_signature_2 = val.into_rust();
2659 /// Proof of funding UTXO ownership by the first public node
2661 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
2662 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_signature_1;
2663 crate::c_types::Signature::from_rust(&(*inner_val))
2665 /// Proof of funding UTXO ownership by the first public node
2667 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
2668 unsafe { &mut *this_ptr.inner }.bitcoin_signature_1 = val.into_rust();
2670 /// Proof of funding UTXO ownership by the second public node
2672 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
2673 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_signature_2;
2674 crate::c_types::Signature::from_rust(&(*inner_val))
2676 /// Proof of funding UTXO ownership by the second public node
2678 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
2679 unsafe { &mut *this_ptr.inner }.bitcoin_signature_2 = val.into_rust();
2681 /// The actual announcement
2683 pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncement) -> crate::ln::msgs::UnsignedChannelAnnouncement {
2684 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents;
2685 crate::ln::msgs::UnsignedChannelAnnouncement { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
2687 /// The actual announcement
2689 pub extern "C" fn ChannelAnnouncement_set_contents(this_ptr: &mut ChannelAnnouncement, mut val: crate::ln::msgs::UnsignedChannelAnnouncement) {
2690 unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_ptr()) };
2694 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 {
2695 ChannelAnnouncement { inner: Box::into_raw(Box::new(nativeChannelAnnouncement {
2696 node_signature_1: node_signature_1_arg.into_rust(),
2697 node_signature_2: node_signature_2_arg.into_rust(),
2698 bitcoin_signature_1: bitcoin_signature_1_arg.into_rust(),
2699 bitcoin_signature_2: bitcoin_signature_2_arg.into_rust(),
2700 contents: *unsafe { Box::from_raw(contents_arg.take_ptr()) },
2701 })), is_owned: true }
2704 use lightning::ln::msgs::UnsignedChannelUpdate as nativeUnsignedChannelUpdateImport;
2705 type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport;
2707 /// The unsigned part of a channel_update
2710 pub struct UnsignedChannelUpdate {
2711 /// Nearly everyhwere, inner must be non-null, however in places where
2712 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2713 pub inner: *mut nativeUnsignedChannelUpdate,
2717 impl Drop for UnsignedChannelUpdate {
2718 fn drop(&mut self) {
2719 if self.is_owned && !self.inner.is_null() {
2720 let _ = unsafe { Box::from_raw(self.inner) };
2725 pub extern "C" fn UnsignedChannelUpdate_free(this_ptr: UnsignedChannelUpdate) { }
2727 /// Used only if an object of this type is returned as a trait impl by a method
2728 extern "C" fn UnsignedChannelUpdate_free_void(this_ptr: *mut c_void) {
2729 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelUpdate); }
2732 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2733 impl UnsignedChannelUpdate {
2734 pub(crate) fn take_ptr(mut self) -> *mut nativeUnsignedChannelUpdate {
2735 assert!(self.is_owned);
2736 let ret = self.inner;
2737 self.inner = std::ptr::null_mut();
2741 impl Clone for UnsignedChannelUpdate {
2742 fn clone(&self) -> Self {
2744 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
2750 /// Used only if an object of this type is returned as a trait impl by a method
2751 pub(crate) extern "C" fn UnsignedChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
2752 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelUpdate)).clone() })) as *mut c_void
2754 /// The genesis hash of the blockchain where the channel is to be opened
2756 pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChannelUpdate) -> *const [u8; 32] {
2757 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
2758 (*inner_val).as_inner()
2760 /// The genesis hash of the blockchain where the channel is to be opened
2762 pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::ThirtyTwoBytes) {
2763 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
2765 /// The short channel ID
2767 pub extern "C" fn UnsignedChannelUpdate_get_short_channel_id(this_ptr: &UnsignedChannelUpdate) -> u64 {
2768 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id;
2771 /// The short channel ID
2773 pub extern "C" fn UnsignedChannelUpdate_set_short_channel_id(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
2774 unsafe { &mut *this_ptr.inner }.short_channel_id = val;
2776 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
2778 pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannelUpdate) -> u32 {
2779 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp;
2782 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
2784 pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
2785 unsafe { &mut *this_ptr.inner }.timestamp = val;
2789 pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 {
2790 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.flags;
2795 pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) {
2796 unsafe { &mut *this_ptr.inner }.flags = val;
2798 /// The number of blocks to subtract from incoming HTLC cltv_expiry values
2800 pub extern "C" fn UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr: &UnsignedChannelUpdate) -> u16 {
2801 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry_delta;
2804 /// The number of blocks to subtract from incoming HTLC cltv_expiry values
2806 pub extern "C" fn UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr: &mut UnsignedChannelUpdate, mut val: u16) {
2807 unsafe { &mut *this_ptr.inner }.cltv_expiry_delta = val;
2809 /// The minimum HTLC size incoming to sender, in milli-satoshi
2811 pub extern "C" fn UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
2812 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_minimum_msat;
2815 /// The minimum HTLC size incoming to sender, in milli-satoshi
2817 pub extern "C" fn UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
2818 unsafe { &mut *this_ptr.inner }.htlc_minimum_msat = val;
2820 /// The base HTLC fee charged by sender, in milli-satoshi
2822 pub extern "C" fn UnsignedChannelUpdate_get_fee_base_msat(this_ptr: &UnsignedChannelUpdate) -> u32 {
2823 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_base_msat;
2826 /// The base HTLC fee charged by sender, in milli-satoshi
2828 pub extern "C" fn UnsignedChannelUpdate_set_fee_base_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
2829 unsafe { &mut *this_ptr.inner }.fee_base_msat = val;
2831 /// The amount to fee multiplier, in micro-satoshi
2833 pub extern "C" fn UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr: &UnsignedChannelUpdate) -> u32 {
2834 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_proportional_millionths;
2837 /// The amount to fee multiplier, in micro-satoshi
2839 pub extern "C" fn UnsignedChannelUpdate_set_fee_proportional_millionths(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
2840 unsafe { &mut *this_ptr.inner }.fee_proportional_millionths = val;
2843 use lightning::ln::msgs::ChannelUpdate as nativeChannelUpdateImport;
2844 type nativeChannelUpdate = nativeChannelUpdateImport;
2846 /// A channel_update message to be sent or received from a peer
2849 pub struct ChannelUpdate {
2850 /// Nearly everyhwere, inner must be non-null, however in places where
2851 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2852 pub inner: *mut nativeChannelUpdate,
2856 impl Drop for ChannelUpdate {
2857 fn drop(&mut self) {
2858 if self.is_owned && !self.inner.is_null() {
2859 let _ = unsafe { Box::from_raw(self.inner) };
2864 pub extern "C" fn ChannelUpdate_free(this_ptr: ChannelUpdate) { }
2866 /// Used only if an object of this type is returned as a trait impl by a method
2867 extern "C" fn ChannelUpdate_free_void(this_ptr: *mut c_void) {
2868 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelUpdate); }
2871 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2872 impl ChannelUpdate {
2873 pub(crate) fn take_ptr(mut self) -> *mut nativeChannelUpdate {
2874 assert!(self.is_owned);
2875 let ret = self.inner;
2876 self.inner = std::ptr::null_mut();
2880 impl Clone for ChannelUpdate {
2881 fn clone(&self) -> Self {
2883 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
2889 /// Used only if an object of this type is returned as a trait impl by a method
2890 pub(crate) extern "C" fn ChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
2891 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelUpdate)).clone() })) as *mut c_void
2893 /// A signature of the channel update
2895 pub extern "C" fn ChannelUpdate_get_signature(this_ptr: &ChannelUpdate) -> crate::c_types::Signature {
2896 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
2897 crate::c_types::Signature::from_rust(&(*inner_val))
2899 /// A signature of the channel update
2901 pub extern "C" fn ChannelUpdate_set_signature(this_ptr: &mut ChannelUpdate, mut val: crate::c_types::Signature) {
2902 unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
2904 /// The actual channel update
2906 pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate::ln::msgs::UnsignedChannelUpdate {
2907 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents;
2908 crate::ln::msgs::UnsignedChannelUpdate { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
2910 /// The actual channel update
2912 pub extern "C" fn ChannelUpdate_set_contents(this_ptr: &mut ChannelUpdate, mut val: crate::ln::msgs::UnsignedChannelUpdate) {
2913 unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_ptr()) };
2917 pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::ln::msgs::UnsignedChannelUpdate) -> ChannelUpdate {
2918 ChannelUpdate { inner: Box::into_raw(Box::new(nativeChannelUpdate {
2919 signature: signature_arg.into_rust(),
2920 contents: *unsafe { Box::from_raw(contents_arg.take_ptr()) },
2921 })), is_owned: true }
2923 /// Used to put an error message in a LightningError
2927 pub enum ErrorAction {
2928 /// The peer took some action which made us think they were useless. Disconnect them.
2930 msg: crate::ln::msgs::ErrorMessage,
2932 /// The peer did something harmless that we weren't able to process, just log and ignore
2934 /// The peer did something incorrect. Tell them.
2936 msg: crate::ln::msgs::ErrorMessage,
2939 use lightning::ln::msgs::ErrorAction as nativeErrorAction;
2942 pub(crate) fn to_native(&self) -> nativeErrorAction {
2944 ErrorAction::DisconnectPeer {ref msg, } => {
2945 let mut msg_nonref = (*msg).clone();
2946 let mut local_msg_nonref = if msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg_nonref.take_ptr()) } }) };
2947 nativeErrorAction::DisconnectPeer {
2948 msg: local_msg_nonref,
2951 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
2952 ErrorAction::SendErrorMessage {ref msg, } => {
2953 let mut msg_nonref = (*msg).clone();
2954 nativeErrorAction::SendErrorMessage {
2955 msg: *unsafe { Box::from_raw(msg_nonref.take_ptr()) },
2961 pub(crate) fn into_native(self) -> nativeErrorAction {
2963 ErrorAction::DisconnectPeer {mut msg, } => {
2964 let mut local_msg = if msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg.take_ptr()) } }) };
2965 nativeErrorAction::DisconnectPeer {
2969 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
2970 ErrorAction::SendErrorMessage {mut msg, } => {
2971 nativeErrorAction::SendErrorMessage {
2972 msg: *unsafe { Box::from_raw(msg.take_ptr()) },
2978 pub(crate) fn from_native(native: &nativeErrorAction) -> Self {
2980 nativeErrorAction::DisconnectPeer {ref msg, } => {
2981 let mut msg_nonref = (*msg).clone();
2982 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 };
2983 ErrorAction::DisconnectPeer {
2984 msg: local_msg_nonref,
2987 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
2988 nativeErrorAction::SendErrorMessage {ref msg, } => {
2989 let mut msg_nonref = (*msg).clone();
2990 ErrorAction::SendErrorMessage {
2991 msg: crate::ln::msgs::ErrorMessage { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
2997 pub(crate) fn native_into(native: nativeErrorAction) -> Self {
2999 nativeErrorAction::DisconnectPeer {mut msg, } => {
3000 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 };
3001 ErrorAction::DisconnectPeer {
3005 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
3006 nativeErrorAction::SendErrorMessage {mut msg, } => {
3007 ErrorAction::SendErrorMessage {
3008 msg: crate::ln::msgs::ErrorMessage { inner: Box::into_raw(Box::new(msg)), is_owned: true },
3015 pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { }
3017 use lightning::ln::msgs::LightningError as nativeLightningErrorImport;
3018 type nativeLightningError = nativeLightningErrorImport;
3020 /// An Err type for failure to process messages.
3023 pub struct LightningError {
3024 /// Nearly everyhwere, inner must be non-null, however in places where
3025 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3026 pub inner: *mut nativeLightningError,
3030 impl Drop for LightningError {
3031 fn drop(&mut self) {
3032 if self.is_owned && !self.inner.is_null() {
3033 let _ = unsafe { Box::from_raw(self.inner) };
3038 pub extern "C" fn LightningError_free(this_ptr: LightningError) { }
3040 /// Used only if an object of this type is returned as a trait impl by a method
3041 extern "C" fn LightningError_free_void(this_ptr: *mut c_void) {
3042 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeLightningError); }
3045 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3046 impl LightningError {
3047 pub(crate) fn take_ptr(mut self) -> *mut nativeLightningError {
3048 assert!(self.is_owned);
3049 let ret = self.inner;
3050 self.inner = std::ptr::null_mut();
3054 /// A human-readable message describing the error
3056 pub extern "C" fn LightningError_get_err(this_ptr: &LightningError) -> crate::c_types::Str {
3057 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.err;
3058 (*inner_val).as_str().into()
3060 /// A human-readable message describing the error
3062 pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: crate::c_types::derived::CVec_u8Z) {
3063 unsafe { &mut *this_ptr.inner }.err = String::from_utf8(val.into_rust()).unwrap();
3065 /// The action which should be taken against the offending peer.
3067 pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate::ln::msgs::ErrorAction {
3068 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.action;
3069 crate::ln::msgs::ErrorAction::from_native(&(*inner_val))
3071 /// The action which should be taken against the offending peer.
3073 pub extern "C" fn LightningError_set_action(this_ptr: &mut LightningError, mut val: crate::ln::msgs::ErrorAction) {
3074 unsafe { &mut *this_ptr.inner }.action = val.into_native();
3078 pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::derived::CVec_u8Z, mut action_arg: crate::ln::msgs::ErrorAction) -> LightningError {
3079 LightningError { inner: Box::into_raw(Box::new(nativeLightningError {
3080 err: String::from_utf8(err_arg.into_rust()).unwrap(),
3081 action: action_arg.into_native(),
3082 })), is_owned: true }
3085 use lightning::ln::msgs::CommitmentUpdate as nativeCommitmentUpdateImport;
3086 type nativeCommitmentUpdate = nativeCommitmentUpdateImport;
3088 /// Struct used to return values from revoke_and_ack messages, containing a bunch of commitment
3089 /// transaction updates if they were pending.
3092 pub struct CommitmentUpdate {
3093 /// Nearly everyhwere, inner must be non-null, however in places where
3094 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3095 pub inner: *mut nativeCommitmentUpdate,
3099 impl Drop for CommitmentUpdate {
3100 fn drop(&mut self) {
3101 if self.is_owned && !self.inner.is_null() {
3102 let _ = unsafe { Box::from_raw(self.inner) };
3107 pub extern "C" fn CommitmentUpdate_free(this_ptr: CommitmentUpdate) { }
3109 /// Used only if an object of this type is returned as a trait impl by a method
3110 extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) {
3111 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentUpdate); }
3114 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3115 impl CommitmentUpdate {
3116 pub(crate) fn take_ptr(mut self) -> *mut nativeCommitmentUpdate {
3117 assert!(self.is_owned);
3118 let ret = self.inner;
3119 self.inner = std::ptr::null_mut();
3123 impl Clone for CommitmentUpdate {
3124 fn clone(&self) -> Self {
3126 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
3132 /// Used only if an object of this type is returned as a trait impl by a method
3133 pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
3134 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentUpdate)).clone() })) as *mut c_void
3136 /// update_add_htlc messages which should be sent
3138 pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) {
3139 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); };
3140 unsafe { &mut *this_ptr.inner }.update_add_htlcs = local_val;
3142 /// update_fulfill_htlc messages which should be sent
3144 pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) {
3145 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); };
3146 unsafe { &mut *this_ptr.inner }.update_fulfill_htlcs = local_val;
3148 /// update_fail_htlc messages which should be sent
3150 pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) {
3151 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); };
3152 unsafe { &mut *this_ptr.inner }.update_fail_htlcs = local_val;
3154 /// update_fail_malformed_htlc messages which should be sent
3156 pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) {
3157 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); };
3158 unsafe { &mut *this_ptr.inner }.update_fail_malformed_htlcs = local_val;
3160 /// An update_fee message which should be sent
3162 pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::ln::msgs::UpdateFee {
3163 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.update_fee;
3164 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 };
3167 /// An update_fee message which should be sent
3169 pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdate, mut val: crate::ln::msgs::UpdateFee) {
3170 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_ptr()) } }) };
3171 unsafe { &mut *this_ptr.inner }.update_fee = local_val;
3173 /// Finally, the commitment_signed message which should be sent
3175 pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::ln::msgs::CommitmentSigned {
3176 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.commitment_signed;
3177 crate::ln::msgs::CommitmentSigned { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
3179 /// Finally, the commitment_signed message which should be sent
3181 pub extern "C" fn CommitmentUpdate_set_commitment_signed(this_ptr: &mut CommitmentUpdate, mut val: crate::ln::msgs::CommitmentSigned) {
3182 unsafe { &mut *this_ptr.inner }.commitment_signed = *unsafe { Box::from_raw(val.take_ptr()) };
3186 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 {
3187 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()) } }); };
3188 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()) } }); };
3189 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()) } }); };
3190 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()) } }); };
3191 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()) } }) };
3192 CommitmentUpdate { inner: Box::into_raw(Box::new(nativeCommitmentUpdate {
3193 update_add_htlcs: local_update_add_htlcs_arg,
3194 update_fulfill_htlcs: local_update_fulfill_htlcs_arg,
3195 update_fail_htlcs: local_update_fail_htlcs_arg,
3196 update_fail_malformed_htlcs: local_update_fail_malformed_htlcs_arg,
3197 update_fee: local_update_fee_arg,
3198 commitment_signed: *unsafe { Box::from_raw(commitment_signed_arg.take_ptr()) },
3199 })), is_owned: true }
3201 /// The information we received from a peer along the route of a payment we originated. This is
3202 /// returned by ChannelMessageHandler::handle_update_fail_htlc to be passed into
3203 /// RoutingMessageHandler::handle_htlc_fail_channel_update to update our network map.
3207 pub enum HTLCFailChannelUpdate {
3208 /// We received an error which included a full ChannelUpdate message.
3209 ChannelUpdateMessage {
3210 msg: crate::ln::msgs::ChannelUpdate,
3212 /// We received an error which indicated only that a channel has been closed
3214 short_channel_id: u64,
3217 /// We received an error which indicated only that a node has failed
3219 node_id: crate::c_types::PublicKey,
3223 use lightning::ln::msgs::HTLCFailChannelUpdate as nativeHTLCFailChannelUpdate;
3224 impl HTLCFailChannelUpdate {
3226 pub(crate) fn to_native(&self) -> nativeHTLCFailChannelUpdate {
3228 HTLCFailChannelUpdate::ChannelUpdateMessage {ref msg, } => {
3229 let mut msg_nonref = (*msg).clone();
3230 nativeHTLCFailChannelUpdate::ChannelUpdateMessage {
3231 msg: *unsafe { Box::from_raw(msg_nonref.take_ptr()) },
3234 HTLCFailChannelUpdate::ChannelClosed {ref short_channel_id, ref is_permanent, } => {
3235 let mut short_channel_id_nonref = (*short_channel_id).clone();
3236 let mut is_permanent_nonref = (*is_permanent).clone();
3237 nativeHTLCFailChannelUpdate::ChannelClosed {
3238 short_channel_id: short_channel_id_nonref,
3239 is_permanent: is_permanent_nonref,
3242 HTLCFailChannelUpdate::NodeFailure {ref node_id, ref is_permanent, } => {
3243 let mut node_id_nonref = (*node_id).clone();
3244 let mut is_permanent_nonref = (*is_permanent).clone();
3245 nativeHTLCFailChannelUpdate::NodeFailure {
3246 node_id: node_id_nonref.into_rust(),
3247 is_permanent: is_permanent_nonref,
3253 pub(crate) fn into_native(self) -> nativeHTLCFailChannelUpdate {
3255 HTLCFailChannelUpdate::ChannelUpdateMessage {mut msg, } => {
3256 nativeHTLCFailChannelUpdate::ChannelUpdateMessage {
3257 msg: *unsafe { Box::from_raw(msg.take_ptr()) },
3260 HTLCFailChannelUpdate::ChannelClosed {mut short_channel_id, mut is_permanent, } => {
3261 nativeHTLCFailChannelUpdate::ChannelClosed {
3262 short_channel_id: short_channel_id,
3263 is_permanent: is_permanent,
3266 HTLCFailChannelUpdate::NodeFailure {mut node_id, mut is_permanent, } => {
3267 nativeHTLCFailChannelUpdate::NodeFailure {
3268 node_id: node_id.into_rust(),
3269 is_permanent: is_permanent,
3275 pub(crate) fn from_native(native: &nativeHTLCFailChannelUpdate) -> Self {
3277 nativeHTLCFailChannelUpdate::ChannelUpdateMessage {ref msg, } => {
3278 let mut msg_nonref = (*msg).clone();
3279 HTLCFailChannelUpdate::ChannelUpdateMessage {
3280 msg: crate::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
3283 nativeHTLCFailChannelUpdate::ChannelClosed {ref short_channel_id, ref is_permanent, } => {
3284 let mut short_channel_id_nonref = (*short_channel_id).clone();
3285 let mut is_permanent_nonref = (*is_permanent).clone();
3286 HTLCFailChannelUpdate::ChannelClosed {
3287 short_channel_id: short_channel_id_nonref,
3288 is_permanent: is_permanent_nonref,
3291 nativeHTLCFailChannelUpdate::NodeFailure {ref node_id, ref is_permanent, } => {
3292 let mut node_id_nonref = (*node_id).clone();
3293 let mut is_permanent_nonref = (*is_permanent).clone();
3294 HTLCFailChannelUpdate::NodeFailure {
3295 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3296 is_permanent: is_permanent_nonref,
3302 pub(crate) fn native_into(native: nativeHTLCFailChannelUpdate) -> Self {
3304 nativeHTLCFailChannelUpdate::ChannelUpdateMessage {mut msg, } => {
3305 HTLCFailChannelUpdate::ChannelUpdateMessage {
3306 msg: crate::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(msg)), is_owned: true },
3309 nativeHTLCFailChannelUpdate::ChannelClosed {mut short_channel_id, mut is_permanent, } => {
3310 HTLCFailChannelUpdate::ChannelClosed {
3311 short_channel_id: short_channel_id,
3312 is_permanent: is_permanent,
3315 nativeHTLCFailChannelUpdate::NodeFailure {mut node_id, mut is_permanent, } => {
3316 HTLCFailChannelUpdate::NodeFailure {
3317 node_id: crate::c_types::PublicKey::from_rust(&node_id),
3318 is_permanent: is_permanent,
3325 pub extern "C" fn HTLCFailChannelUpdate_free(this_ptr: HTLCFailChannelUpdate) { }
3326 /// A trait to describe an object which can receive channel messages.
3328 /// Messages MAY be called in parallel when they originate from different their_node_ids, however
3329 /// they MUST NOT be called in parallel when the two calls have the same their_node_id.
3331 pub struct ChannelMessageHandler {
3332 pub this_arg: *mut c_void,
3333 /// Handle an incoming open_channel message from the given peer.
3334 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),
3335 /// Handle an incoming accept_channel message from the given peer.
3336 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),
3337 /// Handle an incoming funding_created message from the given peer.
3338 pub handle_funding_created: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingCreated),
3339 /// Handle an incoming funding_signed message from the given peer.
3340 pub handle_funding_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingSigned),
3341 /// Handle an incoming funding_locked message from the given peer.
3342 pub handle_funding_locked: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingLocked),
3343 /// Handle an incoming shutdown message from the given peer.
3344 pub handle_shutdown: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::Shutdown),
3345 /// Handle an incoming closing_signed message from the given peer.
3346 pub handle_closing_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ClosingSigned),
3347 /// Handle an incoming update_add_htlc message from the given peer.
3348 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),
3349 /// Handle an incoming update_fulfill_htlc message from the given peer.
3350 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),
3351 /// Handle an incoming update_fail_htlc message from the given peer.
3352 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),
3353 /// Handle an incoming update_fail_malformed_htlc message from the given peer.
3354 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),
3355 /// Handle an incoming commitment_signed message from the given peer.
3356 pub handle_commitment_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::CommitmentSigned),
3357 /// Handle an incoming revoke_and_ack message from the given peer.
3358 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),
3359 /// Handle an incoming update_fee message from the given peer.
3360 pub handle_update_fee: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFee),
3361 /// Handle an incoming announcement_signatures message from the given peer.
3362 pub handle_announcement_signatures: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::AnnouncementSignatures),
3363 /// Indicates a connection to the peer failed/an existing connection was lost. If no connection
3364 /// is believed to be possible in the future (eg they're sending us messages we don't
3365 /// understand or indicate they require unknown feature bits), no_connection_possible is set
3366 /// and any outstanding channels should be failed.
3367 pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, no_connection_possible: bool),
3368 /// Handle a peer reconnecting, possibly generating channel_reestablish message(s).
3369 pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::Init),
3370 /// Handle an incoming channel_reestablish message from the given peer.
3371 pub handle_channel_reestablish: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ChannelReestablish),
3372 /// Handle an incoming error message from the given peer.
3373 pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ErrorMessage),
3374 pub MessageSendEventsProvider: crate::util::events::MessageSendEventsProvider,
3375 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
3377 impl lightning::util::events::MessageSendEventsProvider for ChannelMessageHandler {
3378 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
3379 <crate::util::events::MessageSendEventsProvider as lightning::util::events::MessageSendEventsProvider>::get_and_clear_pending_msg_events(&self.MessageSendEventsProvider)
3382 unsafe impl Send for ChannelMessageHandler {}
3383 unsafe impl Sync for ChannelMessageHandler {}
3385 use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler;
3386 impl rustChannelMessageHandler for ChannelMessageHandler {
3387 fn handle_open_channel(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, their_features: lightning::ln::features::InitFeatures, msg: &lightning::ln::msgs::OpenChannel) {
3388 (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 })
3390 fn handle_accept_channel(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, their_features: lightning::ln::features::InitFeatures, msg: &lightning::ln::msgs::AcceptChannel) {
3391 (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 })
3393 fn handle_funding_created(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::FundingCreated) {
3394 (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 })
3396 fn handle_funding_signed(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::FundingSigned) {
3397 (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 })
3399 fn handle_funding_locked(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::FundingLocked) {
3400 (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 })
3402 fn handle_shutdown(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::Shutdown) {
3403 (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 })
3405 fn handle_closing_signed(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::ClosingSigned) {
3406 (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 })
3408 fn handle_update_add_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateAddHTLC) {
3409 (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 })
3411 fn handle_update_fulfill_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFulfillHTLC) {
3412 (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 })
3414 fn handle_update_fail_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFailHTLC) {
3415 (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 })
3417 fn handle_update_fail_malformed_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) {
3418 (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 })
3420 fn handle_commitment_signed(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::CommitmentSigned) {
3421 (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 })
3423 fn handle_revoke_and_ack(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::RevokeAndACK) {
3424 (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 })
3426 fn handle_update_fee(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFee) {
3427 (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 })
3429 fn handle_announcement_signatures(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::AnnouncementSignatures) {
3430 (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 })
3432 fn peer_disconnected(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, no_connection_possible: bool) {
3433 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), no_connection_possible)
3435 fn peer_connected(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::Init) {
3436 (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 })
3438 fn handle_channel_reestablish(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::ChannelReestablish) {
3439 (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 })
3441 fn handle_error(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::ErrorMessage) {
3442 (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 })
3446 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
3447 // directly as a Deref trait in higher-level structs:
3448 impl std::ops::Deref for ChannelMessageHandler {
3450 fn deref(&self) -> &Self {
3454 /// Calls the free function if one is set
3456 pub extern "C" fn ChannelMessageHandler_free(this_ptr: ChannelMessageHandler) { }
3457 impl Drop for ChannelMessageHandler {
3458 fn drop(&mut self) {
3459 if let Some(f) = self.free {
3464 /// A trait to describe an object which can receive routing messages.
3466 pub struct RoutingMessageHandler {
3467 pub this_arg: *mut c_void,
3468 /// Handle an incoming node_announcement message, returning true if it should be forwarded on,
3469 /// false or returning an Err otherwise.
3471 pub handle_node_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
3472 /// Handle a channel_announcement message, returning true if it should be forwarded on, false
3473 /// or returning an Err otherwise.
3475 pub handle_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
3476 /// Handle an incoming channel_update message, returning true if it should be forwarded on,
3477 /// false or returning an Err otherwise.
3479 pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ,
3480 /// Handle some updates to the route graph that we learned due to an outbound failed payment.
3481 pub handle_htlc_fail_channel_update: extern "C" fn (this_arg: *const c_void, update: &crate::ln::msgs::HTLCFailChannelUpdate),
3482 /// Gets a subset of the channel announcements and updates required to dump our routing table
3483 /// to a remote node, starting at the short_channel_id indicated by starting_point and
3484 /// including the batch_amount entries immediately higher in numerical value than starting_point.
3486 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,
3487 /// Gets a subset of the node announcements required to dump our routing table to a remote node,
3488 /// starting at the node *after* the provided publickey and including batch_amount entries
3489 /// immediately higher (as defined by <PublicKey as Ord>::cmp) than starting_point.
3490 /// If None is provided for starting_point, we start at the first node.
3492 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,
3493 /// Returns whether a full sync should be requested from a peer.
3495 pub should_request_full_sync: extern "C" fn (this_arg: *const c_void, node_id: crate::c_types::PublicKey) -> bool,
3496 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
3498 unsafe impl Send for RoutingMessageHandler {}
3499 unsafe impl Sync for RoutingMessageHandler {}
3501 use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler;
3502 impl rustRoutingMessageHandler for RoutingMessageHandler {
3503 fn handle_node_announcement(&self, msg: &lightning::ln::msgs::NodeAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
3504 let mut ret = (self.handle_node_announcement)(self.this_arg, &crate::ln::msgs::NodeAnnouncement { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false });
3505 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()) } })};
3508 fn handle_channel_announcement(&self, msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
3509 let mut ret = (self.handle_channel_announcement)(self.this_arg, &crate::ln::msgs::ChannelAnnouncement { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false });
3510 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()) } })};
3513 fn handle_channel_update(&self, msg: &lightning::ln::msgs::ChannelUpdate) -> Result<bool, lightning::ln::msgs::LightningError> {
3514 let mut ret = (self.handle_channel_update)(self.this_arg, &crate::ln::msgs::ChannelUpdate { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false });
3515 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()) } })};
3518 fn handle_htlc_fail_channel_update(&self, update: &lightning::ln::msgs::HTLCFailChannelUpdate) {
3519 (self.handle_htlc_fail_channel_update)(self.this_arg, &crate::ln::msgs::HTLCFailChannelUpdate::from_native(&update))
3521 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>)> {
3522 let mut ret = (self.get_next_channel_announcements)(self.this_arg, starting_point, batch_amount);
3523 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 }); };
3526 fn get_next_node_announcements(&self, starting_point: Option<&bitcoin::secp256k1::key::PublicKey>, batch_amount: u8) -> Vec<lightning::ln::msgs::NodeAnnouncement> {
3527 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())) } };
3528 let mut ret = (self.get_next_node_announcements)(self.this_arg, local_starting_point, batch_amount);
3529 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); };
3532 fn should_request_full_sync(&self, node_id: &bitcoin::secp256k1::key::PublicKey) -> bool {
3533 let mut ret = (self.should_request_full_sync)(self.this_arg, crate::c_types::PublicKey::from_rust(&node_id));
3538 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
3539 // directly as a Deref trait in higher-level structs:
3540 impl std::ops::Deref for RoutingMessageHandler {
3542 fn deref(&self) -> &Self {
3546 /// Calls the free function if one is set
3548 pub extern "C" fn RoutingMessageHandler_free(this_ptr: RoutingMessageHandler) { }
3549 impl Drop for RoutingMessageHandler {
3550 fn drop(&mut self) {
3551 if let Some(f) = self.free {
3557 pub extern "C" fn AcceptChannel_write(obj: *const AcceptChannel) -> crate::c_types::derived::CVec_u8Z {
3558 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
3561 pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> AcceptChannel {
3562 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
3563 AcceptChannel { inner: Box::into_raw(Box::new(res)), is_owned: true }
3565 AcceptChannel { inner: std::ptr::null_mut(), is_owned: true }
3569 pub extern "C" fn AnnouncementSignatures_write(obj: *const AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z {
3570 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
3573 pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> AnnouncementSignatures {
3574 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
3575 AnnouncementSignatures { inner: Box::into_raw(Box::new(res)), is_owned: true }
3577 AnnouncementSignatures { inner: std::ptr::null_mut(), is_owned: true }
3581 pub extern "C" fn ChannelReestablish_write(obj: *const ChannelReestablish) -> crate::c_types::derived::CVec_u8Z {
3582 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
3585 pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> ChannelReestablish {
3586 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
3587 ChannelReestablish { inner: Box::into_raw(Box::new(res)), is_owned: true }
3589 ChannelReestablish { inner: std::ptr::null_mut(), is_owned: true }
3593 pub extern "C" fn ClosingSigned_write(obj: *const ClosingSigned) -> crate::c_types::derived::CVec_u8Z {
3594 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
3597 pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> ClosingSigned {
3598 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
3599 ClosingSigned { inner: Box::into_raw(Box::new(res)), is_owned: true }
3601 ClosingSigned { inner: std::ptr::null_mut(), is_owned: true }
3605 pub extern "C" fn CommitmentSigned_write(obj: *const CommitmentSigned) -> crate::c_types::derived::CVec_u8Z {
3606 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
3609 pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> CommitmentSigned {
3610 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
3611 CommitmentSigned { inner: Box::into_raw(Box::new(res)), is_owned: true }
3613 CommitmentSigned { inner: std::ptr::null_mut(), is_owned: true }
3617 pub extern "C" fn FundingCreated_write(obj: *const FundingCreated) -> crate::c_types::derived::CVec_u8Z {
3618 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
3621 pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> FundingCreated {
3622 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
3623 FundingCreated { inner: Box::into_raw(Box::new(res)), is_owned: true }
3625 FundingCreated { inner: std::ptr::null_mut(), is_owned: true }
3629 pub extern "C" fn FundingSigned_write(obj: *const FundingSigned) -> crate::c_types::derived::CVec_u8Z {
3630 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
3633 pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> FundingSigned {
3634 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
3635 FundingSigned { inner: Box::into_raw(Box::new(res)), is_owned: true }
3637 FundingSigned { inner: std::ptr::null_mut(), is_owned: true }
3641 pub extern "C" fn FundingLocked_write(obj: *const FundingLocked) -> crate::c_types::derived::CVec_u8Z {
3642 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
3645 pub extern "C" fn FundingLocked_read(ser: crate::c_types::u8slice) -> FundingLocked {
3646 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
3647 FundingLocked { inner: Box::into_raw(Box::new(res)), is_owned: true }
3649 FundingLocked { inner: std::ptr::null_mut(), is_owned: true }
3653 pub extern "C" fn Init_write(obj: *const Init) -> crate::c_types::derived::CVec_u8Z {
3654 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
3657 pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> Init {
3658 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
3659 Init { inner: Box::into_raw(Box::new(res)), is_owned: true }
3661 Init { inner: std::ptr::null_mut(), is_owned: true }
3665 pub extern "C" fn OpenChannel_write(obj: *const OpenChannel) -> crate::c_types::derived::CVec_u8Z {
3666 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
3669 pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> OpenChannel {
3670 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
3671 OpenChannel { inner: Box::into_raw(Box::new(res)), is_owned: true }
3673 OpenChannel { inner: std::ptr::null_mut(), is_owned: true }
3677 pub extern "C" fn RevokeAndACK_write(obj: *const RevokeAndACK) -> crate::c_types::derived::CVec_u8Z {
3678 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
3681 pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> RevokeAndACK {
3682 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
3683 RevokeAndACK { inner: Box::into_raw(Box::new(res)), is_owned: true }
3685 RevokeAndACK { inner: std::ptr::null_mut(), is_owned: true }
3689 pub extern "C" fn Shutdown_write(obj: *const Shutdown) -> crate::c_types::derived::CVec_u8Z {
3690 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
3693 pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> Shutdown {
3694 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
3695 Shutdown { inner: Box::into_raw(Box::new(res)), is_owned: true }
3697 Shutdown { inner: std::ptr::null_mut(), is_owned: true }
3701 pub extern "C" fn UpdateFailHTLC_write(obj: *const UpdateFailHTLC) -> crate::c_types::derived::CVec_u8Z {
3702 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
3705 pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> UpdateFailHTLC {
3706 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
3707 UpdateFailHTLC { inner: Box::into_raw(Box::new(res)), is_owned: true }
3709 UpdateFailHTLC { inner: std::ptr::null_mut(), is_owned: true }
3713 pub extern "C" fn UpdateFailMalformedHTLC_write(obj: *const UpdateFailMalformedHTLC) -> crate::c_types::derived::CVec_u8Z {
3714 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
3717 pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> UpdateFailMalformedHTLC {
3718 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
3719 UpdateFailMalformedHTLC { inner: Box::into_raw(Box::new(res)), is_owned: true }
3721 UpdateFailMalformedHTLC { inner: std::ptr::null_mut(), is_owned: true }
3725 pub extern "C" fn UpdateFee_write(obj: *const UpdateFee) -> crate::c_types::derived::CVec_u8Z {
3726 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
3729 pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> UpdateFee {
3730 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
3731 UpdateFee { inner: Box::into_raw(Box::new(res)), is_owned: true }
3733 UpdateFee { inner: std::ptr::null_mut(), is_owned: true }
3737 pub extern "C" fn UpdateFulfillHTLC_write(obj: *const UpdateFulfillHTLC) -> crate::c_types::derived::CVec_u8Z {
3738 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
3741 pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> UpdateFulfillHTLC {
3742 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
3743 UpdateFulfillHTLC { inner: Box::into_raw(Box::new(res)), is_owned: true }
3745 UpdateFulfillHTLC { inner: std::ptr::null_mut(), is_owned: true }
3749 pub extern "C" fn UpdateAddHTLC_write(obj: *const UpdateAddHTLC) -> crate::c_types::derived::CVec_u8Z {
3750 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
3753 pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> UpdateAddHTLC {
3754 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
3755 UpdateAddHTLC { inner: Box::into_raw(Box::new(res)), is_owned: true }
3757 UpdateAddHTLC { inner: std::ptr::null_mut(), is_owned: true }
3761 pub extern "C" fn Ping_write(obj: *const Ping) -> crate::c_types::derived::CVec_u8Z {
3762 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
3765 pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> Ping {
3766 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
3767 Ping { inner: Box::into_raw(Box::new(res)), is_owned: true }
3769 Ping { inner: std::ptr::null_mut(), is_owned: true }
3773 pub extern "C" fn Pong_write(obj: *const Pong) -> crate::c_types::derived::CVec_u8Z {
3774 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
3777 pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> Pong {
3778 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
3779 Pong { inner: Box::into_raw(Box::new(res)), is_owned: true }
3781 Pong { inner: std::ptr::null_mut(), is_owned: true }
3785 pub extern "C" fn UnsignedChannelAnnouncement_write(obj: *const UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
3786 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
3789 pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> UnsignedChannelAnnouncement {
3790 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
3791 UnsignedChannelAnnouncement { inner: Box::into_raw(Box::new(res)), is_owned: true }
3793 UnsignedChannelAnnouncement { inner: std::ptr::null_mut(), is_owned: true }
3797 pub extern "C" fn ChannelAnnouncement_write(obj: *const ChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
3798 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
3801 pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> ChannelAnnouncement {
3802 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
3803 ChannelAnnouncement { inner: Box::into_raw(Box::new(res)), is_owned: true }
3805 ChannelAnnouncement { inner: std::ptr::null_mut(), is_owned: true }
3809 pub extern "C" fn UnsignedChannelUpdate_write(obj: *const UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
3810 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
3813 pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> UnsignedChannelUpdate {
3814 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
3815 UnsignedChannelUpdate { inner: Box::into_raw(Box::new(res)), is_owned: true }
3817 UnsignedChannelUpdate { inner: std::ptr::null_mut(), is_owned: true }
3821 pub extern "C" fn ChannelUpdate_write(obj: *const ChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
3822 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
3825 pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> ChannelUpdate {
3826 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
3827 ChannelUpdate { inner: Box::into_raw(Box::new(res)), is_owned: true }
3829 ChannelUpdate { inner: std::ptr::null_mut(), is_owned: true }
3833 pub extern "C" fn ErrorMessage_write(obj: *const ErrorMessage) -> crate::c_types::derived::CVec_u8Z {
3834 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
3837 pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> ErrorMessage {
3838 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
3839 ErrorMessage { inner: Box::into_raw(Box::new(res)), is_owned: true }
3841 ErrorMessage { inner: std::ptr::null_mut(), is_owned: true }
3845 pub extern "C" fn UnsignedNodeAnnouncement_write(obj: *const UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
3846 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
3849 pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> UnsignedNodeAnnouncement {
3850 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
3851 UnsignedNodeAnnouncement { inner: Box::into_raw(Box::new(res)), is_owned: true }
3853 UnsignedNodeAnnouncement { inner: std::ptr::null_mut(), is_owned: true }
3857 pub extern "C" fn NodeAnnouncement_write(obj: *const NodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
3858 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
3861 pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> NodeAnnouncement {
3862 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
3863 NodeAnnouncement { inner: Box::into_raw(Box::new(res)), is_owned: true }
3865 NodeAnnouncement { inner: std::ptr::null_mut(), is_owned: true }