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();
61 use lightning::ln::msgs::Init as nativeInitImport;
62 type nativeInit = nativeInitImport;
64 /// An init message to be sent or received from a peer
68 /// Nearly everywhere, inner must be non-null, however in places where
69 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
70 pub inner: *mut nativeInit,
76 if self.is_owned && !self.inner.is_null() {
77 let _ = unsafe { Box::from_raw(self.inner) };
82 pub extern "C" fn Init_free(this_ptr: Init) { }
84 /// Used only if an object of this type is returned as a trait impl by a method
85 extern "C" fn Init_free_void(this_ptr: *mut c_void) {
86 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeInit); }
89 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
91 pub(crate) fn take_inner(mut self) -> *mut nativeInit {
92 assert!(self.is_owned);
94 self.inner = std::ptr::null_mut();
99 fn clone(&self) -> Self {
101 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
107 /// Used only if an object of this type is returned as a trait impl by a method
108 pub(crate) extern "C" fn Init_clone_void(this_ptr: *const c_void) -> *mut c_void {
109 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInit)).clone() })) as *mut c_void
112 pub extern "C" fn Init_clone(orig: &Init) -> Init {
113 Init { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
116 use lightning::ln::msgs::ErrorMessage as nativeErrorMessageImport;
117 type nativeErrorMessage = nativeErrorMessageImport;
119 /// An error message to be sent or received from a peer
122 pub struct ErrorMessage {
123 /// Nearly everywhere, inner must be non-null, however in places where
124 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
125 pub inner: *mut nativeErrorMessage,
129 impl Drop for ErrorMessage {
131 if self.is_owned && !self.inner.is_null() {
132 let _ = unsafe { Box::from_raw(self.inner) };
137 pub extern "C" fn ErrorMessage_free(this_ptr: ErrorMessage) { }
139 /// Used only if an object of this type is returned as a trait impl by a method
140 extern "C" fn ErrorMessage_free_void(this_ptr: *mut c_void) {
141 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeErrorMessage); }
144 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
146 pub(crate) fn take_inner(mut self) -> *mut nativeErrorMessage {
147 assert!(self.is_owned);
148 let ret = self.inner;
149 self.inner = std::ptr::null_mut();
153 impl Clone for ErrorMessage {
154 fn clone(&self) -> Self {
156 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
162 /// Used only if an object of this type is returned as a trait impl by a method
163 pub(crate) extern "C" fn ErrorMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
164 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeErrorMessage)).clone() })) as *mut c_void
167 pub extern "C" fn ErrorMessage_clone(orig: &ErrorMessage) -> ErrorMessage {
168 ErrorMessage { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
170 /// The channel ID involved in the error
172 pub extern "C" fn ErrorMessage_get_channel_id(this_ptr: &ErrorMessage) -> *const [u8; 32] {
173 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
176 /// The channel ID involved in the error
178 pub extern "C" fn ErrorMessage_set_channel_id(this_ptr: &mut ErrorMessage, mut val: crate::c_types::ThirtyTwoBytes) {
179 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
181 /// A possibly human-readable error description.
182 /// The string should be sanitized before it is used (e.g. emitted to logs
183 /// or printed to stdout). Otherwise, a well crafted error message may trigger a security
184 /// vulnerability in the terminal emulator or the logging subsystem.
186 pub extern "C" fn ErrorMessage_get_data(this_ptr: &ErrorMessage) -> crate::c_types::Str {
187 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.data;
188 (*inner_val).as_str().into()
190 /// A possibly human-readable error description.
191 /// The string should be sanitized before it is used (e.g. emitted to logs
192 /// or printed to stdout). Otherwise, a well crafted error message may trigger a security
193 /// vulnerability in the terminal emulator or the logging subsystem.
195 pub extern "C" fn ErrorMessage_set_data(this_ptr: &mut ErrorMessage, mut val: crate::c_types::derived::CVec_u8Z) {
196 unsafe { &mut *this_ptr.inner }.data = String::from_utf8(val.into_rust()).unwrap();
200 pub extern "C" fn ErrorMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::derived::CVec_u8Z) -> ErrorMessage {
201 ErrorMessage { inner: Box::into_raw(Box::new(nativeErrorMessage {
202 channel_id: channel_id_arg.data,
203 data: String::from_utf8(data_arg.into_rust()).unwrap(),
204 })), is_owned: true }
207 use lightning::ln::msgs::Ping as nativePingImport;
208 type nativePing = nativePingImport;
210 /// A ping message to be sent or received from a peer
214 /// Nearly everywhere, inner must be non-null, however in places where
215 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
216 pub inner: *mut nativePing,
222 if self.is_owned && !self.inner.is_null() {
223 let _ = unsafe { Box::from_raw(self.inner) };
228 pub extern "C" fn Ping_free(this_ptr: Ping) { }
230 /// Used only if an object of this type is returned as a trait impl by a method
231 extern "C" fn Ping_free_void(this_ptr: *mut c_void) {
232 unsafe { let _ = Box::from_raw(this_ptr as *mut nativePing); }
235 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
237 pub(crate) fn take_inner(mut self) -> *mut nativePing {
238 assert!(self.is_owned);
239 let ret = self.inner;
240 self.inner = std::ptr::null_mut();
244 impl Clone for Ping {
245 fn clone(&self) -> Self {
247 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
253 /// Used only if an object of this type is returned as a trait impl by a method
254 pub(crate) extern "C" fn Ping_clone_void(this_ptr: *const c_void) -> *mut c_void {
255 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePing)).clone() })) as *mut c_void
258 pub extern "C" fn Ping_clone(orig: &Ping) -> Ping {
259 Ping { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
261 /// The desired response length
263 pub extern "C" fn Ping_get_ponglen(this_ptr: &Ping) -> u16 {
264 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.ponglen;
267 /// The desired response length
269 pub extern "C" fn Ping_set_ponglen(this_ptr: &mut Ping, mut val: u16) {
270 unsafe { &mut *this_ptr.inner }.ponglen = val;
272 /// The ping packet size.
273 /// This field is not sent on the wire. byteslen zeros are sent.
275 pub extern "C" fn Ping_get_byteslen(this_ptr: &Ping) -> u16 {
276 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.byteslen;
279 /// The ping packet size.
280 /// This field is not sent on the wire. byteslen zeros are sent.
282 pub extern "C" fn Ping_set_byteslen(this_ptr: &mut Ping, mut val: u16) {
283 unsafe { &mut *this_ptr.inner }.byteslen = val;
287 pub extern "C" fn Ping_new(mut ponglen_arg: u16, mut byteslen_arg: u16) -> Ping {
288 Ping { inner: Box::into_raw(Box::new(nativePing {
289 ponglen: ponglen_arg,
290 byteslen: byteslen_arg,
291 })), is_owned: true }
294 use lightning::ln::msgs::Pong as nativePongImport;
295 type nativePong = nativePongImport;
297 /// A pong message to be sent or received from a peer
301 /// Nearly everywhere, inner must be non-null, however in places where
302 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
303 pub inner: *mut nativePong,
309 if self.is_owned && !self.inner.is_null() {
310 let _ = unsafe { Box::from_raw(self.inner) };
315 pub extern "C" fn Pong_free(this_ptr: Pong) { }
317 /// Used only if an object of this type is returned as a trait impl by a method
318 extern "C" fn Pong_free_void(this_ptr: *mut c_void) {
319 unsafe { let _ = Box::from_raw(this_ptr as *mut nativePong); }
322 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
324 pub(crate) fn take_inner(mut self) -> *mut nativePong {
325 assert!(self.is_owned);
326 let ret = self.inner;
327 self.inner = std::ptr::null_mut();
331 impl Clone for Pong {
332 fn clone(&self) -> Self {
334 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
340 /// Used only if an object of this type is returned as a trait impl by a method
341 pub(crate) extern "C" fn Pong_clone_void(this_ptr: *const c_void) -> *mut c_void {
342 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePong)).clone() })) as *mut c_void
345 pub extern "C" fn Pong_clone(orig: &Pong) -> Pong {
346 Pong { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
348 /// The pong packet size.
349 /// This field is not sent on the wire. byteslen zeros are sent.
351 pub extern "C" fn Pong_get_byteslen(this_ptr: &Pong) -> u16 {
352 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.byteslen;
355 /// The pong packet size.
356 /// This field is not sent on the wire. byteslen zeros are sent.
358 pub extern "C" fn Pong_set_byteslen(this_ptr: &mut Pong, mut val: u16) {
359 unsafe { &mut *this_ptr.inner }.byteslen = val;
363 pub extern "C" fn Pong_new(mut byteslen_arg: u16) -> Pong {
364 Pong { inner: Box::into_raw(Box::new(nativePong {
365 byteslen: byteslen_arg,
366 })), is_owned: true }
369 use lightning::ln::msgs::OpenChannel as nativeOpenChannelImport;
370 type nativeOpenChannel = nativeOpenChannelImport;
372 /// An open_channel message to be sent or received from a peer
375 pub struct OpenChannel {
376 /// Nearly everywhere, inner must be non-null, however in places where
377 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
378 pub inner: *mut nativeOpenChannel,
382 impl Drop for OpenChannel {
384 if self.is_owned && !self.inner.is_null() {
385 let _ = unsafe { Box::from_raw(self.inner) };
390 pub extern "C" fn OpenChannel_free(this_ptr: OpenChannel) { }
392 /// Used only if an object of this type is returned as a trait impl by a method
393 extern "C" fn OpenChannel_free_void(this_ptr: *mut c_void) {
394 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeOpenChannel); }
397 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
399 pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannel {
400 assert!(self.is_owned);
401 let ret = self.inner;
402 self.inner = std::ptr::null_mut();
406 impl Clone for OpenChannel {
407 fn clone(&self) -> Self {
409 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
415 /// Used only if an object of this type is returned as a trait impl by a method
416 pub(crate) extern "C" fn OpenChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
417 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOpenChannel)).clone() })) as *mut c_void
420 pub extern "C" fn OpenChannel_clone(orig: &OpenChannel) -> OpenChannel {
421 OpenChannel { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
423 /// The genesis hash of the blockchain where the channel is to be opened
425 pub extern "C" fn OpenChannel_get_chain_hash(this_ptr: &OpenChannel) -> *const [u8; 32] {
426 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
427 (*inner_val).as_inner()
429 /// The genesis hash of the blockchain where the channel is to be opened
431 pub extern "C" fn OpenChannel_set_chain_hash(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
432 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
434 /// A temporary channel ID, until the funding outpoint is announced
436 pub extern "C" fn OpenChannel_get_temporary_channel_id(this_ptr: &OpenChannel) -> *const [u8; 32] {
437 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.temporary_channel_id;
440 /// A temporary channel ID, until the funding outpoint is announced
442 pub extern "C" fn OpenChannel_set_temporary_channel_id(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) {
443 unsafe { &mut *this_ptr.inner }.temporary_channel_id = val.data;
445 /// The channel value
447 pub extern "C" fn OpenChannel_get_funding_satoshis(this_ptr: &OpenChannel) -> u64 {
448 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_satoshis;
451 /// The channel value
453 pub extern "C" fn OpenChannel_set_funding_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
454 unsafe { &mut *this_ptr.inner }.funding_satoshis = val;
456 /// The amount to push to the counterparty as part of the open, in milli-satoshi
458 pub extern "C" fn OpenChannel_get_push_msat(this_ptr: &OpenChannel) -> u64 {
459 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.push_msat;
462 /// The amount to push to the counterparty as part of the open, in milli-satoshi
464 pub extern "C" fn OpenChannel_set_push_msat(this_ptr: &mut OpenChannel, mut val: u64) {
465 unsafe { &mut *this_ptr.inner }.push_msat = val;
467 /// The threshold below which outputs on transactions broadcast by sender will be omitted
469 pub extern "C" fn OpenChannel_get_dust_limit_satoshis(this_ptr: &OpenChannel) -> u64 {
470 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.dust_limit_satoshis;
473 /// The threshold below which outputs on transactions broadcast by sender will be omitted
475 pub extern "C" fn OpenChannel_set_dust_limit_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
476 unsafe { &mut *this_ptr.inner }.dust_limit_satoshis = val;
478 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
480 pub extern "C" fn OpenChannel_get_max_htlc_value_in_flight_msat(this_ptr: &OpenChannel) -> u64 {
481 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_htlc_value_in_flight_msat;
484 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
486 pub extern "C" fn OpenChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut OpenChannel, mut val: u64) {
487 unsafe { &mut *this_ptr.inner }.max_htlc_value_in_flight_msat = val;
489 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
491 pub extern "C" fn OpenChannel_get_channel_reserve_satoshis(this_ptr: &OpenChannel) -> u64 {
492 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_reserve_satoshis;
495 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
497 pub extern "C" fn OpenChannel_set_channel_reserve_satoshis(this_ptr: &mut OpenChannel, mut val: u64) {
498 unsafe { &mut *this_ptr.inner }.channel_reserve_satoshis = val;
500 /// The minimum HTLC size incoming to sender, in milli-satoshi
502 pub extern "C" fn OpenChannel_get_htlc_minimum_msat(this_ptr: &OpenChannel) -> u64 {
503 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_minimum_msat;
506 /// The minimum HTLC size incoming to sender, in milli-satoshi
508 pub extern "C" fn OpenChannel_set_htlc_minimum_msat(this_ptr: &mut OpenChannel, mut val: u64) {
509 unsafe { &mut *this_ptr.inner }.htlc_minimum_msat = val;
511 /// The feerate per 1000-weight of sender generated transactions, until updated by update_fee
513 pub extern "C" fn OpenChannel_get_feerate_per_kw(this_ptr: &OpenChannel) -> u32 {
514 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.feerate_per_kw;
517 /// The feerate per 1000-weight of sender generated transactions, until updated by update_fee
519 pub extern "C" fn OpenChannel_set_feerate_per_kw(this_ptr: &mut OpenChannel, mut val: u32) {
520 unsafe { &mut *this_ptr.inner }.feerate_per_kw = val;
522 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
524 pub extern "C" fn OpenChannel_get_to_self_delay(this_ptr: &OpenChannel) -> u16 {
525 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.to_self_delay;
528 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
530 pub extern "C" fn OpenChannel_set_to_self_delay(this_ptr: &mut OpenChannel, mut val: u16) {
531 unsafe { &mut *this_ptr.inner }.to_self_delay = val;
533 /// The maximum number of inbound HTLCs towards sender
535 pub extern "C" fn OpenChannel_get_max_accepted_htlcs(this_ptr: &OpenChannel) -> u16 {
536 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_accepted_htlcs;
539 /// The maximum number of inbound HTLCs towards sender
541 pub extern "C" fn OpenChannel_set_max_accepted_htlcs(this_ptr: &mut OpenChannel, mut val: u16) {
542 unsafe { &mut *this_ptr.inner }.max_accepted_htlcs = val;
544 /// The sender's key controlling the funding transaction
546 pub extern "C" fn OpenChannel_get_funding_pubkey(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
547 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_pubkey;
548 crate::c_types::PublicKey::from_rust(&(*inner_val))
550 /// The sender's key controlling the funding transaction
552 pub extern "C" fn OpenChannel_set_funding_pubkey(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
553 unsafe { &mut *this_ptr.inner }.funding_pubkey = val.into_rust();
555 /// Used to derive a revocation key for transactions broadcast by counterparty
557 pub extern "C" fn OpenChannel_get_revocation_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
558 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.revocation_basepoint;
559 crate::c_types::PublicKey::from_rust(&(*inner_val))
561 /// Used to derive a revocation key for transactions broadcast by counterparty
563 pub extern "C" fn OpenChannel_set_revocation_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
564 unsafe { &mut *this_ptr.inner }.revocation_basepoint = val.into_rust();
566 /// A payment key to sender for transactions broadcast by counterparty
568 pub extern "C" fn OpenChannel_get_payment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
569 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_point;
570 crate::c_types::PublicKey::from_rust(&(*inner_val))
572 /// A payment key to sender for transactions broadcast by counterparty
574 pub extern "C" fn OpenChannel_set_payment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
575 unsafe { &mut *this_ptr.inner }.payment_point = val.into_rust();
577 /// Used to derive a payment key to sender for transactions broadcast by sender
579 pub extern "C" fn OpenChannel_get_delayed_payment_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
580 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.delayed_payment_basepoint;
581 crate::c_types::PublicKey::from_rust(&(*inner_val))
583 /// Used to derive a payment key to sender for transactions broadcast by sender
585 pub extern "C" fn OpenChannel_set_delayed_payment_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
586 unsafe { &mut *this_ptr.inner }.delayed_payment_basepoint = val.into_rust();
588 /// Used to derive an HTLC payment key to sender
590 pub extern "C" fn OpenChannel_get_htlc_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
591 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_basepoint;
592 crate::c_types::PublicKey::from_rust(&(*inner_val))
594 /// Used to derive an HTLC payment key to sender
596 pub extern "C" fn OpenChannel_set_htlc_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
597 unsafe { &mut *this_ptr.inner }.htlc_basepoint = val.into_rust();
599 /// The first to-be-broadcast-by-sender transaction's per commitment point
601 pub extern "C" fn OpenChannel_get_first_per_commitment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey {
602 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_per_commitment_point;
603 crate::c_types::PublicKey::from_rust(&(*inner_val))
605 /// The first to-be-broadcast-by-sender transaction's per commitment point
607 pub extern "C" fn OpenChannel_set_first_per_commitment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) {
608 unsafe { &mut *this_ptr.inner }.first_per_commitment_point = val.into_rust();
612 pub extern "C" fn OpenChannel_get_channel_flags(this_ptr: &OpenChannel) -> u8 {
613 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_flags;
618 pub extern "C" fn OpenChannel_set_channel_flags(this_ptr: &mut OpenChannel, mut val: u8) {
619 unsafe { &mut *this_ptr.inner }.channel_flags = val;
622 use lightning::ln::msgs::AcceptChannel as nativeAcceptChannelImport;
623 type nativeAcceptChannel = nativeAcceptChannelImport;
625 /// An accept_channel message to be sent or received from a peer
628 pub struct AcceptChannel {
629 /// Nearly everywhere, inner must be non-null, however in places where
630 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
631 pub inner: *mut nativeAcceptChannel,
635 impl Drop for AcceptChannel {
637 if self.is_owned && !self.inner.is_null() {
638 let _ = unsafe { Box::from_raw(self.inner) };
643 pub extern "C" fn AcceptChannel_free(this_ptr: AcceptChannel) { }
645 /// Used only if an object of this type is returned as a trait impl by a method
646 extern "C" fn AcceptChannel_free_void(this_ptr: *mut c_void) {
647 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeAcceptChannel); }
650 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
652 pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannel {
653 assert!(self.is_owned);
654 let ret = self.inner;
655 self.inner = std::ptr::null_mut();
659 impl Clone for AcceptChannel {
660 fn clone(&self) -> Self {
662 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
668 /// Used only if an object of this type is returned as a trait impl by a method
669 pub(crate) extern "C" fn AcceptChannel_clone_void(this_ptr: *const c_void) -> *mut c_void {
670 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAcceptChannel)).clone() })) as *mut c_void
673 pub extern "C" fn AcceptChannel_clone(orig: &AcceptChannel) -> AcceptChannel {
674 AcceptChannel { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
676 /// A temporary channel ID, until the funding outpoint is announced
678 pub extern "C" fn AcceptChannel_get_temporary_channel_id(this_ptr: &AcceptChannel) -> *const [u8; 32] {
679 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.temporary_channel_id;
682 /// A temporary channel ID, until the funding outpoint is announced
684 pub extern "C" fn AcceptChannel_set_temporary_channel_id(this_ptr: &mut AcceptChannel, mut val: crate::c_types::ThirtyTwoBytes) {
685 unsafe { &mut *this_ptr.inner }.temporary_channel_id = val.data;
687 /// The threshold below which outputs on transactions broadcast by sender will be omitted
689 pub extern "C" fn AcceptChannel_get_dust_limit_satoshis(this_ptr: &AcceptChannel) -> u64 {
690 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.dust_limit_satoshis;
693 /// The threshold below which outputs on transactions broadcast by sender will be omitted
695 pub extern "C" fn AcceptChannel_set_dust_limit_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
696 unsafe { &mut *this_ptr.inner }.dust_limit_satoshis = val;
698 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
700 pub extern "C" fn AcceptChannel_get_max_htlc_value_in_flight_msat(this_ptr: &AcceptChannel) -> u64 {
701 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_htlc_value_in_flight_msat;
704 /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi
706 pub extern "C" fn AcceptChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
707 unsafe { &mut *this_ptr.inner }.max_htlc_value_in_flight_msat = val;
709 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
711 pub extern "C" fn AcceptChannel_get_channel_reserve_satoshis(this_ptr: &AcceptChannel) -> u64 {
712 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_reserve_satoshis;
715 /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
717 pub extern "C" fn AcceptChannel_set_channel_reserve_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) {
718 unsafe { &mut *this_ptr.inner }.channel_reserve_satoshis = val;
720 /// The minimum HTLC size incoming to sender, in milli-satoshi
722 pub extern "C" fn AcceptChannel_get_htlc_minimum_msat(this_ptr: &AcceptChannel) -> u64 {
723 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_minimum_msat;
726 /// The minimum HTLC size incoming to sender, in milli-satoshi
728 pub extern "C" fn AcceptChannel_set_htlc_minimum_msat(this_ptr: &mut AcceptChannel, mut val: u64) {
729 unsafe { &mut *this_ptr.inner }.htlc_minimum_msat = val;
731 /// Minimum depth of the funding transaction before the channel is considered open
733 pub extern "C" fn AcceptChannel_get_minimum_depth(this_ptr: &AcceptChannel) -> u32 {
734 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.minimum_depth;
737 /// Minimum depth of the funding transaction before the channel is considered open
739 pub extern "C" fn AcceptChannel_set_minimum_depth(this_ptr: &mut AcceptChannel, mut val: u32) {
740 unsafe { &mut *this_ptr.inner }.minimum_depth = val;
742 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
744 pub extern "C" fn AcceptChannel_get_to_self_delay(this_ptr: &AcceptChannel) -> u16 {
745 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.to_self_delay;
748 /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
750 pub extern "C" fn AcceptChannel_set_to_self_delay(this_ptr: &mut AcceptChannel, mut val: u16) {
751 unsafe { &mut *this_ptr.inner }.to_self_delay = val;
753 /// The maximum number of inbound HTLCs towards sender
755 pub extern "C" fn AcceptChannel_get_max_accepted_htlcs(this_ptr: &AcceptChannel) -> u16 {
756 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_accepted_htlcs;
759 /// The maximum number of inbound HTLCs towards sender
761 pub extern "C" fn AcceptChannel_set_max_accepted_htlcs(this_ptr: &mut AcceptChannel, mut val: u16) {
762 unsafe { &mut *this_ptr.inner }.max_accepted_htlcs = val;
764 /// The sender's key controlling the funding transaction
766 pub extern "C" fn AcceptChannel_get_funding_pubkey(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
767 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_pubkey;
768 crate::c_types::PublicKey::from_rust(&(*inner_val))
770 /// The sender's key controlling the funding transaction
772 pub extern "C" fn AcceptChannel_set_funding_pubkey(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
773 unsafe { &mut *this_ptr.inner }.funding_pubkey = val.into_rust();
775 /// Used to derive a revocation key for transactions broadcast by counterparty
777 pub extern "C" fn AcceptChannel_get_revocation_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
778 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.revocation_basepoint;
779 crate::c_types::PublicKey::from_rust(&(*inner_val))
781 /// Used to derive a revocation key for transactions broadcast by counterparty
783 pub extern "C" fn AcceptChannel_set_revocation_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
784 unsafe { &mut *this_ptr.inner }.revocation_basepoint = val.into_rust();
786 /// A payment key to sender for transactions broadcast by counterparty
788 pub extern "C" fn AcceptChannel_get_payment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
789 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_point;
790 crate::c_types::PublicKey::from_rust(&(*inner_val))
792 /// A payment key to sender for transactions broadcast by counterparty
794 pub extern "C" fn AcceptChannel_set_payment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
795 unsafe { &mut *this_ptr.inner }.payment_point = val.into_rust();
797 /// Used to derive a payment key to sender for transactions broadcast by sender
799 pub extern "C" fn AcceptChannel_get_delayed_payment_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
800 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.delayed_payment_basepoint;
801 crate::c_types::PublicKey::from_rust(&(*inner_val))
803 /// Used to derive a payment key to sender for transactions broadcast by sender
805 pub extern "C" fn AcceptChannel_set_delayed_payment_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
806 unsafe { &mut *this_ptr.inner }.delayed_payment_basepoint = val.into_rust();
808 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
810 pub extern "C" fn AcceptChannel_get_htlc_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
811 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_basepoint;
812 crate::c_types::PublicKey::from_rust(&(*inner_val))
814 /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
816 pub extern "C" fn AcceptChannel_set_htlc_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
817 unsafe { &mut *this_ptr.inner }.htlc_basepoint = val.into_rust();
819 /// The first to-be-broadcast-by-sender transaction's per commitment point
821 pub extern "C" fn AcceptChannel_get_first_per_commitment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey {
822 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_per_commitment_point;
823 crate::c_types::PublicKey::from_rust(&(*inner_val))
825 /// The first to-be-broadcast-by-sender transaction's per commitment point
827 pub extern "C" fn AcceptChannel_set_first_per_commitment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
828 unsafe { &mut *this_ptr.inner }.first_per_commitment_point = val.into_rust();
831 use lightning::ln::msgs::FundingCreated as nativeFundingCreatedImport;
832 type nativeFundingCreated = nativeFundingCreatedImport;
834 /// A funding_created message to be sent or received from a peer
837 pub struct FundingCreated {
838 /// Nearly everywhere, inner must be non-null, however in places where
839 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
840 pub inner: *mut nativeFundingCreated,
844 impl Drop for FundingCreated {
846 if self.is_owned && !self.inner.is_null() {
847 let _ = unsafe { Box::from_raw(self.inner) };
852 pub extern "C" fn FundingCreated_free(this_ptr: FundingCreated) { }
854 /// Used only if an object of this type is returned as a trait impl by a method
855 extern "C" fn FundingCreated_free_void(this_ptr: *mut c_void) {
856 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingCreated); }
859 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
860 impl FundingCreated {
861 pub(crate) fn take_inner(mut self) -> *mut nativeFundingCreated {
862 assert!(self.is_owned);
863 let ret = self.inner;
864 self.inner = std::ptr::null_mut();
868 impl Clone for FundingCreated {
869 fn clone(&self) -> Self {
871 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
877 /// Used only if an object of this type is returned as a trait impl by a method
878 pub(crate) extern "C" fn FundingCreated_clone_void(this_ptr: *const c_void) -> *mut c_void {
879 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingCreated)).clone() })) as *mut c_void
882 pub extern "C" fn FundingCreated_clone(orig: &FundingCreated) -> FundingCreated {
883 FundingCreated { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
885 /// A temporary channel ID, until the funding is established
887 pub extern "C" fn FundingCreated_get_temporary_channel_id(this_ptr: &FundingCreated) -> *const [u8; 32] {
888 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.temporary_channel_id;
891 /// A temporary channel ID, until the funding is established
893 pub extern "C" fn FundingCreated_set_temporary_channel_id(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
894 unsafe { &mut *this_ptr.inner }.temporary_channel_id = val.data;
896 /// The funding transaction ID
898 pub extern "C" fn FundingCreated_get_funding_txid(this_ptr: &FundingCreated) -> *const [u8; 32] {
899 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_txid;
900 (*inner_val).as_inner()
902 /// The funding transaction ID
904 pub extern "C" fn FundingCreated_set_funding_txid(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) {
905 unsafe { &mut *this_ptr.inner }.funding_txid = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap();
907 /// The specific output index funding this channel
909 pub extern "C" fn FundingCreated_get_funding_output_index(this_ptr: &FundingCreated) -> u16 {
910 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_output_index;
913 /// The specific output index funding this channel
915 pub extern "C" fn FundingCreated_set_funding_output_index(this_ptr: &mut FundingCreated, mut val: u16) {
916 unsafe { &mut *this_ptr.inner }.funding_output_index = val;
918 /// The signature of the channel initiator (funder) on the funding transaction
920 pub extern "C" fn FundingCreated_get_signature(this_ptr: &FundingCreated) -> crate::c_types::Signature {
921 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
922 crate::c_types::Signature::from_rust(&(*inner_val))
924 /// The signature of the channel initiator (funder) on the funding transaction
926 pub extern "C" fn FundingCreated_set_signature(this_ptr: &mut FundingCreated, mut val: crate::c_types::Signature) {
927 unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
931 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 {
932 FundingCreated { inner: Box::into_raw(Box::new(nativeFundingCreated {
933 temporary_channel_id: temporary_channel_id_arg.data,
934 funding_txid: ::bitcoin::hash_types::Txid::from_slice(&funding_txid_arg.data[..]).unwrap(),
935 funding_output_index: funding_output_index_arg,
936 signature: signature_arg.into_rust(),
937 })), is_owned: true }
940 use lightning::ln::msgs::FundingSigned as nativeFundingSignedImport;
941 type nativeFundingSigned = nativeFundingSignedImport;
943 /// A funding_signed message to be sent or received from a peer
946 pub struct FundingSigned {
947 /// Nearly everywhere, inner must be non-null, however in places where
948 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
949 pub inner: *mut nativeFundingSigned,
953 impl Drop for FundingSigned {
955 if self.is_owned && !self.inner.is_null() {
956 let _ = unsafe { Box::from_raw(self.inner) };
961 pub extern "C" fn FundingSigned_free(this_ptr: FundingSigned) { }
963 /// Used only if an object of this type is returned as a trait impl by a method
964 extern "C" fn FundingSigned_free_void(this_ptr: *mut c_void) {
965 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingSigned); }
968 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
970 pub(crate) fn take_inner(mut self) -> *mut nativeFundingSigned {
971 assert!(self.is_owned);
972 let ret = self.inner;
973 self.inner = std::ptr::null_mut();
977 impl Clone for FundingSigned {
978 fn clone(&self) -> Self {
980 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
986 /// Used only if an object of this type is returned as a trait impl by a method
987 pub(crate) extern "C" fn FundingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
988 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingSigned)).clone() })) as *mut c_void
991 pub extern "C" fn FundingSigned_clone(orig: &FundingSigned) -> FundingSigned {
992 FundingSigned { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
996 pub extern "C" fn FundingSigned_get_channel_id(this_ptr: &FundingSigned) -> *const [u8; 32] {
997 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1002 pub extern "C" fn FundingSigned_set_channel_id(this_ptr: &mut FundingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
1003 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1005 /// The signature of the channel acceptor (fundee) on the funding transaction
1007 pub extern "C" fn FundingSigned_get_signature(this_ptr: &FundingSigned) -> crate::c_types::Signature {
1008 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
1009 crate::c_types::Signature::from_rust(&(*inner_val))
1011 /// The signature of the channel acceptor (fundee) on the funding transaction
1013 pub extern "C" fn FundingSigned_set_signature(this_ptr: &mut FundingSigned, mut val: crate::c_types::Signature) {
1014 unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
1018 pub extern "C" fn FundingSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut signature_arg: crate::c_types::Signature) -> FundingSigned {
1019 FundingSigned { inner: Box::into_raw(Box::new(nativeFundingSigned {
1020 channel_id: channel_id_arg.data,
1021 signature: signature_arg.into_rust(),
1022 })), is_owned: true }
1025 use lightning::ln::msgs::FundingLocked as nativeFundingLockedImport;
1026 type nativeFundingLocked = nativeFundingLockedImport;
1028 /// A funding_locked message to be sent or received from a peer
1031 pub struct FundingLocked {
1032 /// Nearly everywhere, inner must be non-null, however in places where
1033 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1034 pub inner: *mut nativeFundingLocked,
1038 impl Drop for FundingLocked {
1039 fn drop(&mut self) {
1040 if self.is_owned && !self.inner.is_null() {
1041 let _ = unsafe { Box::from_raw(self.inner) };
1046 pub extern "C" fn FundingLocked_free(this_ptr: FundingLocked) { }
1048 /// Used only if an object of this type is returned as a trait impl by a method
1049 extern "C" fn FundingLocked_free_void(this_ptr: *mut c_void) {
1050 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingLocked); }
1053 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1054 impl FundingLocked {
1055 pub(crate) fn take_inner(mut self) -> *mut nativeFundingLocked {
1056 assert!(self.is_owned);
1057 let ret = self.inner;
1058 self.inner = std::ptr::null_mut();
1062 impl Clone for FundingLocked {
1063 fn clone(&self) -> Self {
1065 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
1071 /// Used only if an object of this type is returned as a trait impl by a method
1072 pub(crate) extern "C" fn FundingLocked_clone_void(this_ptr: *const c_void) -> *mut c_void {
1073 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFundingLocked)).clone() })) as *mut c_void
1076 pub extern "C" fn FundingLocked_clone(orig: &FundingLocked) -> FundingLocked {
1077 FundingLocked { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
1081 pub extern "C" fn FundingLocked_get_channel_id(this_ptr: &FundingLocked) -> *const [u8; 32] {
1082 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1087 pub extern "C" fn FundingLocked_set_channel_id(this_ptr: &mut FundingLocked, mut val: crate::c_types::ThirtyTwoBytes) {
1088 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1090 /// The per-commitment point of the second commitment transaction
1092 pub extern "C" fn FundingLocked_get_next_per_commitment_point(this_ptr: &FundingLocked) -> crate::c_types::PublicKey {
1093 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.next_per_commitment_point;
1094 crate::c_types::PublicKey::from_rust(&(*inner_val))
1096 /// The per-commitment point of the second commitment transaction
1098 pub extern "C" fn FundingLocked_set_next_per_commitment_point(this_ptr: &mut FundingLocked, mut val: crate::c_types::PublicKey) {
1099 unsafe { &mut *this_ptr.inner }.next_per_commitment_point = val.into_rust();
1103 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 {
1104 FundingLocked { inner: Box::into_raw(Box::new(nativeFundingLocked {
1105 channel_id: channel_id_arg.data,
1106 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
1107 })), is_owned: true }
1110 use lightning::ln::msgs::Shutdown as nativeShutdownImport;
1111 type nativeShutdown = nativeShutdownImport;
1113 /// A shutdown message to be sent or received from a peer
1116 pub struct Shutdown {
1117 /// Nearly everywhere, inner must be non-null, however in places where
1118 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1119 pub inner: *mut nativeShutdown,
1123 impl Drop for Shutdown {
1124 fn drop(&mut self) {
1125 if self.is_owned && !self.inner.is_null() {
1126 let _ = unsafe { Box::from_raw(self.inner) };
1131 pub extern "C" fn Shutdown_free(this_ptr: Shutdown) { }
1133 /// Used only if an object of this type is returned as a trait impl by a method
1134 extern "C" fn Shutdown_free_void(this_ptr: *mut c_void) {
1135 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeShutdown); }
1138 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1140 pub(crate) fn take_inner(mut self) -> *mut nativeShutdown {
1141 assert!(self.is_owned);
1142 let ret = self.inner;
1143 self.inner = std::ptr::null_mut();
1147 impl Clone for Shutdown {
1148 fn clone(&self) -> Self {
1150 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
1156 /// Used only if an object of this type is returned as a trait impl by a method
1157 pub(crate) extern "C" fn Shutdown_clone_void(this_ptr: *const c_void) -> *mut c_void {
1158 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeShutdown)).clone() })) as *mut c_void
1161 pub extern "C" fn Shutdown_clone(orig: &Shutdown) -> Shutdown {
1162 Shutdown { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
1166 pub extern "C" fn Shutdown_get_channel_id(this_ptr: &Shutdown) -> *const [u8; 32] {
1167 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1172 pub extern "C" fn Shutdown_set_channel_id(this_ptr: &mut Shutdown, mut val: crate::c_types::ThirtyTwoBytes) {
1173 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1175 /// The destination of this peer's funds on closing.
1176 /// Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
1178 pub extern "C" fn Shutdown_get_scriptpubkey(this_ptr: &Shutdown) -> crate::c_types::u8slice {
1179 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.scriptpubkey;
1180 crate::c_types::u8slice::from_slice(&(*inner_val)[..])
1182 /// The destination of this peer's funds on closing.
1183 /// Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
1185 pub extern "C" fn Shutdown_set_scriptpubkey(this_ptr: &mut Shutdown, mut val: crate::c_types::derived::CVec_u8Z) {
1186 unsafe { &mut *this_ptr.inner }.scriptpubkey = ::bitcoin::blockdata::script::Script::from(val.into_rust());
1190 pub extern "C" fn Shutdown_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut scriptpubkey_arg: crate::c_types::derived::CVec_u8Z) -> Shutdown {
1191 Shutdown { inner: Box::into_raw(Box::new(nativeShutdown {
1192 channel_id: channel_id_arg.data,
1193 scriptpubkey: ::bitcoin::blockdata::script::Script::from(scriptpubkey_arg.into_rust()),
1194 })), is_owned: true }
1197 use lightning::ln::msgs::ClosingSigned as nativeClosingSignedImport;
1198 type nativeClosingSigned = nativeClosingSignedImport;
1200 /// A closing_signed message to be sent or received from a peer
1203 pub struct ClosingSigned {
1204 /// Nearly everywhere, inner must be non-null, however in places where
1205 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1206 pub inner: *mut nativeClosingSigned,
1210 impl Drop for ClosingSigned {
1211 fn drop(&mut self) {
1212 if self.is_owned && !self.inner.is_null() {
1213 let _ = unsafe { Box::from_raw(self.inner) };
1218 pub extern "C" fn ClosingSigned_free(this_ptr: ClosingSigned) { }
1220 /// Used only if an object of this type is returned as a trait impl by a method
1221 extern "C" fn ClosingSigned_free_void(this_ptr: *mut c_void) {
1222 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeClosingSigned); }
1225 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1226 impl ClosingSigned {
1227 pub(crate) fn take_inner(mut self) -> *mut nativeClosingSigned {
1228 assert!(self.is_owned);
1229 let ret = self.inner;
1230 self.inner = std::ptr::null_mut();
1234 impl Clone for ClosingSigned {
1235 fn clone(&self) -> Self {
1237 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
1243 /// Used only if an object of this type is returned as a trait impl by a method
1244 pub(crate) extern "C" fn ClosingSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
1245 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClosingSigned)).clone() })) as *mut c_void
1248 pub extern "C" fn ClosingSigned_clone(orig: &ClosingSigned) -> ClosingSigned {
1249 ClosingSigned { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
1253 pub extern "C" fn ClosingSigned_get_channel_id(this_ptr: &ClosingSigned) -> *const [u8; 32] {
1254 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1259 pub extern "C" fn ClosingSigned_set_channel_id(this_ptr: &mut ClosingSigned, mut val: crate::c_types::ThirtyTwoBytes) {
1260 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1262 /// The proposed total fee for the closing transaction
1264 pub extern "C" fn ClosingSigned_get_fee_satoshis(this_ptr: &ClosingSigned) -> u64 {
1265 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_satoshis;
1268 /// The proposed total fee for the closing transaction
1270 pub extern "C" fn ClosingSigned_set_fee_satoshis(this_ptr: &mut ClosingSigned, mut val: u64) {
1271 unsafe { &mut *this_ptr.inner }.fee_satoshis = val;
1273 /// A signature on the closing transaction
1275 pub extern "C" fn ClosingSigned_get_signature(this_ptr: &ClosingSigned) -> crate::c_types::Signature {
1276 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
1277 crate::c_types::Signature::from_rust(&(*inner_val))
1279 /// A signature on the closing transaction
1281 pub extern "C" fn ClosingSigned_set_signature(this_ptr: &mut ClosingSigned, mut val: crate::c_types::Signature) {
1282 unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
1286 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 {
1287 ClosingSigned { inner: Box::into_raw(Box::new(nativeClosingSigned {
1288 channel_id: channel_id_arg.data,
1289 fee_satoshis: fee_satoshis_arg,
1290 signature: signature_arg.into_rust(),
1291 })), is_owned: true }
1294 use lightning::ln::msgs::UpdateAddHTLC as nativeUpdateAddHTLCImport;
1295 type nativeUpdateAddHTLC = nativeUpdateAddHTLCImport;
1297 /// An update_add_htlc message to be sent or received from a peer
1300 pub struct UpdateAddHTLC {
1301 /// Nearly everywhere, inner must be non-null, however in places where
1302 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1303 pub inner: *mut nativeUpdateAddHTLC,
1307 impl Drop for UpdateAddHTLC {
1308 fn drop(&mut self) {
1309 if self.is_owned && !self.inner.is_null() {
1310 let _ = unsafe { Box::from_raw(self.inner) };
1315 pub extern "C" fn UpdateAddHTLC_free(this_ptr: UpdateAddHTLC) { }
1317 /// Used only if an object of this type is returned as a trait impl by a method
1318 extern "C" fn UpdateAddHTLC_free_void(this_ptr: *mut c_void) {
1319 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateAddHTLC); }
1322 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1323 impl UpdateAddHTLC {
1324 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateAddHTLC {
1325 assert!(self.is_owned);
1326 let ret = self.inner;
1327 self.inner = std::ptr::null_mut();
1331 impl Clone for UpdateAddHTLC {
1332 fn clone(&self) -> Self {
1334 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
1340 /// Used only if an object of this type is returned as a trait impl by a method
1341 pub(crate) extern "C" fn UpdateAddHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1342 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateAddHTLC)).clone() })) as *mut c_void
1345 pub extern "C" fn UpdateAddHTLC_clone(orig: &UpdateAddHTLC) -> UpdateAddHTLC {
1346 UpdateAddHTLC { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
1350 pub extern "C" fn UpdateAddHTLC_get_channel_id(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
1351 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1356 pub extern "C" fn UpdateAddHTLC_set_channel_id(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1357 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1361 pub extern "C" fn UpdateAddHTLC_get_htlc_id(this_ptr: &UpdateAddHTLC) -> u64 {
1362 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_id;
1367 pub extern "C" fn UpdateAddHTLC_set_htlc_id(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
1368 unsafe { &mut *this_ptr.inner }.htlc_id = val;
1370 /// The HTLC value in milli-satoshi
1372 pub extern "C" fn UpdateAddHTLC_get_amount_msat(this_ptr: &UpdateAddHTLC) -> u64 {
1373 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.amount_msat;
1376 /// The HTLC value in milli-satoshi
1378 pub extern "C" fn UpdateAddHTLC_set_amount_msat(this_ptr: &mut UpdateAddHTLC, mut val: u64) {
1379 unsafe { &mut *this_ptr.inner }.amount_msat = val;
1381 /// The payment hash, the pre-image of which controls HTLC redemption
1383 pub extern "C" fn UpdateAddHTLC_get_payment_hash(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] {
1384 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_hash;
1387 /// The payment hash, the pre-image of which controls HTLC redemption
1389 pub extern "C" fn UpdateAddHTLC_set_payment_hash(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1390 unsafe { &mut *this_ptr.inner }.payment_hash = ::lightning::ln::channelmanager::PaymentHash(val.data);
1392 /// The expiry height of the HTLC
1394 pub extern "C" fn UpdateAddHTLC_get_cltv_expiry(this_ptr: &UpdateAddHTLC) -> u32 {
1395 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry;
1398 /// The expiry height of the HTLC
1400 pub extern "C" fn UpdateAddHTLC_set_cltv_expiry(this_ptr: &mut UpdateAddHTLC, mut val: u32) {
1401 unsafe { &mut *this_ptr.inner }.cltv_expiry = val;
1404 use lightning::ln::msgs::UpdateFulfillHTLC as nativeUpdateFulfillHTLCImport;
1405 type nativeUpdateFulfillHTLC = nativeUpdateFulfillHTLCImport;
1407 /// An update_fulfill_htlc message to be sent or received from a peer
1410 pub struct UpdateFulfillHTLC {
1411 /// Nearly everywhere, inner must be non-null, however in places where
1412 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1413 pub inner: *mut nativeUpdateFulfillHTLC,
1417 impl Drop for UpdateFulfillHTLC {
1418 fn drop(&mut self) {
1419 if self.is_owned && !self.inner.is_null() {
1420 let _ = unsafe { Box::from_raw(self.inner) };
1425 pub extern "C" fn UpdateFulfillHTLC_free(this_ptr: UpdateFulfillHTLC) { }
1427 /// Used only if an object of this type is returned as a trait impl by a method
1428 extern "C" fn UpdateFulfillHTLC_free_void(this_ptr: *mut c_void) {
1429 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFulfillHTLC); }
1432 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1433 impl UpdateFulfillHTLC {
1434 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFulfillHTLC {
1435 assert!(self.is_owned);
1436 let ret = self.inner;
1437 self.inner = std::ptr::null_mut();
1441 impl Clone for UpdateFulfillHTLC {
1442 fn clone(&self) -> Self {
1444 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
1450 /// Used only if an object of this type is returned as a trait impl by a method
1451 pub(crate) extern "C" fn UpdateFulfillHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1452 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFulfillHTLC)).clone() })) as *mut c_void
1455 pub extern "C" fn UpdateFulfillHTLC_clone(orig: &UpdateFulfillHTLC) -> UpdateFulfillHTLC {
1456 UpdateFulfillHTLC { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
1460 pub extern "C" fn UpdateFulfillHTLC_get_channel_id(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
1461 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1466 pub extern "C" fn UpdateFulfillHTLC_set_channel_id(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1467 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1471 pub extern "C" fn UpdateFulfillHTLC_get_htlc_id(this_ptr: &UpdateFulfillHTLC) -> u64 {
1472 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_id;
1477 pub extern "C" fn UpdateFulfillHTLC_set_htlc_id(this_ptr: &mut UpdateFulfillHTLC, mut val: u64) {
1478 unsafe { &mut *this_ptr.inner }.htlc_id = val;
1480 /// The pre-image of the payment hash, allowing HTLC redemption
1482 pub extern "C" fn UpdateFulfillHTLC_get_payment_preimage(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] {
1483 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_preimage;
1486 /// The pre-image of the payment hash, allowing HTLC redemption
1488 pub extern "C" fn UpdateFulfillHTLC_set_payment_preimage(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1489 unsafe { &mut *this_ptr.inner }.payment_preimage = ::lightning::ln::channelmanager::PaymentPreimage(val.data);
1493 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 {
1494 UpdateFulfillHTLC { inner: Box::into_raw(Box::new(nativeUpdateFulfillHTLC {
1495 channel_id: channel_id_arg.data,
1496 htlc_id: htlc_id_arg,
1497 payment_preimage: ::lightning::ln::channelmanager::PaymentPreimage(payment_preimage_arg.data),
1498 })), is_owned: true }
1501 use lightning::ln::msgs::UpdateFailHTLC as nativeUpdateFailHTLCImport;
1502 type nativeUpdateFailHTLC = nativeUpdateFailHTLCImport;
1504 /// An update_fail_htlc message to be sent or received from a peer
1507 pub struct UpdateFailHTLC {
1508 /// Nearly everywhere, inner must be non-null, however in places where
1509 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1510 pub inner: *mut nativeUpdateFailHTLC,
1514 impl Drop for UpdateFailHTLC {
1515 fn drop(&mut self) {
1516 if self.is_owned && !self.inner.is_null() {
1517 let _ = unsafe { Box::from_raw(self.inner) };
1522 pub extern "C" fn UpdateFailHTLC_free(this_ptr: UpdateFailHTLC) { }
1524 /// Used only if an object of this type is returned as a trait impl by a method
1525 extern "C" fn UpdateFailHTLC_free_void(this_ptr: *mut c_void) {
1526 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFailHTLC); }
1529 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1530 impl UpdateFailHTLC {
1531 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailHTLC {
1532 assert!(self.is_owned);
1533 let ret = self.inner;
1534 self.inner = std::ptr::null_mut();
1538 impl Clone for UpdateFailHTLC {
1539 fn clone(&self) -> Self {
1541 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
1547 /// Used only if an object of this type is returned as a trait impl by a method
1548 pub(crate) extern "C" fn UpdateFailHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1549 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailHTLC)).clone() })) as *mut c_void
1552 pub extern "C" fn UpdateFailHTLC_clone(orig: &UpdateFailHTLC) -> UpdateFailHTLC {
1553 UpdateFailHTLC { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
1557 pub extern "C" fn UpdateFailHTLC_get_channel_id(this_ptr: &UpdateFailHTLC) -> *const [u8; 32] {
1558 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1563 pub extern "C" fn UpdateFailHTLC_set_channel_id(this_ptr: &mut UpdateFailHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1564 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1568 pub extern "C" fn UpdateFailHTLC_get_htlc_id(this_ptr: &UpdateFailHTLC) -> u64 {
1569 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_id;
1574 pub extern "C" fn UpdateFailHTLC_set_htlc_id(this_ptr: &mut UpdateFailHTLC, mut val: u64) {
1575 unsafe { &mut *this_ptr.inner }.htlc_id = val;
1578 use lightning::ln::msgs::UpdateFailMalformedHTLC as nativeUpdateFailMalformedHTLCImport;
1579 type nativeUpdateFailMalformedHTLC = nativeUpdateFailMalformedHTLCImport;
1581 /// An update_fail_malformed_htlc message to be sent or received from a peer
1584 pub struct UpdateFailMalformedHTLC {
1585 /// Nearly everywhere, inner must be non-null, however in places where
1586 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1587 pub inner: *mut nativeUpdateFailMalformedHTLC,
1591 impl Drop for UpdateFailMalformedHTLC {
1592 fn drop(&mut self) {
1593 if self.is_owned && !self.inner.is_null() {
1594 let _ = unsafe { Box::from_raw(self.inner) };
1599 pub extern "C" fn UpdateFailMalformedHTLC_free(this_ptr: UpdateFailMalformedHTLC) { }
1601 /// Used only if an object of this type is returned as a trait impl by a method
1602 extern "C" fn UpdateFailMalformedHTLC_free_void(this_ptr: *mut c_void) {
1603 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFailMalformedHTLC); }
1606 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1607 impl UpdateFailMalformedHTLC {
1608 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailMalformedHTLC {
1609 assert!(self.is_owned);
1610 let ret = self.inner;
1611 self.inner = std::ptr::null_mut();
1615 impl Clone for UpdateFailMalformedHTLC {
1616 fn clone(&self) -> Self {
1618 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
1624 /// Used only if an object of this type is returned as a trait impl by a method
1625 pub(crate) extern "C" fn UpdateFailMalformedHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
1626 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFailMalformedHTLC)).clone() })) as *mut c_void
1629 pub extern "C" fn UpdateFailMalformedHTLC_clone(orig: &UpdateFailMalformedHTLC) -> UpdateFailMalformedHTLC {
1630 UpdateFailMalformedHTLC { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
1634 pub extern "C" fn UpdateFailMalformedHTLC_get_channel_id(this_ptr: &UpdateFailMalformedHTLC) -> *const [u8; 32] {
1635 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1640 pub extern "C" fn UpdateFailMalformedHTLC_set_channel_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
1641 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1645 pub extern "C" fn UpdateFailMalformedHTLC_get_htlc_id(this_ptr: &UpdateFailMalformedHTLC) -> u64 {
1646 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_id;
1651 pub extern "C" fn UpdateFailMalformedHTLC_set_htlc_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u64) {
1652 unsafe { &mut *this_ptr.inner }.htlc_id = val;
1654 /// The failure code
1656 pub extern "C" fn UpdateFailMalformedHTLC_get_failure_code(this_ptr: &UpdateFailMalformedHTLC) -> u16 {
1657 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.failure_code;
1660 /// The failure code
1662 pub extern "C" fn UpdateFailMalformedHTLC_set_failure_code(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u16) {
1663 unsafe { &mut *this_ptr.inner }.failure_code = val;
1666 use lightning::ln::msgs::CommitmentSigned as nativeCommitmentSignedImport;
1667 type nativeCommitmentSigned = nativeCommitmentSignedImport;
1669 /// A commitment_signed message to be sent or received from a peer
1672 pub struct CommitmentSigned {
1673 /// Nearly everywhere, inner must be non-null, however in places where
1674 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1675 pub inner: *mut nativeCommitmentSigned,
1679 impl Drop for CommitmentSigned {
1680 fn drop(&mut self) {
1681 if self.is_owned && !self.inner.is_null() {
1682 let _ = unsafe { Box::from_raw(self.inner) };
1687 pub extern "C" fn CommitmentSigned_free(this_ptr: CommitmentSigned) { }
1689 /// Used only if an object of this type is returned as a trait impl by a method
1690 extern "C" fn CommitmentSigned_free_void(this_ptr: *mut c_void) {
1691 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentSigned); }
1694 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1695 impl CommitmentSigned {
1696 pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentSigned {
1697 assert!(self.is_owned);
1698 let ret = self.inner;
1699 self.inner = std::ptr::null_mut();
1703 impl Clone for CommitmentSigned {
1704 fn clone(&self) -> Self {
1706 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
1712 /// Used only if an object of this type is returned as a trait impl by a method
1713 pub(crate) extern "C" fn CommitmentSigned_clone_void(this_ptr: *const c_void) -> *mut c_void {
1714 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentSigned)).clone() })) as *mut c_void
1717 pub extern "C" fn CommitmentSigned_clone(orig: &CommitmentSigned) -> CommitmentSigned {
1718 CommitmentSigned { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
1722 pub extern "C" fn CommitmentSigned_get_channel_id(this_ptr: &CommitmentSigned) -> *const [u8; 32] {
1723 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1728 pub extern "C" fn CommitmentSigned_set_channel_id(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::ThirtyTwoBytes) {
1729 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1731 /// A signature on the commitment transaction
1733 pub extern "C" fn CommitmentSigned_get_signature(this_ptr: &CommitmentSigned) -> crate::c_types::Signature {
1734 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
1735 crate::c_types::Signature::from_rust(&(*inner_val))
1737 /// A signature on the commitment transaction
1739 pub extern "C" fn CommitmentSigned_set_signature(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::Signature) {
1740 unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
1742 /// Signatures on the HTLC transactions
1744 pub extern "C" fn CommitmentSigned_set_htlc_signatures(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::derived::CVec_SignatureZ) {
1745 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_rust() }); };
1746 unsafe { &mut *this_ptr.inner }.htlc_signatures = local_val;
1750 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 {
1751 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() }); };
1752 CommitmentSigned { inner: Box::into_raw(Box::new(nativeCommitmentSigned {
1753 channel_id: channel_id_arg.data,
1754 signature: signature_arg.into_rust(),
1755 htlc_signatures: local_htlc_signatures_arg,
1756 })), is_owned: true }
1759 use lightning::ln::msgs::RevokeAndACK as nativeRevokeAndACKImport;
1760 type nativeRevokeAndACK = nativeRevokeAndACKImport;
1762 /// A revoke_and_ack message to be sent or received from a peer
1765 pub struct RevokeAndACK {
1766 /// Nearly everywhere, inner must be non-null, however in places where
1767 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1768 pub inner: *mut nativeRevokeAndACK,
1772 impl Drop for RevokeAndACK {
1773 fn drop(&mut self) {
1774 if self.is_owned && !self.inner.is_null() {
1775 let _ = unsafe { Box::from_raw(self.inner) };
1780 pub extern "C" fn RevokeAndACK_free(this_ptr: RevokeAndACK) { }
1782 /// Used only if an object of this type is returned as a trait impl by a method
1783 extern "C" fn RevokeAndACK_free_void(this_ptr: *mut c_void) {
1784 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRevokeAndACK); }
1787 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1789 pub(crate) fn take_inner(mut self) -> *mut nativeRevokeAndACK {
1790 assert!(self.is_owned);
1791 let ret = self.inner;
1792 self.inner = std::ptr::null_mut();
1796 impl Clone for RevokeAndACK {
1797 fn clone(&self) -> Self {
1799 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
1805 /// Used only if an object of this type is returned as a trait impl by a method
1806 pub(crate) extern "C" fn RevokeAndACK_clone_void(this_ptr: *const c_void) -> *mut c_void {
1807 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRevokeAndACK)).clone() })) as *mut c_void
1810 pub extern "C" fn RevokeAndACK_clone(orig: &RevokeAndACK) -> RevokeAndACK {
1811 RevokeAndACK { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
1815 pub extern "C" fn RevokeAndACK_get_channel_id(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
1816 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1821 pub extern "C" fn RevokeAndACK_set_channel_id(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
1822 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1824 /// The secret corresponding to the per-commitment point
1826 pub extern "C" fn RevokeAndACK_get_per_commitment_secret(this_ptr: &RevokeAndACK) -> *const [u8; 32] {
1827 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.per_commitment_secret;
1830 /// The secret corresponding to the per-commitment point
1832 pub extern "C" fn RevokeAndACK_set_per_commitment_secret(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) {
1833 unsafe { &mut *this_ptr.inner }.per_commitment_secret = val.data;
1835 /// The next sender-broadcast commitment transaction's per-commitment point
1837 pub extern "C" fn RevokeAndACK_get_next_per_commitment_point(this_ptr: &RevokeAndACK) -> crate::c_types::PublicKey {
1838 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.next_per_commitment_point;
1839 crate::c_types::PublicKey::from_rust(&(*inner_val))
1841 /// The next sender-broadcast commitment transaction's per-commitment point
1843 pub extern "C" fn RevokeAndACK_set_next_per_commitment_point(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::PublicKey) {
1844 unsafe { &mut *this_ptr.inner }.next_per_commitment_point = val.into_rust();
1848 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 {
1849 RevokeAndACK { inner: Box::into_raw(Box::new(nativeRevokeAndACK {
1850 channel_id: channel_id_arg.data,
1851 per_commitment_secret: per_commitment_secret_arg.data,
1852 next_per_commitment_point: next_per_commitment_point_arg.into_rust(),
1853 })), is_owned: true }
1856 use lightning::ln::msgs::UpdateFee as nativeUpdateFeeImport;
1857 type nativeUpdateFee = nativeUpdateFeeImport;
1859 /// An update_fee message to be sent or received from a peer
1862 pub struct UpdateFee {
1863 /// Nearly everywhere, inner must be non-null, however in places where
1864 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1865 pub inner: *mut nativeUpdateFee,
1869 impl Drop for UpdateFee {
1870 fn drop(&mut self) {
1871 if self.is_owned && !self.inner.is_null() {
1872 let _ = unsafe { Box::from_raw(self.inner) };
1877 pub extern "C" fn UpdateFee_free(this_ptr: UpdateFee) { }
1879 /// Used only if an object of this type is returned as a trait impl by a method
1880 extern "C" fn UpdateFee_free_void(this_ptr: *mut c_void) {
1881 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFee); }
1884 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1886 pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFee {
1887 assert!(self.is_owned);
1888 let ret = self.inner;
1889 self.inner = std::ptr::null_mut();
1893 impl Clone for UpdateFee {
1894 fn clone(&self) -> Self {
1896 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
1902 /// Used only if an object of this type is returned as a trait impl by a method
1903 pub(crate) extern "C" fn UpdateFee_clone_void(this_ptr: *const c_void) -> *mut c_void {
1904 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUpdateFee)).clone() })) as *mut c_void
1907 pub extern "C" fn UpdateFee_clone(orig: &UpdateFee) -> UpdateFee {
1908 UpdateFee { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
1912 pub extern "C" fn UpdateFee_get_channel_id(this_ptr: &UpdateFee) -> *const [u8; 32] {
1913 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
1918 pub extern "C" fn UpdateFee_set_channel_id(this_ptr: &mut UpdateFee, mut val: crate::c_types::ThirtyTwoBytes) {
1919 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
1921 /// Fee rate per 1000-weight of the transaction
1923 pub extern "C" fn UpdateFee_get_feerate_per_kw(this_ptr: &UpdateFee) -> u32 {
1924 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.feerate_per_kw;
1927 /// Fee rate per 1000-weight of the transaction
1929 pub extern "C" fn UpdateFee_set_feerate_per_kw(this_ptr: &mut UpdateFee, mut val: u32) {
1930 unsafe { &mut *this_ptr.inner }.feerate_per_kw = val;
1934 pub extern "C" fn UpdateFee_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut feerate_per_kw_arg: u32) -> UpdateFee {
1935 UpdateFee { inner: Box::into_raw(Box::new(nativeUpdateFee {
1936 channel_id: channel_id_arg.data,
1937 feerate_per_kw: feerate_per_kw_arg,
1938 })), is_owned: true }
1941 use lightning::ln::msgs::DataLossProtect as nativeDataLossProtectImport;
1942 type nativeDataLossProtect = nativeDataLossProtectImport;
1944 /// Proof that the sender knows the per-commitment secret of the previous commitment transaction.
1945 /// This is used to convince the recipient that the channel is at a certain commitment
1946 /// number even if they lost that data due to a local failure. Of course, the peer may lie
1947 /// and even later commitments may have been revoked.
1950 pub struct DataLossProtect {
1951 /// Nearly everywhere, inner must be non-null, however in places where
1952 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1953 pub inner: *mut nativeDataLossProtect,
1957 impl Drop for DataLossProtect {
1958 fn drop(&mut self) {
1959 if self.is_owned && !self.inner.is_null() {
1960 let _ = unsafe { Box::from_raw(self.inner) };
1965 pub extern "C" fn DataLossProtect_free(this_ptr: DataLossProtect) { }
1967 /// Used only if an object of this type is returned as a trait impl by a method
1968 extern "C" fn DataLossProtect_free_void(this_ptr: *mut c_void) {
1969 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDataLossProtect); }
1972 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1973 impl DataLossProtect {
1974 pub(crate) fn take_inner(mut self) -> *mut nativeDataLossProtect {
1975 assert!(self.is_owned);
1976 let ret = self.inner;
1977 self.inner = std::ptr::null_mut();
1981 impl Clone for DataLossProtect {
1982 fn clone(&self) -> Self {
1984 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
1990 /// Used only if an object of this type is returned as a trait impl by a method
1991 pub(crate) extern "C" fn DataLossProtect_clone_void(this_ptr: *const c_void) -> *mut c_void {
1992 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDataLossProtect)).clone() })) as *mut c_void
1995 pub extern "C" fn DataLossProtect_clone(orig: &DataLossProtect) -> DataLossProtect {
1996 DataLossProtect { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
1998 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
1999 /// belonging to the recipient
2001 pub extern "C" fn DataLossProtect_get_your_last_per_commitment_secret(this_ptr: &DataLossProtect) -> *const [u8; 32] {
2002 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.your_last_per_commitment_secret;
2005 /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
2006 /// belonging to the recipient
2008 pub extern "C" fn DataLossProtect_set_your_last_per_commitment_secret(this_ptr: &mut DataLossProtect, mut val: crate::c_types::ThirtyTwoBytes) {
2009 unsafe { &mut *this_ptr.inner }.your_last_per_commitment_secret = val.data;
2011 /// The sender's per-commitment point for their current commitment transaction
2013 pub extern "C" fn DataLossProtect_get_my_current_per_commitment_point(this_ptr: &DataLossProtect) -> crate::c_types::PublicKey {
2014 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.my_current_per_commitment_point;
2015 crate::c_types::PublicKey::from_rust(&(*inner_val))
2017 /// The sender's per-commitment point for their current commitment transaction
2019 pub extern "C" fn DataLossProtect_set_my_current_per_commitment_point(this_ptr: &mut DataLossProtect, mut val: crate::c_types::PublicKey) {
2020 unsafe { &mut *this_ptr.inner }.my_current_per_commitment_point = val.into_rust();
2024 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 {
2025 DataLossProtect { inner: Box::into_raw(Box::new(nativeDataLossProtect {
2026 your_last_per_commitment_secret: your_last_per_commitment_secret_arg.data,
2027 my_current_per_commitment_point: my_current_per_commitment_point_arg.into_rust(),
2028 })), is_owned: true }
2031 use lightning::ln::msgs::ChannelReestablish as nativeChannelReestablishImport;
2032 type nativeChannelReestablish = nativeChannelReestablishImport;
2034 /// A channel_reestablish message to be sent or received from a peer
2037 pub struct ChannelReestablish {
2038 /// Nearly everywhere, inner must be non-null, however in places where
2039 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2040 pub inner: *mut nativeChannelReestablish,
2044 impl Drop for ChannelReestablish {
2045 fn drop(&mut self) {
2046 if self.is_owned && !self.inner.is_null() {
2047 let _ = unsafe { Box::from_raw(self.inner) };
2052 pub extern "C" fn ChannelReestablish_free(this_ptr: ChannelReestablish) { }
2054 /// Used only if an object of this type is returned as a trait impl by a method
2055 extern "C" fn ChannelReestablish_free_void(this_ptr: *mut c_void) {
2056 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelReestablish); }
2059 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2060 impl ChannelReestablish {
2061 pub(crate) fn take_inner(mut self) -> *mut nativeChannelReestablish {
2062 assert!(self.is_owned);
2063 let ret = self.inner;
2064 self.inner = std::ptr::null_mut();
2068 impl Clone for ChannelReestablish {
2069 fn clone(&self) -> Self {
2071 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
2077 /// Used only if an object of this type is returned as a trait impl by a method
2078 pub(crate) extern "C" fn ChannelReestablish_clone_void(this_ptr: *const c_void) -> *mut c_void {
2079 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelReestablish)).clone() })) as *mut c_void
2082 pub extern "C" fn ChannelReestablish_clone(orig: &ChannelReestablish) -> ChannelReestablish {
2083 ChannelReestablish { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
2087 pub extern "C" fn ChannelReestablish_get_channel_id(this_ptr: &ChannelReestablish) -> *const [u8; 32] {
2088 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
2093 pub extern "C" fn ChannelReestablish_set_channel_id(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) {
2094 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
2096 /// The next commitment number for the sender
2098 pub extern "C" fn ChannelReestablish_get_next_local_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
2099 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.next_local_commitment_number;
2102 /// The next commitment number for the sender
2104 pub extern "C" fn ChannelReestablish_set_next_local_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
2105 unsafe { &mut *this_ptr.inner }.next_local_commitment_number = val;
2107 /// The next commitment number for the recipient
2109 pub extern "C" fn ChannelReestablish_get_next_remote_commitment_number(this_ptr: &ChannelReestablish) -> u64 {
2110 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.next_remote_commitment_number;
2113 /// The next commitment number for the recipient
2115 pub extern "C" fn ChannelReestablish_set_next_remote_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) {
2116 unsafe { &mut *this_ptr.inner }.next_remote_commitment_number = val;
2119 use lightning::ln::msgs::AnnouncementSignatures as nativeAnnouncementSignaturesImport;
2120 type nativeAnnouncementSignatures = nativeAnnouncementSignaturesImport;
2122 /// An announcement_signatures message to be sent or received from a peer
2125 pub struct AnnouncementSignatures {
2126 /// Nearly everywhere, inner must be non-null, however in places where
2127 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2128 pub inner: *mut nativeAnnouncementSignatures,
2132 impl Drop for AnnouncementSignatures {
2133 fn drop(&mut self) {
2134 if self.is_owned && !self.inner.is_null() {
2135 let _ = unsafe { Box::from_raw(self.inner) };
2140 pub extern "C" fn AnnouncementSignatures_free(this_ptr: AnnouncementSignatures) { }
2142 /// Used only if an object of this type is returned as a trait impl by a method
2143 extern "C" fn AnnouncementSignatures_free_void(this_ptr: *mut c_void) {
2144 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeAnnouncementSignatures); }
2147 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2148 impl AnnouncementSignatures {
2149 pub(crate) fn take_inner(mut self) -> *mut nativeAnnouncementSignatures {
2150 assert!(self.is_owned);
2151 let ret = self.inner;
2152 self.inner = std::ptr::null_mut();
2156 impl Clone for AnnouncementSignatures {
2157 fn clone(&self) -> Self {
2159 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
2165 /// Used only if an object of this type is returned as a trait impl by a method
2166 pub(crate) extern "C" fn AnnouncementSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void {
2167 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAnnouncementSignatures)).clone() })) as *mut c_void
2170 pub extern "C" fn AnnouncementSignatures_clone(orig: &AnnouncementSignatures) -> AnnouncementSignatures {
2171 AnnouncementSignatures { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
2175 pub extern "C" fn AnnouncementSignatures_get_channel_id(this_ptr: &AnnouncementSignatures) -> *const [u8; 32] {
2176 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
2181 pub extern "C" fn AnnouncementSignatures_set_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ThirtyTwoBytes) {
2182 unsafe { &mut *this_ptr.inner }.channel_id = val.data;
2184 /// The short channel ID
2186 pub extern "C" fn AnnouncementSignatures_get_short_channel_id(this_ptr: &AnnouncementSignatures) -> u64 {
2187 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id;
2190 /// The short channel ID
2192 pub extern "C" fn AnnouncementSignatures_set_short_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: u64) {
2193 unsafe { &mut *this_ptr.inner }.short_channel_id = val;
2195 /// A signature by the node key
2197 pub extern "C" fn AnnouncementSignatures_get_node_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
2198 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_signature;
2199 crate::c_types::Signature::from_rust(&(*inner_val))
2201 /// A signature by the node key
2203 pub extern "C" fn AnnouncementSignatures_set_node_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
2204 unsafe { &mut *this_ptr.inner }.node_signature = val.into_rust();
2206 /// A signature by the funding key
2208 pub extern "C" fn AnnouncementSignatures_get_bitcoin_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature {
2209 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_signature;
2210 crate::c_types::Signature::from_rust(&(*inner_val))
2212 /// A signature by the funding key
2214 pub extern "C" fn AnnouncementSignatures_set_bitcoin_signature(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::Signature) {
2215 unsafe { &mut *this_ptr.inner }.bitcoin_signature = val.into_rust();
2219 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 {
2220 AnnouncementSignatures { inner: Box::into_raw(Box::new(nativeAnnouncementSignatures {
2221 channel_id: channel_id_arg.data,
2222 short_channel_id: short_channel_id_arg,
2223 node_signature: node_signature_arg.into_rust(),
2224 bitcoin_signature: bitcoin_signature_arg.into_rust(),
2225 })), is_owned: true }
2227 /// An address which can be used to connect to a remote peer
2231 pub enum NetAddress {
2232 /// An IPv4 address/port on which the peer is listening.
2234 addr: crate::c_types::FourBytes,
2237 /// An IPv6 address/port on which the peer is listening.
2239 addr: crate::c_types::SixteenBytes,
2242 /// An old-style Tor onion address/port on which the peer is listening.
2244 addr: crate::c_types::TenBytes,
2247 /// A new-style Tor onion address/port on which the peer is listening.
2248 /// To create the human-readable \"hostname\", concatenate ed25519_pubkey, checksum, and version,
2249 /// wrap as base32 and append \".onion\".
2251 ed25519_pubkey: crate::c_types::ThirtyTwoBytes,
2257 use lightning::ln::msgs::NetAddress as nativeNetAddress;
2260 pub(crate) fn to_native(&self) -> nativeNetAddress {
2262 NetAddress::IPv4 {ref addr, ref port, } => {
2263 let mut addr_nonref = (*addr).clone();
2264 let mut port_nonref = (*port).clone();
2265 nativeNetAddress::IPv4 {
2266 addr: addr_nonref.data,
2270 NetAddress::IPv6 {ref addr, ref port, } => {
2271 let mut addr_nonref = (*addr).clone();
2272 let mut port_nonref = (*port).clone();
2273 nativeNetAddress::IPv6 {
2274 addr: addr_nonref.data,
2278 NetAddress::OnionV2 {ref addr, ref port, } => {
2279 let mut addr_nonref = (*addr).clone();
2280 let mut port_nonref = (*port).clone();
2281 nativeNetAddress::OnionV2 {
2282 addr: addr_nonref.data,
2286 NetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
2287 let mut ed25519_pubkey_nonref = (*ed25519_pubkey).clone();
2288 let mut checksum_nonref = (*checksum).clone();
2289 let mut version_nonref = (*version).clone();
2290 let mut port_nonref = (*port).clone();
2291 nativeNetAddress::OnionV3 {
2292 ed25519_pubkey: ed25519_pubkey_nonref.data,
2293 checksum: checksum_nonref,
2294 version: version_nonref,
2301 pub(crate) fn into_native(self) -> nativeNetAddress {
2303 NetAddress::IPv4 {mut addr, mut port, } => {
2304 nativeNetAddress::IPv4 {
2309 NetAddress::IPv6 {mut addr, mut port, } => {
2310 nativeNetAddress::IPv6 {
2315 NetAddress::OnionV2 {mut addr, mut port, } => {
2316 nativeNetAddress::OnionV2 {
2321 NetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
2322 nativeNetAddress::OnionV3 {
2323 ed25519_pubkey: ed25519_pubkey.data,
2332 pub(crate) fn from_native(native: &nativeNetAddress) -> Self {
2334 nativeNetAddress::IPv4 {ref addr, ref port, } => {
2335 let mut addr_nonref = (*addr).clone();
2336 let mut port_nonref = (*port).clone();
2338 addr: crate::c_types::FourBytes { data: addr_nonref },
2342 nativeNetAddress::IPv6 {ref addr, ref port, } => {
2343 let mut addr_nonref = (*addr).clone();
2344 let mut port_nonref = (*port).clone();
2346 addr: crate::c_types::SixteenBytes { data: addr_nonref },
2350 nativeNetAddress::OnionV2 {ref addr, ref port, } => {
2351 let mut addr_nonref = (*addr).clone();
2352 let mut port_nonref = (*port).clone();
2353 NetAddress::OnionV2 {
2354 addr: crate::c_types::TenBytes { data: addr_nonref },
2358 nativeNetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
2359 let mut ed25519_pubkey_nonref = (*ed25519_pubkey).clone();
2360 let mut checksum_nonref = (*checksum).clone();
2361 let mut version_nonref = (*version).clone();
2362 let mut port_nonref = (*port).clone();
2363 NetAddress::OnionV3 {
2364 ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey_nonref },
2365 checksum: checksum_nonref,
2366 version: version_nonref,
2373 pub(crate) fn native_into(native: nativeNetAddress) -> Self {
2375 nativeNetAddress::IPv4 {mut addr, mut port, } => {
2377 addr: crate::c_types::FourBytes { data: addr },
2381 nativeNetAddress::IPv6 {mut addr, mut port, } => {
2383 addr: crate::c_types::SixteenBytes { data: addr },
2387 nativeNetAddress::OnionV2 {mut addr, mut port, } => {
2388 NetAddress::OnionV2 {
2389 addr: crate::c_types::TenBytes { data: addr },
2393 nativeNetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
2394 NetAddress::OnionV3 {
2395 ed25519_pubkey: crate::c_types::ThirtyTwoBytes { data: ed25519_pubkey },
2405 pub extern "C" fn NetAddress_free(this_ptr: NetAddress) { }
2407 pub extern "C" fn NetAddress_clone(orig: &NetAddress) -> NetAddress {
2411 pub extern "C" fn NetAddress_write(obj: &NetAddress) -> crate::c_types::derived::CVec_u8Z {
2412 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
2415 pub extern "C" fn Result_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CResult_NetAddressu8ZDecodeErrorZ {
2416 let res = crate::c_types::deserialize_obj(ser);
2417 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) }), Err(mut e) => crate::c_types::CResultTempl::err( { e }) }; local_res_0 }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) };
2421 use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport;
2422 type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport;
2424 /// The unsigned part of a node_announcement
2427 pub struct UnsignedNodeAnnouncement {
2428 /// Nearly everywhere, inner must be non-null, however in places where
2429 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2430 pub inner: *mut nativeUnsignedNodeAnnouncement,
2434 impl Drop for UnsignedNodeAnnouncement {
2435 fn drop(&mut self) {
2436 if self.is_owned && !self.inner.is_null() {
2437 let _ = unsafe { Box::from_raw(self.inner) };
2442 pub extern "C" fn UnsignedNodeAnnouncement_free(this_ptr: UnsignedNodeAnnouncement) { }
2444 /// Used only if an object of this type is returned as a trait impl by a method
2445 extern "C" fn UnsignedNodeAnnouncement_free_void(this_ptr: *mut c_void) {
2446 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedNodeAnnouncement); }
2449 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2450 impl UnsignedNodeAnnouncement {
2451 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedNodeAnnouncement {
2452 assert!(self.is_owned);
2453 let ret = self.inner;
2454 self.inner = std::ptr::null_mut();
2458 impl Clone for UnsignedNodeAnnouncement {
2459 fn clone(&self) -> Self {
2461 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
2467 /// Used only if an object of this type is returned as a trait impl by a method
2468 pub(crate) extern "C" fn UnsignedNodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
2469 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedNodeAnnouncement)).clone() })) as *mut c_void
2472 pub extern "C" fn UnsignedNodeAnnouncement_clone(orig: &UnsignedNodeAnnouncement) -> UnsignedNodeAnnouncement {
2473 UnsignedNodeAnnouncement { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
2475 /// The advertised features
2477 pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::ln::features::NodeFeatures {
2478 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features;
2479 crate::ln::features::NodeFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
2481 /// The advertised features
2483 pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::ln::features::NodeFeatures) {
2484 unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_inner()) };
2486 /// A strictly monotonic announcement counter, with gaps allowed
2488 pub extern "C" fn UnsignedNodeAnnouncement_get_timestamp(this_ptr: &UnsignedNodeAnnouncement) -> u32 {
2489 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp;
2492 /// A strictly monotonic announcement counter, with gaps allowed
2494 pub extern "C" fn UnsignedNodeAnnouncement_set_timestamp(this_ptr: &mut UnsignedNodeAnnouncement, mut val: u32) {
2495 unsafe { &mut *this_ptr.inner }.timestamp = val;
2497 /// The node_id this announcement originated from (don't rebroadcast the node_announcement back
2500 pub extern "C" fn UnsignedNodeAnnouncement_get_node_id(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::PublicKey {
2501 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_id;
2502 crate::c_types::PublicKey::from_rust(&(*inner_val))
2504 /// The node_id this announcement originated from (don't rebroadcast the node_announcement back
2507 pub extern "C" fn UnsignedNodeAnnouncement_set_node_id(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::PublicKey) {
2508 unsafe { &mut *this_ptr.inner }.node_id = val.into_rust();
2510 /// An RGB color for UI purposes
2512 pub extern "C" fn UnsignedNodeAnnouncement_get_rgb(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 3] {
2513 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.rgb;
2516 /// An RGB color for UI purposes
2518 pub extern "C" fn UnsignedNodeAnnouncement_set_rgb(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThreeBytes) {
2519 unsafe { &mut *this_ptr.inner }.rgb = val.data;
2521 /// An alias, for UI purposes. This should be sanitized before use. There is no guarantee
2524 pub extern "C" fn UnsignedNodeAnnouncement_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 32] {
2525 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.alias;
2528 /// An alias, for UI purposes. This should be sanitized before use. There is no guarantee
2531 pub extern "C" fn UnsignedNodeAnnouncement_set_alias(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
2532 unsafe { &mut *this_ptr.inner }.alias = val.data;
2534 /// List of addresses on which this node is reachable
2536 pub extern "C" fn UnsignedNodeAnnouncement_set_addresses(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_NetAddressZ) {
2537 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
2538 unsafe { &mut *this_ptr.inner }.addresses = local_val;
2541 use lightning::ln::msgs::NodeAnnouncement as nativeNodeAnnouncementImport;
2542 type nativeNodeAnnouncement = nativeNodeAnnouncementImport;
2544 /// A node_announcement message to be sent or received from a peer
2547 pub struct NodeAnnouncement {
2548 /// Nearly everywhere, inner must be non-null, however in places where
2549 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2550 pub inner: *mut nativeNodeAnnouncement,
2554 impl Drop for NodeAnnouncement {
2555 fn drop(&mut self) {
2556 if self.is_owned && !self.inner.is_null() {
2557 let _ = unsafe { Box::from_raw(self.inner) };
2562 pub extern "C" fn NodeAnnouncement_free(this_ptr: NodeAnnouncement) { }
2564 /// Used only if an object of this type is returned as a trait impl by a method
2565 extern "C" fn NodeAnnouncement_free_void(this_ptr: *mut c_void) {
2566 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeAnnouncement); }
2569 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2570 impl NodeAnnouncement {
2571 pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncement {
2572 assert!(self.is_owned);
2573 let ret = self.inner;
2574 self.inner = std::ptr::null_mut();
2578 impl Clone for NodeAnnouncement {
2579 fn clone(&self) -> Self {
2581 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
2587 /// Used only if an object of this type is returned as a trait impl by a method
2588 pub(crate) extern "C" fn NodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
2589 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeAnnouncement)).clone() })) as *mut c_void
2592 pub extern "C" fn NodeAnnouncement_clone(orig: &NodeAnnouncement) -> NodeAnnouncement {
2593 NodeAnnouncement { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
2595 /// The signature by the node key
2597 pub extern "C" fn NodeAnnouncement_get_signature(this_ptr: &NodeAnnouncement) -> crate::c_types::Signature {
2598 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
2599 crate::c_types::Signature::from_rust(&(*inner_val))
2601 /// The signature by the node key
2603 pub extern "C" fn NodeAnnouncement_set_signature(this_ptr: &mut NodeAnnouncement, mut val: crate::c_types::Signature) {
2604 unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
2606 /// The actual content of the announcement
2608 pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> crate::ln::msgs::UnsignedNodeAnnouncement {
2609 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents;
2610 crate::ln::msgs::UnsignedNodeAnnouncement { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
2612 /// The actual content of the announcement
2614 pub extern "C" fn NodeAnnouncement_set_contents(this_ptr: &mut NodeAnnouncement, mut val: crate::ln::msgs::UnsignedNodeAnnouncement) {
2615 unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_inner()) };
2619 pub extern "C" fn NodeAnnouncement_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::ln::msgs::UnsignedNodeAnnouncement) -> NodeAnnouncement {
2620 NodeAnnouncement { inner: Box::into_raw(Box::new(nativeNodeAnnouncement {
2621 signature: signature_arg.into_rust(),
2622 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
2623 })), is_owned: true }
2626 use lightning::ln::msgs::UnsignedChannelAnnouncement as nativeUnsignedChannelAnnouncementImport;
2627 type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport;
2629 /// The unsigned part of a channel_announcement
2632 pub struct UnsignedChannelAnnouncement {
2633 /// Nearly everywhere, inner must be non-null, however in places where
2634 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2635 pub inner: *mut nativeUnsignedChannelAnnouncement,
2639 impl Drop for UnsignedChannelAnnouncement {
2640 fn drop(&mut self) {
2641 if self.is_owned && !self.inner.is_null() {
2642 let _ = unsafe { Box::from_raw(self.inner) };
2647 pub extern "C" fn UnsignedChannelAnnouncement_free(this_ptr: UnsignedChannelAnnouncement) { }
2649 /// Used only if an object of this type is returned as a trait impl by a method
2650 extern "C" fn UnsignedChannelAnnouncement_free_void(this_ptr: *mut c_void) {
2651 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelAnnouncement); }
2654 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2655 impl UnsignedChannelAnnouncement {
2656 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelAnnouncement {
2657 assert!(self.is_owned);
2658 let ret = self.inner;
2659 self.inner = std::ptr::null_mut();
2663 impl Clone for UnsignedChannelAnnouncement {
2664 fn clone(&self) -> Self {
2666 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
2672 /// Used only if an object of this type is returned as a trait impl by a method
2673 pub(crate) extern "C" fn UnsignedChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
2674 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelAnnouncement)).clone() })) as *mut c_void
2677 pub extern "C" fn UnsignedChannelAnnouncement_clone(orig: &UnsignedChannelAnnouncement) -> UnsignedChannelAnnouncement {
2678 UnsignedChannelAnnouncement { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
2680 /// The advertised channel features
2682 pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::ln::features::ChannelFeatures {
2683 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features;
2684 crate::ln::features::ChannelFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
2686 /// The advertised channel features
2688 pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::ln::features::ChannelFeatures) {
2689 unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_inner()) };
2691 /// The genesis hash of the blockchain where the channel is to be opened
2693 pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &UnsignedChannelAnnouncement) -> *const [u8; 32] {
2694 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
2695 (*inner_val).as_inner()
2697 /// The genesis hash of the blockchain where the channel is to be opened
2699 pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
2700 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
2702 /// The short channel ID
2704 pub extern "C" fn UnsignedChannelAnnouncement_get_short_channel_id(this_ptr: &UnsignedChannelAnnouncement) -> u64 {
2705 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id;
2708 /// The short channel ID
2710 pub extern "C" fn UnsignedChannelAnnouncement_set_short_channel_id(this_ptr: &mut UnsignedChannelAnnouncement, mut val: u64) {
2711 unsafe { &mut *this_ptr.inner }.short_channel_id = val;
2713 /// One of the two node_ids which are endpoints of this channel
2715 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
2716 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_id_1;
2717 crate::c_types::PublicKey::from_rust(&(*inner_val))
2719 /// One of the two node_ids which are endpoints of this channel
2721 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
2722 unsafe { &mut *this_ptr.inner }.node_id_1 = val.into_rust();
2724 /// The other of the two node_ids which are endpoints of this channel
2726 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
2727 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_id_2;
2728 crate::c_types::PublicKey::from_rust(&(*inner_val))
2730 /// The other of the two node_ids which are endpoints of this channel
2732 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
2733 unsafe { &mut *this_ptr.inner }.node_id_2 = val.into_rust();
2735 /// The funding key for the first node
2737 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
2738 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_key_1;
2739 crate::c_types::PublicKey::from_rust(&(*inner_val))
2741 /// The funding key for the first node
2743 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
2744 unsafe { &mut *this_ptr.inner }.bitcoin_key_1 = val.into_rust();
2746 /// The funding key for the second node
2748 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
2749 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_key_2;
2750 crate::c_types::PublicKey::from_rust(&(*inner_val))
2752 /// The funding key for the second node
2754 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
2755 unsafe { &mut *this_ptr.inner }.bitcoin_key_2 = val.into_rust();
2758 use lightning::ln::msgs::ChannelAnnouncement as nativeChannelAnnouncementImport;
2759 type nativeChannelAnnouncement = nativeChannelAnnouncementImport;
2761 /// A channel_announcement message to be sent or received from a peer
2764 pub struct ChannelAnnouncement {
2765 /// Nearly everywhere, inner must be non-null, however in places where
2766 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2767 pub inner: *mut nativeChannelAnnouncement,
2771 impl Drop for ChannelAnnouncement {
2772 fn drop(&mut self) {
2773 if self.is_owned && !self.inner.is_null() {
2774 let _ = unsafe { Box::from_raw(self.inner) };
2779 pub extern "C" fn ChannelAnnouncement_free(this_ptr: ChannelAnnouncement) { }
2781 /// Used only if an object of this type is returned as a trait impl by a method
2782 extern "C" fn ChannelAnnouncement_free_void(this_ptr: *mut c_void) {
2783 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelAnnouncement); }
2786 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2787 impl ChannelAnnouncement {
2788 pub(crate) fn take_inner(mut self) -> *mut nativeChannelAnnouncement {
2789 assert!(self.is_owned);
2790 let ret = self.inner;
2791 self.inner = std::ptr::null_mut();
2795 impl Clone for ChannelAnnouncement {
2796 fn clone(&self) -> Self {
2798 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
2804 /// Used only if an object of this type is returned as a trait impl by a method
2805 pub(crate) extern "C" fn ChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
2806 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelAnnouncement)).clone() })) as *mut c_void
2809 pub extern "C" fn ChannelAnnouncement_clone(orig: &ChannelAnnouncement) -> ChannelAnnouncement {
2810 ChannelAnnouncement { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
2812 /// Authentication of the announcement by the first public node
2814 pub extern "C" fn ChannelAnnouncement_get_node_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
2815 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_signature_1;
2816 crate::c_types::Signature::from_rust(&(*inner_val))
2818 /// Authentication of the announcement by the first public node
2820 pub extern "C" fn ChannelAnnouncement_set_node_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
2821 unsafe { &mut *this_ptr.inner }.node_signature_1 = val.into_rust();
2823 /// Authentication of the announcement by the second public node
2825 pub extern "C" fn ChannelAnnouncement_get_node_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
2826 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_signature_2;
2827 crate::c_types::Signature::from_rust(&(*inner_val))
2829 /// Authentication of the announcement by the second public node
2831 pub extern "C" fn ChannelAnnouncement_set_node_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
2832 unsafe { &mut *this_ptr.inner }.node_signature_2 = val.into_rust();
2834 /// Proof of funding UTXO ownership by the first public node
2836 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
2837 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_signature_1;
2838 crate::c_types::Signature::from_rust(&(*inner_val))
2840 /// Proof of funding UTXO ownership by the first public node
2842 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
2843 unsafe { &mut *this_ptr.inner }.bitcoin_signature_1 = val.into_rust();
2845 /// Proof of funding UTXO ownership by the second public node
2847 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
2848 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_signature_2;
2849 crate::c_types::Signature::from_rust(&(*inner_val))
2851 /// Proof of funding UTXO ownership by the second public node
2853 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
2854 unsafe { &mut *this_ptr.inner }.bitcoin_signature_2 = val.into_rust();
2856 /// The actual announcement
2858 pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncement) -> crate::ln::msgs::UnsignedChannelAnnouncement {
2859 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents;
2860 crate::ln::msgs::UnsignedChannelAnnouncement { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
2862 /// The actual announcement
2864 pub extern "C" fn ChannelAnnouncement_set_contents(this_ptr: &mut ChannelAnnouncement, mut val: crate::ln::msgs::UnsignedChannelAnnouncement) {
2865 unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_inner()) };
2869 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 {
2870 ChannelAnnouncement { inner: Box::into_raw(Box::new(nativeChannelAnnouncement {
2871 node_signature_1: node_signature_1_arg.into_rust(),
2872 node_signature_2: node_signature_2_arg.into_rust(),
2873 bitcoin_signature_1: bitcoin_signature_1_arg.into_rust(),
2874 bitcoin_signature_2: bitcoin_signature_2_arg.into_rust(),
2875 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
2876 })), is_owned: true }
2879 use lightning::ln::msgs::UnsignedChannelUpdate as nativeUnsignedChannelUpdateImport;
2880 type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport;
2882 /// The unsigned part of a channel_update
2885 pub struct UnsignedChannelUpdate {
2886 /// Nearly everywhere, inner must be non-null, however in places where
2887 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2888 pub inner: *mut nativeUnsignedChannelUpdate,
2892 impl Drop for UnsignedChannelUpdate {
2893 fn drop(&mut self) {
2894 if self.is_owned && !self.inner.is_null() {
2895 let _ = unsafe { Box::from_raw(self.inner) };
2900 pub extern "C" fn UnsignedChannelUpdate_free(this_ptr: UnsignedChannelUpdate) { }
2902 /// Used only if an object of this type is returned as a trait impl by a method
2903 extern "C" fn UnsignedChannelUpdate_free_void(this_ptr: *mut c_void) {
2904 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelUpdate); }
2907 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2908 impl UnsignedChannelUpdate {
2909 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelUpdate {
2910 assert!(self.is_owned);
2911 let ret = self.inner;
2912 self.inner = std::ptr::null_mut();
2916 impl Clone for UnsignedChannelUpdate {
2917 fn clone(&self) -> Self {
2919 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
2925 /// Used only if an object of this type is returned as a trait impl by a method
2926 pub(crate) extern "C" fn UnsignedChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
2927 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelUpdate)).clone() })) as *mut c_void
2930 pub extern "C" fn UnsignedChannelUpdate_clone(orig: &UnsignedChannelUpdate) -> UnsignedChannelUpdate {
2931 UnsignedChannelUpdate { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
2933 /// The genesis hash of the blockchain where the channel is to be opened
2935 pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChannelUpdate) -> *const [u8; 32] {
2936 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
2937 (*inner_val).as_inner()
2939 /// The genesis hash of the blockchain where the channel is to be opened
2941 pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::ThirtyTwoBytes) {
2942 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
2944 /// The short channel ID
2946 pub extern "C" fn UnsignedChannelUpdate_get_short_channel_id(this_ptr: &UnsignedChannelUpdate) -> u64 {
2947 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id;
2950 /// The short channel ID
2952 pub extern "C" fn UnsignedChannelUpdate_set_short_channel_id(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
2953 unsafe { &mut *this_ptr.inner }.short_channel_id = val;
2955 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
2957 pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannelUpdate) -> u32 {
2958 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp;
2961 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
2963 pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
2964 unsafe { &mut *this_ptr.inner }.timestamp = val;
2968 pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 {
2969 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.flags;
2974 pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) {
2975 unsafe { &mut *this_ptr.inner }.flags = val;
2977 /// The number of blocks to subtract from incoming HTLC cltv_expiry values
2979 pub extern "C" fn UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr: &UnsignedChannelUpdate) -> u16 {
2980 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry_delta;
2983 /// The number of blocks to subtract from incoming HTLC cltv_expiry values
2985 pub extern "C" fn UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr: &mut UnsignedChannelUpdate, mut val: u16) {
2986 unsafe { &mut *this_ptr.inner }.cltv_expiry_delta = val;
2988 /// The minimum HTLC size incoming to sender, in milli-satoshi
2990 pub extern "C" fn UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
2991 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_minimum_msat;
2994 /// The minimum HTLC size incoming to sender, in milli-satoshi
2996 pub extern "C" fn UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
2997 unsafe { &mut *this_ptr.inner }.htlc_minimum_msat = val;
2999 /// The base HTLC fee charged by sender, in milli-satoshi
3001 pub extern "C" fn UnsignedChannelUpdate_get_fee_base_msat(this_ptr: &UnsignedChannelUpdate) -> u32 {
3002 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_base_msat;
3005 /// The base HTLC fee charged by sender, in milli-satoshi
3007 pub extern "C" fn UnsignedChannelUpdate_set_fee_base_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3008 unsafe { &mut *this_ptr.inner }.fee_base_msat = val;
3010 /// The amount to fee multiplier, in micro-satoshi
3012 pub extern "C" fn UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr: &UnsignedChannelUpdate) -> u32 {
3013 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_proportional_millionths;
3016 /// The amount to fee multiplier, in micro-satoshi
3018 pub extern "C" fn UnsignedChannelUpdate_set_fee_proportional_millionths(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3019 unsafe { &mut *this_ptr.inner }.fee_proportional_millionths = val;
3022 use lightning::ln::msgs::ChannelUpdate as nativeChannelUpdateImport;
3023 type nativeChannelUpdate = nativeChannelUpdateImport;
3025 /// A channel_update message to be sent or received from a peer
3028 pub struct ChannelUpdate {
3029 /// Nearly everywhere, inner must be non-null, however in places where
3030 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3031 pub inner: *mut nativeChannelUpdate,
3035 impl Drop for ChannelUpdate {
3036 fn drop(&mut self) {
3037 if self.is_owned && !self.inner.is_null() {
3038 let _ = unsafe { Box::from_raw(self.inner) };
3043 pub extern "C" fn ChannelUpdate_free(this_ptr: ChannelUpdate) { }
3045 /// Used only if an object of this type is returned as a trait impl by a method
3046 extern "C" fn ChannelUpdate_free_void(this_ptr: *mut c_void) {
3047 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelUpdate); }
3050 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3051 impl ChannelUpdate {
3052 pub(crate) fn take_inner(mut self) -> *mut nativeChannelUpdate {
3053 assert!(self.is_owned);
3054 let ret = self.inner;
3055 self.inner = std::ptr::null_mut();
3059 impl Clone for ChannelUpdate {
3060 fn clone(&self) -> Self {
3062 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
3068 /// Used only if an object of this type is returned as a trait impl by a method
3069 pub(crate) extern "C" fn ChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
3070 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelUpdate)).clone() })) as *mut c_void
3073 pub extern "C" fn ChannelUpdate_clone(orig: &ChannelUpdate) -> ChannelUpdate {
3074 ChannelUpdate { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
3076 /// A signature of the channel update
3078 pub extern "C" fn ChannelUpdate_get_signature(this_ptr: &ChannelUpdate) -> crate::c_types::Signature {
3079 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
3080 crate::c_types::Signature::from_rust(&(*inner_val))
3082 /// A signature of the channel update
3084 pub extern "C" fn ChannelUpdate_set_signature(this_ptr: &mut ChannelUpdate, mut val: crate::c_types::Signature) {
3085 unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
3087 /// The actual channel update
3089 pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate::ln::msgs::UnsignedChannelUpdate {
3090 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents;
3091 crate::ln::msgs::UnsignedChannelUpdate { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
3093 /// The actual channel update
3095 pub extern "C" fn ChannelUpdate_set_contents(this_ptr: &mut ChannelUpdate, mut val: crate::ln::msgs::UnsignedChannelUpdate) {
3096 unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_inner()) };
3100 pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::ln::msgs::UnsignedChannelUpdate) -> ChannelUpdate {
3101 ChannelUpdate { inner: Box::into_raw(Box::new(nativeChannelUpdate {
3102 signature: signature_arg.into_rust(),
3103 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
3104 })), is_owned: true }
3107 use lightning::ln::msgs::QueryChannelRange as nativeQueryChannelRangeImport;
3108 type nativeQueryChannelRange = nativeQueryChannelRangeImport;
3110 /// A query_channel_range message is used to query a peer for channel
3111 /// UTXOs in a range of blocks. The recipient of a query makes a best
3112 /// effort to reply to the query using one or more reply_channel_range
3116 pub struct QueryChannelRange {
3117 /// Nearly everywhere, inner must be non-null, however in places where
3118 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3119 pub inner: *mut nativeQueryChannelRange,
3123 impl Drop for QueryChannelRange {
3124 fn drop(&mut self) {
3125 if self.is_owned && !self.inner.is_null() {
3126 let _ = unsafe { Box::from_raw(self.inner) };
3131 pub extern "C" fn QueryChannelRange_free(this_ptr: QueryChannelRange) { }
3133 /// Used only if an object of this type is returned as a trait impl by a method
3134 extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) {
3135 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryChannelRange); }
3138 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3139 impl QueryChannelRange {
3140 pub(crate) fn take_inner(mut self) -> *mut nativeQueryChannelRange {
3141 assert!(self.is_owned);
3142 let ret = self.inner;
3143 self.inner = std::ptr::null_mut();
3147 impl Clone for QueryChannelRange {
3148 fn clone(&self) -> Self {
3150 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
3156 /// Used only if an object of this type is returned as a trait impl by a method
3157 pub(crate) extern "C" fn QueryChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
3158 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryChannelRange)).clone() })) as *mut c_void
3161 pub extern "C" fn QueryChannelRange_clone(orig: &QueryChannelRange) -> QueryChannelRange {
3162 QueryChannelRange { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
3164 /// The genesis hash of the blockchain being queried
3166 pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *const [u8; 32] {
3167 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3168 (*inner_val).as_inner()
3170 /// The genesis hash of the blockchain being queried
3172 pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
3173 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3175 /// The height of the first block for the channel UTXOs being queried
3177 pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 {
3178 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_blocknum;
3181 /// The height of the first block for the channel UTXOs being queried
3183 pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChannelRange, mut val: u32) {
3184 unsafe { &mut *this_ptr.inner }.first_blocknum = val;
3186 /// The number of blocks to include in the query results
3188 pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 {
3189 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.number_of_blocks;
3192 /// The number of blocks to include in the query results
3194 pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryChannelRange, mut val: u32) {
3195 unsafe { &mut *this_ptr.inner }.number_of_blocks = val;
3199 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 {
3200 QueryChannelRange { inner: Box::into_raw(Box::new(nativeQueryChannelRange {
3201 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3202 first_blocknum: first_blocknum_arg,
3203 number_of_blocks: number_of_blocks_arg,
3204 })), is_owned: true }
3207 use lightning::ln::msgs::ReplyChannelRange as nativeReplyChannelRangeImport;
3208 type nativeReplyChannelRange = nativeReplyChannelRangeImport;
3210 /// A reply_channel_range message is a reply to a query_channel_range
3211 /// message. Multiple reply_channel_range messages can be sent in reply
3212 /// to a single query_channel_range message. The query recipient makes a
3213 /// best effort to respond based on their local network view which may
3214 /// not be a perfect view of the network. The short_channel_ids in the
3215 /// reply are encoded. We only support encoding_type=0 uncompressed
3216 /// serialization and do not support encoding_type=1 zlib serialization.
3219 pub struct ReplyChannelRange {
3220 /// Nearly everywhere, inner must be non-null, however in places where
3221 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3222 pub inner: *mut nativeReplyChannelRange,
3226 impl Drop for ReplyChannelRange {
3227 fn drop(&mut self) {
3228 if self.is_owned && !self.inner.is_null() {
3229 let _ = unsafe { Box::from_raw(self.inner) };
3234 pub extern "C" fn ReplyChannelRange_free(this_ptr: ReplyChannelRange) { }
3236 /// Used only if an object of this type is returned as a trait impl by a method
3237 extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) {
3238 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyChannelRange); }
3241 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3242 impl ReplyChannelRange {
3243 pub(crate) fn take_inner(mut self) -> *mut nativeReplyChannelRange {
3244 assert!(self.is_owned);
3245 let ret = self.inner;
3246 self.inner = std::ptr::null_mut();
3250 impl Clone for ReplyChannelRange {
3251 fn clone(&self) -> Self {
3253 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
3259 /// Used only if an object of this type is returned as a trait impl by a method
3260 pub(crate) extern "C" fn ReplyChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
3261 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyChannelRange)).clone() })) as *mut c_void
3264 pub extern "C" fn ReplyChannelRange_clone(orig: &ReplyChannelRange) -> ReplyChannelRange {
3265 ReplyChannelRange { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
3267 /// The genesis hash of the blockchain being queried
3269 pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *const [u8; 32] {
3270 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3271 (*inner_val).as_inner()
3273 /// The genesis hash of the blockchain being queried
3275 pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
3276 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3278 /// The height of the first block in the range of the reply
3280 pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 {
3281 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_blocknum;
3284 /// The height of the first block in the range of the reply
3286 pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChannelRange, mut val: u32) {
3287 unsafe { &mut *this_ptr.inner }.first_blocknum = val;
3289 /// The number of blocks included in the range of the reply
3291 pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 {
3292 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.number_of_blocks;
3295 /// The number of blocks included in the range of the reply
3297 pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyChannelRange, mut val: u32) {
3298 unsafe { &mut *this_ptr.inner }.number_of_blocks = val;
3300 /// Indicates if the query recipient maintains up-to-date channel
3301 /// information for the chain_hash
3303 pub extern "C" fn ReplyChannelRange_get_full_information(this_ptr: &ReplyChannelRange) -> bool {
3304 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.full_information;
3307 /// Indicates if the query recipient maintains up-to-date channel
3308 /// information for the chain_hash
3310 pub extern "C" fn ReplyChannelRange_set_full_information(this_ptr: &mut ReplyChannelRange, mut val: bool) {
3311 unsafe { &mut *this_ptr.inner }.full_information = val;
3313 /// The short_channel_ids in the channel range
3315 pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::derived::CVec_u64Z) {
3316 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
3317 unsafe { &mut *this_ptr.inner }.short_channel_ids = local_val;
3321 pub extern "C" fn ReplyChannelRange_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut first_blocknum_arg: u32, mut number_of_blocks_arg: u32, mut full_information_arg: bool, mut short_channel_ids_arg: crate::c_types::derived::CVec_u64Z) -> ReplyChannelRange {
3322 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 }); };
3323 ReplyChannelRange { inner: Box::into_raw(Box::new(nativeReplyChannelRange {
3324 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3325 first_blocknum: first_blocknum_arg,
3326 number_of_blocks: number_of_blocks_arg,
3327 full_information: full_information_arg,
3328 short_channel_ids: local_short_channel_ids_arg,
3329 })), is_owned: true }
3332 use lightning::ln::msgs::QueryShortChannelIds as nativeQueryShortChannelIdsImport;
3333 type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport;
3335 /// A query_short_channel_ids message is used to query a peer for
3336 /// routing gossip messages related to one or more short_channel_ids.
3337 /// The query recipient will reply with the latest, if available,
3338 /// channel_announcement, channel_update and node_announcement messages
3339 /// it maintains for the requested short_channel_ids followed by a
3340 /// reply_short_channel_ids_end message. The short_channel_ids sent in
3341 /// this query are encoded. We only support encoding_type=0 uncompressed
3342 /// serialization and do not support encoding_type=1 zlib serialization.
3345 pub struct QueryShortChannelIds {
3346 /// Nearly everywhere, inner must be non-null, however in places where
3347 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3348 pub inner: *mut nativeQueryShortChannelIds,
3352 impl Drop for QueryShortChannelIds {
3353 fn drop(&mut self) {
3354 if self.is_owned && !self.inner.is_null() {
3355 let _ = unsafe { Box::from_raw(self.inner) };
3360 pub extern "C" fn QueryShortChannelIds_free(this_ptr: QueryShortChannelIds) { }
3362 /// Used only if an object of this type is returned as a trait impl by a method
3363 extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) {
3364 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryShortChannelIds); }
3367 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3368 impl QueryShortChannelIds {
3369 pub(crate) fn take_inner(mut self) -> *mut nativeQueryShortChannelIds {
3370 assert!(self.is_owned);
3371 let ret = self.inner;
3372 self.inner = std::ptr::null_mut();
3376 impl Clone for QueryShortChannelIds {
3377 fn clone(&self) -> Self {
3379 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
3385 /// Used only if an object of this type is returned as a trait impl by a method
3386 pub(crate) extern "C" fn QueryShortChannelIds_clone_void(this_ptr: *const c_void) -> *mut c_void {
3387 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryShortChannelIds)).clone() })) as *mut c_void
3390 pub extern "C" fn QueryShortChannelIds_clone(orig: &QueryShortChannelIds) -> QueryShortChannelIds {
3391 QueryShortChannelIds { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
3393 /// The genesis hash of the blockchain being queried
3395 pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *const [u8; 32] {
3396 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3397 (*inner_val).as_inner()
3399 /// The genesis hash of the blockchain being queried
3401 pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::ThirtyTwoBytes) {
3402 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3404 /// The short_channel_ids that are being queried
3406 pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::derived::CVec_u64Z) {
3407 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
3408 unsafe { &mut *this_ptr.inner }.short_channel_ids = local_val;
3412 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 {
3413 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 }); };
3414 QueryShortChannelIds { inner: Box::into_raw(Box::new(nativeQueryShortChannelIds {
3415 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3416 short_channel_ids: local_short_channel_ids_arg,
3417 })), is_owned: true }
3420 use lightning::ln::msgs::ReplyShortChannelIdsEnd as nativeReplyShortChannelIdsEndImport;
3421 type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport;
3423 /// A reply_short_channel_ids_end message is sent as a reply to a
3424 /// query_short_channel_ids message. The query recipient makes a best
3425 /// effort to respond based on their local network view which may not be
3426 /// a perfect view of the network.
3429 pub struct ReplyShortChannelIdsEnd {
3430 /// Nearly everywhere, inner must be non-null, however in places where
3431 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3432 pub inner: *mut nativeReplyShortChannelIdsEnd,
3436 impl Drop for ReplyShortChannelIdsEnd {
3437 fn drop(&mut self) {
3438 if self.is_owned && !self.inner.is_null() {
3439 let _ = unsafe { Box::from_raw(self.inner) };
3444 pub extern "C" fn ReplyShortChannelIdsEnd_free(this_ptr: ReplyShortChannelIdsEnd) { }
3446 /// Used only if an object of this type is returned as a trait impl by a method
3447 extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) {
3448 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyShortChannelIdsEnd); }
3451 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3452 impl ReplyShortChannelIdsEnd {
3453 pub(crate) fn take_inner(mut self) -> *mut nativeReplyShortChannelIdsEnd {
3454 assert!(self.is_owned);
3455 let ret = self.inner;
3456 self.inner = std::ptr::null_mut();
3460 impl Clone for ReplyShortChannelIdsEnd {
3461 fn clone(&self) -> Self {
3463 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
3469 /// Used only if an object of this type is returned as a trait impl by a method
3470 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_void) -> *mut c_void {
3471 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyShortChannelIdsEnd)).clone() })) as *mut c_void
3474 pub extern "C" fn ReplyShortChannelIdsEnd_clone(orig: &ReplyShortChannelIdsEnd) -> ReplyShortChannelIdsEnd {
3475 ReplyShortChannelIdsEnd { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
3477 /// The genesis hash of the blockchain that was queried
3479 pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *const [u8; 32] {
3480 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3481 (*inner_val).as_inner()
3483 /// The genesis hash of the blockchain that was queried
3485 pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) {
3486 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3488 /// Indicates if the query recipient maintains up-to-date channel
3489 /// information for the chain_hash
3491 pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool {
3492 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.full_information;
3495 /// Indicates if the query recipient maintains up-to-date channel
3496 /// information for the chain_hash
3498 pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: bool) {
3499 unsafe { &mut *this_ptr.inner }.full_information = val;
3503 pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd {
3504 ReplyShortChannelIdsEnd { inner: Box::into_raw(Box::new(nativeReplyShortChannelIdsEnd {
3505 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3506 full_information: full_information_arg,
3507 })), is_owned: true }
3510 use lightning::ln::msgs::GossipTimestampFilter as nativeGossipTimestampFilterImport;
3511 type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport;
3513 /// A gossip_timestamp_filter message is used by a node to request
3514 /// gossip relay for messages in the requested time range when the
3515 /// gossip_queries feature has been negotiated.
3518 pub struct GossipTimestampFilter {
3519 /// Nearly everywhere, inner must be non-null, however in places where
3520 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3521 pub inner: *mut nativeGossipTimestampFilter,
3525 impl Drop for GossipTimestampFilter {
3526 fn drop(&mut self) {
3527 if self.is_owned && !self.inner.is_null() {
3528 let _ = unsafe { Box::from_raw(self.inner) };
3533 pub extern "C" fn GossipTimestampFilter_free(this_ptr: GossipTimestampFilter) { }
3535 /// Used only if an object of this type is returned as a trait impl by a method
3536 extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) {
3537 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeGossipTimestampFilter); }
3540 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3541 impl GossipTimestampFilter {
3542 pub(crate) fn take_inner(mut self) -> *mut nativeGossipTimestampFilter {
3543 assert!(self.is_owned);
3544 let ret = self.inner;
3545 self.inner = std::ptr::null_mut();
3549 impl Clone for GossipTimestampFilter {
3550 fn clone(&self) -> Self {
3552 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
3558 /// Used only if an object of this type is returned as a trait impl by a method
3559 pub(crate) extern "C" fn GossipTimestampFilter_clone_void(this_ptr: *const c_void) -> *mut c_void {
3560 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeGossipTimestampFilter)).clone() })) as *mut c_void
3563 pub extern "C" fn GossipTimestampFilter_clone(orig: &GossipTimestampFilter) -> GossipTimestampFilter {
3564 GossipTimestampFilter { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
3566 /// The genesis hash of the blockchain for channel and node information
3568 pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *const [u8; 32] {
3569 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3570 (*inner_val).as_inner()
3572 /// The genesis hash of the blockchain for channel and node information
3574 pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) {
3575 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3577 /// The starting unix timestamp
3579 pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 {
3580 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_timestamp;
3583 /// The starting unix timestamp
3585 pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
3586 unsafe { &mut *this_ptr.inner }.first_timestamp = val;
3588 /// The range of information in seconds
3590 pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 {
3591 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp_range;
3594 /// The range of information in seconds
3596 pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
3597 unsafe { &mut *this_ptr.inner }.timestamp_range = val;
3601 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 {
3602 GossipTimestampFilter { inner: Box::into_raw(Box::new(nativeGossipTimestampFilter {
3603 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3604 first_timestamp: first_timestamp_arg,
3605 timestamp_range: timestamp_range_arg,
3606 })), is_owned: true }
3608 /// Used to put an error message in a LightningError
3612 pub enum ErrorAction {
3613 /// The peer took some action which made us think they were useless. Disconnect them.
3615 msg: crate::ln::msgs::ErrorMessage,
3617 /// The peer did something harmless that we weren't able to process, just log and ignore
3619 /// The peer did something incorrect. Tell them.
3621 msg: crate::ln::msgs::ErrorMessage,
3624 use lightning::ln::msgs::ErrorAction as nativeErrorAction;
3627 pub(crate) fn to_native(&self) -> nativeErrorAction {
3629 ErrorAction::DisconnectPeer {ref msg, } => {
3630 let mut msg_nonref = (*msg).clone();
3631 let mut local_msg_nonref = if msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg_nonref.take_inner()) } }) };
3632 nativeErrorAction::DisconnectPeer {
3633 msg: local_msg_nonref,
3636 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
3637 ErrorAction::SendErrorMessage {ref msg, } => {
3638 let mut msg_nonref = (*msg).clone();
3639 nativeErrorAction::SendErrorMessage {
3640 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3646 pub(crate) fn into_native(self) -> nativeErrorAction {
3648 ErrorAction::DisconnectPeer {mut msg, } => {
3649 let mut local_msg = if msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg.take_inner()) } }) };
3650 nativeErrorAction::DisconnectPeer {
3654 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
3655 ErrorAction::SendErrorMessage {mut msg, } => {
3656 nativeErrorAction::SendErrorMessage {
3657 msg: *unsafe { Box::from_raw(msg.take_inner()) },
3663 pub(crate) fn from_native(native: &nativeErrorAction) -> Self {
3665 nativeErrorAction::DisconnectPeer {ref msg, } => {
3666 let mut msg_nonref = (*msg).clone();
3667 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 };
3668 ErrorAction::DisconnectPeer {
3669 msg: local_msg_nonref,
3672 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
3673 nativeErrorAction::SendErrorMessage {ref msg, } => {
3674 let mut msg_nonref = (*msg).clone();
3675 ErrorAction::SendErrorMessage {
3676 msg: crate::ln::msgs::ErrorMessage { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
3682 pub(crate) fn native_into(native: nativeErrorAction) -> Self {
3684 nativeErrorAction::DisconnectPeer {mut msg, } => {
3685 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 };
3686 ErrorAction::DisconnectPeer {
3690 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
3691 nativeErrorAction::SendErrorMessage {mut msg, } => {
3692 ErrorAction::SendErrorMessage {
3693 msg: crate::ln::msgs::ErrorMessage { inner: Box::into_raw(Box::new(msg)), is_owned: true },
3700 pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { }
3702 pub extern "C" fn ErrorAction_clone(orig: &ErrorAction) -> ErrorAction {
3706 use lightning::ln::msgs::LightningError as nativeLightningErrorImport;
3707 type nativeLightningError = nativeLightningErrorImport;
3709 /// An Err type for failure to process messages.
3712 pub struct LightningError {
3713 /// Nearly everywhere, inner must be non-null, however in places where
3714 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3715 pub inner: *mut nativeLightningError,
3719 impl Drop for LightningError {
3720 fn drop(&mut self) {
3721 if self.is_owned && !self.inner.is_null() {
3722 let _ = unsafe { Box::from_raw(self.inner) };
3727 pub extern "C" fn LightningError_free(this_ptr: LightningError) { }
3729 /// Used only if an object of this type is returned as a trait impl by a method
3730 extern "C" fn LightningError_free_void(this_ptr: *mut c_void) {
3731 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeLightningError); }
3734 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3735 impl LightningError {
3736 pub(crate) fn take_inner(mut self) -> *mut nativeLightningError {
3737 assert!(self.is_owned);
3738 let ret = self.inner;
3739 self.inner = std::ptr::null_mut();
3743 /// A human-readable message describing the error
3745 pub extern "C" fn LightningError_get_err(this_ptr: &LightningError) -> crate::c_types::Str {
3746 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.err;
3747 (*inner_val).as_str().into()
3749 /// A human-readable message describing the error
3751 pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: crate::c_types::derived::CVec_u8Z) {
3752 unsafe { &mut *this_ptr.inner }.err = String::from_utf8(val.into_rust()).unwrap();
3754 /// The action which should be taken against the offending peer.
3756 pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate::ln::msgs::ErrorAction {
3757 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.action;
3758 crate::ln::msgs::ErrorAction::from_native(&(*inner_val))
3760 /// The action which should be taken against the offending peer.
3762 pub extern "C" fn LightningError_set_action(this_ptr: &mut LightningError, mut val: crate::ln::msgs::ErrorAction) {
3763 unsafe { &mut *this_ptr.inner }.action = val.into_native();
3767 pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::derived::CVec_u8Z, mut action_arg: crate::ln::msgs::ErrorAction) -> LightningError {
3768 LightningError { inner: Box::into_raw(Box::new(nativeLightningError {
3769 err: String::from_utf8(err_arg.into_rust()).unwrap(),
3770 action: action_arg.into_native(),
3771 })), is_owned: true }
3774 use lightning::ln::msgs::CommitmentUpdate as nativeCommitmentUpdateImport;
3775 type nativeCommitmentUpdate = nativeCommitmentUpdateImport;
3777 /// Struct used to return values from revoke_and_ack messages, containing a bunch of commitment
3778 /// transaction updates if they were pending.
3781 pub struct CommitmentUpdate {
3782 /// Nearly everywhere, inner must be non-null, however in places where
3783 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3784 pub inner: *mut nativeCommitmentUpdate,
3788 impl Drop for CommitmentUpdate {
3789 fn drop(&mut self) {
3790 if self.is_owned && !self.inner.is_null() {
3791 let _ = unsafe { Box::from_raw(self.inner) };
3796 pub extern "C" fn CommitmentUpdate_free(this_ptr: CommitmentUpdate) { }
3798 /// Used only if an object of this type is returned as a trait impl by a method
3799 extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) {
3800 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentUpdate); }
3803 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3804 impl CommitmentUpdate {
3805 pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentUpdate {
3806 assert!(self.is_owned);
3807 let ret = self.inner;
3808 self.inner = std::ptr::null_mut();
3812 impl Clone for CommitmentUpdate {
3813 fn clone(&self) -> Self {
3815 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
3821 /// Used only if an object of this type is returned as a trait impl by a method
3822 pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
3823 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentUpdate)).clone() })) as *mut c_void
3826 pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentUpdate {
3827 CommitmentUpdate { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
3829 /// update_add_htlc messages which should be sent
3831 pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) {
3832 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
3833 unsafe { &mut *this_ptr.inner }.update_add_htlcs = local_val;
3835 /// update_fulfill_htlc messages which should be sent
3837 pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) {
3838 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
3839 unsafe { &mut *this_ptr.inner }.update_fulfill_htlcs = local_val;
3841 /// update_fail_htlc messages which should be sent
3843 pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) {
3844 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
3845 unsafe { &mut *this_ptr.inner }.update_fail_htlcs = local_val;
3847 /// update_fail_malformed_htlc messages which should be sent
3849 pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) {
3850 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
3851 unsafe { &mut *this_ptr.inner }.update_fail_malformed_htlcs = local_val;
3853 /// An update_fee message which should be sent
3855 pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::ln::msgs::UpdateFee {
3856 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.update_fee;
3857 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 };
3860 /// An update_fee message which should be sent
3862 pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdate, mut val: crate::ln::msgs::UpdateFee) {
3863 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
3864 unsafe { &mut *this_ptr.inner }.update_fee = local_val;
3866 /// Finally, the commitment_signed message which should be sent
3868 pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::ln::msgs::CommitmentSigned {
3869 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.commitment_signed;
3870 crate::ln::msgs::CommitmentSigned { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
3872 /// Finally, the commitment_signed message which should be sent
3874 pub extern "C" fn CommitmentUpdate_set_commitment_signed(this_ptr: &mut CommitmentUpdate, mut val: crate::ln::msgs::CommitmentSigned) {
3875 unsafe { &mut *this_ptr.inner }.commitment_signed = *unsafe { Box::from_raw(val.take_inner()) };
3879 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 {
3880 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()) } }); };
3881 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()) } }); };
3882 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()) } }); };
3883 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()) } }); };
3884 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()) } }) };
3885 CommitmentUpdate { inner: Box::into_raw(Box::new(nativeCommitmentUpdate {
3886 update_add_htlcs: local_update_add_htlcs_arg,
3887 update_fulfill_htlcs: local_update_fulfill_htlcs_arg,
3888 update_fail_htlcs: local_update_fail_htlcs_arg,
3889 update_fail_malformed_htlcs: local_update_fail_malformed_htlcs_arg,
3890 update_fee: local_update_fee_arg,
3891 commitment_signed: *unsafe { Box::from_raw(commitment_signed_arg.take_inner()) },
3892 })), is_owned: true }
3894 /// The information we received from a peer along the route of a payment we originated. This is
3895 /// returned by ChannelMessageHandler::handle_update_fail_htlc to be passed into
3896 /// RoutingMessageHandler::handle_htlc_fail_channel_update to update our network map.
3900 pub enum HTLCFailChannelUpdate {
3901 /// We received an error which included a full ChannelUpdate message.
3902 ChannelUpdateMessage {
3903 msg: crate::ln::msgs::ChannelUpdate,
3905 /// We received an error which indicated only that a channel has been closed
3907 short_channel_id: u64,
3910 /// We received an error which indicated only that a node has failed
3912 node_id: crate::c_types::PublicKey,
3916 use lightning::ln::msgs::HTLCFailChannelUpdate as nativeHTLCFailChannelUpdate;
3917 impl HTLCFailChannelUpdate {
3919 pub(crate) fn to_native(&self) -> nativeHTLCFailChannelUpdate {
3921 HTLCFailChannelUpdate::ChannelUpdateMessage {ref msg, } => {
3922 let mut msg_nonref = (*msg).clone();
3923 nativeHTLCFailChannelUpdate::ChannelUpdateMessage {
3924 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3927 HTLCFailChannelUpdate::ChannelClosed {ref short_channel_id, ref is_permanent, } => {
3928 let mut short_channel_id_nonref = (*short_channel_id).clone();
3929 let mut is_permanent_nonref = (*is_permanent).clone();
3930 nativeHTLCFailChannelUpdate::ChannelClosed {
3931 short_channel_id: short_channel_id_nonref,
3932 is_permanent: is_permanent_nonref,
3935 HTLCFailChannelUpdate::NodeFailure {ref node_id, ref is_permanent, } => {
3936 let mut node_id_nonref = (*node_id).clone();
3937 let mut is_permanent_nonref = (*is_permanent).clone();
3938 nativeHTLCFailChannelUpdate::NodeFailure {
3939 node_id: node_id_nonref.into_rust(),
3940 is_permanent: is_permanent_nonref,
3946 pub(crate) fn into_native(self) -> nativeHTLCFailChannelUpdate {
3948 HTLCFailChannelUpdate::ChannelUpdateMessage {mut msg, } => {
3949 nativeHTLCFailChannelUpdate::ChannelUpdateMessage {
3950 msg: *unsafe { Box::from_raw(msg.take_inner()) },
3953 HTLCFailChannelUpdate::ChannelClosed {mut short_channel_id, mut is_permanent, } => {
3954 nativeHTLCFailChannelUpdate::ChannelClosed {
3955 short_channel_id: short_channel_id,
3956 is_permanent: is_permanent,
3959 HTLCFailChannelUpdate::NodeFailure {mut node_id, mut is_permanent, } => {
3960 nativeHTLCFailChannelUpdate::NodeFailure {
3961 node_id: node_id.into_rust(),
3962 is_permanent: is_permanent,
3968 pub(crate) fn from_native(native: &nativeHTLCFailChannelUpdate) -> Self {
3970 nativeHTLCFailChannelUpdate::ChannelUpdateMessage {ref msg, } => {
3971 let mut msg_nonref = (*msg).clone();
3972 HTLCFailChannelUpdate::ChannelUpdateMessage {
3973 msg: crate::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
3976 nativeHTLCFailChannelUpdate::ChannelClosed {ref short_channel_id, ref is_permanent, } => {
3977 let mut short_channel_id_nonref = (*short_channel_id).clone();
3978 let mut is_permanent_nonref = (*is_permanent).clone();
3979 HTLCFailChannelUpdate::ChannelClosed {
3980 short_channel_id: short_channel_id_nonref,
3981 is_permanent: is_permanent_nonref,
3984 nativeHTLCFailChannelUpdate::NodeFailure {ref node_id, ref is_permanent, } => {
3985 let mut node_id_nonref = (*node_id).clone();
3986 let mut is_permanent_nonref = (*is_permanent).clone();
3987 HTLCFailChannelUpdate::NodeFailure {
3988 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3989 is_permanent: is_permanent_nonref,
3995 pub(crate) fn native_into(native: nativeHTLCFailChannelUpdate) -> Self {
3997 nativeHTLCFailChannelUpdate::ChannelUpdateMessage {mut msg, } => {
3998 HTLCFailChannelUpdate::ChannelUpdateMessage {
3999 msg: crate::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(msg)), is_owned: true },
4002 nativeHTLCFailChannelUpdate::ChannelClosed {mut short_channel_id, mut is_permanent, } => {
4003 HTLCFailChannelUpdate::ChannelClosed {
4004 short_channel_id: short_channel_id,
4005 is_permanent: is_permanent,
4008 nativeHTLCFailChannelUpdate::NodeFailure {mut node_id, mut is_permanent, } => {
4009 HTLCFailChannelUpdate::NodeFailure {
4010 node_id: crate::c_types::PublicKey::from_rust(&node_id),
4011 is_permanent: is_permanent,
4018 pub extern "C" fn HTLCFailChannelUpdate_free(this_ptr: HTLCFailChannelUpdate) { }
4020 pub extern "C" fn HTLCFailChannelUpdate_clone(orig: &HTLCFailChannelUpdate) -> HTLCFailChannelUpdate {
4023 /// A trait to describe an object which can receive channel messages.
4025 /// Messages MAY be called in parallel when they originate from different their_node_ids, however
4026 /// they MUST NOT be called in parallel when the two calls have the same their_node_id.
4028 pub struct ChannelMessageHandler {
4029 pub this_arg: *mut c_void,
4030 /// Handle an incoming open_channel message from the given peer.
4031 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),
4032 /// Handle an incoming accept_channel message from the given peer.
4033 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),
4034 /// Handle an incoming funding_created message from the given peer.
4035 pub handle_funding_created: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingCreated),
4036 /// Handle an incoming funding_signed message from the given peer.
4037 pub handle_funding_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingSigned),
4038 /// Handle an incoming funding_locked message from the given peer.
4039 pub handle_funding_locked: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingLocked),
4040 /// Handle an incoming shutdown message from the given peer.
4041 pub handle_shutdown: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::Shutdown),
4042 /// Handle an incoming closing_signed message from the given peer.
4043 pub handle_closing_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ClosingSigned),
4044 /// Handle an incoming update_add_htlc message from the given peer.
4045 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),
4046 /// Handle an incoming update_fulfill_htlc message from the given peer.
4047 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),
4048 /// Handle an incoming update_fail_htlc message from the given peer.
4049 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),
4050 /// Handle an incoming update_fail_malformed_htlc message from the given peer.
4051 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),
4052 /// Handle an incoming commitment_signed message from the given peer.
4053 pub handle_commitment_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::CommitmentSigned),
4054 /// Handle an incoming revoke_and_ack message from the given peer.
4055 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),
4056 /// Handle an incoming update_fee message from the given peer.
4057 pub handle_update_fee: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFee),
4058 /// Handle an incoming announcement_signatures message from the given peer.
4059 pub handle_announcement_signatures: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::AnnouncementSignatures),
4060 /// Indicates a connection to the peer failed/an existing connection was lost. If no connection
4061 /// is believed to be possible in the future (eg they're sending us messages we don't
4062 /// understand or indicate they require unknown feature bits), no_connection_possible is set
4063 /// and any outstanding channels should be failed.
4064 pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, no_connection_possible: bool),
4065 /// Handle a peer reconnecting, possibly generating channel_reestablish message(s).
4066 pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::Init),
4067 /// Handle an incoming channel_reestablish message from the given peer.
4068 pub handle_channel_reestablish: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ChannelReestablish),
4069 /// Handle an incoming error message from the given peer.
4070 pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ErrorMessage),
4071 pub MessageSendEventsProvider: crate::util::events::MessageSendEventsProvider,
4072 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
4074 impl lightning::util::events::MessageSendEventsProvider for ChannelMessageHandler {
4075 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
4076 <crate::util::events::MessageSendEventsProvider as lightning::util::events::MessageSendEventsProvider>::get_and_clear_pending_msg_events(&self.MessageSendEventsProvider)
4079 unsafe impl Send for ChannelMessageHandler {}
4080 unsafe impl Sync for ChannelMessageHandler {}
4082 use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler;
4083 impl rustChannelMessageHandler for ChannelMessageHandler {
4084 fn handle_open_channel(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, their_features: lightning::ln::features::InitFeatures, msg: &lightning::ln::msgs::OpenChannel) {
4085 (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 })
4087 fn handle_accept_channel(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, their_features: lightning::ln::features::InitFeatures, msg: &lightning::ln::msgs::AcceptChannel) {
4088 (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 })
4090 fn handle_funding_created(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::FundingCreated) {
4091 (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 })
4093 fn handle_funding_signed(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::FundingSigned) {
4094 (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 })
4096 fn handle_funding_locked(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::FundingLocked) {
4097 (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 })
4099 fn handle_shutdown(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::Shutdown) {
4100 (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 })
4102 fn handle_closing_signed(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::ClosingSigned) {
4103 (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 })
4105 fn handle_update_add_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateAddHTLC) {
4106 (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 })
4108 fn handle_update_fulfill_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFulfillHTLC) {
4109 (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 })
4111 fn handle_update_fail_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFailHTLC) {
4112 (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 })
4114 fn handle_update_fail_malformed_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) {
4115 (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 })
4117 fn handle_commitment_signed(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::CommitmentSigned) {
4118 (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 })
4120 fn handle_revoke_and_ack(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::RevokeAndACK) {
4121 (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 })
4123 fn handle_update_fee(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFee) {
4124 (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 })
4126 fn handle_announcement_signatures(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::AnnouncementSignatures) {
4127 (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 })
4129 fn peer_disconnected(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, no_connection_possible: bool) {
4130 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), no_connection_possible)
4132 fn peer_connected(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::Init) {
4133 (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 })
4135 fn handle_channel_reestablish(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::ChannelReestablish) {
4136 (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 })
4138 fn handle_error(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::ErrorMessage) {
4139 (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 })
4143 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
4144 // directly as a Deref trait in higher-level structs:
4145 impl std::ops::Deref for ChannelMessageHandler {
4147 fn deref(&self) -> &Self {
4151 /// Calls the free function if one is set
4153 pub extern "C" fn ChannelMessageHandler_free(this_ptr: ChannelMessageHandler) { }
4154 impl Drop for ChannelMessageHandler {
4155 fn drop(&mut self) {
4156 if let Some(f) = self.free {
4161 /// A trait to describe an object which can receive routing messages.
4163 /// # Implementor DoS Warnings
4165 /// For `gossip_queries` messages there are potential DoS vectors when handling
4166 /// inbound queries. Implementors using an on-disk network graph should be aware of
4167 /// repeated disk I/O for queries accessing different parts of the network graph.
4169 pub struct RoutingMessageHandler {
4170 pub this_arg: *mut c_void,
4171 /// Handle an incoming node_announcement message, returning true if it should be forwarded on,
4172 /// false or returning an Err otherwise.
4174 pub handle_node_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
4175 /// Handle a channel_announcement message, returning true if it should be forwarded on, false
4176 /// or returning an Err otherwise.
4178 pub handle_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
4179 /// Handle an incoming channel_update message, returning true if it should be forwarded on,
4180 /// false or returning an Err otherwise.
4182 pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ,
4183 /// Handle some updates to the route graph that we learned due to an outbound failed payment.
4184 pub handle_htlc_fail_channel_update: extern "C" fn (this_arg: *const c_void, update: &crate::ln::msgs::HTLCFailChannelUpdate),
4185 /// Gets a subset of the channel announcements and updates required to dump our routing table
4186 /// to a remote node, starting at the short_channel_id indicated by starting_point and
4187 /// including the batch_amount entries immediately higher in numerical value than starting_point.
4189 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,
4190 /// Gets a subset of the node announcements required to dump our routing table to a remote node,
4191 /// starting at the node *after* the provided publickey and including batch_amount entries
4192 /// immediately higher (as defined by <PublicKey as Ord>::cmp) than starting_point.
4193 /// If None is provided for starting_point, we start at the first node.
4195 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,
4196 /// Called when a connection is established with a peer. This can be used to
4197 /// perform routing table synchronization using a strategy defined by the
4199 pub sync_routing_table: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, init: &crate::ln::msgs::Init),
4200 /// Handles the reply of a query we initiated to learn about channels
4201 /// for a given range of blocks. We can expect to receive one or more
4202 /// replies to a single query.
4204 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,
4205 /// Handles the reply of a query we initiated asking for routing gossip
4206 /// messages for a list of channels. We should receive this message when
4207 /// a node has completed its best effort to send us the pertaining routing
4208 /// gossip messages.
4210 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,
4211 /// Handles when a peer asks us to send a list of short_channel_ids
4212 /// for the requested range of blocks.
4214 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,
4215 /// Handles when a peer asks us to send routing gossip messages for a
4216 /// list of short_channel_ids.
4218 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,
4219 pub MessageSendEventsProvider: crate::util::events::MessageSendEventsProvider,
4220 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
4222 unsafe impl Send for RoutingMessageHandler {}
4223 unsafe impl Sync for RoutingMessageHandler {}
4224 impl lightning::util::events::MessageSendEventsProvider for RoutingMessageHandler {
4225 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
4226 <crate::util::events::MessageSendEventsProvider as lightning::util::events::MessageSendEventsProvider>::get_and_clear_pending_msg_events(&self.MessageSendEventsProvider)
4230 use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler;
4231 impl rustRoutingMessageHandler for RoutingMessageHandler {
4232 fn handle_node_announcement(&self, msg: &lightning::ln::msgs::NodeAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
4233 let mut ret = (self.handle_node_announcement)(self.this_arg, &crate::ln::msgs::NodeAnnouncement { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false });
4234 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()) } })};
4237 fn handle_channel_announcement(&self, msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
4238 let mut ret = (self.handle_channel_announcement)(self.this_arg, &crate::ln::msgs::ChannelAnnouncement { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false });
4239 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()) } })};
4242 fn handle_channel_update(&self, msg: &lightning::ln::msgs::ChannelUpdate) -> Result<bool, lightning::ln::msgs::LightningError> {
4243 let mut ret = (self.handle_channel_update)(self.this_arg, &crate::ln::msgs::ChannelUpdate { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false });
4244 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()) } })};
4247 fn handle_htlc_fail_channel_update(&self, update: &lightning::ln::msgs::HTLCFailChannelUpdate) {
4248 (self.handle_htlc_fail_channel_update)(self.this_arg, &crate::ln::msgs::HTLCFailChannelUpdate::from_native(&update))
4250 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>)> {
4251 let mut ret = (self.get_next_channel_announcements)(self.this_arg, starting_point, batch_amount);
4252 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 }); };
4255 fn get_next_node_announcements(&self, starting_point: Option<&bitcoin::secp256k1::key::PublicKey>, batch_amount: u8) -> Vec<lightning::ln::msgs::NodeAnnouncement> {
4256 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())) } };
4257 let mut ret = (self.get_next_node_announcements)(self.this_arg, local_starting_point, batch_amount);
4258 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4261 fn sync_routing_table(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, init: &lightning::ln::msgs::Init) {
4262 (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 })
4264 fn handle_reply_channel_range(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: lightning::ln::msgs::ReplyChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
4265 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 });
4266 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()) } })};
4269 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> {
4270 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 });
4271 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()) } })};
4274 fn handle_query_channel_range(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: lightning::ln::msgs::QueryChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
4275 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 });
4276 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()) } })};
4279 fn handle_query_short_channel_ids(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: lightning::ln::msgs::QueryShortChannelIds) -> Result<(), lightning::ln::msgs::LightningError> {
4280 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 });
4281 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()) } })};
4286 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
4287 // directly as a Deref trait in higher-level structs:
4288 impl std::ops::Deref for RoutingMessageHandler {
4290 fn deref(&self) -> &Self {
4294 /// Calls the free function if one is set
4296 pub extern "C" fn RoutingMessageHandler_free(this_ptr: RoutingMessageHandler) { }
4297 impl Drop for RoutingMessageHandler {
4298 fn drop(&mut self) {
4299 if let Some(f) = self.free {
4305 pub extern "C" fn AcceptChannel_write(obj: &AcceptChannel) -> crate::c_types::derived::CVec_u8Z {
4306 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4309 pub(crate) extern "C" fn AcceptChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4310 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannel) })
4313 pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> AcceptChannel {
4314 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4315 AcceptChannel { inner: Box::into_raw(Box::new(res)), is_owned: true }
4317 AcceptChannel { inner: std::ptr::null_mut(), is_owned: true }
4321 pub extern "C" fn AnnouncementSignatures_write(obj: &AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z {
4322 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4325 pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4326 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAnnouncementSignatures) })
4329 pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> AnnouncementSignatures {
4330 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4331 AnnouncementSignatures { inner: Box::into_raw(Box::new(res)), is_owned: true }
4333 AnnouncementSignatures { inner: std::ptr::null_mut(), is_owned: true }
4337 pub extern "C" fn ChannelReestablish_write(obj: &ChannelReestablish) -> crate::c_types::derived::CVec_u8Z {
4338 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4341 pub(crate) extern "C" fn ChannelReestablish_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4342 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReestablish) })
4345 pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReestablishDecodeErrorZ {
4346 let res = crate::c_types::deserialize_obj(ser);
4347 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 } }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) };
4351 pub extern "C" fn ClosingSigned_write(obj: &ClosingSigned) -> crate::c_types::derived::CVec_u8Z {
4352 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4355 pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4356 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSigned) })
4359 pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> ClosingSigned {
4360 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4361 ClosingSigned { inner: Box::into_raw(Box::new(res)), is_owned: true }
4363 ClosingSigned { inner: std::ptr::null_mut(), is_owned: true }
4367 pub extern "C" fn CommitmentSigned_write(obj: &CommitmentSigned) -> crate::c_types::derived::CVec_u8Z {
4368 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4371 pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4372 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentSigned) })
4375 pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> CommitmentSigned {
4376 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4377 CommitmentSigned { inner: Box::into_raw(Box::new(res)), is_owned: true }
4379 CommitmentSigned { inner: std::ptr::null_mut(), is_owned: true }
4383 pub extern "C" fn FundingCreated_write(obj: &FundingCreated) -> crate::c_types::derived::CVec_u8Z {
4384 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4387 pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4388 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingCreated) })
4391 pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> FundingCreated {
4392 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4393 FundingCreated { inner: Box::into_raw(Box::new(res)), is_owned: true }
4395 FundingCreated { inner: std::ptr::null_mut(), is_owned: true }
4399 pub extern "C" fn FundingSigned_write(obj: &FundingSigned) -> crate::c_types::derived::CVec_u8Z {
4400 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4403 pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4404 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingSigned) })
4407 pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> FundingSigned {
4408 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4409 FundingSigned { inner: Box::into_raw(Box::new(res)), is_owned: true }
4411 FundingSigned { inner: std::ptr::null_mut(), is_owned: true }
4415 pub extern "C" fn FundingLocked_write(obj: &FundingLocked) -> crate::c_types::derived::CVec_u8Z {
4416 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4419 pub(crate) extern "C" fn FundingLocked_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4420 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingLocked) })
4423 pub extern "C" fn FundingLocked_read(ser: crate::c_types::u8slice) -> FundingLocked {
4424 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4425 FundingLocked { inner: Box::into_raw(Box::new(res)), is_owned: true }
4427 FundingLocked { inner: std::ptr::null_mut(), is_owned: true }
4431 pub extern "C" fn Init_write(obj: &Init) -> crate::c_types::derived::CVec_u8Z {
4432 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4435 pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4436 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInit) })
4439 pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitDecodeErrorZ {
4440 let res = crate::c_types::deserialize_obj(ser);
4441 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 } }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) };
4445 pub extern "C" fn OpenChannel_write(obj: &OpenChannel) -> crate::c_types::derived::CVec_u8Z {
4446 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4449 pub(crate) extern "C" fn OpenChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4450 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannel) })
4453 pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> OpenChannel {
4454 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4455 OpenChannel { inner: Box::into_raw(Box::new(res)), is_owned: true }
4457 OpenChannel { inner: std::ptr::null_mut(), is_owned: true }
4461 pub extern "C" fn RevokeAndACK_write(obj: &RevokeAndACK) -> crate::c_types::derived::CVec_u8Z {
4462 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4465 pub(crate) extern "C" fn RevokeAndACK_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4466 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevokeAndACK) })
4469 pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> RevokeAndACK {
4470 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4471 RevokeAndACK { inner: Box::into_raw(Box::new(res)), is_owned: true }
4473 RevokeAndACK { inner: std::ptr::null_mut(), is_owned: true }
4477 pub extern "C" fn Shutdown_write(obj: &Shutdown) -> crate::c_types::derived::CVec_u8Z {
4478 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4481 pub(crate) extern "C" fn Shutdown_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4482 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeShutdown) })
4485 pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> Shutdown {
4486 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4487 Shutdown { inner: Box::into_raw(Box::new(res)), is_owned: true }
4489 Shutdown { inner: std::ptr::null_mut(), is_owned: true }
4493 pub extern "C" fn UpdateFailHTLC_write(obj: &UpdateFailHTLC) -> crate::c_types::derived::CVec_u8Z {
4494 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4497 pub(crate) extern "C" fn UpdateFailHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4498 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailHTLC) })
4501 pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> UpdateFailHTLC {
4502 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4503 UpdateFailHTLC { inner: Box::into_raw(Box::new(res)), is_owned: true }
4505 UpdateFailHTLC { inner: std::ptr::null_mut(), is_owned: true }
4509 pub extern "C" fn UpdateFailMalformedHTLC_write(obj: &UpdateFailMalformedHTLC) -> crate::c_types::derived::CVec_u8Z {
4510 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4513 pub(crate) extern "C" fn UpdateFailMalformedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4514 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailMalformedHTLC) })
4517 pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> UpdateFailMalformedHTLC {
4518 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4519 UpdateFailMalformedHTLC { inner: Box::into_raw(Box::new(res)), is_owned: true }
4521 UpdateFailMalformedHTLC { inner: std::ptr::null_mut(), is_owned: true }
4525 pub extern "C" fn UpdateFee_write(obj: &UpdateFee) -> crate::c_types::derived::CVec_u8Z {
4526 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4529 pub(crate) extern "C" fn UpdateFee_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4530 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFee) })
4533 pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> UpdateFee {
4534 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4535 UpdateFee { inner: Box::into_raw(Box::new(res)), is_owned: true }
4537 UpdateFee { inner: std::ptr::null_mut(), is_owned: true }
4541 pub extern "C" fn UpdateFulfillHTLC_write(obj: &UpdateFulfillHTLC) -> crate::c_types::derived::CVec_u8Z {
4542 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4545 pub(crate) extern "C" fn UpdateFulfillHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4546 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFulfillHTLC) })
4549 pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> UpdateFulfillHTLC {
4550 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4551 UpdateFulfillHTLC { inner: Box::into_raw(Box::new(res)), is_owned: true }
4553 UpdateFulfillHTLC { inner: std::ptr::null_mut(), is_owned: true }
4557 pub extern "C" fn UpdateAddHTLC_write(obj: &UpdateAddHTLC) -> crate::c_types::derived::CVec_u8Z {
4558 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4561 pub(crate) extern "C" fn UpdateAddHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4562 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateAddHTLC) })
4565 pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> UpdateAddHTLC {
4566 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4567 UpdateAddHTLC { inner: Box::into_raw(Box::new(res)), is_owned: true }
4569 UpdateAddHTLC { inner: std::ptr::null_mut(), is_owned: true }
4573 pub extern "C" fn Ping_write(obj: &Ping) -> crate::c_types::derived::CVec_u8Z {
4574 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4577 pub(crate) extern "C" fn Ping_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4578 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePing) })
4581 pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PingDecodeErrorZ {
4582 let res = crate::c_types::deserialize_obj(ser);
4583 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 } }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) };
4587 pub extern "C" fn Pong_write(obj: &Pong) -> crate::c_types::derived::CVec_u8Z {
4588 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4591 pub(crate) extern "C" fn Pong_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4592 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePong) })
4595 pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PongDecodeErrorZ {
4596 let res = crate::c_types::deserialize_obj(ser);
4597 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 } }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) };
4601 pub extern "C" fn UnsignedChannelAnnouncement_write(obj: &UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
4602 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4605 pub(crate) extern "C" fn UnsignedChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4606 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelAnnouncement) })
4609 pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelAnnouncementDecodeErrorZ {
4610 let res = crate::c_types::deserialize_obj(ser);
4611 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 } }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) };
4615 pub extern "C" fn ChannelAnnouncement_write(obj: &ChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
4616 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4619 pub(crate) extern "C" fn ChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4620 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelAnnouncement) })
4623 pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> ChannelAnnouncement {
4624 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4625 ChannelAnnouncement { inner: Box::into_raw(Box::new(res)), is_owned: true }
4627 ChannelAnnouncement { inner: std::ptr::null_mut(), is_owned: true }
4631 pub extern "C" fn UnsignedChannelUpdate_write(obj: &UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
4632 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4635 pub(crate) extern "C" fn UnsignedChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4636 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelUpdate) })
4639 pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelUpdateDecodeErrorZ {
4640 let res = crate::c_types::deserialize_obj(ser);
4641 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 } }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) };
4645 pub extern "C" fn ChannelUpdate_write(obj: &ChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
4646 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4649 pub(crate) extern "C" fn ChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4650 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdate) })
4653 pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> ChannelUpdate {
4654 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4655 ChannelUpdate { inner: Box::into_raw(Box::new(res)), is_owned: true }
4657 ChannelUpdate { inner: std::ptr::null_mut(), is_owned: true }
4661 pub extern "C" fn ErrorMessage_write(obj: &ErrorMessage) -> crate::c_types::derived::CVec_u8Z {
4662 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4665 pub(crate) extern "C" fn ErrorMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4666 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeErrorMessage) })
4669 pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ErrorMessageDecodeErrorZ {
4670 let res = crate::c_types::deserialize_obj(ser);
4671 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 } }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) };
4675 pub extern "C" fn UnsignedNodeAnnouncement_write(obj: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
4676 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4679 pub(crate) extern "C" fn UnsignedNodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4680 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedNodeAnnouncement) })
4683 pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedNodeAnnouncementDecodeErrorZ {
4684 let res = crate::c_types::deserialize_obj(ser);
4685 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 } }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) };
4689 pub extern "C" fn NodeAnnouncement_write(obj: &NodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
4690 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4693 pub(crate) extern "C" fn NodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4694 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncement) })
4697 pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> NodeAnnouncement {
4698 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4699 NodeAnnouncement { inner: Box::into_raw(Box::new(res)), is_owned: true }
4701 NodeAnnouncement { inner: std::ptr::null_mut(), is_owned: true }
4705 pub extern "C" fn QueryShortChannelIds_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryShortChannelIdsDecodeErrorZ {
4706 let res = crate::c_types::deserialize_obj(ser);
4707 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 } }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) };
4711 pub extern "C" fn QueryShortChannelIds_write(obj: &QueryShortChannelIds) -> crate::c_types::derived::CVec_u8Z {
4712 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4715 pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4716 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) })
4719 pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyShortChannelIdsEndDecodeErrorZ {
4720 let res = crate::c_types::deserialize_obj(ser);
4721 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 } }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) };
4725 pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z {
4726 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4729 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4730 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) })
4733 pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ {
4734 let res = crate::c_types::deserialize_obj(ser);
4735 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 } }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) };
4739 pub extern "C" fn QueryChannelRange_write(obj: &QueryChannelRange) -> crate::c_types::derived::CVec_u8Z {
4740 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4743 pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4744 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) })
4747 pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyChannelRangeDecodeErrorZ {
4748 let res = crate::c_types::deserialize_obj(ser);
4749 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 } }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) };
4753 pub extern "C" fn ReplyChannelRange_write(obj: &ReplyChannelRange) -> crate::c_types::derived::CVec_u8Z {
4754 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4757 pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4758 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) })
4761 pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_GossipTimestampFilterDecodeErrorZ {
4762 let res = crate::c_types::deserialize_obj(ser);
4763 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 } }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) };
4767 pub extern "C" fn GossipTimestampFilter_write(obj: &GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z {
4768 crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
4771 pub(crate) extern "C" fn GossipTimestampFilter_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4772 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeGossipTimestampFilter) })