1 //! Wire messages, traits representing wire message handlers, and a few error types live here.
3 //! For a normal node you probably don't need to use anything here, however, if you wish to split a
4 //! node into an internet-facing route/message socket handling daemon and a separate daemon (or
5 //! server entirely) which handles only channel-related messages you may wish to implement
6 //! ChannelMessageHandler yourself and use it to re-serialize messages and pass them across
9 //! Note that if you go with such an architecture (instead of passing raw socket events to a
10 //! non-internet-facing system) you trust the frontend internet-facing system to not lie about the
11 //! source node_id of the message, however this does allow you to significantly reduce bandwidth
12 //! between the systems as routing messages can represent a significant chunk of bandwidth usage
13 //! (especially for non-channel-publicly-announcing nodes). As an alternate design which avoids
14 //! this issue, if you have sufficient bidirectional bandwidth between your systems, you may send
15 //! raw socket events into your non-internet-facing system and then send routing events back to
16 //! track the network on the less-secure system.
19 use bitcoin::hashes::Hash;
20 use crate::c_types::*;
23 use lightning::ln::msgs::DecodeError as nativeDecodeErrorImport;
24 type nativeDecodeError = nativeDecodeErrorImport;
26 /// An error in decoding a message or struct.
29 pub struct DecodeError {
30 /// Nearly everywhere, inner must be non-null, however in places where
31 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
32 pub inner: *mut nativeDecodeError,
36 impl Drop for DecodeError {
38 if self.is_owned && !self.inner.is_null() {
39 let _ = unsafe { Box::from_raw(self.inner) };
44 pub extern "C" fn DecodeError_free(this_ptr: DecodeError) { }
46 /// Used only if an object of this type is returned as a trait impl by a method
47 extern "C" fn DecodeError_free_void(this_ptr: *mut c_void) {
48 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDecodeError); }
51 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
53 pub(crate) fn take_inner(mut self) -> *mut nativeDecodeError {
54 assert!(self.is_owned);
56 self.inner = std::ptr::null_mut();
60 impl Clone for DecodeError {
61 fn clone(&self) -> Self {
63 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
64 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
70 /// Used only if an object of this type is returned as a trait impl by a method
71 pub(crate) extern "C" fn DecodeError_clone_void(this_ptr: *const c_void) -> *mut c_void {
72 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDecodeError)).clone() })) as *mut c_void
75 pub extern "C" fn DecodeError_clone(orig: &DecodeError) -> DecodeError {
79 use lightning::ln::msgs::Init as nativeInitImport;
80 type nativeInit = nativeInitImport;
82 /// An init message to be sent or received from a peer
86 /// Nearly everywhere, inner must be non-null, however in places where
87 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
88 pub inner: *mut nativeInit,
94 if self.is_owned && !self.inner.is_null() {
95 let _ = unsafe { Box::from_raw(self.inner) };
100 pub extern "C" fn Init_free(this_ptr: Init) { }
102 /// Used only if an object of this type is returned as a trait impl by a method
103 extern "C" fn Init_free_void(this_ptr: *mut c_void) {
104 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeInit); }
107 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
109 pub(crate) fn take_inner(mut self) -> *mut nativeInit {
110 assert!(self.is_owned);
111 let ret = self.inner;
112 self.inner = std::ptr::null_mut();
116 impl Clone for Init {
117 fn clone(&self) -> Self {
119 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
120 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
126 /// Used only if an object of this type is returned as a trait impl by a method
127 pub(crate) extern "C" fn Init_clone_void(this_ptr: *const c_void) -> *mut c_void {
128 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInit)).clone() })) as *mut c_void
131 pub extern "C" fn Init_clone(orig: &Init) -> Init {
135 use lightning::ln::msgs::ErrorMessage as nativeErrorMessageImport;
136 type nativeErrorMessage = nativeErrorMessageImport;
138 /// An error message to be sent or received from a peer
141 pub struct ErrorMessage {
142 /// Nearly everywhere, inner must be non-null, however in places where
143 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
144 pub inner: *mut nativeErrorMessage,
148 impl Drop for ErrorMessage {
150 if self.is_owned && !self.inner.is_null() {
151 let _ = unsafe { Box::from_raw(self.inner) };
156 pub extern "C" fn ErrorMessage_free(this_ptr: ErrorMessage) { }
158 /// Used only if an object of this type is returned as a trait impl by a method
159 extern "C" fn ErrorMessage_free_void(this_ptr: *mut c_void) {
160 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeErrorMessage); }
163 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
165 pub(crate) fn take_inner(mut self) -> *mut nativeErrorMessage {
166 assert!(self.is_owned);
167 let ret = self.inner;
168 self.inner = std::ptr::null_mut();
172 impl Clone for ErrorMessage {
173 fn clone(&self) -> Self {
175 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
176 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
182 /// Used only if an object of this type is returned as a trait impl by a method
183 pub(crate) extern "C" fn ErrorMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
184 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeErrorMessage)).clone() })) as *mut c_void
187 pub extern "C" fn ErrorMessage_clone(orig: &ErrorMessage) -> ErrorMessage {
190 /// The channel ID involved in the error
192 pub extern "C" fn ErrorMessage_get_channel_id(this_ptr: &ErrorMessage) -> *const [u8; 32] {
193 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
196 /// The channel ID involved in the error
198 pub extern "C" fn ErrorMessage_set_channel_id(this_ptr: &mut ErrorMessage, mut val: crate::c_types::ThirtyTwoBytes) {
199 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
201 /// A possibly human-readable error description.
202 /// The string should be sanitized before it is used (e.g. emitted to logs
203 /// or printed to stdout). Otherwise, a well crafted error message may trigger a security
204 /// vulnerability in the terminal emulator or the logging subsystem.
206 pub extern "C" fn ErrorMessage_get_data(this_ptr: &ErrorMessage) -> crate::c_types::Str {
207 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.data;
208 (*inner_val).as_str().into()
210 /// A possibly human-readable error description.
211 /// The string should be sanitized before it is used (e.g. emitted to logs
212 /// or printed to stdout). Otherwise, a well crafted error message may trigger a security
213 /// vulnerability in the terminal emulator or the logging subsystem.
215 pub extern "C" fn ErrorMessage_set_data(this_ptr: &mut ErrorMessage, mut val: crate::c_types::derived::CVec_u8Z) {
216 unsafe { &mut *this_ptr.inner }.data = String::from_utf8(val.into_rust()).unwrap();
220 pub extern "C" fn ErrorMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::derived::CVec_u8Z) -> ErrorMessage {
221 ErrorMessage { inner: Box::into_raw(Box::new(nativeErrorMessage {
222 channel_id: channel_id_arg.data,
223 data: String::from_utf8(data_arg.into_rust()).unwrap(),
224 })), is_owned: true }
227 use lightning::ln::msgs::Ping as nativePingImport;
228 type nativePing = nativePingImport;
230 /// A ping message to be sent or received from a peer
234 /// Nearly everywhere, inner must be non-null, however in places where
235 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
236 pub inner: *mut nativePing,
242 if self.is_owned && !self.inner.is_null() {
243 let _ = unsafe { Box::from_raw(self.inner) };
248 pub extern "C" fn Ping_free(this_ptr: Ping) { }
250 /// Used only if an object of this type is returned as a trait impl by a method
251 extern "C" fn Ping_free_void(this_ptr: *mut c_void) {
252 unsafe { let _ = Box::from_raw(this_ptr as *mut nativePing); }
255 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
257 pub(crate) fn take_inner(mut self) -> *mut nativePing {
258 assert!(self.is_owned);
259 let ret = self.inner;
260 self.inner = std::ptr::null_mut();
264 impl Clone for Ping {
265 fn clone(&self) -> Self {
267 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
268 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
274 /// Used only if an object of this type is returned as a trait impl by a method
275 pub(crate) extern "C" fn Ping_clone_void(this_ptr: *const c_void) -> *mut c_void {
276 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePing)).clone() })) as *mut c_void
279 pub extern "C" fn Ping_clone(orig: &Ping) -> Ping {
282 /// The desired response length
284 pub extern "C" fn Ping_get_ponglen(this_ptr: &Ping) -> u16 {
285 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.ponglen;
288 /// The desired response length
290 pub extern "C" fn Ping_set_ponglen(this_ptr: &mut Ping, mut val: u16) {
291 unsafe { &mut *this_ptr.inner }.ponglen = val;
293 /// The ping packet size.
294 /// This field is not sent on the wire. byteslen zeros are sent.
296 pub extern "C" fn Ping_get_byteslen(this_ptr: &Ping) -> u16 {
297 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.byteslen;
300 /// The ping packet size.
301 /// This field is not sent on the wire. byteslen zeros are sent.
303 pub extern "C" fn Ping_set_byteslen(this_ptr: &mut Ping, mut val: u16) {
304 unsafe { &mut *this_ptr.inner }.byteslen = val;
308 pub extern "C" fn Ping_new(mut ponglen_arg: u16, mut byteslen_arg: u16) -> Ping {
309 Ping { inner: Box::into_raw(Box::new(nativePing {
310 ponglen: ponglen_arg,
311 byteslen: byteslen_arg,
312 })), is_owned: true }
315 use lightning::ln::msgs::Pong as nativePongImport;
316 type nativePong = nativePongImport;
318 /// A pong message to be sent or received from a peer
322 /// Nearly everywhere, inner must be non-null, however in places where
323 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
324 pub inner: *mut nativePong,
330 if self.is_owned && !self.inner.is_null() {
331 let _ = unsafe { Box::from_raw(self.inner) };
336 pub extern "C" fn Pong_free(this_ptr: Pong) { }
338 /// Used only if an object of this type is returned as a trait impl by a method
339 extern "C" fn Pong_free_void(this_ptr: *mut c_void) {
340 unsafe { let _ = Box::from_raw(this_ptr as *mut nativePong); }
343 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
345 pub(crate) fn take_inner(mut self) -> *mut nativePong {
346 assert!(self.is_owned);
347 let ret = self.inner;
348 self.inner = std::ptr::null_mut();
352 impl Clone for Pong {
353 fn clone(&self) -> Self {
355 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
356 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
362 /// Used only if an object of this type is returned as a trait impl by a method
363 pub(crate) extern "C" fn Pong_clone_void(this_ptr: *const c_void) -> *mut c_void {
364 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePong)).clone() })) as *mut c_void
367 pub extern "C" fn Pong_clone(orig: &Pong) -> Pong {
370 /// The pong packet size.
371 /// This field is not sent on the wire. byteslen zeros are sent.
373 pub extern "C" fn Pong_get_byteslen(this_ptr: &Pong) -> u16 {
374 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.byteslen;
377 /// The pong packet size.
378 /// This field is not sent on the wire. byteslen zeros are sent.
380 pub extern "C" fn Pong_set_byteslen(this_ptr: &mut Pong, mut val: u16) {
381 unsafe { &mut *this_ptr.inner }.byteslen = val;
385 pub extern "C" fn Pong_new(mut byteslen_arg: u16) -> Pong {
386 Pong { inner: Box::into_raw(Box::new(nativePong {
387 byteslen: byteslen_arg,
388 })), is_owned: true }
391 use lightning::ln::msgs::OpenChannel as nativeOpenChannelImport;
392 type nativeOpenChannel = nativeOpenChannelImport;
394 /// An open_channel message to be sent or received from a peer
397 pub struct OpenChannel {
398 /// Nearly everywhere, inner must be non-null, however in places where
399 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
400 pub inner: *mut nativeOpenChannel,
404 impl Drop for OpenChannel {
406 if self.is_owned && !self.inner.is_null() {
407 let _ = unsafe { Box::from_raw(self.inner) };
412 pub extern "C" fn OpenChannel_free(this_ptr: OpenChannel) { }
414 /// Used only if an object of this type is returned as a trait impl by a method
415 extern "C" fn OpenChannel_free_void(this_ptr: *mut c_void) {
416 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeOpenChannel); }
419 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
421 pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannel {
422 assert!(self.is_owned);
423 let ret = self.inner;
424 self.inner = std::ptr::null_mut();
428 impl Clone for OpenChannel {
429 fn clone(&self) -> Self {
431 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
432 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
438 /// Used only if an object of this type is returned as a trait impl by a method
439 pub(crate) extern "C" fn OpenChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
440 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOpenChannel)).clone() })) as *mut c_void
443 pub extern "C" fn OpenChannel_clone(orig: &OpenChannel) -> OpenChannel {
446 /// The genesis hash of the blockchain where the channel is to be opened
448 pub extern "C" fn OpenChannel_get_chain_hash(this_ptr: &OpenChannel) -> *const [u8; 32] {
449 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
450 (*inner_val).as_inner()
452 /// The genesis hash of the blockchain where the channel is to be opened
454 pub extern "C" fn OpenChannel_set_chain_hash(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
455 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
457 /// A temporary channel ID, until the funding outpoint is announced
459 pub extern "C" fn OpenChannel_get_temporary_channel_id(this_ptr: &OpenChannel) -> *const [u8; 32] {
460 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.temporary_channel_id;
463 /// A temporary channel ID, until the funding outpoint is announced
465 pub extern "C" fn OpenChannel_set_temporary_channel_id(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
466 unsafe { &mut *this_ptr.inner }.temporary_channel_id = val.data;
468 /// The channel value
470 pub extern "C" fn OpenChannel_get_funding_satoshis(this_ptr: &OpenChannel) -> u64 {
471 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_satoshis;
474 /// The channel value
476 pub extern "C" fn OpenChannel_set_funding_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
477 unsafe { &mut *this_ptr.inner }.funding_satoshis = val;
479 /// The amount to push to the counterparty as part of the open, in milli-satoshi
481 pub extern "C" fn OpenChannel_get_push_msat(this_ptr: &OpenChannel) -> u64 {
482 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.push_msat;
485 /// The amount to push to the counterparty as part of the open, in milli-satoshi
487 pub extern "C" fn OpenChannel_set_push_msat(this_ptr: &mut OpenChannel, mut val: u64) {
488 unsafe { &mut *this_ptr.inner }.push_msat = val;
490 /// The threshold below which outputs on transactions broadcast by sender will be omitted
492 pub extern "C" fn OpenChannel_get_dust_limit_satoshis(this_ptr: &OpenChannel) -> u64 {
493 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.dust_limit_satoshis;
496 /// The threshold below which outputs on transactions broadcast by sender will be omitted
498 pub extern "C" fn OpenChannel_set_dust_limit_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
499 unsafe { &mut *this_ptr.inner }.dust_limit_satoshis = val;
501 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
503 pub extern "C" fn OpenChannel_get_max_htlc_value_in_flight_msat(this_ptr: &OpenChannel) -> u64 {
504 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_htlc_value_in_flight_msat;
507 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
509 pub extern "C" fn OpenChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut OpenChannel, mut val: u64) {
510 unsafe { &mut *this_ptr.inner }.max_htlc_value_in_flight_msat = val;
512 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
514 pub extern "C" fn OpenChannel_get_channel_reserve_satoshis(this_ptr: &OpenChannel) -> u64 {
515 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_reserve_satoshis;
518 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
520 pub extern "C" fn OpenChannel_set_channel_reserve_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
521 unsafe { &mut *this_ptr.inner }.channel_reserve_satoshis = val;
523 /// The minimum HTLC size incoming to sender, in milli-satoshi
525 pub extern "C" fn OpenChannel_get_htlc_minimum_msat(this_ptr: &OpenChannel) -> u64 {
526 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_minimum_msat;
529 /// The minimum HTLC size incoming to sender, in milli-satoshi
531 pub extern "C" fn OpenChannel_set_htlc_minimum_msat(this_ptr: &mut OpenChannel, mut val: u64) {
532 unsafe { &mut *this_ptr.inner }.htlc_minimum_msat = val;
534 /// The feerate per 1000-weight of sender generated transactions, until updated by update_fee
536 pub extern "C" fn OpenChannel_get_feerate_per_kw(this_ptr: &OpenChannel) -> u32 {
537 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.feerate_per_kw;
540 /// The feerate per 1000-weight of sender generated transactions, until updated by update_fee
542 pub extern "C" fn OpenChannel_set_feerate_per_kw(this_ptr: &mut OpenChannel, mut val: u32) {
543 unsafe { &mut *this_ptr.inner }.feerate_per_kw = val;
545 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
547 pub extern "C" fn OpenChannel_get_to_self_delay(this_ptr: &OpenChannel) -> u16 {
548 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.to_self_delay;
551 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
553 pub extern "C" fn OpenChannel_set_to_self_delay(this_ptr: &mut OpenChannel, mut val: u16) {
554 unsafe { &mut *this_ptr.inner }.to_self_delay = val;
556 /// The maximum number of inbound HTLCs towards sender
558 pub extern "C" fn OpenChannel_get_max_accepted_htlcs(this_ptr: &OpenChannel) -> u16 {
559 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_accepted_htlcs;
562 /// The maximum number of inbound HTLCs towards sender
564 pub extern "C" fn OpenChannel_set_max_accepted_htlcs(this_ptr: &mut OpenChannel, mut val: u16) {
565 unsafe { &mut *this_ptr.inner }.max_accepted_htlcs = val;
567 /// The sender's key controlling the funding transaction
569 pub extern "C" fn OpenChannel_get_funding_pubkey(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
570 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_pubkey;
571 crate::c_types::PublicKey::from_rust(&(*inner_val))
573 /// The sender's key controlling the funding transaction
575 pub extern "C" fn OpenChannel_set_funding_pubkey(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
576 unsafe { &mut *this_ptr.inner }.funding_pubkey = val.into_rust();
578 /// Used to derive a revocation key for transactions broadcast by counterparty
580 pub extern "C" fn OpenChannel_get_revocation_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
581 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.revocation_basepoint;
582 crate::c_types::PublicKey::from_rust(&(*inner_val))
584 /// Used to derive a revocation key for transactions broadcast by counterparty
586 pub extern "C" fn OpenChannel_set_revocation_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
587 unsafe { &mut *this_ptr.inner }.revocation_basepoint = val.into_rust();
589 /// A payment key to sender for transactions broadcast by counterparty
591 pub extern "C" fn OpenChannel_get_payment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
592 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_point;
593 crate::c_types::PublicKey::from_rust(&(*inner_val))
595 /// A payment key to sender for transactions broadcast by counterparty
597 pub extern "C" fn OpenChannel_set_payment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
598 unsafe { &mut *this_ptr.inner }.payment_point = val.into_rust();
600 /// Used to derive a payment key to sender for transactions broadcast by sender
602 pub extern "C" fn OpenChannel_get_delayed_payment_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
603 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.delayed_payment_basepoint;
604 crate::c_types::PublicKey::from_rust(&(*inner_val))
606 /// Used to derive a payment key to sender for transactions broadcast by sender
608 pub extern "C" fn OpenChannel_set_delayed_payment_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
609 unsafe { &mut *this_ptr.inner }.delayed_payment_basepoint = val.into_rust();
611 /// Used to derive an HTLC payment key to sender
613 pub extern "C" fn OpenChannel_get_htlc_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
614 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_basepoint;
615 crate::c_types::PublicKey::from_rust(&(*inner_val))
617 /// Used to derive an HTLC payment key to sender
619 pub extern "C" fn OpenChannel_set_htlc_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
620 unsafe { &mut *this_ptr.inner }.htlc_basepoint = val.into_rust();
622 /// The first to-be-broadcast-by-sender transaction's per commitment point
624 pub extern "C" fn OpenChannel_get_first_per_commitment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
625 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_per_commitment_point;
626 crate::c_types::PublicKey::from_rust(&(*inner_val))
628 /// The first to-be-broadcast-by-sender transaction's per commitment point
630 pub extern "C" fn OpenChannel_set_first_per_commitment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
631 unsafe { &mut *this_ptr.inner }.first_per_commitment_point = val.into_rust();
635 pub extern "C" fn OpenChannel_get_channel_flags(this_ptr: &OpenChannel) -> u8 {
636 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_flags;
641 pub extern "C" fn OpenChannel_set_channel_flags(this_ptr: &mut OpenChannel, mut val: u8) {
642 unsafe { &mut *this_ptr.inner }.channel_flags = val;
645 use lightning::ln::msgs::AcceptChannel as nativeAcceptChannelImport;
646 type nativeAcceptChannel = nativeAcceptChannelImport;
648 /// An accept_channel message to be sent or received from a peer
651 pub struct AcceptChannel {
652 /// Nearly everywhere, inner must be non-null, however in places where
653 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
654 pub inner: *mut nativeAcceptChannel,
658 impl Drop for AcceptChannel {
660 if self.is_owned && !self.inner.is_null() {
661 let _ = unsafe { Box::from_raw(self.inner) };
666 pub extern "C" fn AcceptChannel_free(this_ptr: AcceptChannel) { }
668 /// Used only if an object of this type is returned as a trait impl by a method
669 extern "C" fn AcceptChannel_free_void(this_ptr: *mut c_void) {
670 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeAcceptChannel); }
673 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
675 pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannel {
676 assert!(self.is_owned);
677 let ret = self.inner;
678 self.inner = std::ptr::null_mut();
682 impl Clone for AcceptChannel {
683 fn clone(&self) -> Self {
685 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
686 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
692 /// Used only if an object of this type is returned as a trait impl by a method
693 pub(crate) extern "C" fn AcceptChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
694 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAcceptChannel)).clone() })) as *mut c_void
697 pub extern "C" fn AcceptChannel_clone(orig: &AcceptChannel) -> AcceptChannel {
700 /// A temporary channel ID, until the funding outpoint is announced
702 pub extern "C" fn AcceptChannel_get_temporary_channel_id(this_ptr: &AcceptChannel) -> *const [u8; 32] {
703 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.temporary_channel_id;
706 /// A temporary channel ID, until the funding outpoint is announced
708 pub extern "C" fn AcceptChannel_set_temporary_channel_id(this_ptr: &mut AcceptChannel, mut val: crate::c_types::ThirtyTwoBytes) {
709 unsafe { &mut *this_ptr.inner }.temporary_channel_id = val.data;
711 /// The threshold below which outputs on transactions broadcast by sender will be omitted
713 pub extern "C" fn AcceptChannel_get_dust_limit_satoshis(this_ptr: &AcceptChannel) -> u64 {
714 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.dust_limit_satoshis;
717 /// The threshold below which outputs on transactions broadcast by sender will be omitted
719 pub extern "C" fn AcceptChannel_set_dust_limit_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
720 unsafe { &mut *this_ptr.inner }.dust_limit_satoshis = val;
722 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
724 pub extern "C" fn AcceptChannel_get_max_htlc_value_in_flight_msat(this_ptr: &AcceptChannel) -> u64 {
725 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_htlc_value_in_flight_msat;
728 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
730 pub extern "C" fn AcceptChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
731 unsafe { &mut *this_ptr.inner }.max_htlc_value_in_flight_msat = val;
733 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
735 pub extern "C" fn AcceptChannel_get_channel_reserve_satoshis(this_ptr: &AcceptChannel) -> u64 {
736 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_reserve_satoshis;
739 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
741 pub extern "C" fn AcceptChannel_set_channel_reserve_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
742 unsafe { &mut *this_ptr.inner }.channel_reserve_satoshis = val;
744 /// The minimum HTLC size incoming to sender, in milli-satoshi
746 pub extern "C" fn AcceptChannel_get_htlc_minimum_msat(this_ptr: &AcceptChannel) -> u64 {
747 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_minimum_msat;
750 /// The minimum HTLC size incoming to sender, in milli-satoshi
752 pub extern "C" fn AcceptChannel_set_htlc_minimum_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
753 unsafe { &mut *this_ptr.inner }.htlc_minimum_msat = val;
755 /// Minimum depth of the funding transaction before the channel is considered open
757 pub extern "C" fn AcceptChannel_get_minimum_depth(this_ptr: &AcceptChannel) -> u32 {
758 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.minimum_depth;
761 /// Minimum depth of the funding transaction before the channel is considered open
763 pub extern "C" fn AcceptChannel_set_minimum_depth(this_ptr: &mut AcceptChannel, mut val: u32) {
764 unsafe { &mut *this_ptr.inner }.minimum_depth = val;
766 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
768 pub extern "C" fn AcceptChannel_get_to_self_delay(this_ptr: &AcceptChannel) -> u16 {
769 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.to_self_delay;
772 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
774 pub extern "C" fn AcceptChannel_set_to_self_delay(this_ptr: &mut AcceptChannel, mut val: u16) {
775 unsafe { &mut *this_ptr.inner }.to_self_delay = val;
777 /// The maximum number of inbound HTLCs towards sender
779 pub extern "C" fn AcceptChannel_get_max_accepted_htlcs(this_ptr: &AcceptChannel) -> u16 {
780 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_accepted_htlcs;
783 /// The maximum number of inbound HTLCs towards sender
785 pub extern "C" fn AcceptChannel_set_max_accepted_htlcs(this_ptr: &mut AcceptChannel, mut val: u16) {
786 unsafe { &mut *this_ptr.inner }.max_accepted_htlcs = val;
788 /// The sender's key controlling the funding transaction
790 pub extern "C" fn AcceptChannel_get_funding_pubkey(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
791 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_pubkey;
792 crate::c_types::PublicKey::from_rust(&(*inner_val))
794 /// The sender's key controlling the funding transaction
796 pub extern "C" fn AcceptChannel_set_funding_pubkey(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
797 unsafe { &mut *this_ptr.inner }.funding_pubkey = val.into_rust();
799 /// Used to derive a revocation key for transactions broadcast by counterparty
801 pub extern "C" fn AcceptChannel_get_revocation_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
802 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.revocation_basepoint;
803 crate::c_types::PublicKey::from_rust(&(*inner_val))
805 /// Used to derive a revocation key for transactions broadcast by counterparty
807 pub extern "C" fn AcceptChannel_set_revocation_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
808 unsafe { &mut *this_ptr.inner }.revocation_basepoint = val.into_rust();
810 /// A payment key to sender for transactions broadcast by counterparty
812 pub extern "C" fn AcceptChannel_get_payment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
813 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_point;
814 crate::c_types::PublicKey::from_rust(&(*inner_val))
816 /// A payment key to sender for transactions broadcast by counterparty
818 pub extern "C" fn AcceptChannel_set_payment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
819 unsafe { &mut *this_ptr.inner }.payment_point = val.into_rust();
821 /// Used to derive a payment key to sender for transactions broadcast by sender
823 pub extern "C" fn AcceptChannel_get_delayed_payment_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
824 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.delayed_payment_basepoint;
825 crate::c_types::PublicKey::from_rust(&(*inner_val))
827 /// Used to derive a payment key to sender for transactions broadcast by sender
829 pub extern "C" fn AcceptChannel_set_delayed_payment_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
830 unsafe { &mut *this_ptr.inner }.delayed_payment_basepoint = val.into_rust();
832 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
834 pub extern "C" fn AcceptChannel_get_htlc_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
835 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_basepoint;
836 crate::c_types::PublicKey::from_rust(&(*inner_val))
838 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
840 pub extern "C" fn AcceptChannel_set_htlc_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
841 unsafe { &mut *this_ptr.inner }.htlc_basepoint = val.into_rust();
843 /// The first to-be-broadcast-by-sender transaction's per commitment point
845 pub extern "C" fn AcceptChannel_get_first_per_commitment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
846 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_per_commitment_point;
847 crate::c_types::PublicKey::from_rust(&(*inner_val))
849 /// The first to-be-broadcast-by-sender transaction's per commitment point
851 pub extern "C" fn AcceptChannel_set_first_per_commitment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
852 unsafe { &mut *this_ptr.inner }.first_per_commitment_point = val.into_rust();
855 use lightning::ln::msgs::FundingCreated as nativeFundingCreatedImport;
856 type nativeFundingCreated = nativeFundingCreatedImport;
858 /// A funding_created message to be sent or received from a peer
861 pub struct FundingCreated {
862 /// Nearly everywhere, inner must be non-null, however in places where
863 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
864 pub inner: *mut nativeFundingCreated,
868 impl Drop for FundingCreated {
870 if self.is_owned && !self.inner.is_null() {
871 let _ = unsafe { Box::from_raw(self.inner) };
876 pub extern "C" fn FundingCreated_free(this_ptr: FundingCreated) { }
878 /// Used only if an object of this type is returned as a trait impl by a method
879 extern "C" fn FundingCreated_free_void(this_ptr: *mut c_void) {
880 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingCreated); }
883 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
884 impl FundingCreated {
885 pub(crate) fn take_inner(mut self) -> *mut nativeFundingCreated {
886 assert!(self.is_owned);
887 let ret = self.inner;
888 self.inner = std::ptr::null_mut();
892 impl Clone for FundingCreated {
893 fn clone(&self) -> Self {
895 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
896 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
902 /// Used only if an object of this type is returned as a trait impl by a method
903 pub(crate) extern "C" fn FundingCreated_clone_void(this_ptr: *const c_void) -> *mut c_void {
904 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingCreated)).clone() })) as *mut c_void
907 pub extern "C" fn FundingCreated_clone(orig: &FundingCreated) -> FundingCreated {
910 /// A temporary channel ID, until the funding is established
912 pub extern "C" fn FundingCreated_get_temporary_channel_id(this_ptr: &FundingCreated) -> *const [u8; 32] {
913 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.temporary_channel_id;
916 /// A temporary channel ID, until the funding is established
918 pub extern "C" fn FundingCreated_set_temporary_channel_id(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
919 unsafe { &mut *this_ptr.inner }.temporary_channel_id = val.data;
921 /// The funding transaction ID
923 pub extern "C" fn FundingCreated_get_funding_txid(this_ptr: &FundingCreated) -> *const [u8; 32] {
924 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_txid;
925 (*inner_val).as_inner()
927 /// The funding transaction ID
929 pub extern "C" fn FundingCreated_set_funding_txid(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
930 unsafe { &mut *this_ptr.inner }.funding_txid = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
932 /// The specific output index funding this channel
934 pub extern "C" fn FundingCreated_get_funding_output_index(this_ptr: &FundingCreated) -> u16 {
935 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_output_index;
938 /// The specific output index funding this channel
940 pub extern "C" fn FundingCreated_set_funding_output_index(this_ptr: &mut FundingCreated, mut val: u16) {
941 unsafe { &mut *this_ptr.inner }.funding_output_index = val;
943 /// The signature of the channel initiator (funder) on the funding transaction
945 pub extern "C" fn FundingCreated_get_signature(this_ptr: &FundingCreated) -> crate::c_types::Signature {
946 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
947 crate::c_types::Signature::from_rust(&(*inner_val))
949 /// The signature of the channel initiator (funder) on the funding transaction
951 pub extern "C" fn FundingCreated_set_signature(this_ptr: &mut FundingCreated, mut val: crate::c_types::Signature) {
952 unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
956 pub extern "C" fn FundingCreated_new(mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_txid_arg: crate::c_types::ThirtyTwoBytes, mut funding_output_index_arg: u16, mut signature_arg: crate::c_types::Signature) -> FundingCreated {
957 FundingCreated { inner: Box::into_raw(Box::new(nativeFundingCreated {
958 temporary_channel_id: temporary_channel_id_arg.data,
959 funding_txid: ::bitcoin::hash_types::Txid::from_slice(&funding_txid_arg.data[..]).unwrap(),
960 funding_output_index: funding_output_index_arg,
961 signature: signature_arg.into_rust(),
962 })), is_owned: true }
965 use lightning::ln::msgs::FundingSigned as nativeFundingSignedImport;
966 type nativeFundingSigned = nativeFundingSignedImport;
968 /// A funding_signed message to be sent or received from a peer
971 pub struct FundingSigned {
972 /// Nearly everywhere, inner must be non-null, however in places where
973 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
974 pub inner: *mut nativeFundingSigned,
978 impl Drop for FundingSigned {
980 if self.is_owned && !self.inner.is_null() {
981 let _ = unsafe { Box::from_raw(self.inner) };
986 pub extern "C" fn FundingSigned_free(this_ptr: FundingSigned) { }
988 /// Used only if an object of this type is returned as a trait impl by a method
989 extern "C" fn FundingSigned_free_void(this_ptr: *mut c_void) {
990 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingSigned); }
993 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
995 pub(crate) fn take_inner(mut self) -> *mut nativeFundingSigned {
996 assert!(self.is_owned);
997 let ret = self.inner;
998 self.inner = std::ptr::null_mut();
1002 impl Clone for FundingSigned {
1003 fn clone(&self) -> Self {
1005 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1006 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1012 /// Used only if an object of this type is returned as a trait impl by a method
1013 pub(crate) extern "C" fn FundingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
1014 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingSigned)).clone() })) as *mut c_void
1017 pub extern "C" fn FundingSigned_clone(orig: &FundingSigned) -> FundingSigned {
1022 pub extern "C" fn FundingSigned_get_channel_id(this_ptr: &FundingSigned) -> *const [u8; 32] {
1023 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1028 pub extern "C" fn FundingSigned_set_channel_id(this_ptr: &mut FundingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
1029 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1031 /// The signature of the channel acceptor (fundee) on the funding transaction
1033 pub extern "C" fn FundingSigned_get_signature(this_ptr: &FundingSigned) -> crate::c_types::Signature {
1034 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
1035 crate::c_types::Signature::from_rust(&(*inner_val))
1037 /// The signature of the channel acceptor (fundee) on the funding transaction
1039 pub extern "C" fn FundingSigned_set_signature(this_ptr: &mut FundingSigned, mut val: crate::c_types::Signature) {
1040 unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
1044 pub extern "C" fn FundingSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut signature_arg: crate::c_types::Signature) -> FundingSigned {
1045 FundingSigned { inner: Box::into_raw(Box::new(nativeFundingSigned {
1046 channel_id: channel_id_arg.data,
1047 signature: signature_arg.into_rust(),
1048 })), is_owned: true }
1051 use lightning::ln::msgs::FundingLocked as nativeFundingLockedImport;
1052 type nativeFundingLocked = nativeFundingLockedImport;
1054 /// A funding_locked message to be sent or received from a peer
1057 pub struct FundingLocked {
1058 /// Nearly everywhere, inner must be non-null, however in places where
1059 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1060 pub inner: *mut nativeFundingLocked,
1064 impl Drop for FundingLocked {
1065 fn drop(&mut self) {
1066 if self.is_owned && !self.inner.is_null() {
1067 let _ = unsafe { Box::from_raw(self.inner) };
1072 pub extern "C" fn FundingLocked_free(this_ptr: FundingLocked) { }
1074 /// Used only if an object of this type is returned as a trait impl by a method
1075 extern "C" fn FundingLocked_free_void(this_ptr: *mut c_void) {
1076 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingLocked); }
1079 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1080 impl FundingLocked {
1081 pub(crate) fn take_inner(mut self) -> *mut nativeFundingLocked {
1082 assert!(self.is_owned);
1083 let ret = self.inner;
1084 self.inner = std::ptr::null_mut();
1088 impl Clone for FundingLocked {
1089 fn clone(&self) -> Self {
1091 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1092 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1098 /// Used only if an object of this type is returned as a trait impl by a method
1099 pub(crate) extern "C" fn FundingLocked_clone_void(this_ptr: *const c_void) -> *mut c_void {
1100 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingLocked)).clone() })) as *mut c_void
1103 pub extern "C" fn FundingLocked_clone(orig: &FundingLocked) -> FundingLocked {
1108 pub extern "C" fn FundingLocked_get_channel_id(this_ptr: &FundingLocked) -> *const [u8; 32] {
1109 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1114 pub extern "C" fn FundingLocked_set_channel_id(this_ptr: &mut FundingLocked, mut val: crate::c_types::ThirtyTwoBytes) {
1115 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1117 /// The per-commitment point of the second commitment transaction
1119 pub extern "C" fn FundingLocked_get_next_per_commitment_point(this_ptr: &FundingLocked) -> crate::c_types::PublicKey {
1120 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.next_per_commitment_point;
1121 crate::c_types::PublicKey::from_rust(&(*inner_val))
1123 /// The per-commitment point of the second commitment transaction
1125 pub extern "C" fn FundingLocked_set_next_per_commitment_point(this_ptr: &mut FundingLocked, mut val: crate::c_types::PublicKey) {
1126 unsafe { &mut *this_ptr.inner }.next_per_commitment_point = val.into_rust();
1130 pub extern "C" fn FundingLocked_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut next_per_commitment_point_arg: crate::c_types::PublicKey) -> FundingLocked {
1131 FundingLocked { inner: Box::into_raw(Box::new(nativeFundingLocked {
1132 channel_id: channel_id_arg.data,
1133 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
1134 })), is_owned: true }
1137 use lightning::ln::msgs::Shutdown as nativeShutdownImport;
1138 type nativeShutdown = nativeShutdownImport;
1140 /// A shutdown message to be sent or received from a peer
1143 pub struct Shutdown {
1144 /// Nearly everywhere, inner must be non-null, however in places where
1145 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1146 pub inner: *mut nativeShutdown,
1150 impl Drop for Shutdown {
1151 fn drop(&mut self) {
1152 if self.is_owned && !self.inner.is_null() {
1153 let _ = unsafe { Box::from_raw(self.inner) };
1158 pub extern "C" fn Shutdown_free(this_ptr: Shutdown) { }
1160 /// Used only if an object of this type is returned as a trait impl by a method
1161 extern "C" fn Shutdown_free_void(this_ptr: *mut c_void) {
1162 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeShutdown); }
1165 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1167 pub(crate) fn take_inner(mut self) -> *mut nativeShutdown {
1168 assert!(self.is_owned);
1169 let ret = self.inner;
1170 self.inner = std::ptr::null_mut();
1174 impl Clone for Shutdown {
1175 fn clone(&self) -> Self {
1177 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1178 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1184 /// Used only if an object of this type is returned as a trait impl by a method
1185 pub(crate) extern "C" fn Shutdown_clone_void(this_ptr: *const c_void) -> *mut c_void {
1186 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeShutdown)).clone() })) as *mut c_void
1189 pub extern "C" fn Shutdown_clone(orig: &Shutdown) -> Shutdown {
1194 pub extern "C" fn Shutdown_get_channel_id(this_ptr: &Shutdown) -> *const [u8; 32] {
1195 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1200 pub extern "C" fn Shutdown_set_channel_id(this_ptr: &mut Shutdown, mut val: crate::c_types::ThirtyTwoBytes) {
1201 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1203 /// The destination of this peer's funds on closing.
1204 /// Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
1206 pub extern "C" fn Shutdown_get_scriptpubkey(this_ptr: &Shutdown) -> crate::c_types::u8slice {
1207 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.scriptpubkey;
1208 crate::c_types::u8slice::from_slice(&(*inner_val)[..])
1210 /// The destination of this peer's funds on closing.
1211 /// Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
1213 pub extern "C" fn Shutdown_set_scriptpubkey(this_ptr: &mut Shutdown, mut val: crate::c_types::derived::CVec_u8Z) {
1214 unsafe { &mut *this_ptr.inner }.scriptpubkey = ::bitcoin::blockdata::script::Script::from(val.into_rust());
1218 pub extern "C" fn Shutdown_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut scriptpubkey_arg: crate::c_types::derived::CVec_u8Z) -> Shutdown {
1219 Shutdown { inner: Box::into_raw(Box::new(nativeShutdown {
1220 channel_id: channel_id_arg.data,
1221 scriptpubkey: ::bitcoin::blockdata::script::Script::from(scriptpubkey_arg.into_rust()),
1222 })), is_owned: true }
1225 use lightning::ln::msgs::ClosingSigned as nativeClosingSignedImport;
1226 type nativeClosingSigned = nativeClosingSignedImport;
1228 /// A closing_signed message to be sent or received from a peer
1231 pub struct ClosingSigned {
1232 /// Nearly everywhere, inner must be non-null, however in places where
1233 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1234 pub inner: *mut nativeClosingSigned,
1238 impl Drop for ClosingSigned {
1239 fn drop(&mut self) {
1240 if self.is_owned && !self.inner.is_null() {
1241 let _ = unsafe { Box::from_raw(self.inner) };
1246 pub extern "C" fn ClosingSigned_free(this_ptr: ClosingSigned) { }
1248 /// Used only if an object of this type is returned as a trait impl by a method
1249 extern "C" fn ClosingSigned_free_void(this_ptr: *mut c_void) {
1250 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeClosingSigned); }
1253 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1254 impl ClosingSigned {
1255 pub(crate) fn take_inner(mut self) -> *mut nativeClosingSigned {
1256 assert!(self.is_owned);
1257 let ret = self.inner;
1258 self.inner = std::ptr::null_mut();
1262 impl Clone for ClosingSigned {
1263 fn clone(&self) -> Self {
1265 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1266 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1272 /// Used only if an object of this type is returned as a trait impl by a method
1273 pub(crate) extern "C" fn ClosingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
1274 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClosingSigned)).clone() })) as *mut c_void
1277 pub extern "C" fn ClosingSigned_clone(orig: &ClosingSigned) -> ClosingSigned {
1282 pub extern "C" fn ClosingSigned_get_channel_id(this_ptr: &ClosingSigned) -> *const [u8; 32] {
1283 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1288 pub extern "C" fn ClosingSigned_set_channel_id(this_ptr: &mut ClosingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
1289 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1291 /// The proposed total fee for the closing transaction
1293 pub extern "C" fn ClosingSigned_get_fee_satoshis(this_ptr: &ClosingSigned) -> u64 {
1294 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_satoshis;
1297 /// The proposed total fee for the closing transaction
1299 pub extern "C" fn ClosingSigned_set_fee_satoshis(this_ptr: &mut ClosingSigned, mut val: u64) {
1300 unsafe { &mut *this_ptr.inner }.fee_satoshis = val;
1302 /// A signature on the closing transaction
1304 pub extern "C" fn ClosingSigned_get_signature(this_ptr: &ClosingSigned) -> crate::c_types::Signature {
1305 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
1306 crate::c_types::Signature::from_rust(&(*inner_val))
1308 /// A signature on the closing transaction
1310 pub extern "C" fn ClosingSigned_set_signature(this_ptr: &mut ClosingSigned, mut val: crate::c_types::Signature) {
1311 unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
1315 pub extern "C" fn ClosingSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut fee_satoshis_arg: u64, mut signature_arg: crate::c_types::Signature) -> ClosingSigned {
1316 ClosingSigned { inner: Box::into_raw(Box::new(nativeClosingSigned {
1317 channel_id: channel_id_arg.data,
1318 fee_satoshis: fee_satoshis_arg,
1319 signature: signature_arg.into_rust(),
1320 })), is_owned: true }
1323 use lightning::ln::msgs::UpdateAddHTLC as nativeUpdateAddHTLCImport;
1324 type nativeUpdateAddHTLC = nativeUpdateAddHTLCImport;
1326 /// An update_add_htlc message to be sent or received from a peer
1329 pub struct UpdateAddHTLC {
1330 /// Nearly everywhere, inner must be non-null, however in places where
1331 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1332 pub inner: *mut nativeUpdateAddHTLC,
1336 impl Drop for UpdateAddHTLC {
1337 fn drop(&mut self) {
1338 if self.is_owned && !self.inner.is_null() {
1339 let _ = unsafe { Box::from_raw(self.inner) };
1344 pub extern "C" fn UpdateAddHTLC_free(this_ptr: UpdateAddHTLC) { }
1346 /// Used only if an object of this type is returned as a trait impl by a method
1347 extern "C" fn UpdateAddHTLC_free_void(this_ptr: *mut c_void) {
1348 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateAddHTLC); }
1351 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1352 impl UpdateAddHTLC {
1353 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateAddHTLC {
1354 assert!(self.is_owned);
1355 let ret = self.inner;
1356 self.inner = std::ptr::null_mut();
1360 impl Clone for UpdateAddHTLC {
1361 fn clone(&self) -> Self {
1363 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1364 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1370 /// Used only if an object of this type is returned as a trait impl by a method
1371 pub(crate) extern "C" fn UpdateAddHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1372 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateAddHTLC)).clone() })) as *mut c_void
1375 pub extern "C" fn UpdateAddHTLC_clone(orig: &UpdateAddHTLC) -> UpdateAddHTLC {
1380 pub extern "C" fn UpdateAddHTLC_get_channel_id(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
1381 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1386 pub extern "C" fn UpdateAddHTLC_set_channel_id(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1387 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1391 pub extern "C" fn UpdateAddHTLC_get_htlc_id(this_ptr: &UpdateAddHTLC) -> u64 {
1392 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_id;
1397 pub extern "C" fn UpdateAddHTLC_set_htlc_id(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
1398 unsafe { &mut *this_ptr.inner }.htlc_id = val;
1400 /// The HTLC value in milli-satoshi
1402 pub extern "C" fn UpdateAddHTLC_get_amount_msat(this_ptr: &UpdateAddHTLC) -> u64 {
1403 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.amount_msat;
1406 /// The HTLC value in milli-satoshi
1408 pub extern "C" fn UpdateAddHTLC_set_amount_msat(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
1409 unsafe { &mut *this_ptr.inner }.amount_msat = val;
1411 /// The payment hash, the pre-image of which controls HTLC redemption
1413 pub extern "C" fn UpdateAddHTLC_get_payment_hash(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
1414 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_hash;
1417 /// The payment hash, the pre-image of which controls HTLC redemption
1419 pub extern "C" fn UpdateAddHTLC_set_payment_hash(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1420 unsafe { &mut *this_ptr.inner }.payment_hash = ::lightning::ln::channelmanager::PaymentHash(val.data);
1422 /// The expiry height of the HTLC
1424 pub extern "C" fn UpdateAddHTLC_get_cltv_expiry(this_ptr: &UpdateAddHTLC) -> u32 {
1425 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry;
1428 /// The expiry height of the HTLC
1430 pub extern "C" fn UpdateAddHTLC_set_cltv_expiry(this_ptr: &mut UpdateAddHTLC, mut val: u32) {
1431 unsafe { &mut *this_ptr.inner }.cltv_expiry = val;
1434 use lightning::ln::msgs::UpdateFulfillHTLC as nativeUpdateFulfillHTLCImport;
1435 type nativeUpdateFulfillHTLC = nativeUpdateFulfillHTLCImport;
1437 /// An update_fulfill_htlc message to be sent or received from a peer
1440 pub struct UpdateFulfillHTLC {
1441 /// Nearly everywhere, inner must be non-null, however in places where
1442 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1443 pub inner: *mut nativeUpdateFulfillHTLC,
1447 impl Drop for UpdateFulfillHTLC {
1448 fn drop(&mut self) {
1449 if self.is_owned && !self.inner.is_null() {
1450 let _ = unsafe { Box::from_raw(self.inner) };
1455 pub extern "C" fn UpdateFulfillHTLC_free(this_ptr: UpdateFulfillHTLC) { }
1457 /// Used only if an object of this type is returned as a trait impl by a method
1458 extern "C" fn UpdateFulfillHTLC_free_void(this_ptr: *mut c_void) {
1459 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFulfillHTLC); }
1462 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1463 impl UpdateFulfillHTLC {
1464 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFulfillHTLC {
1465 assert!(self.is_owned);
1466 let ret = self.inner;
1467 self.inner = std::ptr::null_mut();
1471 impl Clone for UpdateFulfillHTLC {
1472 fn clone(&self) -> Self {
1474 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1475 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1481 /// Used only if an object of this type is returned as a trait impl by a method
1482 pub(crate) extern "C" fn UpdateFulfillHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1483 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFulfillHTLC)).clone() })) as *mut c_void
1486 pub extern "C" fn UpdateFulfillHTLC_clone(orig: &UpdateFulfillHTLC) -> UpdateFulfillHTLC {
1491 pub extern "C" fn UpdateFulfillHTLC_get_channel_id(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
1492 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1497 pub extern "C" fn UpdateFulfillHTLC_set_channel_id(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1498 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1502 pub extern "C" fn UpdateFulfillHTLC_get_htlc_id(this_ptr: &UpdateFulfillHTLC) -> u64 {
1503 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_id;
1508 pub extern "C" fn UpdateFulfillHTLC_set_htlc_id(this_ptr: &mut UpdateFulfillHTLC, mut val: u64) {
1509 unsafe { &mut *this_ptr.inner }.htlc_id = val;
1511 /// The pre-image of the payment hash, allowing HTLC redemption
1513 pub extern "C" fn UpdateFulfillHTLC_get_payment_preimage(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
1514 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_preimage;
1517 /// The pre-image of the payment hash, allowing HTLC redemption
1519 pub extern "C" fn UpdateFulfillHTLC_set_payment_preimage(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1520 unsafe { &mut *this_ptr.inner }.payment_preimage = ::lightning::ln::channelmanager::PaymentPreimage(val.data);
1524 pub extern "C" fn UpdateFulfillHTLC_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut htlc_id_arg: u64, mut payment_preimage_arg: crate::c_types::ThirtyTwoBytes) -> UpdateFulfillHTLC {
1525 UpdateFulfillHTLC { inner: Box::into_raw(Box::new(nativeUpdateFulfillHTLC {
1526 channel_id: channel_id_arg.data,
1527 htlc_id: htlc_id_arg,
1528 payment_preimage: ::lightning::ln::channelmanager::PaymentPreimage(payment_preimage_arg.data),
1529 })), is_owned: true }
1532 use lightning::ln::msgs::UpdateFailHTLC as nativeUpdateFailHTLCImport;
1533 type nativeUpdateFailHTLC = nativeUpdateFailHTLCImport;
1535 /// An update_fail_htlc message to be sent or received from a peer
1538 pub struct UpdateFailHTLC {
1539 /// Nearly everywhere, inner must be non-null, however in places where
1540 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1541 pub inner: *mut nativeUpdateFailHTLC,
1545 impl Drop for UpdateFailHTLC {
1546 fn drop(&mut self) {
1547 if self.is_owned && !self.inner.is_null() {
1548 let _ = unsafe { Box::from_raw(self.inner) };
1553 pub extern "C" fn UpdateFailHTLC_free(this_ptr: UpdateFailHTLC) { }
1555 /// Used only if an object of this type is returned as a trait impl by a method
1556 extern "C" fn UpdateFailHTLC_free_void(this_ptr: *mut c_void) {
1557 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFailHTLC); }
1560 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1561 impl UpdateFailHTLC {
1562 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailHTLC {
1563 assert!(self.is_owned);
1564 let ret = self.inner;
1565 self.inner = std::ptr::null_mut();
1569 impl Clone for UpdateFailHTLC {
1570 fn clone(&self) -> Self {
1572 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1573 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1579 /// Used only if an object of this type is returned as a trait impl by a method
1580 pub(crate) extern "C" fn UpdateFailHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1581 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailHTLC)).clone() })) as *mut c_void
1584 pub extern "C" fn UpdateFailHTLC_clone(orig: &UpdateFailHTLC) -> UpdateFailHTLC {
1589 pub extern "C" fn UpdateFailHTLC_get_channel_id(this_ptr: &UpdateFailHTLC) -> *const [u8; 32] {
1590 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1595 pub extern "C" fn UpdateFailHTLC_set_channel_id(this_ptr: &mut UpdateFailHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1596 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1600 pub extern "C" fn UpdateFailHTLC_get_htlc_id(this_ptr: &UpdateFailHTLC) -> u64 {
1601 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_id;
1606 pub extern "C" fn UpdateFailHTLC_set_htlc_id(this_ptr: &mut UpdateFailHTLC, mut val: u64) {
1607 unsafe { &mut *this_ptr.inner }.htlc_id = val;
1610 use lightning::ln::msgs::UpdateFailMalformedHTLC as nativeUpdateFailMalformedHTLCImport;
1611 type nativeUpdateFailMalformedHTLC = nativeUpdateFailMalformedHTLCImport;
1613 /// An update_fail_malformed_htlc message to be sent or received from a peer
1616 pub struct UpdateFailMalformedHTLC {
1617 /// Nearly everywhere, inner must be non-null, however in places where
1618 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1619 pub inner: *mut nativeUpdateFailMalformedHTLC,
1623 impl Drop for UpdateFailMalformedHTLC {
1624 fn drop(&mut self) {
1625 if self.is_owned && !self.inner.is_null() {
1626 let _ = unsafe { Box::from_raw(self.inner) };
1631 pub extern "C" fn UpdateFailMalformedHTLC_free(this_ptr: UpdateFailMalformedHTLC) { }
1633 /// Used only if an object of this type is returned as a trait impl by a method
1634 extern "C" fn UpdateFailMalformedHTLC_free_void(this_ptr: *mut c_void) {
1635 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFailMalformedHTLC); }
1638 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1639 impl UpdateFailMalformedHTLC {
1640 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailMalformedHTLC {
1641 assert!(self.is_owned);
1642 let ret = self.inner;
1643 self.inner = std::ptr::null_mut();
1647 impl Clone for UpdateFailMalformedHTLC {
1648 fn clone(&self) -> Self {
1650 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1651 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1657 /// Used only if an object of this type is returned as a trait impl by a method
1658 pub(crate) extern "C" fn UpdateFailMalformedHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1659 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailMalformedHTLC)).clone() })) as *mut c_void
1662 pub extern "C" fn UpdateFailMalformedHTLC_clone(orig: &UpdateFailMalformedHTLC) -> UpdateFailMalformedHTLC {
1667 pub extern "C" fn UpdateFailMalformedHTLC_get_channel_id(this_ptr: &UpdateFailMalformedHTLC) -> *const [u8; 32] {
1668 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1673 pub extern "C" fn UpdateFailMalformedHTLC_set_channel_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1674 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1678 pub extern "C" fn UpdateFailMalformedHTLC_get_htlc_id(this_ptr: &UpdateFailMalformedHTLC) -> u64 {
1679 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_id;
1684 pub extern "C" fn UpdateFailMalformedHTLC_set_htlc_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u64) {
1685 unsafe { &mut *this_ptr.inner }.htlc_id = val;
1687 /// The failure code
1689 pub extern "C" fn UpdateFailMalformedHTLC_get_failure_code(this_ptr: &UpdateFailMalformedHTLC) -> u16 {
1690 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.failure_code;
1693 /// The failure code
1695 pub extern "C" fn UpdateFailMalformedHTLC_set_failure_code(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u16) {
1696 unsafe { &mut *this_ptr.inner }.failure_code = val;
1699 use lightning::ln::msgs::CommitmentSigned as nativeCommitmentSignedImport;
1700 type nativeCommitmentSigned = nativeCommitmentSignedImport;
1702 /// A commitment_signed message to be sent or received from a peer
1705 pub struct CommitmentSigned {
1706 /// Nearly everywhere, inner must be non-null, however in places where
1707 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1708 pub inner: *mut nativeCommitmentSigned,
1712 impl Drop for CommitmentSigned {
1713 fn drop(&mut self) {
1714 if self.is_owned && !self.inner.is_null() {
1715 let _ = unsafe { Box::from_raw(self.inner) };
1720 pub extern "C" fn CommitmentSigned_free(this_ptr: CommitmentSigned) { }
1722 /// Used only if an object of this type is returned as a trait impl by a method
1723 extern "C" fn CommitmentSigned_free_void(this_ptr: *mut c_void) {
1724 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentSigned); }
1727 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1728 impl CommitmentSigned {
1729 pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentSigned {
1730 assert!(self.is_owned);
1731 let ret = self.inner;
1732 self.inner = std::ptr::null_mut();
1736 impl Clone for CommitmentSigned {
1737 fn clone(&self) -> Self {
1739 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1740 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1746 /// Used only if an object of this type is returned as a trait impl by a method
1747 pub(crate) extern "C" fn CommitmentSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
1748 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentSigned)).clone() })) as *mut c_void
1751 pub extern "C" fn CommitmentSigned_clone(orig: &CommitmentSigned) -> CommitmentSigned {
1756 pub extern "C" fn CommitmentSigned_get_channel_id(this_ptr: &CommitmentSigned) -> *const [u8; 32] {
1757 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1762 pub extern "C" fn CommitmentSigned_set_channel_id(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::ThirtyTwoBytes) {
1763 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1765 /// A signature on the commitment transaction
1767 pub extern "C" fn CommitmentSigned_get_signature(this_ptr: &CommitmentSigned) -> crate::c_types::Signature {
1768 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
1769 crate::c_types::Signature::from_rust(&(*inner_val))
1771 /// A signature on the commitment transaction
1773 pub extern "C" fn CommitmentSigned_set_signature(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::Signature) {
1774 unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
1776 /// Signatures on the HTLC transactions
1778 pub extern "C" fn CommitmentSigned_set_htlc_signatures(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::derived::CVec_SignatureZ) {
1779 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_rust() }); };
1780 unsafe { &mut *this_ptr.inner }.htlc_signatures = local_val;
1784 pub extern "C" fn CommitmentSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut signature_arg: crate::c_types::Signature, mut htlc_signatures_arg: crate::c_types::derived::CVec_SignatureZ) -> CommitmentSigned {
1785 let mut local_htlc_signatures_arg = Vec::new(); for mut item in htlc_signatures_arg.into_rust().drain(..) { local_htlc_signatures_arg.push( { item.into_rust() }); };
1786 CommitmentSigned { inner: Box::into_raw(Box::new(nativeCommitmentSigned {
1787 channel_id: channel_id_arg.data,
1788 signature: signature_arg.into_rust(),
1789 htlc_signatures: local_htlc_signatures_arg,
1790 })), is_owned: true }
1793 use lightning::ln::msgs::RevokeAndACK as nativeRevokeAndACKImport;
1794 type nativeRevokeAndACK = nativeRevokeAndACKImport;
1796 /// A revoke_and_ack message to be sent or received from a peer
1799 pub struct RevokeAndACK {
1800 /// Nearly everywhere, inner must be non-null, however in places where
1801 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1802 pub inner: *mut nativeRevokeAndACK,
1806 impl Drop for RevokeAndACK {
1807 fn drop(&mut self) {
1808 if self.is_owned && !self.inner.is_null() {
1809 let _ = unsafe { Box::from_raw(self.inner) };
1814 pub extern "C" fn RevokeAndACK_free(this_ptr: RevokeAndACK) { }
1816 /// Used only if an object of this type is returned as a trait impl by a method
1817 extern "C" fn RevokeAndACK_free_void(this_ptr: *mut c_void) {
1818 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRevokeAndACK); }
1821 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1823 pub(crate) fn take_inner(mut self) -> *mut nativeRevokeAndACK {
1824 assert!(self.is_owned);
1825 let ret = self.inner;
1826 self.inner = std::ptr::null_mut();
1830 impl Clone for RevokeAndACK {
1831 fn clone(&self) -> Self {
1833 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1834 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1840 /// Used only if an object of this type is returned as a trait impl by a method
1841 pub(crate) extern "C" fn RevokeAndACK_clone_void(this_ptr: *const c_void) -> *mut c_void {
1842 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRevokeAndACK)).clone() })) as *mut c_void
1845 pub extern "C" fn RevokeAndACK_clone(orig: &RevokeAndACK) -> RevokeAndACK {
1850 pub extern "C" fn RevokeAndACK_get_channel_id(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
1851 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1856 pub extern "C" fn RevokeAndACK_set_channel_id(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
1857 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1859 /// The secret corresponding to the per-commitment point
1861 pub extern "C" fn RevokeAndACK_get_per_commitment_secret(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
1862 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.per_commitment_secret;
1865 /// The secret corresponding to the per-commitment point
1867 pub extern "C" fn RevokeAndACK_set_per_commitment_secret(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
1868 unsafe { &mut *this_ptr.inner }.per_commitment_secret = val.data;
1870 /// The next sender-broadcast commitment transaction's per-commitment point
1872 pub extern "C" fn RevokeAndACK_get_next_per_commitment_point(this_ptr: &RevokeAndACK) -> crate::c_types::PublicKey {
1873 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.next_per_commitment_point;
1874 crate::c_types::PublicKey::from_rust(&(*inner_val))
1876 /// The next sender-broadcast commitment transaction's per-commitment point
1878 pub extern "C" fn RevokeAndACK_set_next_per_commitment_point(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::PublicKey) {
1879 unsafe { &mut *this_ptr.inner }.next_per_commitment_point = val.into_rust();
1883 pub extern "C" fn RevokeAndACK_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut per_commitment_secret_arg: crate::c_types::ThirtyTwoBytes, mut next_per_commitment_point_arg: crate::c_types::PublicKey) -> RevokeAndACK {
1884 RevokeAndACK { inner: Box::into_raw(Box::new(nativeRevokeAndACK {
1885 channel_id: channel_id_arg.data,
1886 per_commitment_secret: per_commitment_secret_arg.data,
1887 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
1888 })), is_owned: true }
1891 use lightning::ln::msgs::UpdateFee as nativeUpdateFeeImport;
1892 type nativeUpdateFee = nativeUpdateFeeImport;
1894 /// An update_fee message to be sent or received from a peer
1897 pub struct UpdateFee {
1898 /// Nearly everywhere, inner must be non-null, however in places where
1899 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1900 pub inner: *mut nativeUpdateFee,
1904 impl Drop for UpdateFee {
1905 fn drop(&mut self) {
1906 if self.is_owned && !self.inner.is_null() {
1907 let _ = unsafe { Box::from_raw(self.inner) };
1912 pub extern "C" fn UpdateFee_free(this_ptr: UpdateFee) { }
1914 /// Used only if an object of this type is returned as a trait impl by a method
1915 extern "C" fn UpdateFee_free_void(this_ptr: *mut c_void) {
1916 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFee); }
1919 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1921 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFee {
1922 assert!(self.is_owned);
1923 let ret = self.inner;
1924 self.inner = std::ptr::null_mut();
1928 impl Clone for UpdateFee {
1929 fn clone(&self) -> Self {
1931 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
1932 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1938 /// Used only if an object of this type is returned as a trait impl by a method
1939 pub(crate) extern "C" fn UpdateFee_clone_void(this_ptr: *const c_void) -> *mut c_void {
1940 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFee)).clone() })) as *mut c_void
1943 pub extern "C" fn UpdateFee_clone(orig: &UpdateFee) -> UpdateFee {
1948 pub extern "C" fn UpdateFee_get_channel_id(this_ptr: &UpdateFee) -> *const [u8; 32] {
1949 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1954 pub extern "C" fn UpdateFee_set_channel_id(this_ptr: &mut UpdateFee, mut val: crate::c_types::ThirtyTwoBytes) {
1955 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1957 /// Fee rate per 1000-weight of the transaction
1959 pub extern "C" fn UpdateFee_get_feerate_per_kw(this_ptr: &UpdateFee) -> u32 {
1960 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.feerate_per_kw;
1963 /// Fee rate per 1000-weight of the transaction
1965 pub extern "C" fn UpdateFee_set_feerate_per_kw(this_ptr: &mut UpdateFee, mut val: u32) {
1966 unsafe { &mut *this_ptr.inner }.feerate_per_kw = val;
1970 pub extern "C" fn UpdateFee_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut feerate_per_kw_arg: u32) -> UpdateFee {
1971 UpdateFee { inner: Box::into_raw(Box::new(nativeUpdateFee {
1972 channel_id: channel_id_arg.data,
1973 feerate_per_kw: feerate_per_kw_arg,
1974 })), is_owned: true }
1977 use lightning::ln::msgs::DataLossProtect as nativeDataLossProtectImport;
1978 type nativeDataLossProtect = nativeDataLossProtectImport;
1980 /// Proof that the sender knows the per-commitment secret of the previous commitment transaction.
1981 /// This is used to convince the recipient that the channel is at a certain commitment
1982 /// number even if they lost that data due to a local failure. Of course, the peer may lie
1983 /// and even later commitments may have been revoked.
1986 pub struct DataLossProtect {
1987 /// Nearly everywhere, inner must be non-null, however in places where
1988 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1989 pub inner: *mut nativeDataLossProtect,
1993 impl Drop for DataLossProtect {
1994 fn drop(&mut self) {
1995 if self.is_owned && !self.inner.is_null() {
1996 let _ = unsafe { Box::from_raw(self.inner) };
2001 pub extern "C" fn DataLossProtect_free(this_ptr: DataLossProtect) { }
2003 /// Used only if an object of this type is returned as a trait impl by a method
2004 extern "C" fn DataLossProtect_free_void(this_ptr: *mut c_void) {
2005 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDataLossProtect); }
2008 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2009 impl DataLossProtect {
2010 pub(crate) fn take_inner(mut self) -> *mut nativeDataLossProtect {
2011 assert!(self.is_owned);
2012 let ret = self.inner;
2013 self.inner = std::ptr::null_mut();
2017 impl Clone for DataLossProtect {
2018 fn clone(&self) -> Self {
2020 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
2021 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2027 /// Used only if an object of this type is returned as a trait impl by a method
2028 pub(crate) extern "C" fn DataLossProtect_clone_void(this_ptr: *const c_void) -> *mut c_void {
2029 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDataLossProtect)).clone() })) as *mut c_void
2032 pub extern "C" fn DataLossProtect_clone(orig: &DataLossProtect) -> DataLossProtect {
2035 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
2036 /// belonging to the recipient
2038 pub extern "C" fn DataLossProtect_get_your_last_per_commitment_secret(this_ptr: &DataLossProtect) -> *const [u8; 32] {
2039 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.your_last_per_commitment_secret;
2042 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
2043 /// belonging to the recipient
2045 pub extern "C" fn DataLossProtect_set_your_last_per_commitment_secret(this_ptr: &mut DataLossProtect, mut val: crate::c_types::ThirtyTwoBytes) {
2046 unsafe { &mut *this_ptr.inner }.your_last_per_commitment_secret = val.data;
2048 /// The sender's per-commitment point for their current commitment transaction
2050 pub extern "C" fn DataLossProtect_get_my_current_per_commitment_point(this_ptr: &DataLossProtect) -> crate::c_types::PublicKey {
2051 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.my_current_per_commitment_point;
2052 crate::c_types::PublicKey::from_rust(&(*inner_val))
2054 /// The sender's per-commitment point for their current commitment transaction
2056 pub extern "C" fn DataLossProtect_set_my_current_per_commitment_point(this_ptr: &mut DataLossProtect, mut val: crate::c_types::PublicKey) {
2057 unsafe { &mut *this_ptr.inner }.my_current_per_commitment_point = val.into_rust();
2061 pub extern "C" fn DataLossProtect_new(mut your_last_per_commitment_secret_arg: crate::c_types::ThirtyTwoBytes, mut my_current_per_commitment_point_arg: crate::c_types::PublicKey) -> DataLossProtect {
2062 DataLossProtect { inner: Box::into_raw(Box::new(nativeDataLossProtect {
2063 your_last_per_commitment_secret: your_last_per_commitment_secret_arg.data,
2064 my_current_per_commitment_point: my_current_per_commitment_point_arg.into_rust(),
2065 })), is_owned: true }
2068 use lightning::ln::msgs::ChannelReestablish as nativeChannelReestablishImport;
2069 type nativeChannelReestablish = nativeChannelReestablishImport;
2071 /// A channel_reestablish message to be sent or received from a peer
2074 pub struct ChannelReestablish {
2075 /// Nearly everywhere, inner must be non-null, however in places where
2076 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2077 pub inner: *mut nativeChannelReestablish,
2081 impl Drop for ChannelReestablish {
2082 fn drop(&mut self) {
2083 if self.is_owned && !self.inner.is_null() {
2084 let _ = unsafe { Box::from_raw(self.inner) };
2089 pub extern "C" fn ChannelReestablish_free(this_ptr: ChannelReestablish) { }
2091 /// Used only if an object of this type is returned as a trait impl by a method
2092 extern "C" fn ChannelReestablish_free_void(this_ptr: *mut c_void) {
2093 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelReestablish); }
2096 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2097 impl ChannelReestablish {
2098 pub(crate) fn take_inner(mut self) -> *mut nativeChannelReestablish {
2099 assert!(self.is_owned);
2100 let ret = self.inner;
2101 self.inner = std::ptr::null_mut();
2105 impl Clone for ChannelReestablish {
2106 fn clone(&self) -> Self {
2108 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
2109 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2115 /// Used only if an object of this type is returned as a trait impl by a method
2116 pub(crate) extern "C" fn ChannelReestablish_clone_void(this_ptr: *const c_void) -> *mut c_void {
2117 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelReestablish)).clone() })) as *mut c_void
2120 pub extern "C" fn ChannelReestablish_clone(orig: &ChannelReestablish) -> ChannelReestablish {
2125 pub extern "C" fn ChannelReestablish_get_channel_id(this_ptr: &ChannelReestablish) -> *const [u8; 32] {
2126 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
2131 pub extern "C" fn ChannelReestablish_set_channel_id(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) {
2132 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
2134 /// The next commitment number for the sender
2136 pub extern "C" fn ChannelReestablish_get_next_local_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
2137 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.next_local_commitment_number;
2140 /// The next commitment number for the sender
2142 pub extern "C" fn ChannelReestablish_set_next_local_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
2143 unsafe { &mut *this_ptr.inner }.next_local_commitment_number = val;
2145 /// The next commitment number for the recipient
2147 pub extern "C" fn ChannelReestablish_get_next_remote_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
2148 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.next_remote_commitment_number;
2151 /// The next commitment number for the recipient
2153 pub extern "C" fn ChannelReestablish_set_next_remote_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
2154 unsafe { &mut *this_ptr.inner }.next_remote_commitment_number = val;
2157 use lightning::ln::msgs::AnnouncementSignatures as nativeAnnouncementSignaturesImport;
2158 type nativeAnnouncementSignatures = nativeAnnouncementSignaturesImport;
2160 /// An announcement_signatures message to be sent or received from a peer
2163 pub struct AnnouncementSignatures {
2164 /// Nearly everywhere, inner must be non-null, however in places where
2165 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2166 pub inner: *mut nativeAnnouncementSignatures,
2170 impl Drop for AnnouncementSignatures {
2171 fn drop(&mut self) {
2172 if self.is_owned && !self.inner.is_null() {
2173 let _ = unsafe { Box::from_raw(self.inner) };
2178 pub extern "C" fn AnnouncementSignatures_free(this_ptr: AnnouncementSignatures) { }
2180 /// Used only if an object of this type is returned as a trait impl by a method
2181 extern "C" fn AnnouncementSignatures_free_void(this_ptr: *mut c_void) {
2182 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeAnnouncementSignatures); }
2185 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2186 impl AnnouncementSignatures {
2187 pub(crate) fn take_inner(mut self) -> *mut nativeAnnouncementSignatures {
2188 assert!(self.is_owned);
2189 let ret = self.inner;
2190 self.inner = std::ptr::null_mut();
2194 impl Clone for AnnouncementSignatures {
2195 fn clone(&self) -> Self {
2197 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
2198 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2204 /// Used only if an object of this type is returned as a trait impl by a method
2205 pub(crate) extern "C" fn AnnouncementSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
2206 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAnnouncementSignatures)).clone() })) as *mut c_void
2209 pub extern "C" fn AnnouncementSignatures_clone(orig: &AnnouncementSignatures) -> AnnouncementSignatures {
2214 pub extern "C" fn AnnouncementSignatures_get_channel_id(this_ptr: &AnnouncementSignatures) -> *const [u8; 32] {
2215 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
2220 pub extern "C" fn AnnouncementSignatures_set_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
2221 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
2223 /// The short channel ID
2225 pub extern "C" fn AnnouncementSignatures_get_short_channel_id(this_ptr: &AnnouncementSignatures) -> u64 {
2226 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id;
2229 /// The short channel ID
2231 pub extern "C" fn AnnouncementSignatures_set_short_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: u64) {
2232 unsafe { &mut *this_ptr.inner }.short_channel_id = val;
2234 /// A signature by the node key
2236 pub extern "C" fn AnnouncementSignatures_get_node_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
2237 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_signature;
2238 crate::c_types::Signature::from_rust(&(*inner_val))
2240 /// A signature by the node key
2242 pub extern "C" fn AnnouncementSignatures_set_node_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
2243 unsafe { &mut *this_ptr.inner }.node_signature = val.into_rust();
2245 /// A signature by the funding key
2247 pub extern "C" fn AnnouncementSignatures_get_bitcoin_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
2248 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_signature;
2249 crate::c_types::Signature::from_rust(&(*inner_val))
2251 /// A signature by the funding key
2253 pub extern "C" fn AnnouncementSignatures_set_bitcoin_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
2254 unsafe { &mut *this_ptr.inner }.bitcoin_signature = val.into_rust();
2258 pub extern "C" fn AnnouncementSignatures_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_id_arg: u64, mut node_signature_arg: crate::c_types::Signature, mut bitcoin_signature_arg: crate::c_types::Signature) -> AnnouncementSignatures {
2259 AnnouncementSignatures { inner: Box::into_raw(Box::new(nativeAnnouncementSignatures {
2260 channel_id: channel_id_arg.data,
2261 short_channel_id: short_channel_id_arg,
2262 node_signature: node_signature_arg.into_rust(),
2263 bitcoin_signature: bitcoin_signature_arg.into_rust(),
2264 })), is_owned: true }
2266 /// An address which can be used to connect to a remote peer
2270 pub enum NetAddress {
2271 /// An IPv4 address/port on which the peer is listening.
2273 addr: crate::c_types::FourBytes,
2276 /// An IPv6 address/port on which the peer is listening.
2278 addr: crate::c_types::SixteenBytes,
2281 /// An old-style Tor onion address/port on which the peer is listening.
2283 addr: crate::c_types::TenBytes,
2286 /// A new-style Tor onion address/port on which the peer is listening.
2287 /// To create the human-readable \"hostname\", concatenate ed25519_pubkey, checksum, and version,
2288 /// wrap as base32 and append \".onion\".
2290 ed25519_pubkey: crate::c_types::ThirtyTwoBytes,
2296 use lightning::ln::msgs::NetAddress as nativeNetAddress;
2299 pub(crate) fn to_native(&self) -> nativeNetAddress {
2301 NetAddress::IPv4 {ref addr, ref port, } => {
2302 let mut addr_nonref = (*addr).clone();
2303 let mut port_nonref = (*port).clone();
2304 nativeNetAddress::IPv4 {
2305 addr: addr_nonref.data,
2309 NetAddress::IPv6 {ref addr, ref port, } => {
2310 let mut addr_nonref = (*addr).clone();
2311 let mut port_nonref = (*port).clone();
2312 nativeNetAddress::IPv6 {
2313 addr: addr_nonref.data,
2317 NetAddress::OnionV2 {ref addr, ref port, } => {
2318 let mut addr_nonref = (*addr).clone();
2319 let mut port_nonref = (*port).clone();
2320 nativeNetAddress::OnionV2 {
2321 addr: addr_nonref.data,
2325 NetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
2326 let mut ed25519_pubkey_nonref = (*ed25519_pubkey).clone();
2327 let mut checksum_nonref = (*checksum).clone();
2328 let mut version_nonref = (*version).clone();
2329 let mut port_nonref = (*port).clone();
2330 nativeNetAddress::OnionV3 {
2331 ed25519_pubkey: ed25519_pubkey_nonref.data,
2332 checksum: checksum_nonref,
2333 version: version_nonref,
2340 pub(crate) fn into_native(self) -> nativeNetAddress {
2342 NetAddress::IPv4 {mut addr, mut port, } => {
2343 nativeNetAddress::IPv4 {
2348 NetAddress::IPv6 {mut addr, mut port, } => {
2349 nativeNetAddress::IPv6 {
2354 NetAddress::OnionV2 {mut addr, mut port, } => {
2355 nativeNetAddress::OnionV2 {
2360 NetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
2361 nativeNetAddress::OnionV3 {
2362 ed25519_pubkey: ed25519_pubkey.data,
2371 pub(crate) fn from_native(native: &nativeNetAddress) -> Self {
2373 nativeNetAddress::IPv4 {ref addr, ref port, } => {
2374 let mut addr_nonref = (*addr).clone();
2375 let mut port_nonref = (*port).clone();
2377 addr: crate::c_types::FourBytes { data: addr_nonref },
2381 nativeNetAddress::IPv6 {ref addr, ref port, } => {
2382 let mut addr_nonref = (*addr).clone();
2383 let mut port_nonref = (*port).clone();
2385 addr: crate::c_types::SixteenBytes { data: addr_nonref },
2389 nativeNetAddress::OnionV2 {ref addr, ref port, } => {
2390 let mut addr_nonref = (*addr).clone();
2391 let mut port_nonref = (*port).clone();
2392 NetAddress::OnionV2 {
2393 addr: crate::c_types::TenBytes { data: addr_nonref },
2397 nativeNetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
2398 let mut ed25519_pubkey_nonref = (*ed25519_pubkey).clone();
2399 let mut checksum_nonref = (*checksum).clone();
2400 let mut version_nonref = (*version).clone();
2401 let mut port_nonref = (*port).clone();
2402 NetAddress::OnionV3 {
2403 ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey_nonref },
2404 checksum: checksum_nonref,
2405 version: version_nonref,
2412 pub(crate) fn native_into(native: nativeNetAddress) -> Self {
2414 nativeNetAddress::IPv4 {mut addr, mut port, } => {
2416 addr: crate::c_types::FourBytes { data: addr },
2420 nativeNetAddress::IPv6 {mut addr, mut port, } => {
2422 addr: crate::c_types::SixteenBytes { data: addr },
2426 nativeNetAddress::OnionV2 {mut addr, mut port, } => {
2427 NetAddress::OnionV2 {
2428 addr: crate::c_types::TenBytes { data: addr },
2432 nativeNetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
2433 NetAddress::OnionV3 {
2434 ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey },
2444 pub extern "C" fn NetAddress_free(this_ptr: NetAddress) { }
2446 pub extern "C" fn NetAddress_clone(orig: &NetAddress) -> NetAddress {
2450 pub extern "C" fn NetAddress_write(obj: &NetAddress) -> crate::c_types::derived::CVec_u8Z {
2451 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
2454 pub extern "C" fn Result_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CResult_NetAddressu8ZDecodeErrorZ {
2455 let res = crate::c_types::deserialize_obj(ser);
2456 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = match o { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::NetAddress::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { e }).into() }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
2460 use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport;
2461 type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport;
2463 /// The unsigned part of a node_announcement
2466 pub struct UnsignedNodeAnnouncement {
2467 /// Nearly everywhere, inner must be non-null, however in places where
2468 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2469 pub inner: *mut nativeUnsignedNodeAnnouncement,
2473 impl Drop for UnsignedNodeAnnouncement {
2474 fn drop(&mut self) {
2475 if self.is_owned && !self.inner.is_null() {
2476 let _ = unsafe { Box::from_raw(self.inner) };
2481 pub extern "C" fn UnsignedNodeAnnouncement_free(this_ptr: UnsignedNodeAnnouncement) { }
2483 /// Used only if an object of this type is returned as a trait impl by a method
2484 extern "C" fn UnsignedNodeAnnouncement_free_void(this_ptr: *mut c_void) {
2485 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedNodeAnnouncement); }
2488 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2489 impl UnsignedNodeAnnouncement {
2490 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedNodeAnnouncement {
2491 assert!(self.is_owned);
2492 let ret = self.inner;
2493 self.inner = std::ptr::null_mut();
2497 impl Clone for UnsignedNodeAnnouncement {
2498 fn clone(&self) -> Self {
2500 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
2501 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2507 /// Used only if an object of this type is returned as a trait impl by a method
2508 pub(crate) extern "C" fn UnsignedNodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
2509 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedNodeAnnouncement)).clone() })) as *mut c_void
2512 pub extern "C" fn UnsignedNodeAnnouncement_clone(orig: &UnsignedNodeAnnouncement) -> UnsignedNodeAnnouncement {
2515 /// The advertised features
2517 pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::ln::features::NodeFeatures {
2518 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features;
2519 crate::ln::features::NodeFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
2521 /// The advertised features
2523 pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::ln::features::NodeFeatures) {
2524 unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_inner()) };
2526 /// A strictly monotonic announcement counter, with gaps allowed
2528 pub extern "C" fn UnsignedNodeAnnouncement_get_timestamp(this_ptr: &UnsignedNodeAnnouncement) -> u32 {
2529 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp;
2532 /// A strictly monotonic announcement counter, with gaps allowed
2534 pub extern "C" fn UnsignedNodeAnnouncement_set_timestamp(this_ptr: &mut UnsignedNodeAnnouncement, mut val: u32) {
2535 unsafe { &mut *this_ptr.inner }.timestamp = val;
2537 /// The node_id this announcement originated from (don't rebroadcast the node_announcement back
2540 pub extern "C" fn UnsignedNodeAnnouncement_get_node_id(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::PublicKey {
2541 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_id;
2542 crate::c_types::PublicKey::from_rust(&(*inner_val))
2544 /// The node_id this announcement originated from (don't rebroadcast the node_announcement back
2547 pub extern "C" fn UnsignedNodeAnnouncement_set_node_id(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::PublicKey) {
2548 unsafe { &mut *this_ptr.inner }.node_id = val.into_rust();
2550 /// An RGB color for UI purposes
2552 pub extern "C" fn UnsignedNodeAnnouncement_get_rgb(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 3] {
2553 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.rgb;
2556 /// An RGB color for UI purposes
2558 pub extern "C" fn UnsignedNodeAnnouncement_set_rgb(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThreeBytes) {
2559 unsafe { &mut *this_ptr.inner }.rgb = val.data;
2561 /// An alias, for UI purposes. This should be sanitized before use. There is no guarantee
2564 pub extern "C" fn UnsignedNodeAnnouncement_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 32] {
2565 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.alias;
2568 /// An alias, for UI purposes. This should be sanitized before use. There is no guarantee
2571 pub extern "C" fn UnsignedNodeAnnouncement_set_alias(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
2572 unsafe { &mut *this_ptr.inner }.alias = val.data;
2574 /// List of addresses on which this node is reachable
2576 pub extern "C" fn UnsignedNodeAnnouncement_set_addresses(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_NetAddressZ) {
2577 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
2578 unsafe { &mut *this_ptr.inner }.addresses = local_val;
2581 use lightning::ln::msgs::NodeAnnouncement as nativeNodeAnnouncementImport;
2582 type nativeNodeAnnouncement = nativeNodeAnnouncementImport;
2584 /// A node_announcement message to be sent or received from a peer
2587 pub struct NodeAnnouncement {
2588 /// Nearly everywhere, inner must be non-null, however in places where
2589 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2590 pub inner: *mut nativeNodeAnnouncement,
2594 impl Drop for NodeAnnouncement {
2595 fn drop(&mut self) {
2596 if self.is_owned && !self.inner.is_null() {
2597 let _ = unsafe { Box::from_raw(self.inner) };
2602 pub extern "C" fn NodeAnnouncement_free(this_ptr: NodeAnnouncement) { }
2604 /// Used only if an object of this type is returned as a trait impl by a method
2605 extern "C" fn NodeAnnouncement_free_void(this_ptr: *mut c_void) {
2606 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeAnnouncement); }
2609 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2610 impl NodeAnnouncement {
2611 pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncement {
2612 assert!(self.is_owned);
2613 let ret = self.inner;
2614 self.inner = std::ptr::null_mut();
2618 impl Clone for NodeAnnouncement {
2619 fn clone(&self) -> Self {
2621 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
2622 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2628 /// Used only if an object of this type is returned as a trait impl by a method
2629 pub(crate) extern "C" fn NodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
2630 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeAnnouncement)).clone() })) as *mut c_void
2633 pub extern "C" fn NodeAnnouncement_clone(orig: &NodeAnnouncement) -> NodeAnnouncement {
2636 /// The signature by the node key
2638 pub extern "C" fn NodeAnnouncement_get_signature(this_ptr: &NodeAnnouncement) -> crate::c_types::Signature {
2639 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
2640 crate::c_types::Signature::from_rust(&(*inner_val))
2642 /// The signature by the node key
2644 pub extern "C" fn NodeAnnouncement_set_signature(this_ptr: &mut NodeAnnouncement, mut val: crate::c_types::Signature) {
2645 unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
2647 /// The actual content of the announcement
2649 pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> crate::ln::msgs::UnsignedNodeAnnouncement {
2650 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents;
2651 crate::ln::msgs::UnsignedNodeAnnouncement { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
2653 /// The actual content of the announcement
2655 pub extern "C" fn NodeAnnouncement_set_contents(this_ptr: &mut NodeAnnouncement, mut val: crate::ln::msgs::UnsignedNodeAnnouncement) {
2656 unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_inner()) };
2660 pub extern "C" fn NodeAnnouncement_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::ln::msgs::UnsignedNodeAnnouncement) -> NodeAnnouncement {
2661 NodeAnnouncement { inner: Box::into_raw(Box::new(nativeNodeAnnouncement {
2662 signature: signature_arg.into_rust(),
2663 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
2664 })), is_owned: true }
2667 use lightning::ln::msgs::UnsignedChannelAnnouncement as nativeUnsignedChannelAnnouncementImport;
2668 type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport;
2670 /// The unsigned part of a channel_announcement
2673 pub struct UnsignedChannelAnnouncement {
2674 /// Nearly everywhere, inner must be non-null, however in places where
2675 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2676 pub inner: *mut nativeUnsignedChannelAnnouncement,
2680 impl Drop for UnsignedChannelAnnouncement {
2681 fn drop(&mut self) {
2682 if self.is_owned && !self.inner.is_null() {
2683 let _ = unsafe { Box::from_raw(self.inner) };
2688 pub extern "C" fn UnsignedChannelAnnouncement_free(this_ptr: UnsignedChannelAnnouncement) { }
2690 /// Used only if an object of this type is returned as a trait impl by a method
2691 extern "C" fn UnsignedChannelAnnouncement_free_void(this_ptr: *mut c_void) {
2692 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelAnnouncement); }
2695 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2696 impl UnsignedChannelAnnouncement {
2697 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelAnnouncement {
2698 assert!(self.is_owned);
2699 let ret = self.inner;
2700 self.inner = std::ptr::null_mut();
2704 impl Clone for UnsignedChannelAnnouncement {
2705 fn clone(&self) -> Self {
2707 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
2708 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2714 /// Used only if an object of this type is returned as a trait impl by a method
2715 pub(crate) extern "C" fn UnsignedChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
2716 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelAnnouncement)).clone() })) as *mut c_void
2719 pub extern "C" fn UnsignedChannelAnnouncement_clone(orig: &UnsignedChannelAnnouncement) -> UnsignedChannelAnnouncement {
2722 /// The advertised channel features
2724 pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::ln::features::ChannelFeatures {
2725 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features;
2726 crate::ln::features::ChannelFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
2728 /// The advertised channel features
2730 pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::ln::features::ChannelFeatures) {
2731 unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_inner()) };
2733 /// The genesis hash of the blockchain where the channel is to be opened
2735 pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &UnsignedChannelAnnouncement) -> *const [u8; 32] {
2736 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
2737 (*inner_val).as_inner()
2739 /// The genesis hash of the blockchain where the channel is to be opened
2741 pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
2742 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
2744 /// The short channel ID
2746 pub extern "C" fn UnsignedChannelAnnouncement_get_short_channel_id(this_ptr: &UnsignedChannelAnnouncement) -> u64 {
2747 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id;
2750 /// The short channel ID
2752 pub extern "C" fn UnsignedChannelAnnouncement_set_short_channel_id(this_ptr: &mut UnsignedChannelAnnouncement, mut val: u64) {
2753 unsafe { &mut *this_ptr.inner }.short_channel_id = val;
2755 /// One of the two node_ids which are endpoints of this channel
2757 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
2758 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_id_1;
2759 crate::c_types::PublicKey::from_rust(&(*inner_val))
2761 /// One of the two node_ids which are endpoints of this channel
2763 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
2764 unsafe { &mut *this_ptr.inner }.node_id_1 = val.into_rust();
2766 /// The other of the two node_ids which are endpoints of this channel
2768 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
2769 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_id_2;
2770 crate::c_types::PublicKey::from_rust(&(*inner_val))
2772 /// The other of the two node_ids which are endpoints of this channel
2774 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
2775 unsafe { &mut *this_ptr.inner }.node_id_2 = val.into_rust();
2777 /// The funding key for the first node
2779 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
2780 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_key_1;
2781 crate::c_types::PublicKey::from_rust(&(*inner_val))
2783 /// The funding key for the first node
2785 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
2786 unsafe { &mut *this_ptr.inner }.bitcoin_key_1 = val.into_rust();
2788 /// The funding key for the second node
2790 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
2791 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_key_2;
2792 crate::c_types::PublicKey::from_rust(&(*inner_val))
2794 /// The funding key for the second node
2796 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
2797 unsafe { &mut *this_ptr.inner }.bitcoin_key_2 = val.into_rust();
2800 use lightning::ln::msgs::ChannelAnnouncement as nativeChannelAnnouncementImport;
2801 type nativeChannelAnnouncement = nativeChannelAnnouncementImport;
2803 /// A channel_announcement message to be sent or received from a peer
2806 pub struct ChannelAnnouncement {
2807 /// Nearly everywhere, inner must be non-null, however in places where
2808 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2809 pub inner: *mut nativeChannelAnnouncement,
2813 impl Drop for ChannelAnnouncement {
2814 fn drop(&mut self) {
2815 if self.is_owned && !self.inner.is_null() {
2816 let _ = unsafe { Box::from_raw(self.inner) };
2821 pub extern "C" fn ChannelAnnouncement_free(this_ptr: ChannelAnnouncement) { }
2823 /// Used only if an object of this type is returned as a trait impl by a method
2824 extern "C" fn ChannelAnnouncement_free_void(this_ptr: *mut c_void) {
2825 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelAnnouncement); }
2828 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2829 impl ChannelAnnouncement {
2830 pub(crate) fn take_inner(mut self) -> *mut nativeChannelAnnouncement {
2831 assert!(self.is_owned);
2832 let ret = self.inner;
2833 self.inner = std::ptr::null_mut();
2837 impl Clone for ChannelAnnouncement {
2838 fn clone(&self) -> Self {
2840 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
2841 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2847 /// Used only if an object of this type is returned as a trait impl by a method
2848 pub(crate) extern "C" fn ChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
2849 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelAnnouncement)).clone() })) as *mut c_void
2852 pub extern "C" fn ChannelAnnouncement_clone(orig: &ChannelAnnouncement) -> ChannelAnnouncement {
2855 /// Authentication of the announcement by the first public node
2857 pub extern "C" fn ChannelAnnouncement_get_node_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
2858 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_signature_1;
2859 crate::c_types::Signature::from_rust(&(*inner_val))
2861 /// Authentication of the announcement by the first public node
2863 pub extern "C" fn ChannelAnnouncement_set_node_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
2864 unsafe { &mut *this_ptr.inner }.node_signature_1 = val.into_rust();
2866 /// Authentication of the announcement by the second public node
2868 pub extern "C" fn ChannelAnnouncement_get_node_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
2869 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_signature_2;
2870 crate::c_types::Signature::from_rust(&(*inner_val))
2872 /// Authentication of the announcement by the second public node
2874 pub extern "C" fn ChannelAnnouncement_set_node_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
2875 unsafe { &mut *this_ptr.inner }.node_signature_2 = val.into_rust();
2877 /// Proof of funding UTXO ownership by the first public node
2879 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
2880 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_signature_1;
2881 crate::c_types::Signature::from_rust(&(*inner_val))
2883 /// Proof of funding UTXO ownership by the first public node
2885 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
2886 unsafe { &mut *this_ptr.inner }.bitcoin_signature_1 = val.into_rust();
2888 /// Proof of funding UTXO ownership by the second public node
2890 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
2891 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_signature_2;
2892 crate::c_types::Signature::from_rust(&(*inner_val))
2894 /// Proof of funding UTXO ownership by the second public node
2896 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
2897 unsafe { &mut *this_ptr.inner }.bitcoin_signature_2 = val.into_rust();
2899 /// The actual announcement
2901 pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncement) -> crate::ln::msgs::UnsignedChannelAnnouncement {
2902 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents;
2903 crate::ln::msgs::UnsignedChannelAnnouncement { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
2905 /// The actual announcement
2907 pub extern "C" fn ChannelAnnouncement_set_contents(this_ptr: &mut ChannelAnnouncement, mut val: crate::ln::msgs::UnsignedChannelAnnouncement) {
2908 unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_inner()) };
2912 pub extern "C" fn ChannelAnnouncement_new(mut node_signature_1_arg: crate::c_types::Signature, mut node_signature_2_arg: crate::c_types::Signature, mut bitcoin_signature_1_arg: crate::c_types::Signature, mut bitcoin_signature_2_arg: crate::c_types::Signature, mut contents_arg: crate::ln::msgs::UnsignedChannelAnnouncement) -> ChannelAnnouncement {
2913 ChannelAnnouncement { inner: Box::into_raw(Box::new(nativeChannelAnnouncement {
2914 node_signature_1: node_signature_1_arg.into_rust(),
2915 node_signature_2: node_signature_2_arg.into_rust(),
2916 bitcoin_signature_1: bitcoin_signature_1_arg.into_rust(),
2917 bitcoin_signature_2: bitcoin_signature_2_arg.into_rust(),
2918 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
2919 })), is_owned: true }
2922 use lightning::ln::msgs::UnsignedChannelUpdate as nativeUnsignedChannelUpdateImport;
2923 type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport;
2925 /// The unsigned part of a channel_update
2928 pub struct UnsignedChannelUpdate {
2929 /// Nearly everywhere, inner must be non-null, however in places where
2930 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2931 pub inner: *mut nativeUnsignedChannelUpdate,
2935 impl Drop for UnsignedChannelUpdate {
2936 fn drop(&mut self) {
2937 if self.is_owned && !self.inner.is_null() {
2938 let _ = unsafe { Box::from_raw(self.inner) };
2943 pub extern "C" fn UnsignedChannelUpdate_free(this_ptr: UnsignedChannelUpdate) { }
2945 /// Used only if an object of this type is returned as a trait impl by a method
2946 extern "C" fn UnsignedChannelUpdate_free_void(this_ptr: *mut c_void) {
2947 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelUpdate); }
2950 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2951 impl UnsignedChannelUpdate {
2952 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelUpdate {
2953 assert!(self.is_owned);
2954 let ret = self.inner;
2955 self.inner = std::ptr::null_mut();
2959 impl Clone for UnsignedChannelUpdate {
2960 fn clone(&self) -> Self {
2962 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
2963 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
2969 /// Used only if an object of this type is returned as a trait impl by a method
2970 pub(crate) extern "C" fn UnsignedChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
2971 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelUpdate)).clone() })) as *mut c_void
2974 pub extern "C" fn UnsignedChannelUpdate_clone(orig: &UnsignedChannelUpdate) -> UnsignedChannelUpdate {
2977 /// The genesis hash of the blockchain where the channel is to be opened
2979 pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChannelUpdate) -> *const [u8; 32] {
2980 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
2981 (*inner_val).as_inner()
2983 /// The genesis hash of the blockchain where the channel is to be opened
2985 pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::ThirtyTwoBytes) {
2986 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
2988 /// The short channel ID
2990 pub extern "C" fn UnsignedChannelUpdate_get_short_channel_id(this_ptr: &UnsignedChannelUpdate) -> u64 {
2991 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id;
2994 /// The short channel ID
2996 pub extern "C" fn UnsignedChannelUpdate_set_short_channel_id(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
2997 unsafe { &mut *this_ptr.inner }.short_channel_id = val;
2999 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
3001 pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannelUpdate) -> u32 {
3002 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp;
3005 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
3007 pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3008 unsafe { &mut *this_ptr.inner }.timestamp = val;
3012 pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 {
3013 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.flags;
3018 pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) {
3019 unsafe { &mut *this_ptr.inner }.flags = val;
3021 /// The number of blocks to subtract from incoming HTLC cltv_expiry values
3023 pub extern "C" fn UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr: &UnsignedChannelUpdate) -> u16 {
3024 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry_delta;
3027 /// The number of blocks to subtract from incoming HTLC cltv_expiry values
3029 pub extern "C" fn UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr: &mut UnsignedChannelUpdate, mut val: u16) {
3030 unsafe { &mut *this_ptr.inner }.cltv_expiry_delta = val;
3032 /// The minimum HTLC size incoming to sender, in milli-satoshi
3034 pub extern "C" fn UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
3035 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_minimum_msat;
3038 /// The minimum HTLC size incoming to sender, in milli-satoshi
3040 pub extern "C" fn UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
3041 unsafe { &mut *this_ptr.inner }.htlc_minimum_msat = val;
3043 /// The base HTLC fee charged by sender, in milli-satoshi
3045 pub extern "C" fn UnsignedChannelUpdate_get_fee_base_msat(this_ptr: &UnsignedChannelUpdate) -> u32 {
3046 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_base_msat;
3049 /// The base HTLC fee charged by sender, in milli-satoshi
3051 pub extern "C" fn UnsignedChannelUpdate_set_fee_base_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3052 unsafe { &mut *this_ptr.inner }.fee_base_msat = val;
3054 /// The amount to fee multiplier, in micro-satoshi
3056 pub extern "C" fn UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr: &UnsignedChannelUpdate) -> u32 {
3057 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_proportional_millionths;
3060 /// The amount to fee multiplier, in micro-satoshi
3062 pub extern "C" fn UnsignedChannelUpdate_set_fee_proportional_millionths(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3063 unsafe { &mut *this_ptr.inner }.fee_proportional_millionths = val;
3066 use lightning::ln::msgs::ChannelUpdate as nativeChannelUpdateImport;
3067 type nativeChannelUpdate = nativeChannelUpdateImport;
3069 /// A channel_update message to be sent or received from a peer
3072 pub struct ChannelUpdate {
3073 /// Nearly everywhere, inner must be non-null, however in places where
3074 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3075 pub inner: *mut nativeChannelUpdate,
3079 impl Drop for ChannelUpdate {
3080 fn drop(&mut self) {
3081 if self.is_owned && !self.inner.is_null() {
3082 let _ = unsafe { Box::from_raw(self.inner) };
3087 pub extern "C" fn ChannelUpdate_free(this_ptr: ChannelUpdate) { }
3089 /// Used only if an object of this type is returned as a trait impl by a method
3090 extern "C" fn ChannelUpdate_free_void(this_ptr: *mut c_void) {
3091 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelUpdate); }
3094 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3095 impl ChannelUpdate {
3096 pub(crate) fn take_inner(mut self) -> *mut nativeChannelUpdate {
3097 assert!(self.is_owned);
3098 let ret = self.inner;
3099 self.inner = std::ptr::null_mut();
3103 impl Clone for ChannelUpdate {
3104 fn clone(&self) -> Self {
3106 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
3107 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3113 /// Used only if an object of this type is returned as a trait impl by a method
3114 pub(crate) extern "C" fn ChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
3115 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelUpdate)).clone() })) as *mut c_void
3118 pub extern "C" fn ChannelUpdate_clone(orig: &ChannelUpdate) -> ChannelUpdate {
3121 /// A signature of the channel update
3123 pub extern "C" fn ChannelUpdate_get_signature(this_ptr: &ChannelUpdate) -> crate::c_types::Signature {
3124 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
3125 crate::c_types::Signature::from_rust(&(*inner_val))
3127 /// A signature of the channel update
3129 pub extern "C" fn ChannelUpdate_set_signature(this_ptr: &mut ChannelUpdate, mut val: crate::c_types::Signature) {
3130 unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
3132 /// The actual channel update
3134 pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate::ln::msgs::UnsignedChannelUpdate {
3135 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents;
3136 crate::ln::msgs::UnsignedChannelUpdate { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
3138 /// The actual channel update
3140 pub extern "C" fn ChannelUpdate_set_contents(this_ptr: &mut ChannelUpdate, mut val: crate::ln::msgs::UnsignedChannelUpdate) {
3141 unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_inner()) };
3145 pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::ln::msgs::UnsignedChannelUpdate) -> ChannelUpdate {
3146 ChannelUpdate { inner: Box::into_raw(Box::new(nativeChannelUpdate {
3147 signature: signature_arg.into_rust(),
3148 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
3149 })), is_owned: true }
3152 use lightning::ln::msgs::QueryChannelRange as nativeQueryChannelRangeImport;
3153 type nativeQueryChannelRange = nativeQueryChannelRangeImport;
3155 /// A query_channel_range message is used to query a peer for channel
3156 /// UTXOs in a range of blocks. The recipient of a query makes a best
3157 /// effort to reply to the query using one or more reply_channel_range
3161 pub struct QueryChannelRange {
3162 /// Nearly everywhere, inner must be non-null, however in places where
3163 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3164 pub inner: *mut nativeQueryChannelRange,
3168 impl Drop for QueryChannelRange {
3169 fn drop(&mut self) {
3170 if self.is_owned && !self.inner.is_null() {
3171 let _ = unsafe { Box::from_raw(self.inner) };
3176 pub extern "C" fn QueryChannelRange_free(this_ptr: QueryChannelRange) { }
3178 /// Used only if an object of this type is returned as a trait impl by a method
3179 extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) {
3180 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryChannelRange); }
3183 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3184 impl QueryChannelRange {
3185 pub(crate) fn take_inner(mut self) -> *mut nativeQueryChannelRange {
3186 assert!(self.is_owned);
3187 let ret = self.inner;
3188 self.inner = std::ptr::null_mut();
3192 impl Clone for QueryChannelRange {
3193 fn clone(&self) -> Self {
3195 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
3196 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3202 /// Used only if an object of this type is returned as a trait impl by a method
3203 pub(crate) extern "C" fn QueryChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
3204 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryChannelRange)).clone() })) as *mut c_void
3207 pub extern "C" fn QueryChannelRange_clone(orig: &QueryChannelRange) -> QueryChannelRange {
3210 /// The genesis hash of the blockchain being queried
3212 pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *const [u8; 32] {
3213 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3214 (*inner_val).as_inner()
3216 /// The genesis hash of the blockchain being queried
3218 pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
3219 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3221 /// The height of the first block for the channel UTXOs being queried
3223 pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 {
3224 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_blocknum;
3227 /// The height of the first block for the channel UTXOs being queried
3229 pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChannelRange, mut val: u32) {
3230 unsafe { &mut *this_ptr.inner }.first_blocknum = val;
3232 /// The number of blocks to include in the query results
3234 pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 {
3235 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.number_of_blocks;
3238 /// The number of blocks to include in the query results
3240 pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryChannelRange, mut val: u32) {
3241 unsafe { &mut *this_ptr.inner }.number_of_blocks = val;
3245 pub extern "C" fn QueryChannelRange_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut first_blocknum_arg: u32, mut number_of_blocks_arg: u32) -> QueryChannelRange {
3246 QueryChannelRange { inner: Box::into_raw(Box::new(nativeQueryChannelRange {
3247 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3248 first_blocknum: first_blocknum_arg,
3249 number_of_blocks: number_of_blocks_arg,
3250 })), is_owned: true }
3253 use lightning::ln::msgs::ReplyChannelRange as nativeReplyChannelRangeImport;
3254 type nativeReplyChannelRange = nativeReplyChannelRangeImport;
3256 /// A reply_channel_range message is a reply to a query_channel_range
3257 /// message. Multiple reply_channel_range messages can be sent in reply
3258 /// to a single query_channel_range message. The query recipient makes a
3259 /// best effort to respond based on their local network view which may
3260 /// not be a perfect view of the network. The short_channel_ids in the
3261 /// reply are encoded. We only support encoding_type=0 uncompressed
3262 /// serialization and do not support encoding_type=1 zlib serialization.
3265 pub struct ReplyChannelRange {
3266 /// Nearly everywhere, inner must be non-null, however in places where
3267 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3268 pub inner: *mut nativeReplyChannelRange,
3272 impl Drop for ReplyChannelRange {
3273 fn drop(&mut self) {
3274 if self.is_owned && !self.inner.is_null() {
3275 let _ = unsafe { Box::from_raw(self.inner) };
3280 pub extern "C" fn ReplyChannelRange_free(this_ptr: ReplyChannelRange) { }
3282 /// Used only if an object of this type is returned as a trait impl by a method
3283 extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) {
3284 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyChannelRange); }
3287 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3288 impl ReplyChannelRange {
3289 pub(crate) fn take_inner(mut self) -> *mut nativeReplyChannelRange {
3290 assert!(self.is_owned);
3291 let ret = self.inner;
3292 self.inner = std::ptr::null_mut();
3296 impl Clone for ReplyChannelRange {
3297 fn clone(&self) -> Self {
3299 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
3300 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3306 /// Used only if an object of this type is returned as a trait impl by a method
3307 pub(crate) extern "C" fn ReplyChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
3308 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyChannelRange)).clone() })) as *mut c_void
3311 pub extern "C" fn ReplyChannelRange_clone(orig: &ReplyChannelRange) -> ReplyChannelRange {
3314 /// The genesis hash of the blockchain being queried
3316 pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *const [u8; 32] {
3317 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3318 (*inner_val).as_inner()
3320 /// The genesis hash of the blockchain being queried
3322 pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
3323 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3325 /// The height of the first block in the range of the reply
3327 pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 {
3328 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_blocknum;
3331 /// The height of the first block in the range of the reply
3333 pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChannelRange, mut val: u32) {
3334 unsafe { &mut *this_ptr.inner }.first_blocknum = val;
3336 /// The number of blocks included in the range of the reply
3338 pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 {
3339 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.number_of_blocks;
3342 /// The number of blocks included in the range of the reply
3344 pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyChannelRange, mut val: u32) {
3345 unsafe { &mut *this_ptr.inner }.number_of_blocks = val;
3347 /// True when this is the final reply for a query
3349 pub extern "C" fn ReplyChannelRange_get_sync_complete(this_ptr: &ReplyChannelRange) -> bool {
3350 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.sync_complete;
3353 /// True when this is the final reply for a query
3355 pub extern "C" fn ReplyChannelRange_set_sync_complete(this_ptr: &mut ReplyChannelRange, mut val: bool) {
3356 unsafe { &mut *this_ptr.inner }.sync_complete = val;
3358 /// The short_channel_ids in the channel range
3360 pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::derived::CVec_u64Z) {
3361 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
3362 unsafe { &mut *this_ptr.inner }.short_channel_ids = local_val;
3366 pub extern "C" fn ReplyChannelRange_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut first_blocknum_arg: u32, mut number_of_blocks_arg: u32, mut sync_complete_arg: bool, mut short_channel_ids_arg: crate::c_types::derived::CVec_u64Z) -> ReplyChannelRange {
3367 let mut local_short_channel_ids_arg = Vec::new(); for mut item in short_channel_ids_arg.into_rust().drain(..) { local_short_channel_ids_arg.push( { item }); };
3368 ReplyChannelRange { inner: Box::into_raw(Box::new(nativeReplyChannelRange {
3369 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3370 first_blocknum: first_blocknum_arg,
3371 number_of_blocks: number_of_blocks_arg,
3372 sync_complete: sync_complete_arg,
3373 short_channel_ids: local_short_channel_ids_arg,
3374 })), is_owned: true }
3377 use lightning::ln::msgs::QueryShortChannelIds as nativeQueryShortChannelIdsImport;
3378 type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport;
3380 /// A query_short_channel_ids message is used to query a peer for
3381 /// routing gossip messages related to one or more short_channel_ids.
3382 /// The query recipient will reply with the latest, if available,
3383 /// channel_announcement, channel_update and node_announcement messages
3384 /// it maintains for the requested short_channel_ids followed by a
3385 /// reply_short_channel_ids_end message. The short_channel_ids sent in
3386 /// this query are encoded. We only support encoding_type=0 uncompressed
3387 /// serialization and do not support encoding_type=1 zlib serialization.
3390 pub struct QueryShortChannelIds {
3391 /// Nearly everywhere, inner must be non-null, however in places where
3392 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3393 pub inner: *mut nativeQueryShortChannelIds,
3397 impl Drop for QueryShortChannelIds {
3398 fn drop(&mut self) {
3399 if self.is_owned && !self.inner.is_null() {
3400 let _ = unsafe { Box::from_raw(self.inner) };
3405 pub extern "C" fn QueryShortChannelIds_free(this_ptr: QueryShortChannelIds) { }
3407 /// Used only if an object of this type is returned as a trait impl by a method
3408 extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) {
3409 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryShortChannelIds); }
3412 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3413 impl QueryShortChannelIds {
3414 pub(crate) fn take_inner(mut self) -> *mut nativeQueryShortChannelIds {
3415 assert!(self.is_owned);
3416 let ret = self.inner;
3417 self.inner = std::ptr::null_mut();
3421 impl Clone for QueryShortChannelIds {
3422 fn clone(&self) -> Self {
3424 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
3425 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3431 /// Used only if an object of this type is returned as a trait impl by a method
3432 pub(crate) extern "C" fn QueryShortChannelIds_clone_void(this_ptr: *const c_void) -> *mut c_void {
3433 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryShortChannelIds)).clone() })) as *mut c_void
3436 pub extern "C" fn QueryShortChannelIds_clone(orig: &QueryShortChannelIds) -> QueryShortChannelIds {
3439 /// The genesis hash of the blockchain being queried
3441 pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *const [u8; 32] {
3442 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3443 (*inner_val).as_inner()
3445 /// The genesis hash of the blockchain being queried
3447 pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::ThirtyTwoBytes) {
3448 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3450 /// The short_channel_ids that are being queried
3452 pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::derived::CVec_u64Z) {
3453 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
3454 unsafe { &mut *this_ptr.inner }.short_channel_ids = local_val;
3458 pub extern "C" fn QueryShortChannelIds_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_ids_arg: crate::c_types::derived::CVec_u64Z) -> QueryShortChannelIds {
3459 let mut local_short_channel_ids_arg = Vec::new(); for mut item in short_channel_ids_arg.into_rust().drain(..) { local_short_channel_ids_arg.push( { item }); };
3460 QueryShortChannelIds { inner: Box::into_raw(Box::new(nativeQueryShortChannelIds {
3461 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3462 short_channel_ids: local_short_channel_ids_arg,
3463 })), is_owned: true }
3466 use lightning::ln::msgs::ReplyShortChannelIdsEnd as nativeReplyShortChannelIdsEndImport;
3467 type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport;
3469 /// A reply_short_channel_ids_end message is sent as a reply to a
3470 /// query_short_channel_ids message. The query recipient makes a best
3471 /// effort to respond based on their local network view which may not be
3472 /// a perfect view of the network.
3475 pub struct ReplyShortChannelIdsEnd {
3476 /// Nearly everywhere, inner must be non-null, however in places where
3477 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3478 pub inner: *mut nativeReplyShortChannelIdsEnd,
3482 impl Drop for ReplyShortChannelIdsEnd {
3483 fn drop(&mut self) {
3484 if self.is_owned && !self.inner.is_null() {
3485 let _ = unsafe { Box::from_raw(self.inner) };
3490 pub extern "C" fn ReplyShortChannelIdsEnd_free(this_ptr: ReplyShortChannelIdsEnd) { }
3492 /// Used only if an object of this type is returned as a trait impl by a method
3493 extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) {
3494 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyShortChannelIdsEnd); }
3497 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3498 impl ReplyShortChannelIdsEnd {
3499 pub(crate) fn take_inner(mut self) -> *mut nativeReplyShortChannelIdsEnd {
3500 assert!(self.is_owned);
3501 let ret = self.inner;
3502 self.inner = std::ptr::null_mut();
3506 impl Clone for ReplyShortChannelIdsEnd {
3507 fn clone(&self) -> Self {
3509 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
3510 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3516 /// Used only if an object of this type is returned as a trait impl by a method
3517 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_void) -> *mut c_void {
3518 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyShortChannelIdsEnd)).clone() })) as *mut c_void
3521 pub extern "C" fn ReplyShortChannelIdsEnd_clone(orig: &ReplyShortChannelIdsEnd) -> ReplyShortChannelIdsEnd {
3524 /// The genesis hash of the blockchain that was queried
3526 pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *const [u8; 32] {
3527 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3528 (*inner_val).as_inner()
3530 /// The genesis hash of the blockchain that was queried
3532 pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) {
3533 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3535 /// Indicates if the query recipient maintains up-to-date channel
3536 /// information for the chain_hash
3538 pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool {
3539 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.full_information;
3542 /// Indicates if the query recipient maintains up-to-date channel
3543 /// information for the chain_hash
3545 pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: bool) {
3546 unsafe { &mut *this_ptr.inner }.full_information = val;
3550 pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd {
3551 ReplyShortChannelIdsEnd { inner: Box::into_raw(Box::new(nativeReplyShortChannelIdsEnd {
3552 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3553 full_information: full_information_arg,
3554 })), is_owned: true }
3557 use lightning::ln::msgs::GossipTimestampFilter as nativeGossipTimestampFilterImport;
3558 type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport;
3560 /// A gossip_timestamp_filter message is used by a node to request
3561 /// gossip relay for messages in the requested time range when the
3562 /// gossip_queries feature has been negotiated.
3565 pub struct GossipTimestampFilter {
3566 /// Nearly everywhere, inner must be non-null, however in places where
3567 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3568 pub inner: *mut nativeGossipTimestampFilter,
3572 impl Drop for GossipTimestampFilter {
3573 fn drop(&mut self) {
3574 if self.is_owned && !self.inner.is_null() {
3575 let _ = unsafe { Box::from_raw(self.inner) };
3580 pub extern "C" fn GossipTimestampFilter_free(this_ptr: GossipTimestampFilter) { }
3582 /// Used only if an object of this type is returned as a trait impl by a method
3583 extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) {
3584 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeGossipTimestampFilter); }
3587 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3588 impl GossipTimestampFilter {
3589 pub(crate) fn take_inner(mut self) -> *mut nativeGossipTimestampFilter {
3590 assert!(self.is_owned);
3591 let ret = self.inner;
3592 self.inner = std::ptr::null_mut();
3596 impl Clone for GossipTimestampFilter {
3597 fn clone(&self) -> Self {
3599 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
3600 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3606 /// Used only if an object of this type is returned as a trait impl by a method
3607 pub(crate) extern "C" fn GossipTimestampFilter_clone_void(this_ptr: *const c_void) -> *mut c_void {
3608 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeGossipTimestampFilter)).clone() })) as *mut c_void
3611 pub extern "C" fn GossipTimestampFilter_clone(orig: &GossipTimestampFilter) -> GossipTimestampFilter {
3614 /// The genesis hash of the blockchain for channel and node information
3616 pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *const [u8; 32] {
3617 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3618 (*inner_val).as_inner()
3620 /// The genesis hash of the blockchain for channel and node information
3622 pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) {
3623 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3625 /// The starting unix timestamp
3627 pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 {
3628 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_timestamp;
3631 /// The starting unix timestamp
3633 pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
3634 unsafe { &mut *this_ptr.inner }.first_timestamp = val;
3636 /// The range of information in seconds
3638 pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 {
3639 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp_range;
3642 /// The range of information in seconds
3644 pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
3645 unsafe { &mut *this_ptr.inner }.timestamp_range = val;
3649 pub extern "C" fn GossipTimestampFilter_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut first_timestamp_arg: u32, mut timestamp_range_arg: u32) -> GossipTimestampFilter {
3650 GossipTimestampFilter { inner: Box::into_raw(Box::new(nativeGossipTimestampFilter {
3651 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3652 first_timestamp: first_timestamp_arg,
3653 timestamp_range: timestamp_range_arg,
3654 })), is_owned: true }
3656 /// Used to put an error message in a LightningError
3660 pub enum ErrorAction {
3661 /// The peer took some action which made us think they were useless. Disconnect them.
3663 msg: crate::ln::msgs::ErrorMessage,
3665 /// The peer did something harmless that we weren't able to process, just log and ignore
3667 /// The peer did something incorrect. Tell them.
3669 msg: crate::ln::msgs::ErrorMessage,
3672 use lightning::ln::msgs::ErrorAction as nativeErrorAction;
3675 pub(crate) fn to_native(&self) -> nativeErrorAction {
3677 ErrorAction::DisconnectPeer {ref msg, } => {
3678 let mut msg_nonref = (*msg).clone();
3679 let mut local_msg_nonref = if msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg_nonref.take_inner()) } }) };
3680 nativeErrorAction::DisconnectPeer {
3681 msg: local_msg_nonref,
3684 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
3685 ErrorAction::SendErrorMessage {ref msg, } => {
3686 let mut msg_nonref = (*msg).clone();
3687 nativeErrorAction::SendErrorMessage {
3688 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3694 pub(crate) fn into_native(self) -> nativeErrorAction {
3696 ErrorAction::DisconnectPeer {mut msg, } => {
3697 let mut local_msg = if msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg.take_inner()) } }) };
3698 nativeErrorAction::DisconnectPeer {
3702 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
3703 ErrorAction::SendErrorMessage {mut msg, } => {
3704 nativeErrorAction::SendErrorMessage {
3705 msg: *unsafe { Box::from_raw(msg.take_inner()) },
3711 pub(crate) fn from_native(native: &nativeErrorAction) -> Self {
3713 nativeErrorAction::DisconnectPeer {ref msg, } => {
3714 let mut msg_nonref = (*msg).clone();
3715 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 };
3716 ErrorAction::DisconnectPeer {
3717 msg: local_msg_nonref,
3720 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
3721 nativeErrorAction::SendErrorMessage {ref msg, } => {
3722 let mut msg_nonref = (*msg).clone();
3723 ErrorAction::SendErrorMessage {
3724 msg: crate::ln::msgs::ErrorMessage { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
3730 pub(crate) fn native_into(native: nativeErrorAction) -> Self {
3732 nativeErrorAction::DisconnectPeer {mut msg, } => {
3733 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 };
3734 ErrorAction::DisconnectPeer {
3738 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
3739 nativeErrorAction::SendErrorMessage {mut msg, } => {
3740 ErrorAction::SendErrorMessage {
3741 msg: crate::ln::msgs::ErrorMessage { inner: Box::into_raw(Box::new(msg)), is_owned: true },
3748 pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { }
3750 pub extern "C" fn ErrorAction_clone(orig: &ErrorAction) -> ErrorAction {
3754 use lightning::ln::msgs::LightningError as nativeLightningErrorImport;
3755 type nativeLightningError = nativeLightningErrorImport;
3757 /// An Err type for failure to process messages.
3760 pub struct LightningError {
3761 /// Nearly everywhere, inner must be non-null, however in places where
3762 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3763 pub inner: *mut nativeLightningError,
3767 impl Drop for LightningError {
3768 fn drop(&mut self) {
3769 if self.is_owned && !self.inner.is_null() {
3770 let _ = unsafe { Box::from_raw(self.inner) };
3775 pub extern "C" fn LightningError_free(this_ptr: LightningError) { }
3777 /// Used only if an object of this type is returned as a trait impl by a method
3778 extern "C" fn LightningError_free_void(this_ptr: *mut c_void) {
3779 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeLightningError); }
3782 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3783 impl LightningError {
3784 pub(crate) fn take_inner(mut self) -> *mut nativeLightningError {
3785 assert!(self.is_owned);
3786 let ret = self.inner;
3787 self.inner = std::ptr::null_mut();
3791 impl Clone for LightningError {
3792 fn clone(&self) -> Self {
3794 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
3795 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3801 /// Used only if an object of this type is returned as a trait impl by a method
3802 pub(crate) extern "C" fn LightningError_clone_void(this_ptr: *const c_void) -> *mut c_void {
3803 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeLightningError)).clone() })) as *mut c_void
3806 pub extern "C" fn LightningError_clone(orig: &LightningError) -> LightningError {
3809 /// A human-readable message describing the error
3811 pub extern "C" fn LightningError_get_err(this_ptr: &LightningError) -> crate::c_types::Str {
3812 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.err;
3813 (*inner_val).as_str().into()
3815 /// A human-readable message describing the error
3817 pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: crate::c_types::derived::CVec_u8Z) {
3818 unsafe { &mut *this_ptr.inner }.err = String::from_utf8(val.into_rust()).unwrap();
3820 /// The action which should be taken against the offending peer.
3822 pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate::ln::msgs::ErrorAction {
3823 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.action;
3824 crate::ln::msgs::ErrorAction::from_native(&(*inner_val))
3826 /// The action which should be taken against the offending peer.
3828 pub extern "C" fn LightningError_set_action(this_ptr: &mut LightningError, mut val: crate::ln::msgs::ErrorAction) {
3829 unsafe { &mut *this_ptr.inner }.action = val.into_native();
3833 pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::derived::CVec_u8Z, mut action_arg: crate::ln::msgs::ErrorAction) -> LightningError {
3834 LightningError { inner: Box::into_raw(Box::new(nativeLightningError {
3835 err: String::from_utf8(err_arg.into_rust()).unwrap(),
3836 action: action_arg.into_native(),
3837 })), is_owned: true }
3840 use lightning::ln::msgs::CommitmentUpdate as nativeCommitmentUpdateImport;
3841 type nativeCommitmentUpdate = nativeCommitmentUpdateImport;
3843 /// Struct used to return values from revoke_and_ack messages, containing a bunch of commitment
3844 /// transaction updates if they were pending.
3847 pub struct CommitmentUpdate {
3848 /// Nearly everywhere, inner must be non-null, however in places where
3849 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3850 pub inner: *mut nativeCommitmentUpdate,
3854 impl Drop for CommitmentUpdate {
3855 fn drop(&mut self) {
3856 if self.is_owned && !self.inner.is_null() {
3857 let _ = unsafe { Box::from_raw(self.inner) };
3862 pub extern "C" fn CommitmentUpdate_free(this_ptr: CommitmentUpdate) { }
3864 /// Used only if an object of this type is returned as a trait impl by a method
3865 extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) {
3866 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentUpdate); }
3869 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3870 impl CommitmentUpdate {
3871 pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentUpdate {
3872 assert!(self.is_owned);
3873 let ret = self.inner;
3874 self.inner = std::ptr::null_mut();
3878 impl Clone for CommitmentUpdate {
3879 fn clone(&self) -> Self {
3881 inner: if self.inner.is_null() { std::ptr::null_mut() } else {
3882 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
3888 /// Used only if an object of this type is returned as a trait impl by a method
3889 pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
3890 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentUpdate)).clone() })) as *mut c_void
3893 pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentUpdate {
3896 /// update_add_htlc messages which should be sent
3898 pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) {
3899 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
3900 unsafe { &mut *this_ptr.inner }.update_add_htlcs = local_val;
3902 /// update_fulfill_htlc messages which should be sent
3904 pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) {
3905 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
3906 unsafe { &mut *this_ptr.inner }.update_fulfill_htlcs = local_val;
3908 /// update_fail_htlc messages which should be sent
3910 pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) {
3911 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
3912 unsafe { &mut *this_ptr.inner }.update_fail_htlcs = local_val;
3914 /// update_fail_malformed_htlc messages which should be sent
3916 pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) {
3917 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
3918 unsafe { &mut *this_ptr.inner }.update_fail_malformed_htlcs = local_val;
3920 /// An update_fee message which should be sent
3922 pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::ln::msgs::UpdateFee {
3923 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.update_fee;
3924 let mut local_inner_val = crate::ln::msgs::UpdateFee { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { { (inner_val.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false };
3927 /// An update_fee message which should be sent
3929 pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdate, mut val: crate::ln::msgs::UpdateFee) {
3930 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
3931 unsafe { &mut *this_ptr.inner }.update_fee = local_val;
3933 /// Finally, the commitment_signed message which should be sent
3935 pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::ln::msgs::CommitmentSigned {
3936 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.commitment_signed;
3937 crate::ln::msgs::CommitmentSigned { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
3939 /// Finally, the commitment_signed message which should be sent
3941 pub extern "C" fn CommitmentUpdate_set_commitment_signed(this_ptr: &mut CommitmentUpdate, mut val: crate::ln::msgs::CommitmentSigned) {
3942 unsafe { &mut *this_ptr.inner }.commitment_signed = *unsafe { Box::from_raw(val.take_inner()) };
3946 pub extern "C" fn CommitmentUpdate_new(mut update_add_htlcs_arg: crate::c_types::derived::CVec_UpdateAddHTLCZ, mut update_fulfill_htlcs_arg: crate::c_types::derived::CVec_UpdateFulfillHTLCZ, mut update_fail_htlcs_arg: crate::c_types::derived::CVec_UpdateFailHTLCZ, mut update_fail_malformed_htlcs_arg: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ, mut update_fee_arg: crate::ln::msgs::UpdateFee, mut commitment_signed_arg: crate::ln::msgs::CommitmentSigned) -> CommitmentUpdate {
3947 let mut local_update_add_htlcs_arg = Vec::new(); for mut item in update_add_htlcs_arg.into_rust().drain(..) { local_update_add_htlcs_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
3948 let mut local_update_fulfill_htlcs_arg = Vec::new(); for mut item in update_fulfill_htlcs_arg.into_rust().drain(..) { local_update_fulfill_htlcs_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
3949 let mut local_update_fail_htlcs_arg = Vec::new(); for mut item in update_fail_htlcs_arg.into_rust().drain(..) { local_update_fail_htlcs_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
3950 let mut local_update_fail_malformed_htlcs_arg = Vec::new(); for mut item in update_fail_malformed_htlcs_arg.into_rust().drain(..) { local_update_fail_malformed_htlcs_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
3951 let mut local_update_fee_arg = if update_fee_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(update_fee_arg.take_inner()) } }) };
3952 CommitmentUpdate { inner: Box::into_raw(Box::new(nativeCommitmentUpdate {
3953 update_add_htlcs: local_update_add_htlcs_arg,
3954 update_fulfill_htlcs: local_update_fulfill_htlcs_arg,
3955 update_fail_htlcs: local_update_fail_htlcs_arg,
3956 update_fail_malformed_htlcs: local_update_fail_malformed_htlcs_arg,
3957 update_fee: local_update_fee_arg,
3958 commitment_signed: *unsafe { Box::from_raw(commitment_signed_arg.take_inner()) },
3959 })), is_owned: true }
3961 /// The information we received from a peer along the route of a payment we originated. This is
3962 /// returned by ChannelMessageHandler::handle_update_fail_htlc to be passed into
3963 /// RoutingMessageHandler::handle_htlc_fail_channel_update to update our network map.
3967 pub enum HTLCFailChannelUpdate {
3968 /// We received an error which included a full ChannelUpdate message.
3969 ChannelUpdateMessage {
3970 msg: crate::ln::msgs::ChannelUpdate,
3972 /// We received an error which indicated only that a channel has been closed
3974 short_channel_id: u64,
3977 /// We received an error which indicated only that a node has failed
3979 node_id: crate::c_types::PublicKey,
3983 use lightning::ln::msgs::HTLCFailChannelUpdate as nativeHTLCFailChannelUpdate;
3984 impl HTLCFailChannelUpdate {
3986 pub(crate) fn to_native(&self) -> nativeHTLCFailChannelUpdate {
3988 HTLCFailChannelUpdate::ChannelUpdateMessage {ref msg, } => {
3989 let mut msg_nonref = (*msg).clone();
3990 nativeHTLCFailChannelUpdate::ChannelUpdateMessage {
3991 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3994 HTLCFailChannelUpdate::ChannelClosed {ref short_channel_id, ref is_permanent, } => {
3995 let mut short_channel_id_nonref = (*short_channel_id).clone();
3996 let mut is_permanent_nonref = (*is_permanent).clone();
3997 nativeHTLCFailChannelUpdate::ChannelClosed {
3998 short_channel_id: short_channel_id_nonref,
3999 is_permanent: is_permanent_nonref,
4002 HTLCFailChannelUpdate::NodeFailure {ref node_id, ref is_permanent, } => {
4003 let mut node_id_nonref = (*node_id).clone();
4004 let mut is_permanent_nonref = (*is_permanent).clone();
4005 nativeHTLCFailChannelUpdate::NodeFailure {
4006 node_id: node_id_nonref.into_rust(),
4007 is_permanent: is_permanent_nonref,
4013 pub(crate) fn into_native(self) -> nativeHTLCFailChannelUpdate {
4015 HTLCFailChannelUpdate::ChannelUpdateMessage {mut msg, } => {
4016 nativeHTLCFailChannelUpdate::ChannelUpdateMessage {
4017 msg: *unsafe { Box::from_raw(msg.take_inner()) },
4020 HTLCFailChannelUpdate::ChannelClosed {mut short_channel_id, mut is_permanent, } => {
4021 nativeHTLCFailChannelUpdate::ChannelClosed {
4022 short_channel_id: short_channel_id,
4023 is_permanent: is_permanent,
4026 HTLCFailChannelUpdate::NodeFailure {mut node_id, mut is_permanent, } => {
4027 nativeHTLCFailChannelUpdate::NodeFailure {
4028 node_id: node_id.into_rust(),
4029 is_permanent: is_permanent,
4035 pub(crate) fn from_native(native: &nativeHTLCFailChannelUpdate) -> Self {
4037 nativeHTLCFailChannelUpdate::ChannelUpdateMessage {ref msg, } => {
4038 let mut msg_nonref = (*msg).clone();
4039 HTLCFailChannelUpdate::ChannelUpdateMessage {
4040 msg: crate::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
4043 nativeHTLCFailChannelUpdate::ChannelClosed {ref short_channel_id, ref is_permanent, } => {
4044 let mut short_channel_id_nonref = (*short_channel_id).clone();
4045 let mut is_permanent_nonref = (*is_permanent).clone();
4046 HTLCFailChannelUpdate::ChannelClosed {
4047 short_channel_id: short_channel_id_nonref,
4048 is_permanent: is_permanent_nonref,
4051 nativeHTLCFailChannelUpdate::NodeFailure {ref node_id, ref is_permanent, } => {
4052 let mut node_id_nonref = (*node_id).clone();
4053 let mut is_permanent_nonref = (*is_permanent).clone();
4054 HTLCFailChannelUpdate::NodeFailure {
4055 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
4056 is_permanent: is_permanent_nonref,
4062 pub(crate) fn native_into(native: nativeHTLCFailChannelUpdate) -> Self {
4064 nativeHTLCFailChannelUpdate::ChannelUpdateMessage {mut msg, } => {
4065 HTLCFailChannelUpdate::ChannelUpdateMessage {
4066 msg: crate::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(msg)), is_owned: true },
4069 nativeHTLCFailChannelUpdate::ChannelClosed {mut short_channel_id, mut is_permanent, } => {
4070 HTLCFailChannelUpdate::ChannelClosed {
4071 short_channel_id: short_channel_id,
4072 is_permanent: is_permanent,
4075 nativeHTLCFailChannelUpdate::NodeFailure {mut node_id, mut is_permanent, } => {
4076 HTLCFailChannelUpdate::NodeFailure {
4077 node_id: crate::c_types::PublicKey::from_rust(&node_id),
4078 is_permanent: is_permanent,
4085 pub extern "C" fn HTLCFailChannelUpdate_free(this_ptr: HTLCFailChannelUpdate) { }
4087 pub extern "C" fn HTLCFailChannelUpdate_clone(orig: &HTLCFailChannelUpdate) -> HTLCFailChannelUpdate {
4090 /// A trait to describe an object which can receive channel messages.
4092 /// Messages MAY be called in parallel when they originate from different their_node_ids, however
4093 /// they MUST NOT be called in parallel when the two calls have the same their_node_id.
4095 pub struct ChannelMessageHandler {
4096 pub this_arg: *mut c_void,
4097 /// Handle an incoming open_channel message from the given peer.
4098 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),
4099 /// Handle an incoming accept_channel message from the given peer.
4100 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),
4101 /// Handle an incoming funding_created message from the given peer.
4102 pub handle_funding_created: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingCreated),
4103 /// Handle an incoming funding_signed message from the given peer.
4104 pub handle_funding_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingSigned),
4105 /// Handle an incoming funding_locked message from the given peer.
4106 pub handle_funding_locked: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingLocked),
4107 /// Handle an incoming shutdown message from the given peer.
4108 pub handle_shutdown: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::Shutdown),
4109 /// Handle an incoming closing_signed message from the given peer.
4110 pub handle_closing_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ClosingSigned),
4111 /// Handle an incoming update_add_htlc message from the given peer.
4112 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),
4113 /// Handle an incoming update_fulfill_htlc message from the given peer.
4114 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),
4115 /// Handle an incoming update_fail_htlc message from the given peer.
4116 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),
4117 /// Handle an incoming update_fail_malformed_htlc message from the given peer.
4118 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),
4119 /// Handle an incoming commitment_signed message from the given peer.
4120 pub handle_commitment_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::CommitmentSigned),
4121 /// Handle an incoming revoke_and_ack message from the given peer.
4122 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),
4123 /// Handle an incoming update_fee message from the given peer.
4124 pub handle_update_fee: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFee),
4125 /// Handle an incoming announcement_signatures message from the given peer.
4126 pub handle_announcement_signatures: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::AnnouncementSignatures),
4127 /// Indicates a connection to the peer failed/an existing connection was lost. If no connection
4128 /// is believed to be possible in the future (eg they're sending us messages we don't
4129 /// understand or indicate they require unknown feature bits), no_connection_possible is set
4130 /// and any outstanding channels should be failed.
4131 pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, no_connection_possible: bool),
4132 /// Handle a peer reconnecting, possibly generating channel_reestablish message(s).
4133 pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::Init),
4134 /// Handle an incoming channel_reestablish message from the given peer.
4135 pub handle_channel_reestablish: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ChannelReestablish),
4136 /// Handle an incoming error message from the given peer.
4137 pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ErrorMessage),
4138 pub MessageSendEventsProvider: crate::util::events::MessageSendEventsProvider,
4139 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
4141 impl lightning::util::events::MessageSendEventsProvider for ChannelMessageHandler {
4142 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
4143 <crate::util::events::MessageSendEventsProvider as lightning::util::events::MessageSendEventsProvider>::get_and_clear_pending_msg_events(&self.MessageSendEventsProvider)
4146 unsafe impl Send for ChannelMessageHandler {}
4147 unsafe impl Sync for ChannelMessageHandler {}
4149 use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler;
4150 impl rustChannelMessageHandler for ChannelMessageHandler {
4151 fn handle_open_channel(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, their_features: lightning::ln::features::InitFeatures, msg: &lightning::ln::msgs::OpenChannel) {
4152 (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 })
4154 fn handle_accept_channel(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, their_features: lightning::ln::features::InitFeatures, msg: &lightning::ln::msgs::AcceptChannel) {
4155 (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 })
4157 fn handle_funding_created(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::FundingCreated) {
4158 (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 })
4160 fn handle_funding_signed(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::FundingSigned) {
4161 (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 })
4163 fn handle_funding_locked(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::FundingLocked) {
4164 (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 })
4166 fn handle_shutdown(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::Shutdown) {
4167 (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 })
4169 fn handle_closing_signed(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::ClosingSigned) {
4170 (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 })
4172 fn handle_update_add_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateAddHTLC) {
4173 (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 })
4175 fn handle_update_fulfill_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFulfillHTLC) {
4176 (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 })
4178 fn handle_update_fail_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFailHTLC) {
4179 (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 })
4181 fn handle_update_fail_malformed_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) {
4182 (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 })
4184 fn handle_commitment_signed(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::CommitmentSigned) {
4185 (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 })
4187 fn handle_revoke_and_ack(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::RevokeAndACK) {
4188 (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 })
4190 fn handle_update_fee(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFee) {
4191 (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 })
4193 fn handle_announcement_signatures(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::AnnouncementSignatures) {
4194 (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 })
4196 fn peer_disconnected(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, no_connection_possible: bool) {
4197 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), no_connection_possible)
4199 fn peer_connected(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::Init) {
4200 (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 })
4202 fn handle_channel_reestablish(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::ChannelReestablish) {
4203 (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 })
4205 fn handle_error(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::ErrorMessage) {
4206 (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 })
4210 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
4211 // directly as a Deref trait in higher-level structs:
4212 impl std::ops::Deref for ChannelMessageHandler {
4214 fn deref(&self) -> &Self {
4218 /// Calls the free function if one is set
4220 pub extern "C" fn ChannelMessageHandler_free(this_ptr: ChannelMessageHandler) { }
4221 impl Drop for ChannelMessageHandler {
4222 fn drop(&mut self) {
4223 if let Some(f) = self.free {
4228 /// A trait to describe an object which can receive routing messages.
4230 /// # Implementor DoS Warnings
4232 /// For `gossip_queries` messages there are potential DoS vectors when handling
4233 /// inbound queries. Implementors using an on-disk network graph should be aware of
4234 /// repeated disk I/O for queries accessing different parts of the network graph.
4236 pub struct RoutingMessageHandler {
4237 pub this_arg: *mut c_void,
4238 /// Handle an incoming node_announcement message, returning true if it should be forwarded on,
4239 /// false or returning an Err otherwise.
4241 pub handle_node_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
4242 /// Handle a channel_announcement message, returning true if it should be forwarded on, false
4243 /// or returning an Err otherwise.
4245 pub handle_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
4246 /// Handle an incoming channel_update message, returning true if it should be forwarded on,
4247 /// false or returning an Err otherwise.
4249 pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ,
4250 /// Handle some updates to the route graph that we learned due to an outbound failed payment.
4251 pub handle_htlc_fail_channel_update: extern "C" fn (this_arg: *const c_void, update: &crate::ln::msgs::HTLCFailChannelUpdate),
4252 /// Gets a subset of the channel announcements and updates required to dump our routing table
4253 /// to a remote node, starting at the short_channel_id indicated by starting_point and
4254 /// including the batch_amount entries immediately higher in numerical value than starting_point.
4256 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,
4257 /// Gets a subset of the node announcements required to dump our routing table to a remote node,
4258 /// starting at the node *after* the provided publickey and including batch_amount entries
4259 /// immediately higher (as defined by <PublicKey as Ord>::cmp) than starting_point.
4260 /// If None is provided for starting_point, we start at the first node.
4262 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,
4263 /// Called when a connection is established with a peer. This can be used to
4264 /// perform routing table synchronization using a strategy defined by the
4266 pub sync_routing_table: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, init: &crate::ln::msgs::Init),
4267 /// Handles the reply of a query we initiated to learn about channels
4268 /// for a given range of blocks. We can expect to receive one or more
4269 /// replies to a single query.
4271 pub handle_reply_channel_range: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ,
4272 /// Handles the reply of a query we initiated asking for routing gossip
4273 /// messages for a list of channels. We should receive this message when
4274 /// a node has completed its best effort to send us the pertaining routing
4275 /// gossip messages.
4277 pub handle_reply_short_channel_ids_end: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CResult_NoneLightningErrorZ,
4278 /// Handles when a peer asks us to send a list of short_channel_ids
4279 /// for the requested range of blocks.
4281 pub handle_query_channel_range: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ,
4282 /// Handles when a peer asks us to send routing gossip messages for a
4283 /// list of short_channel_ids.
4285 pub handle_query_short_channel_ids: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CResult_NoneLightningErrorZ,
4286 pub MessageSendEventsProvider: crate::util::events::MessageSendEventsProvider,
4287 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
4289 unsafe impl Send for RoutingMessageHandler {}
4290 unsafe impl Sync for RoutingMessageHandler {}
4291 impl lightning::util::events::MessageSendEventsProvider for RoutingMessageHandler {
4292 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
4293 <crate::util::events::MessageSendEventsProvider as lightning::util::events::MessageSendEventsProvider>::get_and_clear_pending_msg_events(&self.MessageSendEventsProvider)
4297 use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler;
4298 impl rustRoutingMessageHandler for RoutingMessageHandler {
4299 fn handle_node_announcement(&self, msg: &lightning::ln::msgs::NodeAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
4300 let mut ret = (self.handle_node_announcement)(self.this_arg, &crate::ln::msgs::NodeAnnouncement { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false });
4301 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
4304 fn handle_channel_announcement(&self, msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
4305 let mut ret = (self.handle_channel_announcement)(self.this_arg, &crate::ln::msgs::ChannelAnnouncement { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false });
4306 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
4309 fn handle_channel_update(&self, msg: &lightning::ln::msgs::ChannelUpdate) -> Result<bool, lightning::ln::msgs::LightningError> {
4310 let mut ret = (self.handle_channel_update)(self.this_arg, &crate::ln::msgs::ChannelUpdate { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false });
4311 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
4314 fn handle_htlc_fail_channel_update(&self, update: &lightning::ln::msgs::HTLCFailChannelUpdate) {
4315 (self.handle_htlc_fail_channel_update)(self.this_arg, &crate::ln::msgs::HTLCFailChannelUpdate::from_native(&update))
4317 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>)> {
4318 let mut ret = (self.get_next_channel_announcements)(self.this_arg, starting_point, batch_amount);
4319 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = item.to_rust(); let mut local_orig_ret_0_1 = if orig_ret_0_1.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(orig_ret_0_1.take_inner()) } }) }; let mut local_orig_ret_0_2 = if orig_ret_0_2.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(orig_ret_0_2.take_inner()) } }) }; let mut local_ret_0 = (*unsafe { Box::from_raw(orig_ret_0_0.take_inner()) }, local_orig_ret_0_1, local_orig_ret_0_2); local_ret_0 }); };
4322 fn get_next_node_announcements(&self, starting_point: Option<&bitcoin::secp256k1::key::PublicKey>, batch_amount: u8) -> Vec<lightning::ln::msgs::NodeAnnouncement> {
4323 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())) } };
4324 let mut ret = (self.get_next_node_announcements)(self.this_arg, local_starting_point, batch_amount);
4325 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4328 fn sync_routing_table(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, init: &lightning::ln::msgs::Init) {
4329 (self.sync_routing_table)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::ln::msgs::Init { inner: unsafe { (init as *const _) as *mut _ }, is_owned: false })
4331 fn handle_reply_channel_range(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: lightning::ln::msgs::ReplyChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
4332 let mut ret = (self.handle_reply_channel_range)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::ln::msgs::ReplyChannelRange { inner: Box::into_raw(Box::new(msg)), is_owned: true });
4333 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
4336 fn handle_reply_short_channel_ids_end(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: lightning::ln::msgs::ReplyShortChannelIdsEnd) -> Result<(), lightning::ln::msgs::LightningError> {
4337 let mut ret = (self.handle_reply_short_channel_ids_end)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::ln::msgs::ReplyShortChannelIdsEnd { inner: Box::into_raw(Box::new(msg)), is_owned: true });
4338 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
4341 fn handle_query_channel_range(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: lightning::ln::msgs::QueryChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
4342 let mut ret = (self.handle_query_channel_range)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::ln::msgs::QueryChannelRange { inner: Box::into_raw(Box::new(msg)), is_owned: true });
4343 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
4346 fn handle_query_short_channel_ids(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: lightning::ln::msgs::QueryShortChannelIds) -> Result<(), lightning::ln::msgs::LightningError> {
4347 let mut ret = (self.handle_query_short_channel_ids)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::ln::msgs::QueryShortChannelIds { inner: Box::into_raw(Box::new(msg)), is_owned: true });
4348 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
4353 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
4354 // directly as a Deref trait in higher-level structs:
4355 impl std::ops::Deref for RoutingMessageHandler {
4357 fn deref(&self) -> &Self {
4361 /// Calls the free function if one is set
4363 pub extern "C" fn RoutingMessageHandler_free(this_ptr: RoutingMessageHandler) { }
4364 impl Drop for RoutingMessageHandler {
4365 fn drop(&mut self) {
4366 if let Some(f) = self.free {
4372 pub extern "C" fn AcceptChannel_write(obj: &AcceptChannel) -> crate::c_types::derived::CVec_u8Z {
4373 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4376 pub(crate) extern "C" fn AcceptChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4377 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannel) })
4380 pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> AcceptChannel {
4381 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4382 AcceptChannel { inner: Box::into_raw(Box::new(res)), is_owned: true }
4384 AcceptChannel { inner: std::ptr::null_mut(), is_owned: true }
4388 pub extern "C" fn AnnouncementSignatures_write(obj: &AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z {
4389 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4392 pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4393 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAnnouncementSignatures) })
4396 pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> AnnouncementSignatures {
4397 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4398 AnnouncementSignatures { inner: Box::into_raw(Box::new(res)), is_owned: true }
4400 AnnouncementSignatures { inner: std::ptr::null_mut(), is_owned: true }
4404 pub extern "C" fn ChannelReestablish_write(obj: &ChannelReestablish) -> crate::c_types::derived::CVec_u8Z {
4405 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4408 pub(crate) extern "C" fn ChannelReestablish_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4409 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReestablish) })
4412 pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReestablishDecodeErrorZ {
4413 let res = crate::c_types::deserialize_obj(ser);
4414 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::ChannelReestablish { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4418 pub extern "C" fn ClosingSigned_write(obj: &ClosingSigned) -> crate::c_types::derived::CVec_u8Z {
4419 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4422 pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4423 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSigned) })
4426 pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> ClosingSigned {
4427 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4428 ClosingSigned { inner: Box::into_raw(Box::new(res)), is_owned: true }
4430 ClosingSigned { inner: std::ptr::null_mut(), is_owned: true }
4434 pub extern "C" fn CommitmentSigned_write(obj: &CommitmentSigned) -> crate::c_types::derived::CVec_u8Z {
4435 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4438 pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4439 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentSigned) })
4442 pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> CommitmentSigned {
4443 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4444 CommitmentSigned { inner: Box::into_raw(Box::new(res)), is_owned: true }
4446 CommitmentSigned { inner: std::ptr::null_mut(), is_owned: true }
4450 pub extern "C" fn FundingCreated_write(obj: &FundingCreated) -> crate::c_types::derived::CVec_u8Z {
4451 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4454 pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4455 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingCreated) })
4458 pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> FundingCreated {
4459 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4460 FundingCreated { inner: Box::into_raw(Box::new(res)), is_owned: true }
4462 FundingCreated { inner: std::ptr::null_mut(), is_owned: true }
4466 pub extern "C" fn FundingSigned_write(obj: &FundingSigned) -> crate::c_types::derived::CVec_u8Z {
4467 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4470 pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4471 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingSigned) })
4474 pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> FundingSigned {
4475 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4476 FundingSigned { inner: Box::into_raw(Box::new(res)), is_owned: true }
4478 FundingSigned { inner: std::ptr::null_mut(), is_owned: true }
4482 pub extern "C" fn FundingLocked_write(obj: &FundingLocked) -> crate::c_types::derived::CVec_u8Z {
4483 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4486 pub(crate) extern "C" fn FundingLocked_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4487 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingLocked) })
4490 pub extern "C" fn FundingLocked_read(ser: crate::c_types::u8slice) -> FundingLocked {
4491 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4492 FundingLocked { inner: Box::into_raw(Box::new(res)), is_owned: true }
4494 FundingLocked { inner: std::ptr::null_mut(), is_owned: true }
4498 pub extern "C" fn Init_write(obj: &Init) -> crate::c_types::derived::CVec_u8Z {
4499 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4502 pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4503 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInit) })
4506 pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitDecodeErrorZ {
4507 let res = crate::c_types::deserialize_obj(ser);
4508 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::Init { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4512 pub extern "C" fn OpenChannel_write(obj: &OpenChannel) -> crate::c_types::derived::CVec_u8Z {
4513 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4516 pub(crate) extern "C" fn OpenChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4517 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannel) })
4520 pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> OpenChannel {
4521 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4522 OpenChannel { inner: Box::into_raw(Box::new(res)), is_owned: true }
4524 OpenChannel { inner: std::ptr::null_mut(), is_owned: true }
4528 pub extern "C" fn RevokeAndACK_write(obj: &RevokeAndACK) -> crate::c_types::derived::CVec_u8Z {
4529 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4532 pub(crate) extern "C" fn RevokeAndACK_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4533 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevokeAndACK) })
4536 pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> RevokeAndACK {
4537 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4538 RevokeAndACK { inner: Box::into_raw(Box::new(res)), is_owned: true }
4540 RevokeAndACK { inner: std::ptr::null_mut(), is_owned: true }
4544 pub extern "C" fn Shutdown_write(obj: &Shutdown) -> crate::c_types::derived::CVec_u8Z {
4545 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4548 pub(crate) extern "C" fn Shutdown_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4549 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeShutdown) })
4552 pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> Shutdown {
4553 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4554 Shutdown { inner: Box::into_raw(Box::new(res)), is_owned: true }
4556 Shutdown { inner: std::ptr::null_mut(), is_owned: true }
4560 pub extern "C" fn UpdateFailHTLC_write(obj: &UpdateFailHTLC) -> crate::c_types::derived::CVec_u8Z {
4561 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4564 pub(crate) extern "C" fn UpdateFailHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4565 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailHTLC) })
4568 pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> UpdateFailHTLC {
4569 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4570 UpdateFailHTLC { inner: Box::into_raw(Box::new(res)), is_owned: true }
4572 UpdateFailHTLC { inner: std::ptr::null_mut(), is_owned: true }
4576 pub extern "C" fn UpdateFailMalformedHTLC_write(obj: &UpdateFailMalformedHTLC) -> crate::c_types::derived::CVec_u8Z {
4577 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4580 pub(crate) extern "C" fn UpdateFailMalformedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4581 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailMalformedHTLC) })
4584 pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> UpdateFailMalformedHTLC {
4585 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4586 UpdateFailMalformedHTLC { inner: Box::into_raw(Box::new(res)), is_owned: true }
4588 UpdateFailMalformedHTLC { inner: std::ptr::null_mut(), is_owned: true }
4592 pub extern "C" fn UpdateFee_write(obj: &UpdateFee) -> crate::c_types::derived::CVec_u8Z {
4593 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4596 pub(crate) extern "C" fn UpdateFee_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4597 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFee) })
4600 pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> UpdateFee {
4601 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4602 UpdateFee { inner: Box::into_raw(Box::new(res)), is_owned: true }
4604 UpdateFee { inner: std::ptr::null_mut(), is_owned: true }
4608 pub extern "C" fn UpdateFulfillHTLC_write(obj: &UpdateFulfillHTLC) -> crate::c_types::derived::CVec_u8Z {
4609 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4612 pub(crate) extern "C" fn UpdateFulfillHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4613 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFulfillHTLC) })
4616 pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> UpdateFulfillHTLC {
4617 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4618 UpdateFulfillHTLC { inner: Box::into_raw(Box::new(res)), is_owned: true }
4620 UpdateFulfillHTLC { inner: std::ptr::null_mut(), is_owned: true }
4624 pub extern "C" fn UpdateAddHTLC_write(obj: &UpdateAddHTLC) -> crate::c_types::derived::CVec_u8Z {
4625 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4628 pub(crate) extern "C" fn UpdateAddHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4629 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateAddHTLC) })
4632 pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> UpdateAddHTLC {
4633 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4634 UpdateAddHTLC { inner: Box::into_raw(Box::new(res)), is_owned: true }
4636 UpdateAddHTLC { inner: std::ptr::null_mut(), is_owned: true }
4640 pub extern "C" fn Ping_write(obj: &Ping) -> crate::c_types::derived::CVec_u8Z {
4641 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4644 pub(crate) extern "C" fn Ping_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4645 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePing) })
4648 pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PingDecodeErrorZ {
4649 let res = crate::c_types::deserialize_obj(ser);
4650 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::Ping { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4654 pub extern "C" fn Pong_write(obj: &Pong) -> crate::c_types::derived::CVec_u8Z {
4655 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4658 pub(crate) extern "C" fn Pong_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4659 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePong) })
4662 pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PongDecodeErrorZ {
4663 let res = crate::c_types::deserialize_obj(ser);
4664 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::Pong { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4668 pub extern "C" fn UnsignedChannelAnnouncement_write(obj: &UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
4669 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4672 pub(crate) extern "C" fn UnsignedChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4673 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelAnnouncement) })
4676 pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelAnnouncementDecodeErrorZ {
4677 let res = crate::c_types::deserialize_obj(ser);
4678 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::UnsignedChannelAnnouncement { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4682 pub extern "C" fn ChannelAnnouncement_write(obj: &ChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
4683 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4686 pub(crate) extern "C" fn ChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4687 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelAnnouncement) })
4690 pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> ChannelAnnouncement {
4691 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4692 ChannelAnnouncement { inner: Box::into_raw(Box::new(res)), is_owned: true }
4694 ChannelAnnouncement { inner: std::ptr::null_mut(), is_owned: true }
4698 pub extern "C" fn UnsignedChannelUpdate_write(obj: &UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
4699 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4702 pub(crate) extern "C" fn UnsignedChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4703 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelUpdate) })
4706 pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelUpdateDecodeErrorZ {
4707 let res = crate::c_types::deserialize_obj(ser);
4708 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::UnsignedChannelUpdate { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4712 pub extern "C" fn ChannelUpdate_write(obj: &ChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
4713 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4716 pub(crate) extern "C" fn ChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4717 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdate) })
4720 pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> ChannelUpdate {
4721 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4722 ChannelUpdate { inner: Box::into_raw(Box::new(res)), is_owned: true }
4724 ChannelUpdate { inner: std::ptr::null_mut(), is_owned: true }
4728 pub extern "C" fn ErrorMessage_write(obj: &ErrorMessage) -> crate::c_types::derived::CVec_u8Z {
4729 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4732 pub(crate) extern "C" fn ErrorMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4733 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeErrorMessage) })
4736 pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ErrorMessageDecodeErrorZ {
4737 let res = crate::c_types::deserialize_obj(ser);
4738 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::ErrorMessage { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4742 pub extern "C" fn UnsignedNodeAnnouncement_write(obj: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
4743 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4746 pub(crate) extern "C" fn UnsignedNodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4747 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedNodeAnnouncement) })
4750 pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedNodeAnnouncementDecodeErrorZ {
4751 let res = crate::c_types::deserialize_obj(ser);
4752 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::UnsignedNodeAnnouncement { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4756 pub extern "C" fn NodeAnnouncement_write(obj: &NodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
4757 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4760 pub(crate) extern "C" fn NodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4761 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncement) })
4764 pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> NodeAnnouncement {
4765 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4766 NodeAnnouncement { inner: Box::into_raw(Box::new(res)), is_owned: true }
4768 NodeAnnouncement { inner: std::ptr::null_mut(), is_owned: true }
4772 pub extern "C" fn QueryShortChannelIds_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryShortChannelIdsDecodeErrorZ {
4773 let res = crate::c_types::deserialize_obj(ser);
4774 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::QueryShortChannelIds { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4778 pub extern "C" fn QueryShortChannelIds_write(obj: &QueryShortChannelIds) -> crate::c_types::derived::CVec_u8Z {
4779 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4782 pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4783 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) })
4786 pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyShortChannelIdsEndDecodeErrorZ {
4787 let res = crate::c_types::deserialize_obj(ser);
4788 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::ReplyShortChannelIdsEnd { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4792 pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z {
4793 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4796 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4797 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) })
4800 pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ {
4801 let res = crate::c_types::deserialize_obj(ser);
4802 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::QueryChannelRange { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4806 pub extern "C" fn QueryChannelRange_write(obj: &QueryChannelRange) -> crate::c_types::derived::CVec_u8Z {
4807 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4810 pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4811 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) })
4814 pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyChannelRangeDecodeErrorZ {
4815 let res = crate::c_types::deserialize_obj(ser);
4816 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::ReplyChannelRange { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4820 pub extern "C" fn ReplyChannelRange_write(obj: &ReplyChannelRange) -> crate::c_types::derived::CVec_u8Z {
4821 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4824 pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4825 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) })
4828 pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_GossipTimestampFilterDecodeErrorZ {
4829 let res = crate::c_types::deserialize_obj(ser);
4830 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::msgs::GossipTimestampFilter { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
4834 pub extern "C" fn GossipTimestampFilter_write(obj: &GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z {
4835 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4838 pub(crate) extern "C" fn GossipTimestampFilter_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4839 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeGossipTimestampFilter) })