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 }
2924 use lightning::ln::msgs::QueryChannelRange as nativeQueryChannelRangeImport;
2925 type nativeQueryChannelRange = nativeQueryChannelRangeImport;
2927 /// A query_channel_range message is used to query a peer for channel
2928 /// UTXOs in a range of blocks. The recipient of a query makes a best
2929 /// effort to reply to the query using one or more reply_channel_range
2933 pub struct QueryChannelRange {
2934 /// Nearly everyhwere, inner must be non-null, however in places where
2935 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2936 pub inner: *mut nativeQueryChannelRange,
2940 impl Drop for QueryChannelRange {
2941 fn drop(&mut self) {
2942 if self.is_owned && !self.inner.is_null() {
2943 let _ = unsafe { Box::from_raw(self.inner) };
2948 pub extern "C" fn QueryChannelRange_free(this_ptr: QueryChannelRange) { }
2950 /// Used only if an object of this type is returned as a trait impl by a method
2951 extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) {
2952 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryChannelRange); }
2955 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2956 impl QueryChannelRange {
2957 pub(crate) fn take_ptr(mut self) -> *mut nativeQueryChannelRange {
2958 assert!(self.is_owned);
2959 let ret = self.inner;
2960 self.inner = std::ptr::null_mut();
2964 impl Clone for QueryChannelRange {
2965 fn clone(&self) -> Self {
2967 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
2973 /// Used only if an object of this type is returned as a trait impl by a method
2974 pub(crate) extern "C" fn QueryChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
2975 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryChannelRange)).clone() })) as *mut c_void
2977 /// The genesis hash of the blockchain being queried
2979 pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *const [u8; 32] {
2980 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
2981 (*inner_val).as_inner()
2983 /// The genesis hash of the blockchain being queried
2985 pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
2986 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
2988 /// The height of the first block for the channel UTXOs being queried
2990 pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 {
2991 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_blocknum;
2994 /// The height of the first block for the channel UTXOs being queried
2996 pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChannelRange, mut val: u32) {
2997 unsafe { &mut *this_ptr.inner }.first_blocknum = val;
2999 /// The number of blocks to include in the query results
3001 pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 {
3002 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.number_of_blocks;
3005 /// The number of blocks to include in the query results
3007 pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryChannelRange, mut val: u32) {
3008 unsafe { &mut *this_ptr.inner }.number_of_blocks = val;
3012 pub extern "C" fn QueryChannelRange_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut first_blocknum_arg: u32, mut number_of_blocks_arg: u32) -> QueryChannelRange {
3013 QueryChannelRange { inner: Box::into_raw(Box::new(nativeQueryChannelRange {
3014 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3015 first_blocknum: first_blocknum_arg,
3016 number_of_blocks: number_of_blocks_arg,
3017 })), is_owned: true }
3020 use lightning::ln::msgs::ReplyChannelRange as nativeReplyChannelRangeImport;
3021 type nativeReplyChannelRange = nativeReplyChannelRangeImport;
3023 /// A reply_channel_range message is a reply to a query_channel_range
3024 /// message. Multiple reply_channel_range messages can be sent in reply
3025 /// to a single query_channel_range message. The query recipient makes a
3026 /// best effort to respond based on their local network view which may
3027 /// not be a perfect view of the network. The short_channel_ids in the
3028 /// reply are encoded. We only support encoding_type=0 uncompressed
3029 /// serialization and do not support encoding_type=1 zlib serialization.
3032 pub struct ReplyChannelRange {
3033 /// Nearly everyhwere, inner must be non-null, however in places where
3034 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3035 pub inner: *mut nativeReplyChannelRange,
3039 impl Drop for ReplyChannelRange {
3040 fn drop(&mut self) {
3041 if self.is_owned && !self.inner.is_null() {
3042 let _ = unsafe { Box::from_raw(self.inner) };
3047 pub extern "C" fn ReplyChannelRange_free(this_ptr: ReplyChannelRange) { }
3049 /// Used only if an object of this type is returned as a trait impl by a method
3050 extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) {
3051 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyChannelRange); }
3054 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3055 impl ReplyChannelRange {
3056 pub(crate) fn take_ptr(mut self) -> *mut nativeReplyChannelRange {
3057 assert!(self.is_owned);
3058 let ret = self.inner;
3059 self.inner = std::ptr::null_mut();
3063 impl Clone for ReplyChannelRange {
3064 fn clone(&self) -> Self {
3066 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
3072 /// Used only if an object of this type is returned as a trait impl by a method
3073 pub(crate) extern "C" fn ReplyChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
3074 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyChannelRange)).clone() })) as *mut c_void
3076 /// The genesis hash of the blockchain being queried
3078 pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *const [u8; 32] {
3079 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3080 (*inner_val).as_inner()
3082 /// The genesis hash of the blockchain being queried
3084 pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
3085 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3087 /// The height of the first block in the range of the reply
3089 pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 {
3090 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_blocknum;
3093 /// The height of the first block in the range of the reply
3095 pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChannelRange, mut val: u32) {
3096 unsafe { &mut *this_ptr.inner }.first_blocknum = val;
3098 /// The number of blocks included in the range of the reply
3100 pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 {
3101 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.number_of_blocks;
3104 /// The number of blocks included in the range of the reply
3106 pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyChannelRange, mut val: u32) {
3107 unsafe { &mut *this_ptr.inner }.number_of_blocks = val;
3109 /// Indicates if the query recipient maintains up-to-date channel
3110 /// information for the chain_hash
3112 pub extern "C" fn ReplyChannelRange_get_full_information(this_ptr: &ReplyChannelRange) -> bool {
3113 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.full_information;
3116 /// Indicates if the query recipient maintains up-to-date channel
3117 /// information for the chain_hash
3119 pub extern "C" fn ReplyChannelRange_set_full_information(this_ptr: &mut ReplyChannelRange, mut val: bool) {
3120 unsafe { &mut *this_ptr.inner }.full_information = val;
3122 /// The short_channel_ids in the channel range
3124 pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::derived::CVec_u64Z) {
3125 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
3126 unsafe { &mut *this_ptr.inner }.short_channel_ids = local_val;
3130 pub extern "C" fn ReplyChannelRange_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut first_blocknum_arg: u32, mut number_of_blocks_arg: u32, mut full_information_arg: bool, mut short_channel_ids_arg: crate::c_types::derived::CVec_u64Z) -> ReplyChannelRange {
3131 let mut local_short_channel_ids_arg = Vec::new(); for mut item in short_channel_ids_arg.into_rust().drain(..) { local_short_channel_ids_arg.push( { item }); };
3132 ReplyChannelRange { inner: Box::into_raw(Box::new(nativeReplyChannelRange {
3133 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3134 first_blocknum: first_blocknum_arg,
3135 number_of_blocks: number_of_blocks_arg,
3136 full_information: full_information_arg,
3137 short_channel_ids: local_short_channel_ids_arg,
3138 })), is_owned: true }
3141 use lightning::ln::msgs::QueryShortChannelIds as nativeQueryShortChannelIdsImport;
3142 type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport;
3144 /// A query_short_channel_ids message is used to query a peer for
3145 /// routing gossip messages related to one or more short_channel_ids.
3146 /// The query recipient will reply with the latest, if available,
3147 /// channel_announcement, channel_update and node_announcement messages
3148 /// it maintains for the requested short_channel_ids followed by a
3149 /// reply_short_channel_ids_end message. The short_channel_ids sent in
3150 /// this query are encoded. We only support encoding_type=0 uncompressed
3151 /// serialization and do not support encoding_type=1 zlib serialization.
3154 pub struct QueryShortChannelIds {
3155 /// Nearly everyhwere, inner must be non-null, however in places where
3156 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3157 pub inner: *mut nativeQueryShortChannelIds,
3161 impl Drop for QueryShortChannelIds {
3162 fn drop(&mut self) {
3163 if self.is_owned && !self.inner.is_null() {
3164 let _ = unsafe { Box::from_raw(self.inner) };
3169 pub extern "C" fn QueryShortChannelIds_free(this_ptr: QueryShortChannelIds) { }
3171 /// Used only if an object of this type is returned as a trait impl by a method
3172 extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) {
3173 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryShortChannelIds); }
3176 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3177 impl QueryShortChannelIds {
3178 pub(crate) fn take_ptr(mut self) -> *mut nativeQueryShortChannelIds {
3179 assert!(self.is_owned);
3180 let ret = self.inner;
3181 self.inner = std::ptr::null_mut();
3185 impl Clone for QueryShortChannelIds {
3186 fn clone(&self) -> Self {
3188 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
3194 /// Used only if an object of this type is returned as a trait impl by a method
3195 pub(crate) extern "C" fn QueryShortChannelIds_clone_void(this_ptr: *const c_void) -> *mut c_void {
3196 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryShortChannelIds)).clone() })) as *mut c_void
3198 /// The genesis hash of the blockchain being queried
3200 pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *const [u8; 32] {
3201 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3202 (*inner_val).as_inner()
3204 /// The genesis hash of the blockchain being queried
3206 pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::ThirtyTwoBytes) {
3207 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3209 /// The short_channel_ids that are being queried
3211 pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::derived::CVec_u64Z) {
3212 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
3213 unsafe { &mut *this_ptr.inner }.short_channel_ids = local_val;
3217 pub extern "C" fn QueryShortChannelIds_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_ids_arg: crate::c_types::derived::CVec_u64Z) -> QueryShortChannelIds {
3218 let mut local_short_channel_ids_arg = Vec::new(); for mut item in short_channel_ids_arg.into_rust().drain(..) { local_short_channel_ids_arg.push( { item }); };
3219 QueryShortChannelIds { inner: Box::into_raw(Box::new(nativeQueryShortChannelIds {
3220 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3221 short_channel_ids: local_short_channel_ids_arg,
3222 })), is_owned: true }
3225 use lightning::ln::msgs::ReplyShortChannelIdsEnd as nativeReplyShortChannelIdsEndImport;
3226 type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport;
3228 /// A reply_short_channel_ids_end message is sent as a reply to a
3229 /// query_short_channel_ids message. The query recipient makes a best
3230 /// effort to respond based on their local network view which may not be
3231 /// a perfect view of the network.
3234 pub struct ReplyShortChannelIdsEnd {
3235 /// Nearly everyhwere, inner must be non-null, however in places where
3236 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3237 pub inner: *mut nativeReplyShortChannelIdsEnd,
3241 impl Drop for ReplyShortChannelIdsEnd {
3242 fn drop(&mut self) {
3243 if self.is_owned && !self.inner.is_null() {
3244 let _ = unsafe { Box::from_raw(self.inner) };
3249 pub extern "C" fn ReplyShortChannelIdsEnd_free(this_ptr: ReplyShortChannelIdsEnd) { }
3251 /// Used only if an object of this type is returned as a trait impl by a method
3252 extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) {
3253 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyShortChannelIdsEnd); }
3256 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3257 impl ReplyShortChannelIdsEnd {
3258 pub(crate) fn take_ptr(mut self) -> *mut nativeReplyShortChannelIdsEnd {
3259 assert!(self.is_owned);
3260 let ret = self.inner;
3261 self.inner = std::ptr::null_mut();
3265 impl Clone for ReplyShortChannelIdsEnd {
3266 fn clone(&self) -> Self {
3268 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
3274 /// Used only if an object of this type is returned as a trait impl by a method
3275 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_void) -> *mut c_void {
3276 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyShortChannelIdsEnd)).clone() })) as *mut c_void
3278 /// The genesis hash of the blockchain that was queried
3280 pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *const [u8; 32] {
3281 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3282 (*inner_val).as_inner()
3284 /// The genesis hash of the blockchain that was queried
3286 pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) {
3287 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3289 /// Indicates if the query recipient maintains up-to-date channel
3290 /// information for the chain_hash
3292 pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool {
3293 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.full_information;
3296 /// Indicates if the query recipient maintains up-to-date channel
3297 /// information for the chain_hash
3299 pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: bool) {
3300 unsafe { &mut *this_ptr.inner }.full_information = val;
3304 pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd {
3305 ReplyShortChannelIdsEnd { inner: Box::into_raw(Box::new(nativeReplyShortChannelIdsEnd {
3306 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3307 full_information: full_information_arg,
3308 })), is_owned: true }
3311 use lightning::ln::msgs::GossipTimestampFilter as nativeGossipTimestampFilterImport;
3312 type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport;
3314 /// A gossip_timestamp_filter message is used by a node to request
3315 /// gossip relay for messages in the requested time range when the
3316 /// gossip_queries feature has been negotiated.
3319 pub struct GossipTimestampFilter {
3320 /// Nearly everyhwere, inner must be non-null, however in places where
3321 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3322 pub inner: *mut nativeGossipTimestampFilter,
3326 impl Drop for GossipTimestampFilter {
3327 fn drop(&mut self) {
3328 if self.is_owned && !self.inner.is_null() {
3329 let _ = unsafe { Box::from_raw(self.inner) };
3334 pub extern "C" fn GossipTimestampFilter_free(this_ptr: GossipTimestampFilter) { }
3336 /// Used only if an object of this type is returned as a trait impl by a method
3337 extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) {
3338 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeGossipTimestampFilter); }
3341 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3342 impl GossipTimestampFilter {
3343 pub(crate) fn take_ptr(mut self) -> *mut nativeGossipTimestampFilter {
3344 assert!(self.is_owned);
3345 let ret = self.inner;
3346 self.inner = std::ptr::null_mut();
3350 impl Clone for GossipTimestampFilter {
3351 fn clone(&self) -> Self {
3353 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
3359 /// Used only if an object of this type is returned as a trait impl by a method
3360 pub(crate) extern "C" fn GossipTimestampFilter_clone_void(this_ptr: *const c_void) -> *mut c_void {
3361 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeGossipTimestampFilter)).clone() })) as *mut c_void
3363 /// The genesis hash of the blockchain for channel and node information
3365 pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *const [u8; 32] {
3366 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3367 (*inner_val).as_inner()
3369 /// The genesis hash of the blockchain for channel and node information
3371 pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) {
3372 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3374 /// The starting unix timestamp
3376 pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 {
3377 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_timestamp;
3380 /// The starting unix timestamp
3382 pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
3383 unsafe { &mut *this_ptr.inner }.first_timestamp = val;
3385 /// The range of information in seconds
3387 pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 {
3388 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp_range;
3391 /// The range of information in seconds
3393 pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
3394 unsafe { &mut *this_ptr.inner }.timestamp_range = val;
3398 pub extern "C" fn GossipTimestampFilter_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut first_timestamp_arg: u32, mut timestamp_range_arg: u32) -> GossipTimestampFilter {
3399 GossipTimestampFilter { inner: Box::into_raw(Box::new(nativeGossipTimestampFilter {
3400 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3401 first_timestamp: first_timestamp_arg,
3402 timestamp_range: timestamp_range_arg,
3403 })), is_owned: true }
3405 /// Used to put an error message in a LightningError
3409 pub enum ErrorAction {
3410 /// The peer took some action which made us think they were useless. Disconnect them.
3412 msg: crate::ln::msgs::ErrorMessage,
3414 /// The peer did something harmless that we weren't able to process, just log and ignore
3416 /// The peer did something incorrect. Tell them.
3418 msg: crate::ln::msgs::ErrorMessage,
3421 use lightning::ln::msgs::ErrorAction as nativeErrorAction;
3424 pub(crate) fn to_native(&self) -> nativeErrorAction {
3426 ErrorAction::DisconnectPeer {ref msg, } => {
3427 let mut msg_nonref = (*msg).clone();
3428 let mut local_msg_nonref = if msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg_nonref.take_ptr()) } }) };
3429 nativeErrorAction::DisconnectPeer {
3430 msg: local_msg_nonref,
3433 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
3434 ErrorAction::SendErrorMessage {ref msg, } => {
3435 let mut msg_nonref = (*msg).clone();
3436 nativeErrorAction::SendErrorMessage {
3437 msg: *unsafe { Box::from_raw(msg_nonref.take_ptr()) },
3443 pub(crate) fn into_native(self) -> nativeErrorAction {
3445 ErrorAction::DisconnectPeer {mut msg, } => {
3446 let mut local_msg = if msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg.take_ptr()) } }) };
3447 nativeErrorAction::DisconnectPeer {
3451 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
3452 ErrorAction::SendErrorMessage {mut msg, } => {
3453 nativeErrorAction::SendErrorMessage {
3454 msg: *unsafe { Box::from_raw(msg.take_ptr()) },
3460 pub(crate) fn from_native(native: &nativeErrorAction) -> Self {
3462 nativeErrorAction::DisconnectPeer {ref msg, } => {
3463 let mut msg_nonref = (*msg).clone();
3464 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 };
3465 ErrorAction::DisconnectPeer {
3466 msg: local_msg_nonref,
3469 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
3470 nativeErrorAction::SendErrorMessage {ref msg, } => {
3471 let mut msg_nonref = (*msg).clone();
3472 ErrorAction::SendErrorMessage {
3473 msg: crate::ln::msgs::ErrorMessage { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
3479 pub(crate) fn native_into(native: nativeErrorAction) -> Self {
3481 nativeErrorAction::DisconnectPeer {mut msg, } => {
3482 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 };
3483 ErrorAction::DisconnectPeer {
3487 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
3488 nativeErrorAction::SendErrorMessage {mut msg, } => {
3489 ErrorAction::SendErrorMessage {
3490 msg: crate::ln::msgs::ErrorMessage { inner: Box::into_raw(Box::new(msg)), is_owned: true },
3497 pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { }
3499 use lightning::ln::msgs::LightningError as nativeLightningErrorImport;
3500 type nativeLightningError = nativeLightningErrorImport;
3502 /// An Err type for failure to process messages.
3505 pub struct LightningError {
3506 /// Nearly everyhwere, inner must be non-null, however in places where
3507 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3508 pub inner: *mut nativeLightningError,
3512 impl Drop for LightningError {
3513 fn drop(&mut self) {
3514 if self.is_owned && !self.inner.is_null() {
3515 let _ = unsafe { Box::from_raw(self.inner) };
3520 pub extern "C" fn LightningError_free(this_ptr: LightningError) { }
3522 /// Used only if an object of this type is returned as a trait impl by a method
3523 extern "C" fn LightningError_free_void(this_ptr: *mut c_void) {
3524 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeLightningError); }
3527 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3528 impl LightningError {
3529 pub(crate) fn take_ptr(mut self) -> *mut nativeLightningError {
3530 assert!(self.is_owned);
3531 let ret = self.inner;
3532 self.inner = std::ptr::null_mut();
3536 /// A human-readable message describing the error
3538 pub extern "C" fn LightningError_get_err(this_ptr: &LightningError) -> crate::c_types::Str {
3539 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.err;
3540 (*inner_val).as_str().into()
3542 /// A human-readable message describing the error
3544 pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: crate::c_types::derived::CVec_u8Z) {
3545 unsafe { &mut *this_ptr.inner }.err = String::from_utf8(val.into_rust()).unwrap();
3547 /// The action which should be taken against the offending peer.
3549 pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate::ln::msgs::ErrorAction {
3550 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.action;
3551 crate::ln::msgs::ErrorAction::from_native(&(*inner_val))
3553 /// The action which should be taken against the offending peer.
3555 pub extern "C" fn LightningError_set_action(this_ptr: &mut LightningError, mut val: crate::ln::msgs::ErrorAction) {
3556 unsafe { &mut *this_ptr.inner }.action = val.into_native();
3560 pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::derived::CVec_u8Z, mut action_arg: crate::ln::msgs::ErrorAction) -> LightningError {
3561 LightningError { inner: Box::into_raw(Box::new(nativeLightningError {
3562 err: String::from_utf8(err_arg.into_rust()).unwrap(),
3563 action: action_arg.into_native(),
3564 })), is_owned: true }
3567 use lightning::ln::msgs::CommitmentUpdate as nativeCommitmentUpdateImport;
3568 type nativeCommitmentUpdate = nativeCommitmentUpdateImport;
3570 /// Struct used to return values from revoke_and_ack messages, containing a bunch of commitment
3571 /// transaction updates if they were pending.
3574 pub struct CommitmentUpdate {
3575 /// Nearly everyhwere, inner must be non-null, however in places where
3576 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3577 pub inner: *mut nativeCommitmentUpdate,
3581 impl Drop for CommitmentUpdate {
3582 fn drop(&mut self) {
3583 if self.is_owned && !self.inner.is_null() {
3584 let _ = unsafe { Box::from_raw(self.inner) };
3589 pub extern "C" fn CommitmentUpdate_free(this_ptr: CommitmentUpdate) { }
3591 /// Used only if an object of this type is returned as a trait impl by a method
3592 extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) {
3593 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentUpdate); }
3596 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3597 impl CommitmentUpdate {
3598 pub(crate) fn take_ptr(mut self) -> *mut nativeCommitmentUpdate {
3599 assert!(self.is_owned);
3600 let ret = self.inner;
3601 self.inner = std::ptr::null_mut();
3605 impl Clone for CommitmentUpdate {
3606 fn clone(&self) -> Self {
3608 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
3614 /// Used only if an object of this type is returned as a trait impl by a method
3615 pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
3616 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentUpdate)).clone() })) as *mut c_void
3618 /// update_add_htlc messages which should be sent
3620 pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) {
3621 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); };
3622 unsafe { &mut *this_ptr.inner }.update_add_htlcs = local_val;
3624 /// update_fulfill_htlc messages which should be sent
3626 pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) {
3627 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); };
3628 unsafe { &mut *this_ptr.inner }.update_fulfill_htlcs = local_val;
3630 /// update_fail_htlc messages which should be sent
3632 pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) {
3633 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); };
3634 unsafe { &mut *this_ptr.inner }.update_fail_htlcs = local_val;
3636 /// update_fail_malformed_htlc messages which should be sent
3638 pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) {
3639 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); };
3640 unsafe { &mut *this_ptr.inner }.update_fail_malformed_htlcs = local_val;
3642 /// An update_fee message which should be sent
3644 pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::ln::msgs::UpdateFee {
3645 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.update_fee;
3646 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 };
3649 /// An update_fee message which should be sent
3651 pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdate, mut val: crate::ln::msgs::UpdateFee) {
3652 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_ptr()) } }) };
3653 unsafe { &mut *this_ptr.inner }.update_fee = local_val;
3655 /// Finally, the commitment_signed message which should be sent
3657 pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::ln::msgs::CommitmentSigned {
3658 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.commitment_signed;
3659 crate::ln::msgs::CommitmentSigned { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
3661 /// Finally, the commitment_signed message which should be sent
3663 pub extern "C" fn CommitmentUpdate_set_commitment_signed(this_ptr: &mut CommitmentUpdate, mut val: crate::ln::msgs::CommitmentSigned) {
3664 unsafe { &mut *this_ptr.inner }.commitment_signed = *unsafe { Box::from_raw(val.take_ptr()) };
3668 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 {
3669 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()) } }); };
3670 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()) } }); };
3671 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()) } }); };
3672 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()) } }); };
3673 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()) } }) };
3674 CommitmentUpdate { inner: Box::into_raw(Box::new(nativeCommitmentUpdate {
3675 update_add_htlcs: local_update_add_htlcs_arg,
3676 update_fulfill_htlcs: local_update_fulfill_htlcs_arg,
3677 update_fail_htlcs: local_update_fail_htlcs_arg,
3678 update_fail_malformed_htlcs: local_update_fail_malformed_htlcs_arg,
3679 update_fee: local_update_fee_arg,
3680 commitment_signed: *unsafe { Box::from_raw(commitment_signed_arg.take_ptr()) },
3681 })), is_owned: true }
3683 /// The information we received from a peer along the route of a payment we originated. This is
3684 /// returned by ChannelMessageHandler::handle_update_fail_htlc to be passed into
3685 /// RoutingMessageHandler::handle_htlc_fail_channel_update to update our network map.
3689 pub enum HTLCFailChannelUpdate {
3690 /// We received an error which included a full ChannelUpdate message.
3691 ChannelUpdateMessage {
3692 msg: crate::ln::msgs::ChannelUpdate,
3694 /// We received an error which indicated only that a channel has been closed
3696 short_channel_id: u64,
3699 /// We received an error which indicated only that a node has failed
3701 node_id: crate::c_types::PublicKey,
3705 use lightning::ln::msgs::HTLCFailChannelUpdate as nativeHTLCFailChannelUpdate;
3706 impl HTLCFailChannelUpdate {
3708 pub(crate) fn to_native(&self) -> nativeHTLCFailChannelUpdate {
3710 HTLCFailChannelUpdate::ChannelUpdateMessage {ref msg, } => {
3711 let mut msg_nonref = (*msg).clone();
3712 nativeHTLCFailChannelUpdate::ChannelUpdateMessage {
3713 msg: *unsafe { Box::from_raw(msg_nonref.take_ptr()) },
3716 HTLCFailChannelUpdate::ChannelClosed {ref short_channel_id, ref is_permanent, } => {
3717 let mut short_channel_id_nonref = (*short_channel_id).clone();
3718 let mut is_permanent_nonref = (*is_permanent).clone();
3719 nativeHTLCFailChannelUpdate::ChannelClosed {
3720 short_channel_id: short_channel_id_nonref,
3721 is_permanent: is_permanent_nonref,
3724 HTLCFailChannelUpdate::NodeFailure {ref node_id, ref is_permanent, } => {
3725 let mut node_id_nonref = (*node_id).clone();
3726 let mut is_permanent_nonref = (*is_permanent).clone();
3727 nativeHTLCFailChannelUpdate::NodeFailure {
3728 node_id: node_id_nonref.into_rust(),
3729 is_permanent: is_permanent_nonref,
3735 pub(crate) fn into_native(self) -> nativeHTLCFailChannelUpdate {
3737 HTLCFailChannelUpdate::ChannelUpdateMessage {mut msg, } => {
3738 nativeHTLCFailChannelUpdate::ChannelUpdateMessage {
3739 msg: *unsafe { Box::from_raw(msg.take_ptr()) },
3742 HTLCFailChannelUpdate::ChannelClosed {mut short_channel_id, mut is_permanent, } => {
3743 nativeHTLCFailChannelUpdate::ChannelClosed {
3744 short_channel_id: short_channel_id,
3745 is_permanent: is_permanent,
3748 HTLCFailChannelUpdate::NodeFailure {mut node_id, mut is_permanent, } => {
3749 nativeHTLCFailChannelUpdate::NodeFailure {
3750 node_id: node_id.into_rust(),
3751 is_permanent: is_permanent,
3757 pub(crate) fn from_native(native: &nativeHTLCFailChannelUpdate) -> Self {
3759 nativeHTLCFailChannelUpdate::ChannelUpdateMessage {ref msg, } => {
3760 let mut msg_nonref = (*msg).clone();
3761 HTLCFailChannelUpdate::ChannelUpdateMessage {
3762 msg: crate::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
3765 nativeHTLCFailChannelUpdate::ChannelClosed {ref short_channel_id, ref is_permanent, } => {
3766 let mut short_channel_id_nonref = (*short_channel_id).clone();
3767 let mut is_permanent_nonref = (*is_permanent).clone();
3768 HTLCFailChannelUpdate::ChannelClosed {
3769 short_channel_id: short_channel_id_nonref,
3770 is_permanent: is_permanent_nonref,
3773 nativeHTLCFailChannelUpdate::NodeFailure {ref node_id, ref is_permanent, } => {
3774 let mut node_id_nonref = (*node_id).clone();
3775 let mut is_permanent_nonref = (*is_permanent).clone();
3776 HTLCFailChannelUpdate::NodeFailure {
3777 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3778 is_permanent: is_permanent_nonref,
3784 pub(crate) fn native_into(native: nativeHTLCFailChannelUpdate) -> Self {
3786 nativeHTLCFailChannelUpdate::ChannelUpdateMessage {mut msg, } => {
3787 HTLCFailChannelUpdate::ChannelUpdateMessage {
3788 msg: crate::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(msg)), is_owned: true },
3791 nativeHTLCFailChannelUpdate::ChannelClosed {mut short_channel_id, mut is_permanent, } => {
3792 HTLCFailChannelUpdate::ChannelClosed {
3793 short_channel_id: short_channel_id,
3794 is_permanent: is_permanent,
3797 nativeHTLCFailChannelUpdate::NodeFailure {mut node_id, mut is_permanent, } => {
3798 HTLCFailChannelUpdate::NodeFailure {
3799 node_id: crate::c_types::PublicKey::from_rust(&node_id),
3800 is_permanent: is_permanent,
3807 pub extern "C" fn HTLCFailChannelUpdate_free(this_ptr: HTLCFailChannelUpdate) { }
3808 /// A trait to describe an object which can receive channel messages.
3810 /// Messages MAY be called in parallel when they originate from different their_node_ids, however
3811 /// they MUST NOT be called in parallel when the two calls have the same their_node_id.
3813 pub struct ChannelMessageHandler {
3814 pub this_arg: *mut c_void,
3815 /// Handle an incoming open_channel message from the given peer.
3816 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),
3817 /// Handle an incoming accept_channel message from the given peer.
3818 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),
3819 /// Handle an incoming funding_created message from the given peer.
3820 pub handle_funding_created: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingCreated),
3821 /// Handle an incoming funding_signed message from the given peer.
3822 pub handle_funding_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingSigned),
3823 /// Handle an incoming funding_locked message from the given peer.
3824 pub handle_funding_locked: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingLocked),
3825 /// Handle an incoming shutdown message from the given peer.
3826 pub handle_shutdown: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::Shutdown),
3827 /// Handle an incoming closing_signed message from the given peer.
3828 pub handle_closing_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ClosingSigned),
3829 /// Handle an incoming update_add_htlc message from the given peer.
3830 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),
3831 /// Handle an incoming update_fulfill_htlc message from the given peer.
3832 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),
3833 /// Handle an incoming update_fail_htlc message from the given peer.
3834 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),
3835 /// Handle an incoming update_fail_malformed_htlc message from the given peer.
3836 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),
3837 /// Handle an incoming commitment_signed message from the given peer.
3838 pub handle_commitment_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::CommitmentSigned),
3839 /// Handle an incoming revoke_and_ack message from the given peer.
3840 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),
3841 /// Handle an incoming update_fee message from the given peer.
3842 pub handle_update_fee: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFee),
3843 /// Handle an incoming announcement_signatures message from the given peer.
3844 pub handle_announcement_signatures: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::AnnouncementSignatures),
3845 /// Indicates a connection to the peer failed/an existing connection was lost. If no connection
3846 /// is believed to be possible in the future (eg they're sending us messages we don't
3847 /// understand or indicate they require unknown feature bits), no_connection_possible is set
3848 /// and any outstanding channels should be failed.
3849 pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, no_connection_possible: bool),
3850 /// Handle a peer reconnecting, possibly generating channel_reestablish message(s).
3851 pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::Init),
3852 /// Handle an incoming channel_reestablish message from the given peer.
3853 pub handle_channel_reestablish: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ChannelReestablish),
3854 /// Handle an incoming error message from the given peer.
3855 pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ErrorMessage),
3856 pub MessageSendEventsProvider: crate::util::events::MessageSendEventsProvider,
3857 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
3859 impl lightning::util::events::MessageSendEventsProvider for ChannelMessageHandler {
3860 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
3861 <crate::util::events::MessageSendEventsProvider as lightning::util::events::MessageSendEventsProvider>::get_and_clear_pending_msg_events(&self.MessageSendEventsProvider)
3864 unsafe impl Send for ChannelMessageHandler {}
3865 unsafe impl Sync for ChannelMessageHandler {}
3867 use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler;
3868 impl rustChannelMessageHandler for ChannelMessageHandler {
3869 fn handle_open_channel(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, their_features: lightning::ln::features::InitFeatures, msg: &lightning::ln::msgs::OpenChannel) {
3870 (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 })
3872 fn handle_accept_channel(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, their_features: lightning::ln::features::InitFeatures, msg: &lightning::ln::msgs::AcceptChannel) {
3873 (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 })
3875 fn handle_funding_created(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::FundingCreated) {
3876 (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 })
3878 fn handle_funding_signed(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::FundingSigned) {
3879 (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 })
3881 fn handle_funding_locked(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::FundingLocked) {
3882 (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 })
3884 fn handle_shutdown(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::Shutdown) {
3885 (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 })
3887 fn handle_closing_signed(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::ClosingSigned) {
3888 (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 })
3890 fn handle_update_add_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateAddHTLC) {
3891 (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 })
3893 fn handle_update_fulfill_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFulfillHTLC) {
3894 (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 })
3896 fn handle_update_fail_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFailHTLC) {
3897 (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 })
3899 fn handle_update_fail_malformed_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) {
3900 (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 })
3902 fn handle_commitment_signed(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::CommitmentSigned) {
3903 (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 })
3905 fn handle_revoke_and_ack(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::RevokeAndACK) {
3906 (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 })
3908 fn handle_update_fee(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFee) {
3909 (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 })
3911 fn handle_announcement_signatures(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::AnnouncementSignatures) {
3912 (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 })
3914 fn peer_disconnected(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, no_connection_possible: bool) {
3915 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), no_connection_possible)
3917 fn peer_connected(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::Init) {
3918 (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 })
3920 fn handle_channel_reestablish(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::ChannelReestablish) {
3921 (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 })
3923 fn handle_error(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::ErrorMessage) {
3924 (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 })
3928 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
3929 // directly as a Deref trait in higher-level structs:
3930 impl std::ops::Deref for ChannelMessageHandler {
3932 fn deref(&self) -> &Self {
3936 /// Calls the free function if one is set
3938 pub extern "C" fn ChannelMessageHandler_free(this_ptr: ChannelMessageHandler) { }
3939 impl Drop for ChannelMessageHandler {
3940 fn drop(&mut self) {
3941 if let Some(f) = self.free {
3946 /// A trait to describe an object which can receive routing messages.
3948 pub struct RoutingMessageHandler {
3949 pub this_arg: *mut c_void,
3950 /// Handle an incoming node_announcement message, returning true if it should be forwarded on,
3951 /// false or returning an Err otherwise.
3953 pub handle_node_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
3954 /// Handle a channel_announcement message, returning true if it should be forwarded on, false
3955 /// or returning an Err otherwise.
3957 pub handle_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
3958 /// Handle an incoming channel_update message, returning true if it should be forwarded on,
3959 /// false or returning an Err otherwise.
3961 pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ,
3962 /// Handle some updates to the route graph that we learned due to an outbound failed payment.
3963 pub handle_htlc_fail_channel_update: extern "C" fn (this_arg: *const c_void, update: &crate::ln::msgs::HTLCFailChannelUpdate),
3964 /// Gets a subset of the channel announcements and updates required to dump our routing table
3965 /// to a remote node, starting at the short_channel_id indicated by starting_point and
3966 /// including the batch_amount entries immediately higher in numerical value than starting_point.
3968 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,
3969 /// Gets a subset of the node announcements required to dump our routing table to a remote node,
3970 /// starting at the node *after* the provided publickey and including batch_amount entries
3971 /// immediately higher (as defined by <PublicKey as Ord>::cmp) than starting_point.
3972 /// If None is provided for starting_point, we start at the first node.
3974 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,
3975 /// Returns whether a full sync should be requested from a peer.
3977 pub should_request_full_sync: extern "C" fn (this_arg: *const c_void, node_id: crate::c_types::PublicKey) -> bool,
3978 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
3980 unsafe impl Send for RoutingMessageHandler {}
3981 unsafe impl Sync for RoutingMessageHandler {}
3983 use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler;
3984 impl rustRoutingMessageHandler for RoutingMessageHandler {
3985 fn handle_node_announcement(&self, msg: &lightning::ln::msgs::NodeAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
3986 let mut ret = (self.handle_node_announcement)(self.this_arg, &crate::ln::msgs::NodeAnnouncement { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false });
3987 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()) } })};
3990 fn handle_channel_announcement(&self, msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
3991 let mut ret = (self.handle_channel_announcement)(self.this_arg, &crate::ln::msgs::ChannelAnnouncement { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false });
3992 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()) } })};
3995 fn handle_channel_update(&self, msg: &lightning::ln::msgs::ChannelUpdate) -> Result<bool, lightning::ln::msgs::LightningError> {
3996 let mut ret = (self.handle_channel_update)(self.this_arg, &crate::ln::msgs::ChannelUpdate { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false });
3997 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()) } })};
4000 fn handle_htlc_fail_channel_update(&self, update: &lightning::ln::msgs::HTLCFailChannelUpdate) {
4001 (self.handle_htlc_fail_channel_update)(self.this_arg, &crate::ln::msgs::HTLCFailChannelUpdate::from_native(&update))
4003 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>)> {
4004 let mut ret = (self.get_next_channel_announcements)(self.this_arg, starting_point, batch_amount);
4005 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 }); };
4008 fn get_next_node_announcements(&self, starting_point: Option<&bitcoin::secp256k1::key::PublicKey>, batch_amount: u8) -> Vec<lightning::ln::msgs::NodeAnnouncement> {
4009 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())) } };
4010 let mut ret = (self.get_next_node_announcements)(self.this_arg, local_starting_point, batch_amount);
4011 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); };
4014 fn should_request_full_sync(&self, node_id: &bitcoin::secp256k1::key::PublicKey) -> bool {
4015 let mut ret = (self.should_request_full_sync)(self.this_arg, crate::c_types::PublicKey::from_rust(&node_id));
4020 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
4021 // directly as a Deref trait in higher-level structs:
4022 impl std::ops::Deref for RoutingMessageHandler {
4024 fn deref(&self) -> &Self {
4028 /// Calls the free function if one is set
4030 pub extern "C" fn RoutingMessageHandler_free(this_ptr: RoutingMessageHandler) { }
4031 impl Drop for RoutingMessageHandler {
4032 fn drop(&mut self) {
4033 if let Some(f) = self.free {
4039 pub extern "C" fn AcceptChannel_write(obj: *const AcceptChannel) -> crate::c_types::derived::CVec_u8Z {
4040 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4043 pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> AcceptChannel {
4044 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4045 AcceptChannel { inner: Box::into_raw(Box::new(res)), is_owned: true }
4047 AcceptChannel { inner: std::ptr::null_mut(), is_owned: true }
4051 pub extern "C" fn AnnouncementSignatures_write(obj: *const AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z {
4052 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4055 pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> AnnouncementSignatures {
4056 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4057 AnnouncementSignatures { inner: Box::into_raw(Box::new(res)), is_owned: true }
4059 AnnouncementSignatures { inner: std::ptr::null_mut(), is_owned: true }
4063 pub extern "C" fn ChannelReestablish_write(obj: *const ChannelReestablish) -> crate::c_types::derived::CVec_u8Z {
4064 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4067 pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> ChannelReestablish {
4068 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4069 ChannelReestablish { inner: Box::into_raw(Box::new(res)), is_owned: true }
4071 ChannelReestablish { inner: std::ptr::null_mut(), is_owned: true }
4075 pub extern "C" fn ClosingSigned_write(obj: *const ClosingSigned) -> crate::c_types::derived::CVec_u8Z {
4076 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4079 pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> ClosingSigned {
4080 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4081 ClosingSigned { inner: Box::into_raw(Box::new(res)), is_owned: true }
4083 ClosingSigned { inner: std::ptr::null_mut(), is_owned: true }
4087 pub extern "C" fn CommitmentSigned_write(obj: *const CommitmentSigned) -> crate::c_types::derived::CVec_u8Z {
4088 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4091 pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> CommitmentSigned {
4092 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4093 CommitmentSigned { inner: Box::into_raw(Box::new(res)), is_owned: true }
4095 CommitmentSigned { inner: std::ptr::null_mut(), is_owned: true }
4099 pub extern "C" fn FundingCreated_write(obj: *const FundingCreated) -> crate::c_types::derived::CVec_u8Z {
4100 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4103 pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> FundingCreated {
4104 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4105 FundingCreated { inner: Box::into_raw(Box::new(res)), is_owned: true }
4107 FundingCreated { inner: std::ptr::null_mut(), is_owned: true }
4111 pub extern "C" fn FundingSigned_write(obj: *const FundingSigned) -> crate::c_types::derived::CVec_u8Z {
4112 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4115 pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> FundingSigned {
4116 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4117 FundingSigned { inner: Box::into_raw(Box::new(res)), is_owned: true }
4119 FundingSigned { inner: std::ptr::null_mut(), is_owned: true }
4123 pub extern "C" fn FundingLocked_write(obj: *const FundingLocked) -> crate::c_types::derived::CVec_u8Z {
4124 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4127 pub extern "C" fn FundingLocked_read(ser: crate::c_types::u8slice) -> FundingLocked {
4128 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4129 FundingLocked { inner: Box::into_raw(Box::new(res)), is_owned: true }
4131 FundingLocked { inner: std::ptr::null_mut(), is_owned: true }
4135 pub extern "C" fn Init_write(obj: *const Init) -> crate::c_types::derived::CVec_u8Z {
4136 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4139 pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> Init {
4140 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4141 Init { inner: Box::into_raw(Box::new(res)), is_owned: true }
4143 Init { inner: std::ptr::null_mut(), is_owned: true }
4147 pub extern "C" fn OpenChannel_write(obj: *const OpenChannel) -> crate::c_types::derived::CVec_u8Z {
4148 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4151 pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> OpenChannel {
4152 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4153 OpenChannel { inner: Box::into_raw(Box::new(res)), is_owned: true }
4155 OpenChannel { inner: std::ptr::null_mut(), is_owned: true }
4159 pub extern "C" fn RevokeAndACK_write(obj: *const RevokeAndACK) -> crate::c_types::derived::CVec_u8Z {
4160 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4163 pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> RevokeAndACK {
4164 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4165 RevokeAndACK { inner: Box::into_raw(Box::new(res)), is_owned: true }
4167 RevokeAndACK { inner: std::ptr::null_mut(), is_owned: true }
4171 pub extern "C" fn Shutdown_write(obj: *const Shutdown) -> crate::c_types::derived::CVec_u8Z {
4172 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4175 pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> Shutdown {
4176 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4177 Shutdown { inner: Box::into_raw(Box::new(res)), is_owned: true }
4179 Shutdown { inner: std::ptr::null_mut(), is_owned: true }
4183 pub extern "C" fn UpdateFailHTLC_write(obj: *const UpdateFailHTLC) -> crate::c_types::derived::CVec_u8Z {
4184 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4187 pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> UpdateFailHTLC {
4188 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4189 UpdateFailHTLC { inner: Box::into_raw(Box::new(res)), is_owned: true }
4191 UpdateFailHTLC { inner: std::ptr::null_mut(), is_owned: true }
4195 pub extern "C" fn UpdateFailMalformedHTLC_write(obj: *const UpdateFailMalformedHTLC) -> crate::c_types::derived::CVec_u8Z {
4196 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4199 pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> UpdateFailMalformedHTLC {
4200 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4201 UpdateFailMalformedHTLC { inner: Box::into_raw(Box::new(res)), is_owned: true }
4203 UpdateFailMalformedHTLC { inner: std::ptr::null_mut(), is_owned: true }
4207 pub extern "C" fn UpdateFee_write(obj: *const UpdateFee) -> crate::c_types::derived::CVec_u8Z {
4208 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4211 pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> UpdateFee {
4212 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4213 UpdateFee { inner: Box::into_raw(Box::new(res)), is_owned: true }
4215 UpdateFee { inner: std::ptr::null_mut(), is_owned: true }
4219 pub extern "C" fn UpdateFulfillHTLC_write(obj: *const UpdateFulfillHTLC) -> crate::c_types::derived::CVec_u8Z {
4220 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4223 pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> UpdateFulfillHTLC {
4224 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4225 UpdateFulfillHTLC { inner: Box::into_raw(Box::new(res)), is_owned: true }
4227 UpdateFulfillHTLC { inner: std::ptr::null_mut(), is_owned: true }
4231 pub extern "C" fn UpdateAddHTLC_write(obj: *const UpdateAddHTLC) -> crate::c_types::derived::CVec_u8Z {
4232 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4235 pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> UpdateAddHTLC {
4236 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4237 UpdateAddHTLC { inner: Box::into_raw(Box::new(res)), is_owned: true }
4239 UpdateAddHTLC { inner: std::ptr::null_mut(), is_owned: true }
4243 pub extern "C" fn Ping_write(obj: *const Ping) -> crate::c_types::derived::CVec_u8Z {
4244 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4247 pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> Ping {
4248 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4249 Ping { inner: Box::into_raw(Box::new(res)), is_owned: true }
4251 Ping { inner: std::ptr::null_mut(), is_owned: true }
4255 pub extern "C" fn Pong_write(obj: *const Pong) -> crate::c_types::derived::CVec_u8Z {
4256 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4259 pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> Pong {
4260 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4261 Pong { inner: Box::into_raw(Box::new(res)), is_owned: true }
4263 Pong { inner: std::ptr::null_mut(), is_owned: true }
4267 pub extern "C" fn UnsignedChannelAnnouncement_write(obj: *const UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
4268 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4271 pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> UnsignedChannelAnnouncement {
4272 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4273 UnsignedChannelAnnouncement { inner: Box::into_raw(Box::new(res)), is_owned: true }
4275 UnsignedChannelAnnouncement { inner: std::ptr::null_mut(), is_owned: true }
4279 pub extern "C" fn ChannelAnnouncement_write(obj: *const ChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
4280 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4283 pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> ChannelAnnouncement {
4284 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4285 ChannelAnnouncement { inner: Box::into_raw(Box::new(res)), is_owned: true }
4287 ChannelAnnouncement { inner: std::ptr::null_mut(), is_owned: true }
4291 pub extern "C" fn UnsignedChannelUpdate_write(obj: *const UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
4292 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4295 pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> UnsignedChannelUpdate {
4296 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4297 UnsignedChannelUpdate { inner: Box::into_raw(Box::new(res)), is_owned: true }
4299 UnsignedChannelUpdate { inner: std::ptr::null_mut(), is_owned: true }
4303 pub extern "C" fn ChannelUpdate_write(obj: *const ChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
4304 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4307 pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> ChannelUpdate {
4308 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4309 ChannelUpdate { inner: Box::into_raw(Box::new(res)), is_owned: true }
4311 ChannelUpdate { inner: std::ptr::null_mut(), is_owned: true }
4315 pub extern "C" fn ErrorMessage_write(obj: *const ErrorMessage) -> crate::c_types::derived::CVec_u8Z {
4316 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4319 pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> ErrorMessage {
4320 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4321 ErrorMessage { inner: Box::into_raw(Box::new(res)), is_owned: true }
4323 ErrorMessage { inner: std::ptr::null_mut(), is_owned: true }
4327 pub extern "C" fn UnsignedNodeAnnouncement_write(obj: *const UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
4328 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4331 pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> UnsignedNodeAnnouncement {
4332 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4333 UnsignedNodeAnnouncement { inner: Box::into_raw(Box::new(res)), is_owned: true }
4335 UnsignedNodeAnnouncement { inner: std::ptr::null_mut(), is_owned: true }
4339 pub extern "C" fn NodeAnnouncement_write(obj: *const NodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
4340 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4343 pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> NodeAnnouncement {
4344 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4345 NodeAnnouncement { inner: Box::into_raw(Box::new(res)), is_owned: true }
4347 NodeAnnouncement { inner: std::ptr::null_mut(), is_owned: true }
4351 pub extern "C" fn QueryShortChannelIds_read(ser: crate::c_types::u8slice) -> QueryShortChannelIds {
4352 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4353 QueryShortChannelIds { inner: Box::into_raw(Box::new(res)), is_owned: true }
4355 QueryShortChannelIds { inner: std::ptr::null_mut(), is_owned: true }
4359 pub extern "C" fn QueryShortChannelIds_write(obj: *const QueryShortChannelIds) -> crate::c_types::derived::CVec_u8Z {
4360 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4363 pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> ReplyShortChannelIdsEnd {
4364 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4365 ReplyShortChannelIdsEnd { inner: Box::into_raw(Box::new(res)), is_owned: true }
4367 ReplyShortChannelIdsEnd { inner: std::ptr::null_mut(), is_owned: true }
4371 pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: *const ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z {
4372 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4375 pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> QueryChannelRange {
4376 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4377 QueryChannelRange { inner: Box::into_raw(Box::new(res)), is_owned: true }
4379 QueryChannelRange { inner: std::ptr::null_mut(), is_owned: true }
4383 pub extern "C" fn QueryChannelRange_write(obj: *const QueryChannelRange) -> crate::c_types::derived::CVec_u8Z {
4384 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4387 pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> ReplyChannelRange {
4388 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4389 ReplyChannelRange { inner: Box::into_raw(Box::new(res)), is_owned: true }
4391 ReplyChannelRange { inner: std::ptr::null_mut(), is_owned: true }
4395 pub extern "C" fn ReplyChannelRange_write(obj: *const ReplyChannelRange) -> crate::c_types::derived::CVec_u8Z {
4396 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4399 pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> GossipTimestampFilter {
4400 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4401 GossipTimestampFilter { inner: Box::into_raw(Box::new(res)), is_owned: true }
4403 GossipTimestampFilter { inner: std::ptr::null_mut(), is_owned: true }
4407 pub extern "C" fn GossipTimestampFilter_write(obj: *const GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z {
4408 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })