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 use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport;
2412 type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport;
2414 /// The unsigned part of a node_announcement
2417 pub struct UnsignedNodeAnnouncement {
2418 /// Nearly everywhere, inner must be non-null, however in places where
2419 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2420 pub inner: *mut nativeUnsignedNodeAnnouncement,
2424 impl Drop for UnsignedNodeAnnouncement {
2425 fn drop(&mut self) {
2426 if self.is_owned && !self.inner.is_null() {
2427 let _ = unsafe { Box::from_raw(self.inner) };
2432 pub extern "C" fn UnsignedNodeAnnouncement_free(this_ptr: UnsignedNodeAnnouncement) { }
2434 /// Used only if an object of this type is returned as a trait impl by a method
2435 extern "C" fn UnsignedNodeAnnouncement_free_void(this_ptr: *mut c_void) {
2436 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedNodeAnnouncement); }
2439 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2440 impl UnsignedNodeAnnouncement {
2441 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedNodeAnnouncement {
2442 assert!(self.is_owned);
2443 let ret = self.inner;
2444 self.inner = std::ptr::null_mut();
2448 impl Clone for UnsignedNodeAnnouncement {
2449 fn clone(&self) -> Self {
2451 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
2457 /// Used only if an object of this type is returned as a trait impl by a method
2458 pub(crate) extern "C" fn UnsignedNodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
2459 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedNodeAnnouncement)).clone() })) as *mut c_void
2462 pub extern "C" fn UnsignedNodeAnnouncement_clone(orig: &UnsignedNodeAnnouncement) -> UnsignedNodeAnnouncement {
2463 UnsignedNodeAnnouncement { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
2465 /// The advertised features
2467 pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::ln::features::NodeFeatures {
2468 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features;
2469 crate::ln::features::NodeFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
2471 /// The advertised features
2473 pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::ln::features::NodeFeatures) {
2474 unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_inner()) };
2476 /// A strictly monotonic announcement counter, with gaps allowed
2478 pub extern "C" fn UnsignedNodeAnnouncement_get_timestamp(this_ptr: &UnsignedNodeAnnouncement) -> u32 {
2479 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp;
2482 /// A strictly monotonic announcement counter, with gaps allowed
2484 pub extern "C" fn UnsignedNodeAnnouncement_set_timestamp(this_ptr: &mut UnsignedNodeAnnouncement, mut val: u32) {
2485 unsafe { &mut *this_ptr.inner }.timestamp = val;
2487 /// The node_id this announcement originated from (don't rebroadcast the node_announcement back
2490 pub extern "C" fn UnsignedNodeAnnouncement_get_node_id(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::PublicKey {
2491 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_id;
2492 crate::c_types::PublicKey::from_rust(&(*inner_val))
2494 /// The node_id this announcement originated from (don't rebroadcast the node_announcement back
2497 pub extern "C" fn UnsignedNodeAnnouncement_set_node_id(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::PublicKey) {
2498 unsafe { &mut *this_ptr.inner }.node_id = val.into_rust();
2500 /// An RGB color for UI purposes
2502 pub extern "C" fn UnsignedNodeAnnouncement_get_rgb(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 3] {
2503 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.rgb;
2506 /// An RGB color for UI purposes
2508 pub extern "C" fn UnsignedNodeAnnouncement_set_rgb(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThreeBytes) {
2509 unsafe { &mut *this_ptr.inner }.rgb = val.data;
2511 /// An alias, for UI purposes. This should be sanitized before use. There is no guarantee
2514 pub extern "C" fn UnsignedNodeAnnouncement_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 32] {
2515 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.alias;
2518 /// An alias, for UI purposes. This should be sanitized before use. There is no guarantee
2521 pub extern "C" fn UnsignedNodeAnnouncement_set_alias(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
2522 unsafe { &mut *this_ptr.inner }.alias = val.data;
2524 /// List of addresses on which this node is reachable
2526 pub extern "C" fn UnsignedNodeAnnouncement_set_addresses(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_NetAddressZ) {
2527 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); };
2528 unsafe { &mut *this_ptr.inner }.addresses = local_val;
2531 use lightning::ln::msgs::NodeAnnouncement as nativeNodeAnnouncementImport;
2532 type nativeNodeAnnouncement = nativeNodeAnnouncementImport;
2534 /// A node_announcement message to be sent or received from a peer
2537 pub struct NodeAnnouncement {
2538 /// Nearly everywhere, inner must be non-null, however in places where
2539 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2540 pub inner: *mut nativeNodeAnnouncement,
2544 impl Drop for NodeAnnouncement {
2545 fn drop(&mut self) {
2546 if self.is_owned && !self.inner.is_null() {
2547 let _ = unsafe { Box::from_raw(self.inner) };
2552 pub extern "C" fn NodeAnnouncement_free(this_ptr: NodeAnnouncement) { }
2554 /// Used only if an object of this type is returned as a trait impl by a method
2555 extern "C" fn NodeAnnouncement_free_void(this_ptr: *mut c_void) {
2556 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeAnnouncement); }
2559 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2560 impl NodeAnnouncement {
2561 pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncement {
2562 assert!(self.is_owned);
2563 let ret = self.inner;
2564 self.inner = std::ptr::null_mut();
2568 impl Clone for NodeAnnouncement {
2569 fn clone(&self) -> Self {
2571 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
2577 /// Used only if an object of this type is returned as a trait impl by a method
2578 pub(crate) extern "C" fn NodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
2579 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNodeAnnouncement)).clone() })) as *mut c_void
2582 pub extern "C" fn NodeAnnouncement_clone(orig: &NodeAnnouncement) -> NodeAnnouncement {
2583 NodeAnnouncement { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
2585 /// The signature by the node key
2587 pub extern "C" fn NodeAnnouncement_get_signature(this_ptr: &NodeAnnouncement) -> crate::c_types::Signature {
2588 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
2589 crate::c_types::Signature::from_rust(&(*inner_val))
2591 /// The signature by the node key
2593 pub extern "C" fn NodeAnnouncement_set_signature(this_ptr: &mut NodeAnnouncement, mut val: crate::c_types::Signature) {
2594 unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
2596 /// The actual content of the announcement
2598 pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> crate::ln::msgs::UnsignedNodeAnnouncement {
2599 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents;
2600 crate::ln::msgs::UnsignedNodeAnnouncement { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
2602 /// The actual content of the announcement
2604 pub extern "C" fn NodeAnnouncement_set_contents(this_ptr: &mut NodeAnnouncement, mut val: crate::ln::msgs::UnsignedNodeAnnouncement) {
2605 unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_inner()) };
2609 pub extern "C" fn NodeAnnouncement_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::ln::msgs::UnsignedNodeAnnouncement) -> NodeAnnouncement {
2610 NodeAnnouncement { inner: Box::into_raw(Box::new(nativeNodeAnnouncement {
2611 signature: signature_arg.into_rust(),
2612 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
2613 })), is_owned: true }
2616 use lightning::ln::msgs::UnsignedChannelAnnouncement as nativeUnsignedChannelAnnouncementImport;
2617 type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport;
2619 /// The unsigned part of a channel_announcement
2622 pub struct UnsignedChannelAnnouncement {
2623 /// Nearly everywhere, inner must be non-null, however in places where
2624 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2625 pub inner: *mut nativeUnsignedChannelAnnouncement,
2629 impl Drop for UnsignedChannelAnnouncement {
2630 fn drop(&mut self) {
2631 if self.is_owned && !self.inner.is_null() {
2632 let _ = unsafe { Box::from_raw(self.inner) };
2637 pub extern "C" fn UnsignedChannelAnnouncement_free(this_ptr: UnsignedChannelAnnouncement) { }
2639 /// Used only if an object of this type is returned as a trait impl by a method
2640 extern "C" fn UnsignedChannelAnnouncement_free_void(this_ptr: *mut c_void) {
2641 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelAnnouncement); }
2644 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2645 impl UnsignedChannelAnnouncement {
2646 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelAnnouncement {
2647 assert!(self.is_owned);
2648 let ret = self.inner;
2649 self.inner = std::ptr::null_mut();
2653 impl Clone for UnsignedChannelAnnouncement {
2654 fn clone(&self) -> Self {
2656 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
2662 /// Used only if an object of this type is returned as a trait impl by a method
2663 pub(crate) extern "C" fn UnsignedChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
2664 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelAnnouncement)).clone() })) as *mut c_void
2667 pub extern "C" fn UnsignedChannelAnnouncement_clone(orig: &UnsignedChannelAnnouncement) -> UnsignedChannelAnnouncement {
2668 UnsignedChannelAnnouncement { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
2670 /// The advertised channel features
2672 pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::ln::features::ChannelFeatures {
2673 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features;
2674 crate::ln::features::ChannelFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
2676 /// The advertised channel features
2678 pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::ln::features::ChannelFeatures) {
2679 unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_inner()) };
2681 /// The genesis hash of the blockchain where the channel is to be opened
2683 pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &UnsignedChannelAnnouncement) -> *const [u8; 32] {
2684 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
2685 (*inner_val).as_inner()
2687 /// The genesis hash of the blockchain where the channel is to be opened
2689 pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) {
2690 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
2692 /// The short channel ID
2694 pub extern "C" fn UnsignedChannelAnnouncement_get_short_channel_id(this_ptr: &UnsignedChannelAnnouncement) -> u64 {
2695 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id;
2698 /// The short channel ID
2700 pub extern "C" fn UnsignedChannelAnnouncement_set_short_channel_id(this_ptr: &mut UnsignedChannelAnnouncement, mut val: u64) {
2701 unsafe { &mut *this_ptr.inner }.short_channel_id = val;
2703 /// One of the two node_ids which are endpoints of this channel
2705 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
2706 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_id_1;
2707 crate::c_types::PublicKey::from_rust(&(*inner_val))
2709 /// One of the two node_ids which are endpoints of this channel
2711 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
2712 unsafe { &mut *this_ptr.inner }.node_id_1 = val.into_rust();
2714 /// The other of the two node_ids which are endpoints of this channel
2716 pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
2717 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_id_2;
2718 crate::c_types::PublicKey::from_rust(&(*inner_val))
2720 /// The other of the two node_ids which are endpoints of this channel
2722 pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
2723 unsafe { &mut *this_ptr.inner }.node_id_2 = val.into_rust();
2725 /// The funding key for the first node
2727 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
2728 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_key_1;
2729 crate::c_types::PublicKey::from_rust(&(*inner_val))
2731 /// The funding key for the first node
2733 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
2734 unsafe { &mut *this_ptr.inner }.bitcoin_key_1 = val.into_rust();
2736 /// The funding key for the second node
2738 pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey {
2739 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_key_2;
2740 crate::c_types::PublicKey::from_rust(&(*inner_val))
2742 /// The funding key for the second node
2744 pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_2(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::PublicKey) {
2745 unsafe { &mut *this_ptr.inner }.bitcoin_key_2 = val.into_rust();
2748 use lightning::ln::msgs::ChannelAnnouncement as nativeChannelAnnouncementImport;
2749 type nativeChannelAnnouncement = nativeChannelAnnouncementImport;
2751 /// A channel_announcement message to be sent or received from a peer
2754 pub struct ChannelAnnouncement {
2755 /// Nearly everywhere, inner must be non-null, however in places where
2756 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2757 pub inner: *mut nativeChannelAnnouncement,
2761 impl Drop for ChannelAnnouncement {
2762 fn drop(&mut self) {
2763 if self.is_owned && !self.inner.is_null() {
2764 let _ = unsafe { Box::from_raw(self.inner) };
2769 pub extern "C" fn ChannelAnnouncement_free(this_ptr: ChannelAnnouncement) { }
2771 /// Used only if an object of this type is returned as a trait impl by a method
2772 extern "C" fn ChannelAnnouncement_free_void(this_ptr: *mut c_void) {
2773 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelAnnouncement); }
2776 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2777 impl ChannelAnnouncement {
2778 pub(crate) fn take_inner(mut self) -> *mut nativeChannelAnnouncement {
2779 assert!(self.is_owned);
2780 let ret = self.inner;
2781 self.inner = std::ptr::null_mut();
2785 impl Clone for ChannelAnnouncement {
2786 fn clone(&self) -> Self {
2788 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
2794 /// Used only if an object of this type is returned as a trait impl by a method
2795 pub(crate) extern "C" fn ChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
2796 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelAnnouncement)).clone() })) as *mut c_void
2799 pub extern "C" fn ChannelAnnouncement_clone(orig: &ChannelAnnouncement) -> ChannelAnnouncement {
2800 ChannelAnnouncement { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
2802 /// Authentication of the announcement by the first public node
2804 pub extern "C" fn ChannelAnnouncement_get_node_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
2805 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_signature_1;
2806 crate::c_types::Signature::from_rust(&(*inner_val))
2808 /// Authentication of the announcement by the first public node
2810 pub extern "C" fn ChannelAnnouncement_set_node_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
2811 unsafe { &mut *this_ptr.inner }.node_signature_1 = val.into_rust();
2813 /// Authentication of the announcement by the second public node
2815 pub extern "C" fn ChannelAnnouncement_get_node_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
2816 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_signature_2;
2817 crate::c_types::Signature::from_rust(&(*inner_val))
2819 /// Authentication of the announcement by the second public node
2821 pub extern "C" fn ChannelAnnouncement_set_node_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
2822 unsafe { &mut *this_ptr.inner }.node_signature_2 = val.into_rust();
2824 /// Proof of funding UTXO ownership by the first public node
2826 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
2827 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_signature_1;
2828 crate::c_types::Signature::from_rust(&(*inner_val))
2830 /// Proof of funding UTXO ownership by the first public node
2832 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_1(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
2833 unsafe { &mut *this_ptr.inner }.bitcoin_signature_1 = val.into_rust();
2835 /// Proof of funding UTXO ownership by the second public node
2837 pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature {
2838 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_signature_2;
2839 crate::c_types::Signature::from_rust(&(*inner_val))
2841 /// Proof of funding UTXO ownership by the second public node
2843 pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_2(this_ptr: &mut ChannelAnnouncement, mut val: crate::c_types::Signature) {
2844 unsafe { &mut *this_ptr.inner }.bitcoin_signature_2 = val.into_rust();
2846 /// The actual announcement
2848 pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncement) -> crate::ln::msgs::UnsignedChannelAnnouncement {
2849 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents;
2850 crate::ln::msgs::UnsignedChannelAnnouncement { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
2852 /// The actual announcement
2854 pub extern "C" fn ChannelAnnouncement_set_contents(this_ptr: &mut ChannelAnnouncement, mut val: crate::ln::msgs::UnsignedChannelAnnouncement) {
2855 unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_inner()) };
2859 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 {
2860 ChannelAnnouncement { inner: Box::into_raw(Box::new(nativeChannelAnnouncement {
2861 node_signature_1: node_signature_1_arg.into_rust(),
2862 node_signature_2: node_signature_2_arg.into_rust(),
2863 bitcoin_signature_1: bitcoin_signature_1_arg.into_rust(),
2864 bitcoin_signature_2: bitcoin_signature_2_arg.into_rust(),
2865 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
2866 })), is_owned: true }
2869 use lightning::ln::msgs::UnsignedChannelUpdate as nativeUnsignedChannelUpdateImport;
2870 type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport;
2872 /// The unsigned part of a channel_update
2875 pub struct UnsignedChannelUpdate {
2876 /// Nearly everywhere, inner must be non-null, however in places where
2877 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2878 pub inner: *mut nativeUnsignedChannelUpdate,
2882 impl Drop for UnsignedChannelUpdate {
2883 fn drop(&mut self) {
2884 if self.is_owned && !self.inner.is_null() {
2885 let _ = unsafe { Box::from_raw(self.inner) };
2890 pub extern "C" fn UnsignedChannelUpdate_free(this_ptr: UnsignedChannelUpdate) { }
2892 /// Used only if an object of this type is returned as a trait impl by a method
2893 extern "C" fn UnsignedChannelUpdate_free_void(this_ptr: *mut c_void) {
2894 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelUpdate); }
2897 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2898 impl UnsignedChannelUpdate {
2899 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelUpdate {
2900 assert!(self.is_owned);
2901 let ret = self.inner;
2902 self.inner = std::ptr::null_mut();
2906 impl Clone for UnsignedChannelUpdate {
2907 fn clone(&self) -> Self {
2909 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
2915 /// Used only if an object of this type is returned as a trait impl by a method
2916 pub(crate) extern "C" fn UnsignedChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
2917 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelUpdate)).clone() })) as *mut c_void
2920 pub extern "C" fn UnsignedChannelUpdate_clone(orig: &UnsignedChannelUpdate) -> UnsignedChannelUpdate {
2921 UnsignedChannelUpdate { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
2923 /// The genesis hash of the blockchain where the channel is to be opened
2925 pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChannelUpdate) -> *const [u8; 32] {
2926 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
2927 (*inner_val).as_inner()
2929 /// The genesis hash of the blockchain where the channel is to be opened
2931 pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::ThirtyTwoBytes) {
2932 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
2934 /// The short channel ID
2936 pub extern "C" fn UnsignedChannelUpdate_get_short_channel_id(this_ptr: &UnsignedChannelUpdate) -> u64 {
2937 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id;
2940 /// The short channel ID
2942 pub extern "C" fn UnsignedChannelUpdate_set_short_channel_id(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
2943 unsafe { &mut *this_ptr.inner }.short_channel_id = val;
2945 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
2947 pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannelUpdate) -> u32 {
2948 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp;
2951 /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
2953 pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
2954 unsafe { &mut *this_ptr.inner }.timestamp = val;
2958 pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 {
2959 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.flags;
2964 pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) {
2965 unsafe { &mut *this_ptr.inner }.flags = val;
2967 /// The number of blocks to subtract from incoming HTLC cltv_expiry values
2969 pub extern "C" fn UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr: &UnsignedChannelUpdate) -> u16 {
2970 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry_delta;
2973 /// The number of blocks to subtract from incoming HTLC cltv_expiry values
2975 pub extern "C" fn UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr: &mut UnsignedChannelUpdate, mut val: u16) {
2976 unsafe { &mut *this_ptr.inner }.cltv_expiry_delta = val;
2978 /// The minimum HTLC size incoming to sender, in milli-satoshi
2980 pub extern "C" fn UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 {
2981 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_minimum_msat;
2984 /// The minimum HTLC size incoming to sender, in milli-satoshi
2986 pub extern "C" fn UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u64) {
2987 unsafe { &mut *this_ptr.inner }.htlc_minimum_msat = val;
2989 /// The base HTLC fee charged by sender, in milli-satoshi
2991 pub extern "C" fn UnsignedChannelUpdate_get_fee_base_msat(this_ptr: &UnsignedChannelUpdate) -> u32 {
2992 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_base_msat;
2995 /// The base HTLC fee charged by sender, in milli-satoshi
2997 pub extern "C" fn UnsignedChannelUpdate_set_fee_base_msat(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
2998 unsafe { &mut *this_ptr.inner }.fee_base_msat = val;
3000 /// The amount to fee multiplier, in micro-satoshi
3002 pub extern "C" fn UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr: &UnsignedChannelUpdate) -> u32 {
3003 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_proportional_millionths;
3006 /// The amount to fee multiplier, in micro-satoshi
3008 pub extern "C" fn UnsignedChannelUpdate_set_fee_proportional_millionths(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) {
3009 unsafe { &mut *this_ptr.inner }.fee_proportional_millionths = val;
3012 use lightning::ln::msgs::ChannelUpdate as nativeChannelUpdateImport;
3013 type nativeChannelUpdate = nativeChannelUpdateImport;
3015 /// A channel_update message to be sent or received from a peer
3018 pub struct ChannelUpdate {
3019 /// Nearly everywhere, inner must be non-null, however in places where
3020 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3021 pub inner: *mut nativeChannelUpdate,
3025 impl Drop for ChannelUpdate {
3026 fn drop(&mut self) {
3027 if self.is_owned && !self.inner.is_null() {
3028 let _ = unsafe { Box::from_raw(self.inner) };
3033 pub extern "C" fn ChannelUpdate_free(this_ptr: ChannelUpdate) { }
3035 /// Used only if an object of this type is returned as a trait impl by a method
3036 extern "C" fn ChannelUpdate_free_void(this_ptr: *mut c_void) {
3037 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelUpdate); }
3040 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3041 impl ChannelUpdate {
3042 pub(crate) fn take_inner(mut self) -> *mut nativeChannelUpdate {
3043 assert!(self.is_owned);
3044 let ret = self.inner;
3045 self.inner = std::ptr::null_mut();
3049 impl Clone for ChannelUpdate {
3050 fn clone(&self) -> Self {
3052 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
3058 /// Used only if an object of this type is returned as a trait impl by a method
3059 pub(crate) extern "C" fn ChannelUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
3060 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelUpdate)).clone() })) as *mut c_void
3063 pub extern "C" fn ChannelUpdate_clone(orig: &ChannelUpdate) -> ChannelUpdate {
3064 ChannelUpdate { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
3066 /// A signature of the channel update
3068 pub extern "C" fn ChannelUpdate_get_signature(this_ptr: &ChannelUpdate) -> crate::c_types::Signature {
3069 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature;
3070 crate::c_types::Signature::from_rust(&(*inner_val))
3072 /// A signature of the channel update
3074 pub extern "C" fn ChannelUpdate_set_signature(this_ptr: &mut ChannelUpdate, mut val: crate::c_types::Signature) {
3075 unsafe { &mut *this_ptr.inner }.signature = val.into_rust();
3077 /// The actual channel update
3079 pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate::ln::msgs::UnsignedChannelUpdate {
3080 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents;
3081 crate::ln::msgs::UnsignedChannelUpdate { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
3083 /// The actual channel update
3085 pub extern "C" fn ChannelUpdate_set_contents(this_ptr: &mut ChannelUpdate, mut val: crate::ln::msgs::UnsignedChannelUpdate) {
3086 unsafe { &mut *this_ptr.inner }.contents = *unsafe { Box::from_raw(val.take_inner()) };
3090 pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::Signature, mut contents_arg: crate::ln::msgs::UnsignedChannelUpdate) -> ChannelUpdate {
3091 ChannelUpdate { inner: Box::into_raw(Box::new(nativeChannelUpdate {
3092 signature: signature_arg.into_rust(),
3093 contents: *unsafe { Box::from_raw(contents_arg.take_inner()) },
3094 })), is_owned: true }
3097 use lightning::ln::msgs::QueryChannelRange as nativeQueryChannelRangeImport;
3098 type nativeQueryChannelRange = nativeQueryChannelRangeImport;
3100 /// A query_channel_range message is used to query a peer for channel
3101 /// UTXOs in a range of blocks. The recipient of a query makes a best
3102 /// effort to reply to the query using one or more reply_channel_range
3106 pub struct QueryChannelRange {
3107 /// Nearly everywhere, inner must be non-null, however in places where
3108 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3109 pub inner: *mut nativeQueryChannelRange,
3113 impl Drop for QueryChannelRange {
3114 fn drop(&mut self) {
3115 if self.is_owned && !self.inner.is_null() {
3116 let _ = unsafe { Box::from_raw(self.inner) };
3121 pub extern "C" fn QueryChannelRange_free(this_ptr: QueryChannelRange) { }
3123 /// Used only if an object of this type is returned as a trait impl by a method
3124 extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) {
3125 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryChannelRange); }
3128 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3129 impl QueryChannelRange {
3130 pub(crate) fn take_inner(mut self) -> *mut nativeQueryChannelRange {
3131 assert!(self.is_owned);
3132 let ret = self.inner;
3133 self.inner = std::ptr::null_mut();
3137 impl Clone for QueryChannelRange {
3138 fn clone(&self) -> Self {
3140 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
3146 /// Used only if an object of this type is returned as a trait impl by a method
3147 pub(crate) extern "C" fn QueryChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
3148 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryChannelRange)).clone() })) as *mut c_void
3151 pub extern "C" fn QueryChannelRange_clone(orig: &QueryChannelRange) -> QueryChannelRange {
3152 QueryChannelRange { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
3154 /// The genesis hash of the blockchain being queried
3156 pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *const [u8; 32] {
3157 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3158 (*inner_val).as_inner()
3160 /// The genesis hash of the blockchain being queried
3162 pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
3163 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3165 /// The height of the first block for the channel UTXOs being queried
3167 pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 {
3168 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_blocknum;
3171 /// The height of the first block for the channel UTXOs being queried
3173 pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChannelRange, mut val: u32) {
3174 unsafe { &mut *this_ptr.inner }.first_blocknum = val;
3176 /// The number of blocks to include in the query results
3178 pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 {
3179 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.number_of_blocks;
3182 /// The number of blocks to include in the query results
3184 pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryChannelRange, mut val: u32) {
3185 unsafe { &mut *this_ptr.inner }.number_of_blocks = val;
3189 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 {
3190 QueryChannelRange { inner: Box::into_raw(Box::new(nativeQueryChannelRange {
3191 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3192 first_blocknum: first_blocknum_arg,
3193 number_of_blocks: number_of_blocks_arg,
3194 })), is_owned: true }
3197 use lightning::ln::msgs::ReplyChannelRange as nativeReplyChannelRangeImport;
3198 type nativeReplyChannelRange = nativeReplyChannelRangeImport;
3200 /// A reply_channel_range message is a reply to a query_channel_range
3201 /// message. Multiple reply_channel_range messages can be sent in reply
3202 /// to a single query_channel_range message. The query recipient makes a
3203 /// best effort to respond based on their local network view which may
3204 /// not be a perfect view of the network. The short_channel_ids in the
3205 /// reply are encoded. We only support encoding_type=0 uncompressed
3206 /// serialization and do not support encoding_type=1 zlib serialization.
3209 pub struct ReplyChannelRange {
3210 /// Nearly everywhere, inner must be non-null, however in places where
3211 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3212 pub inner: *mut nativeReplyChannelRange,
3216 impl Drop for ReplyChannelRange {
3217 fn drop(&mut self) {
3218 if self.is_owned && !self.inner.is_null() {
3219 let _ = unsafe { Box::from_raw(self.inner) };
3224 pub extern "C" fn ReplyChannelRange_free(this_ptr: ReplyChannelRange) { }
3226 /// Used only if an object of this type is returned as a trait impl by a method
3227 extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) {
3228 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyChannelRange); }
3231 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3232 impl ReplyChannelRange {
3233 pub(crate) fn take_inner(mut self) -> *mut nativeReplyChannelRange {
3234 assert!(self.is_owned);
3235 let ret = self.inner;
3236 self.inner = std::ptr::null_mut();
3240 impl Clone for ReplyChannelRange {
3241 fn clone(&self) -> Self {
3243 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
3249 /// Used only if an object of this type is returned as a trait impl by a method
3250 pub(crate) extern "C" fn ReplyChannelRange_clone_void(this_ptr: *const c_void) -> *mut c_void {
3251 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyChannelRange)).clone() })) as *mut c_void
3254 pub extern "C" fn ReplyChannelRange_clone(orig: &ReplyChannelRange) -> ReplyChannelRange {
3255 ReplyChannelRange { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
3257 /// The genesis hash of the blockchain being queried
3259 pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *const [u8; 32] {
3260 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3261 (*inner_val).as_inner()
3263 /// The genesis hash of the blockchain being queried
3265 pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) {
3266 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3268 /// The height of the first block in the range of the reply
3270 pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 {
3271 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_blocknum;
3274 /// The height of the first block in the range of the reply
3276 pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChannelRange, mut val: u32) {
3277 unsafe { &mut *this_ptr.inner }.first_blocknum = val;
3279 /// The number of blocks included in the range of the reply
3281 pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 {
3282 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.number_of_blocks;
3285 /// The number of blocks included in the range of the reply
3287 pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyChannelRange, mut val: u32) {
3288 unsafe { &mut *this_ptr.inner }.number_of_blocks = val;
3290 /// Indicates if the query recipient maintains up-to-date channel
3291 /// information for the chain_hash
3293 pub extern "C" fn ReplyChannelRange_get_full_information(this_ptr: &ReplyChannelRange) -> bool {
3294 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.full_information;
3297 /// Indicates if the query recipient maintains up-to-date channel
3298 /// information for the chain_hash
3300 pub extern "C" fn ReplyChannelRange_set_full_information(this_ptr: &mut ReplyChannelRange, mut val: bool) {
3301 unsafe { &mut *this_ptr.inner }.full_information = val;
3303 /// The short_channel_ids in the channel range
3305 pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::derived::CVec_u64Z) {
3306 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
3307 unsafe { &mut *this_ptr.inner }.short_channel_ids = local_val;
3311 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 {
3312 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 }); };
3313 ReplyChannelRange { inner: Box::into_raw(Box::new(nativeReplyChannelRange {
3314 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3315 first_blocknum: first_blocknum_arg,
3316 number_of_blocks: number_of_blocks_arg,
3317 full_information: full_information_arg,
3318 short_channel_ids: local_short_channel_ids_arg,
3319 })), is_owned: true }
3322 use lightning::ln::msgs::QueryShortChannelIds as nativeQueryShortChannelIdsImport;
3323 type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport;
3325 /// A query_short_channel_ids message is used to query a peer for
3326 /// routing gossip messages related to one or more short_channel_ids.
3327 /// The query recipient will reply with the latest, if available,
3328 /// channel_announcement, channel_update and node_announcement messages
3329 /// it maintains for the requested short_channel_ids followed by a
3330 /// reply_short_channel_ids_end message. The short_channel_ids sent in
3331 /// this query are encoded. We only support encoding_type=0 uncompressed
3332 /// serialization and do not support encoding_type=1 zlib serialization.
3335 pub struct QueryShortChannelIds {
3336 /// Nearly everywhere, inner must be non-null, however in places where
3337 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3338 pub inner: *mut nativeQueryShortChannelIds,
3342 impl Drop for QueryShortChannelIds {
3343 fn drop(&mut self) {
3344 if self.is_owned && !self.inner.is_null() {
3345 let _ = unsafe { Box::from_raw(self.inner) };
3350 pub extern "C" fn QueryShortChannelIds_free(this_ptr: QueryShortChannelIds) { }
3352 /// Used only if an object of this type is returned as a trait impl by a method
3353 extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) {
3354 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryShortChannelIds); }
3357 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3358 impl QueryShortChannelIds {
3359 pub(crate) fn take_inner(mut self) -> *mut nativeQueryShortChannelIds {
3360 assert!(self.is_owned);
3361 let ret = self.inner;
3362 self.inner = std::ptr::null_mut();
3366 impl Clone for QueryShortChannelIds {
3367 fn clone(&self) -> Self {
3369 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
3375 /// Used only if an object of this type is returned as a trait impl by a method
3376 pub(crate) extern "C" fn QueryShortChannelIds_clone_void(this_ptr: *const c_void) -> *mut c_void {
3377 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQueryShortChannelIds)).clone() })) as *mut c_void
3380 pub extern "C" fn QueryShortChannelIds_clone(orig: &QueryShortChannelIds) -> QueryShortChannelIds {
3381 QueryShortChannelIds { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
3383 /// The genesis hash of the blockchain being queried
3385 pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *const [u8; 32] {
3386 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3387 (*inner_val).as_inner()
3389 /// The genesis hash of the blockchain being queried
3391 pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::ThirtyTwoBytes) {
3392 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3394 /// The short_channel_ids that are being queried
3396 pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::derived::CVec_u64Z) {
3397 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
3398 unsafe { &mut *this_ptr.inner }.short_channel_ids = local_val;
3402 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 {
3403 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 }); };
3404 QueryShortChannelIds { inner: Box::into_raw(Box::new(nativeQueryShortChannelIds {
3405 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3406 short_channel_ids: local_short_channel_ids_arg,
3407 })), is_owned: true }
3410 use lightning::ln::msgs::ReplyShortChannelIdsEnd as nativeReplyShortChannelIdsEndImport;
3411 type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport;
3413 /// A reply_short_channel_ids_end message is sent as a reply to a
3414 /// query_short_channel_ids message. The query recipient makes a best
3415 /// effort to respond based on their local network view which may not be
3416 /// a perfect view of the network.
3419 pub struct ReplyShortChannelIdsEnd {
3420 /// Nearly everywhere, inner must be non-null, however in places where
3421 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3422 pub inner: *mut nativeReplyShortChannelIdsEnd,
3426 impl Drop for ReplyShortChannelIdsEnd {
3427 fn drop(&mut self) {
3428 if self.is_owned && !self.inner.is_null() {
3429 let _ = unsafe { Box::from_raw(self.inner) };
3434 pub extern "C" fn ReplyShortChannelIdsEnd_free(this_ptr: ReplyShortChannelIdsEnd) { }
3436 /// Used only if an object of this type is returned as a trait impl by a method
3437 extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) {
3438 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyShortChannelIdsEnd); }
3441 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3442 impl ReplyShortChannelIdsEnd {
3443 pub(crate) fn take_inner(mut self) -> *mut nativeReplyShortChannelIdsEnd {
3444 assert!(self.is_owned);
3445 let ret = self.inner;
3446 self.inner = std::ptr::null_mut();
3450 impl Clone for ReplyShortChannelIdsEnd {
3451 fn clone(&self) -> Self {
3453 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
3459 /// Used only if an object of this type is returned as a trait impl by a method
3460 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_clone_void(this_ptr: *const c_void) -> *mut c_void {
3461 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReplyShortChannelIdsEnd)).clone() })) as *mut c_void
3464 pub extern "C" fn ReplyShortChannelIdsEnd_clone(orig: &ReplyShortChannelIdsEnd) -> ReplyShortChannelIdsEnd {
3465 ReplyShortChannelIdsEnd { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
3467 /// The genesis hash of the blockchain that was queried
3469 pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *const [u8; 32] {
3470 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3471 (*inner_val).as_inner()
3473 /// The genesis hash of the blockchain that was queried
3475 pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) {
3476 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3478 /// Indicates if the query recipient maintains up-to-date channel
3479 /// information for the chain_hash
3481 pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool {
3482 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.full_information;
3485 /// Indicates if the query recipient maintains up-to-date channel
3486 /// information for the chain_hash
3488 pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: bool) {
3489 unsafe { &mut *this_ptr.inner }.full_information = val;
3493 pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd {
3494 ReplyShortChannelIdsEnd { inner: Box::into_raw(Box::new(nativeReplyShortChannelIdsEnd {
3495 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3496 full_information: full_information_arg,
3497 })), is_owned: true }
3500 use lightning::ln::msgs::GossipTimestampFilter as nativeGossipTimestampFilterImport;
3501 type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport;
3503 /// A gossip_timestamp_filter message is used by a node to request
3504 /// gossip relay for messages in the requested time range when the
3505 /// gossip_queries feature has been negotiated.
3508 pub struct GossipTimestampFilter {
3509 /// Nearly everywhere, inner must be non-null, however in places where
3510 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3511 pub inner: *mut nativeGossipTimestampFilter,
3515 impl Drop for GossipTimestampFilter {
3516 fn drop(&mut self) {
3517 if self.is_owned && !self.inner.is_null() {
3518 let _ = unsafe { Box::from_raw(self.inner) };
3523 pub extern "C" fn GossipTimestampFilter_free(this_ptr: GossipTimestampFilter) { }
3525 /// Used only if an object of this type is returned as a trait impl by a method
3526 extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) {
3527 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeGossipTimestampFilter); }
3530 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3531 impl GossipTimestampFilter {
3532 pub(crate) fn take_inner(mut self) -> *mut nativeGossipTimestampFilter {
3533 assert!(self.is_owned);
3534 let ret = self.inner;
3535 self.inner = std::ptr::null_mut();
3539 impl Clone for GossipTimestampFilter {
3540 fn clone(&self) -> Self {
3542 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
3548 /// Used only if an object of this type is returned as a trait impl by a method
3549 pub(crate) extern "C" fn GossipTimestampFilter_clone_void(this_ptr: *const c_void) -> *mut c_void {
3550 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeGossipTimestampFilter)).clone() })) as *mut c_void
3553 pub extern "C" fn GossipTimestampFilter_clone(orig: &GossipTimestampFilter) -> GossipTimestampFilter {
3554 GossipTimestampFilter { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
3556 /// The genesis hash of the blockchain for channel and node information
3558 pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *const [u8; 32] {
3559 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash;
3560 (*inner_val).as_inner()
3562 /// The genesis hash of the blockchain for channel and node information
3564 pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) {
3565 unsafe { &mut *this_ptr.inner }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap();
3567 /// The starting unix timestamp
3569 pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 {
3570 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_timestamp;
3573 /// The starting unix timestamp
3575 pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
3576 unsafe { &mut *this_ptr.inner }.first_timestamp = val;
3578 /// The range of information in seconds
3580 pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 {
3581 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp_range;
3584 /// The range of information in seconds
3586 pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut GossipTimestampFilter, mut val: u32) {
3587 unsafe { &mut *this_ptr.inner }.timestamp_range = val;
3591 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 {
3592 GossipTimestampFilter { inner: Box::into_raw(Box::new(nativeGossipTimestampFilter {
3593 chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(),
3594 first_timestamp: first_timestamp_arg,
3595 timestamp_range: timestamp_range_arg,
3596 })), is_owned: true }
3598 /// Used to put an error message in a LightningError
3602 pub enum ErrorAction {
3603 /// The peer took some action which made us think they were useless. Disconnect them.
3605 msg: crate::ln::msgs::ErrorMessage,
3607 /// The peer did something harmless that we weren't able to process, just log and ignore
3609 /// The peer did something incorrect. Tell them.
3611 msg: crate::ln::msgs::ErrorMessage,
3614 use lightning::ln::msgs::ErrorAction as nativeErrorAction;
3617 pub(crate) fn to_native(&self) -> nativeErrorAction {
3619 ErrorAction::DisconnectPeer {ref msg, } => {
3620 let mut msg_nonref = (*msg).clone();
3621 let mut local_msg_nonref = if msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg_nonref.take_inner()) } }) };
3622 nativeErrorAction::DisconnectPeer {
3623 msg: local_msg_nonref,
3626 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
3627 ErrorAction::SendErrorMessage {ref msg, } => {
3628 let mut msg_nonref = (*msg).clone();
3629 nativeErrorAction::SendErrorMessage {
3630 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3636 pub(crate) fn into_native(self) -> nativeErrorAction {
3638 ErrorAction::DisconnectPeer {mut msg, } => {
3639 let mut local_msg = if msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(msg.take_inner()) } }) };
3640 nativeErrorAction::DisconnectPeer {
3644 ErrorAction::IgnoreError => nativeErrorAction::IgnoreError,
3645 ErrorAction::SendErrorMessage {mut msg, } => {
3646 nativeErrorAction::SendErrorMessage {
3647 msg: *unsafe { Box::from_raw(msg.take_inner()) },
3653 pub(crate) fn from_native(native: &nativeErrorAction) -> Self {
3655 nativeErrorAction::DisconnectPeer {ref msg, } => {
3656 let mut msg_nonref = (*msg).clone();
3657 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 };
3658 ErrorAction::DisconnectPeer {
3659 msg: local_msg_nonref,
3662 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
3663 nativeErrorAction::SendErrorMessage {ref msg, } => {
3664 let mut msg_nonref = (*msg).clone();
3665 ErrorAction::SendErrorMessage {
3666 msg: crate::ln::msgs::ErrorMessage { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
3672 pub(crate) fn native_into(native: nativeErrorAction) -> Self {
3674 nativeErrorAction::DisconnectPeer {mut msg, } => {
3675 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 };
3676 ErrorAction::DisconnectPeer {
3680 nativeErrorAction::IgnoreError => ErrorAction::IgnoreError,
3681 nativeErrorAction::SendErrorMessage {mut msg, } => {
3682 ErrorAction::SendErrorMessage {
3683 msg: crate::ln::msgs::ErrorMessage { inner: Box::into_raw(Box::new(msg)), is_owned: true },
3690 pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { }
3692 pub extern "C" fn ErrorAction_clone(orig: &ErrorAction) -> ErrorAction {
3696 use lightning::ln::msgs::LightningError as nativeLightningErrorImport;
3697 type nativeLightningError = nativeLightningErrorImport;
3699 /// An Err type for failure to process messages.
3702 pub struct LightningError {
3703 /// Nearly everywhere, inner must be non-null, however in places where
3704 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3705 pub inner: *mut nativeLightningError,
3709 impl Drop for LightningError {
3710 fn drop(&mut self) {
3711 if self.is_owned && !self.inner.is_null() {
3712 let _ = unsafe { Box::from_raw(self.inner) };
3717 pub extern "C" fn LightningError_free(this_ptr: LightningError) { }
3719 /// Used only if an object of this type is returned as a trait impl by a method
3720 extern "C" fn LightningError_free_void(this_ptr: *mut c_void) {
3721 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeLightningError); }
3724 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3725 impl LightningError {
3726 pub(crate) fn take_inner(mut self) -> *mut nativeLightningError {
3727 assert!(self.is_owned);
3728 let ret = self.inner;
3729 self.inner = std::ptr::null_mut();
3733 /// A human-readable message describing the error
3735 pub extern "C" fn LightningError_get_err(this_ptr: &LightningError) -> crate::c_types::Str {
3736 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.err;
3737 (*inner_val).as_str().into()
3739 /// A human-readable message describing the error
3741 pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: crate::c_types::derived::CVec_u8Z) {
3742 unsafe { &mut *this_ptr.inner }.err = String::from_utf8(val.into_rust()).unwrap();
3744 /// The action which should be taken against the offending peer.
3746 pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate::ln::msgs::ErrorAction {
3747 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.action;
3748 crate::ln::msgs::ErrorAction::from_native(&(*inner_val))
3750 /// The action which should be taken against the offending peer.
3752 pub extern "C" fn LightningError_set_action(this_ptr: &mut LightningError, mut val: crate::ln::msgs::ErrorAction) {
3753 unsafe { &mut *this_ptr.inner }.action = val.into_native();
3757 pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::derived::CVec_u8Z, mut action_arg: crate::ln::msgs::ErrorAction) -> LightningError {
3758 LightningError { inner: Box::into_raw(Box::new(nativeLightningError {
3759 err: String::from_utf8(err_arg.into_rust()).unwrap(),
3760 action: action_arg.into_native(),
3761 })), is_owned: true }
3764 use lightning::ln::msgs::CommitmentUpdate as nativeCommitmentUpdateImport;
3765 type nativeCommitmentUpdate = nativeCommitmentUpdateImport;
3767 /// Struct used to return values from revoke_and_ack messages, containing a bunch of commitment
3768 /// transaction updates if they were pending.
3771 pub struct CommitmentUpdate {
3772 /// Nearly everywhere, inner must be non-null, however in places where
3773 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3774 pub inner: *mut nativeCommitmentUpdate,
3778 impl Drop for CommitmentUpdate {
3779 fn drop(&mut self) {
3780 if self.is_owned && !self.inner.is_null() {
3781 let _ = unsafe { Box::from_raw(self.inner) };
3786 pub extern "C" fn CommitmentUpdate_free(this_ptr: CommitmentUpdate) { }
3788 /// Used only if an object of this type is returned as a trait impl by a method
3789 extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) {
3790 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentUpdate); }
3793 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3794 impl CommitmentUpdate {
3795 pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentUpdate {
3796 assert!(self.is_owned);
3797 let ret = self.inner;
3798 self.inner = std::ptr::null_mut();
3802 impl Clone for CommitmentUpdate {
3803 fn clone(&self) -> Self {
3805 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
3811 /// Used only if an object of this type is returned as a trait impl by a method
3812 pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
3813 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCommitmentUpdate)).clone() })) as *mut c_void
3816 pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentUpdate {
3817 CommitmentUpdate { inner: Box::into_raw(Box::new(unsafe { &*orig.inner }.clone())), is_owned: true }
3819 /// update_add_htlc messages which should be sent
3821 pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) {
3822 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
3823 unsafe { &mut *this_ptr.inner }.update_add_htlcs = local_val;
3825 /// update_fulfill_htlc messages which should be sent
3827 pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) {
3828 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
3829 unsafe { &mut *this_ptr.inner }.update_fulfill_htlcs = local_val;
3831 /// update_fail_htlc messages which should be sent
3833 pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) {
3834 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
3835 unsafe { &mut *this_ptr.inner }.update_fail_htlcs = local_val;
3837 /// update_fail_malformed_htlc messages which should be sent
3839 pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) {
3840 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
3841 unsafe { &mut *this_ptr.inner }.update_fail_malformed_htlcs = local_val;
3843 /// An update_fee message which should be sent
3845 pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::ln::msgs::UpdateFee {
3846 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.update_fee;
3847 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 };
3850 /// An update_fee message which should be sent
3852 pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdate, mut val: crate::ln::msgs::UpdateFee) {
3853 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
3854 unsafe { &mut *this_ptr.inner }.update_fee = local_val;
3856 /// Finally, the commitment_signed message which should be sent
3858 pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::ln::msgs::CommitmentSigned {
3859 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.commitment_signed;
3860 crate::ln::msgs::CommitmentSigned { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
3862 /// Finally, the commitment_signed message which should be sent
3864 pub extern "C" fn CommitmentUpdate_set_commitment_signed(this_ptr: &mut CommitmentUpdate, mut val: crate::ln::msgs::CommitmentSigned) {
3865 unsafe { &mut *this_ptr.inner }.commitment_signed = *unsafe { Box::from_raw(val.take_inner()) };
3869 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 {
3870 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()) } }); };
3871 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()) } }); };
3872 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()) } }); };
3873 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()) } }); };
3874 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()) } }) };
3875 CommitmentUpdate { inner: Box::into_raw(Box::new(nativeCommitmentUpdate {
3876 update_add_htlcs: local_update_add_htlcs_arg,
3877 update_fulfill_htlcs: local_update_fulfill_htlcs_arg,
3878 update_fail_htlcs: local_update_fail_htlcs_arg,
3879 update_fail_malformed_htlcs: local_update_fail_malformed_htlcs_arg,
3880 update_fee: local_update_fee_arg,
3881 commitment_signed: *unsafe { Box::from_raw(commitment_signed_arg.take_inner()) },
3882 })), is_owned: true }
3884 /// The information we received from a peer along the route of a payment we originated. This is
3885 /// returned by ChannelMessageHandler::handle_update_fail_htlc to be passed into
3886 /// RoutingMessageHandler::handle_htlc_fail_channel_update to update our network map.
3890 pub enum HTLCFailChannelUpdate {
3891 /// We received an error which included a full ChannelUpdate message.
3892 ChannelUpdateMessage {
3893 msg: crate::ln::msgs::ChannelUpdate,
3895 /// We received an error which indicated only that a channel has been closed
3897 short_channel_id: u64,
3900 /// We received an error which indicated only that a node has failed
3902 node_id: crate::c_types::PublicKey,
3906 use lightning::ln::msgs::HTLCFailChannelUpdate as nativeHTLCFailChannelUpdate;
3907 impl HTLCFailChannelUpdate {
3909 pub(crate) fn to_native(&self) -> nativeHTLCFailChannelUpdate {
3911 HTLCFailChannelUpdate::ChannelUpdateMessage {ref msg, } => {
3912 let mut msg_nonref = (*msg).clone();
3913 nativeHTLCFailChannelUpdate::ChannelUpdateMessage {
3914 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3917 HTLCFailChannelUpdate::ChannelClosed {ref short_channel_id, ref is_permanent, } => {
3918 let mut short_channel_id_nonref = (*short_channel_id).clone();
3919 let mut is_permanent_nonref = (*is_permanent).clone();
3920 nativeHTLCFailChannelUpdate::ChannelClosed {
3921 short_channel_id: short_channel_id_nonref,
3922 is_permanent: is_permanent_nonref,
3925 HTLCFailChannelUpdate::NodeFailure {ref node_id, ref is_permanent, } => {
3926 let mut node_id_nonref = (*node_id).clone();
3927 let mut is_permanent_nonref = (*is_permanent).clone();
3928 nativeHTLCFailChannelUpdate::NodeFailure {
3929 node_id: node_id_nonref.into_rust(),
3930 is_permanent: is_permanent_nonref,
3936 pub(crate) fn into_native(self) -> nativeHTLCFailChannelUpdate {
3938 HTLCFailChannelUpdate::ChannelUpdateMessage {mut msg, } => {
3939 nativeHTLCFailChannelUpdate::ChannelUpdateMessage {
3940 msg: *unsafe { Box::from_raw(msg.take_inner()) },
3943 HTLCFailChannelUpdate::ChannelClosed {mut short_channel_id, mut is_permanent, } => {
3944 nativeHTLCFailChannelUpdate::ChannelClosed {
3945 short_channel_id: short_channel_id,
3946 is_permanent: is_permanent,
3949 HTLCFailChannelUpdate::NodeFailure {mut node_id, mut is_permanent, } => {
3950 nativeHTLCFailChannelUpdate::NodeFailure {
3951 node_id: node_id.into_rust(),
3952 is_permanent: is_permanent,
3958 pub(crate) fn from_native(native: &nativeHTLCFailChannelUpdate) -> Self {
3960 nativeHTLCFailChannelUpdate::ChannelUpdateMessage {ref msg, } => {
3961 let mut msg_nonref = (*msg).clone();
3962 HTLCFailChannelUpdate::ChannelUpdateMessage {
3963 msg: crate::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
3966 nativeHTLCFailChannelUpdate::ChannelClosed {ref short_channel_id, ref is_permanent, } => {
3967 let mut short_channel_id_nonref = (*short_channel_id).clone();
3968 let mut is_permanent_nonref = (*is_permanent).clone();
3969 HTLCFailChannelUpdate::ChannelClosed {
3970 short_channel_id: short_channel_id_nonref,
3971 is_permanent: is_permanent_nonref,
3974 nativeHTLCFailChannelUpdate::NodeFailure {ref node_id, ref is_permanent, } => {
3975 let mut node_id_nonref = (*node_id).clone();
3976 let mut is_permanent_nonref = (*is_permanent).clone();
3977 HTLCFailChannelUpdate::NodeFailure {
3978 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3979 is_permanent: is_permanent_nonref,
3985 pub(crate) fn native_into(native: nativeHTLCFailChannelUpdate) -> Self {
3987 nativeHTLCFailChannelUpdate::ChannelUpdateMessage {mut msg, } => {
3988 HTLCFailChannelUpdate::ChannelUpdateMessage {
3989 msg: crate::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(msg)), is_owned: true },
3992 nativeHTLCFailChannelUpdate::ChannelClosed {mut short_channel_id, mut is_permanent, } => {
3993 HTLCFailChannelUpdate::ChannelClosed {
3994 short_channel_id: short_channel_id,
3995 is_permanent: is_permanent,
3998 nativeHTLCFailChannelUpdate::NodeFailure {mut node_id, mut is_permanent, } => {
3999 HTLCFailChannelUpdate::NodeFailure {
4000 node_id: crate::c_types::PublicKey::from_rust(&node_id),
4001 is_permanent: is_permanent,
4008 pub extern "C" fn HTLCFailChannelUpdate_free(this_ptr: HTLCFailChannelUpdate) { }
4010 pub extern "C" fn HTLCFailChannelUpdate_clone(orig: &HTLCFailChannelUpdate) -> HTLCFailChannelUpdate {
4013 /// A trait to describe an object which can receive channel messages.
4015 /// Messages MAY be called in parallel when they originate from different their_node_ids, however
4016 /// they MUST NOT be called in parallel when the two calls have the same their_node_id.
4018 pub struct ChannelMessageHandler {
4019 pub this_arg: *mut c_void,
4020 /// Handle an incoming open_channel message from the given peer.
4021 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),
4022 /// Handle an incoming accept_channel message from the given peer.
4023 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),
4024 /// Handle an incoming funding_created message from the given peer.
4025 pub handle_funding_created: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingCreated),
4026 /// Handle an incoming funding_signed message from the given peer.
4027 pub handle_funding_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingSigned),
4028 /// Handle an incoming funding_locked message from the given peer.
4029 pub handle_funding_locked: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingLocked),
4030 /// Handle an incoming shutdown message from the given peer.
4031 pub handle_shutdown: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::Shutdown),
4032 /// Handle an incoming closing_signed message from the given peer.
4033 pub handle_closing_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ClosingSigned),
4034 /// Handle an incoming update_add_htlc message from the given peer.
4035 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),
4036 /// Handle an incoming update_fulfill_htlc message from the given peer.
4037 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),
4038 /// Handle an incoming update_fail_htlc message from the given peer.
4039 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),
4040 /// Handle an incoming update_fail_malformed_htlc message from the given peer.
4041 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),
4042 /// Handle an incoming commitment_signed message from the given peer.
4043 pub handle_commitment_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::CommitmentSigned),
4044 /// Handle an incoming revoke_and_ack message from the given peer.
4045 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),
4046 /// Handle an incoming update_fee message from the given peer.
4047 pub handle_update_fee: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFee),
4048 /// Handle an incoming announcement_signatures message from the given peer.
4049 pub handle_announcement_signatures: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::AnnouncementSignatures),
4050 /// Indicates a connection to the peer failed/an existing connection was lost. If no connection
4051 /// is believed to be possible in the future (eg they're sending us messages we don't
4052 /// understand or indicate they require unknown feature bits), no_connection_possible is set
4053 /// and any outstanding channels should be failed.
4054 pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, no_connection_possible: bool),
4055 /// Handle a peer reconnecting, possibly generating channel_reestablish message(s).
4056 pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::Init),
4057 /// Handle an incoming channel_reestablish message from the given peer.
4058 pub handle_channel_reestablish: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ChannelReestablish),
4059 /// Handle an incoming error message from the given peer.
4060 pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ErrorMessage),
4061 pub MessageSendEventsProvider: crate::util::events::MessageSendEventsProvider,
4062 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
4064 impl lightning::util::events::MessageSendEventsProvider for ChannelMessageHandler {
4065 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
4066 <crate::util::events::MessageSendEventsProvider as lightning::util::events::MessageSendEventsProvider>::get_and_clear_pending_msg_events(&self.MessageSendEventsProvider)
4069 unsafe impl Send for ChannelMessageHandler {}
4070 unsafe impl Sync for ChannelMessageHandler {}
4072 use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler;
4073 impl rustChannelMessageHandler for ChannelMessageHandler {
4074 fn handle_open_channel(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, their_features: lightning::ln::features::InitFeatures, msg: &lightning::ln::msgs::OpenChannel) {
4075 (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 })
4077 fn handle_accept_channel(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, their_features: lightning::ln::features::InitFeatures, msg: &lightning::ln::msgs::AcceptChannel) {
4078 (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 })
4080 fn handle_funding_created(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::FundingCreated) {
4081 (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 })
4083 fn handle_funding_signed(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::FundingSigned) {
4084 (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 })
4086 fn handle_funding_locked(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::FundingLocked) {
4087 (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 })
4089 fn handle_shutdown(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::Shutdown) {
4090 (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 })
4092 fn handle_closing_signed(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::ClosingSigned) {
4093 (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 })
4095 fn handle_update_add_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateAddHTLC) {
4096 (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 })
4098 fn handle_update_fulfill_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFulfillHTLC) {
4099 (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 })
4101 fn handle_update_fail_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFailHTLC) {
4102 (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 })
4104 fn handle_update_fail_malformed_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) {
4105 (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 })
4107 fn handle_commitment_signed(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::CommitmentSigned) {
4108 (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 })
4110 fn handle_revoke_and_ack(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::RevokeAndACK) {
4111 (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 })
4113 fn handle_update_fee(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFee) {
4114 (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 })
4116 fn handle_announcement_signatures(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::AnnouncementSignatures) {
4117 (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 })
4119 fn peer_disconnected(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, no_connection_possible: bool) {
4120 (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), no_connection_possible)
4122 fn peer_connected(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::Init) {
4123 (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 })
4125 fn handle_channel_reestablish(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::ChannelReestablish) {
4126 (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 })
4128 fn handle_error(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::ErrorMessage) {
4129 (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 })
4133 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
4134 // directly as a Deref trait in higher-level structs:
4135 impl std::ops::Deref for ChannelMessageHandler {
4137 fn deref(&self) -> &Self {
4141 /// Calls the free function if one is set
4143 pub extern "C" fn ChannelMessageHandler_free(this_ptr: ChannelMessageHandler) { }
4144 impl Drop for ChannelMessageHandler {
4145 fn drop(&mut self) {
4146 if let Some(f) = self.free {
4151 /// A trait to describe an object which can receive routing messages.
4153 /// # Implementor DoS Warnings
4155 /// For `gossip_queries` messages there are potential DoS vectors when handling
4156 /// inbound queries. Implementors using an on-disk network graph should be aware of
4157 /// repeated disk I/O for queries accessing different parts of the network graph.
4159 pub struct RoutingMessageHandler {
4160 pub this_arg: *mut c_void,
4161 /// Handle an incoming node_announcement message, returning true if it should be forwarded on,
4162 /// false or returning an Err otherwise.
4164 pub handle_node_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
4165 /// Handle a channel_announcement message, returning true if it should be forwarded on, false
4166 /// or returning an Err otherwise.
4168 pub handle_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ,
4169 /// Handle an incoming channel_update message, returning true if it should be forwarded on,
4170 /// false or returning an Err otherwise.
4172 pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ,
4173 /// Handle some updates to the route graph that we learned due to an outbound failed payment.
4174 pub handle_htlc_fail_channel_update: extern "C" fn (this_arg: *const c_void, update: &crate::ln::msgs::HTLCFailChannelUpdate),
4175 /// Gets a subset of the channel announcements and updates required to dump our routing table
4176 /// to a remote node, starting at the short_channel_id indicated by starting_point and
4177 /// including the batch_amount entries immediately higher in numerical value than starting_point.
4179 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,
4180 /// Gets a subset of the node announcements required to dump our routing table to a remote node,
4181 /// starting at the node *after* the provided publickey and including batch_amount entries
4182 /// immediately higher (as defined by <PublicKey as Ord>::cmp) than starting_point.
4183 /// If None is provided for starting_point, we start at the first node.
4185 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,
4186 /// Called when a connection is established with a peer. This can be used to
4187 /// perform routing table synchronization using a strategy defined by the
4189 pub sync_routing_table: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, init: &crate::ln::msgs::Init),
4190 /// Handles the reply of a query we initiated to learn about channels
4191 /// for a given range of blocks. We can expect to receive one or more
4192 /// replies to a single query.
4194 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,
4195 /// Handles the reply of a query we initiated asking for routing gossip
4196 /// messages for a list of channels. We should receive this message when
4197 /// a node has completed its best effort to send us the pertaining routing
4198 /// gossip messages.
4200 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,
4201 /// Handles when a peer asks us to send a list of short_channel_ids
4202 /// for the requested range of blocks.
4204 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,
4205 /// Handles when a peer asks us to send routing gossip messages for a
4206 /// list of short_channel_ids.
4208 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,
4209 pub MessageSendEventsProvider: crate::util::events::MessageSendEventsProvider,
4210 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
4212 unsafe impl Send for RoutingMessageHandler {}
4213 unsafe impl Sync for RoutingMessageHandler {}
4214 impl lightning::util::events::MessageSendEventsProvider for RoutingMessageHandler {
4215 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
4216 <crate::util::events::MessageSendEventsProvider as lightning::util::events::MessageSendEventsProvider>::get_and_clear_pending_msg_events(&self.MessageSendEventsProvider)
4220 use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler;
4221 impl rustRoutingMessageHandler for RoutingMessageHandler {
4222 fn handle_node_announcement(&self, msg: &lightning::ln::msgs::NodeAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
4223 let mut ret = (self.handle_node_announcement)(self.this_arg, &crate::ln::msgs::NodeAnnouncement { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false });
4224 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()) } })};
4227 fn handle_channel_announcement(&self, msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result<bool, lightning::ln::msgs::LightningError> {
4228 let mut ret = (self.handle_channel_announcement)(self.this_arg, &crate::ln::msgs::ChannelAnnouncement { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false });
4229 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()) } })};
4232 fn handle_channel_update(&self, msg: &lightning::ln::msgs::ChannelUpdate) -> Result<bool, lightning::ln::msgs::LightningError> {
4233 let mut ret = (self.handle_channel_update)(self.this_arg, &crate::ln::msgs::ChannelUpdate { 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_htlc_fail_channel_update(&self, update: &lightning::ln::msgs::HTLCFailChannelUpdate) {
4238 (self.handle_htlc_fail_channel_update)(self.this_arg, &crate::ln::msgs::HTLCFailChannelUpdate::from_native(&update))
4240 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>)> {
4241 let mut ret = (self.get_next_channel_announcements)(self.this_arg, starting_point, batch_amount);
4242 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 }); };
4245 fn get_next_node_announcements(&self, starting_point: Option<&bitcoin::secp256k1::key::PublicKey>, batch_amount: u8) -> Vec<lightning::ln::msgs::NodeAnnouncement> {
4246 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())) } };
4247 let mut ret = (self.get_next_node_announcements)(self.this_arg, local_starting_point, batch_amount);
4248 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
4251 fn sync_routing_table(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, init: &lightning::ln::msgs::Init) {
4252 (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 })
4254 fn handle_reply_channel_range(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: lightning::ln::msgs::ReplyChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
4255 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 });
4256 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()) } })};
4259 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> {
4260 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 });
4261 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()) } })};
4264 fn handle_query_channel_range(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: lightning::ln::msgs::QueryChannelRange) -> Result<(), lightning::ln::msgs::LightningError> {
4265 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 });
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_query_short_channel_ids(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: lightning::ln::msgs::QueryShortChannelIds) -> Result<(), lightning::ln::msgs::LightningError> {
4270 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 });
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()) } })};
4276 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
4277 // directly as a Deref trait in higher-level structs:
4278 impl std::ops::Deref for RoutingMessageHandler {
4280 fn deref(&self) -> &Self {
4284 /// Calls the free function if one is set
4286 pub extern "C" fn RoutingMessageHandler_free(this_ptr: RoutingMessageHandler) { }
4287 impl Drop for RoutingMessageHandler {
4288 fn drop(&mut self) {
4289 if let Some(f) = self.free {
4295 pub extern "C" fn AcceptChannel_write(obj: *const AcceptChannel) -> crate::c_types::derived::CVec_u8Z {
4296 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4299 pub(crate) extern "C" fn AcceptChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4300 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannel) })
4303 pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> AcceptChannel {
4304 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4305 AcceptChannel { inner: Box::into_raw(Box::new(res)), is_owned: true }
4307 AcceptChannel { inner: std::ptr::null_mut(), is_owned: true }
4311 pub extern "C" fn AnnouncementSignatures_write(obj: *const AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z {
4312 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4315 pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4316 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAnnouncementSignatures) })
4319 pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> AnnouncementSignatures {
4320 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4321 AnnouncementSignatures { inner: Box::into_raw(Box::new(res)), is_owned: true }
4323 AnnouncementSignatures { inner: std::ptr::null_mut(), is_owned: true }
4327 pub extern "C" fn ChannelReestablish_write(obj: *const ChannelReestablish) -> crate::c_types::derived::CVec_u8Z {
4328 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4331 pub(crate) extern "C" fn ChannelReestablish_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4332 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReestablish) })
4335 pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReestablishDecodeErrorZ {
4336 let res = crate::c_types::deserialize_obj(ser);
4337 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 } }) };
4341 pub extern "C" fn ClosingSigned_write(obj: *const ClosingSigned) -> crate::c_types::derived::CVec_u8Z {
4342 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4345 pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4346 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSigned) })
4349 pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> ClosingSigned {
4350 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4351 ClosingSigned { inner: Box::into_raw(Box::new(res)), is_owned: true }
4353 ClosingSigned { inner: std::ptr::null_mut(), is_owned: true }
4357 pub extern "C" fn CommitmentSigned_write(obj: *const CommitmentSigned) -> crate::c_types::derived::CVec_u8Z {
4358 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4361 pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4362 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentSigned) })
4365 pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> CommitmentSigned {
4366 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4367 CommitmentSigned { inner: Box::into_raw(Box::new(res)), is_owned: true }
4369 CommitmentSigned { inner: std::ptr::null_mut(), is_owned: true }
4373 pub extern "C" fn FundingCreated_write(obj: *const FundingCreated) -> crate::c_types::derived::CVec_u8Z {
4374 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4377 pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4378 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingCreated) })
4381 pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> FundingCreated {
4382 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4383 FundingCreated { inner: Box::into_raw(Box::new(res)), is_owned: true }
4385 FundingCreated { inner: std::ptr::null_mut(), is_owned: true }
4389 pub extern "C" fn FundingSigned_write(obj: *const FundingSigned) -> crate::c_types::derived::CVec_u8Z {
4390 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4393 pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4394 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingSigned) })
4397 pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> FundingSigned {
4398 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4399 FundingSigned { inner: Box::into_raw(Box::new(res)), is_owned: true }
4401 FundingSigned { inner: std::ptr::null_mut(), is_owned: true }
4405 pub extern "C" fn FundingLocked_write(obj: *const FundingLocked) -> crate::c_types::derived::CVec_u8Z {
4406 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4409 pub(crate) extern "C" fn FundingLocked_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4410 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingLocked) })
4413 pub extern "C" fn FundingLocked_read(ser: crate::c_types::u8slice) -> FundingLocked {
4414 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4415 FundingLocked { inner: Box::into_raw(Box::new(res)), is_owned: true }
4417 FundingLocked { inner: std::ptr::null_mut(), is_owned: true }
4421 pub extern "C" fn Init_write(obj: *const Init) -> crate::c_types::derived::CVec_u8Z {
4422 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4425 pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4426 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInit) })
4429 pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitDecodeErrorZ {
4430 let res = crate::c_types::deserialize_obj(ser);
4431 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 } }) };
4435 pub extern "C" fn OpenChannel_write(obj: *const OpenChannel) -> crate::c_types::derived::CVec_u8Z {
4436 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4439 pub(crate) extern "C" fn OpenChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4440 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannel) })
4443 pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> OpenChannel {
4444 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4445 OpenChannel { inner: Box::into_raw(Box::new(res)), is_owned: true }
4447 OpenChannel { inner: std::ptr::null_mut(), is_owned: true }
4451 pub extern "C" fn RevokeAndACK_write(obj: *const RevokeAndACK) -> crate::c_types::derived::CVec_u8Z {
4452 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4455 pub(crate) extern "C" fn RevokeAndACK_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4456 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevokeAndACK) })
4459 pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> RevokeAndACK {
4460 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4461 RevokeAndACK { inner: Box::into_raw(Box::new(res)), is_owned: true }
4463 RevokeAndACK { inner: std::ptr::null_mut(), is_owned: true }
4467 pub extern "C" fn Shutdown_write(obj: *const Shutdown) -> crate::c_types::derived::CVec_u8Z {
4468 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4471 pub(crate) extern "C" fn Shutdown_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4472 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeShutdown) })
4475 pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> Shutdown {
4476 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4477 Shutdown { inner: Box::into_raw(Box::new(res)), is_owned: true }
4479 Shutdown { inner: std::ptr::null_mut(), is_owned: true }
4483 pub extern "C" fn UpdateFailHTLC_write(obj: *const UpdateFailHTLC) -> crate::c_types::derived::CVec_u8Z {
4484 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4487 pub(crate) extern "C" fn UpdateFailHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4488 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailHTLC) })
4491 pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> UpdateFailHTLC {
4492 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4493 UpdateFailHTLC { inner: Box::into_raw(Box::new(res)), is_owned: true }
4495 UpdateFailHTLC { inner: std::ptr::null_mut(), is_owned: true }
4499 pub extern "C" fn UpdateFailMalformedHTLC_write(obj: *const UpdateFailMalformedHTLC) -> crate::c_types::derived::CVec_u8Z {
4500 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4503 pub(crate) extern "C" fn UpdateFailMalformedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4504 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailMalformedHTLC) })
4507 pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> UpdateFailMalformedHTLC {
4508 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4509 UpdateFailMalformedHTLC { inner: Box::into_raw(Box::new(res)), is_owned: true }
4511 UpdateFailMalformedHTLC { inner: std::ptr::null_mut(), is_owned: true }
4515 pub extern "C" fn UpdateFee_write(obj: *const UpdateFee) -> crate::c_types::derived::CVec_u8Z {
4516 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4519 pub(crate) extern "C" fn UpdateFee_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4520 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFee) })
4523 pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> UpdateFee {
4524 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4525 UpdateFee { inner: Box::into_raw(Box::new(res)), is_owned: true }
4527 UpdateFee { inner: std::ptr::null_mut(), is_owned: true }
4531 pub extern "C" fn UpdateFulfillHTLC_write(obj: *const UpdateFulfillHTLC) -> crate::c_types::derived::CVec_u8Z {
4532 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4535 pub(crate) extern "C" fn UpdateFulfillHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4536 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFulfillHTLC) })
4539 pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> UpdateFulfillHTLC {
4540 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4541 UpdateFulfillHTLC { inner: Box::into_raw(Box::new(res)), is_owned: true }
4543 UpdateFulfillHTLC { inner: std::ptr::null_mut(), is_owned: true }
4547 pub extern "C" fn UpdateAddHTLC_write(obj: *const UpdateAddHTLC) -> crate::c_types::derived::CVec_u8Z {
4548 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4551 pub(crate) extern "C" fn UpdateAddHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4552 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateAddHTLC) })
4555 pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> UpdateAddHTLC {
4556 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4557 UpdateAddHTLC { inner: Box::into_raw(Box::new(res)), is_owned: true }
4559 UpdateAddHTLC { inner: std::ptr::null_mut(), is_owned: true }
4563 pub extern "C" fn Ping_write(obj: *const Ping) -> crate::c_types::derived::CVec_u8Z {
4564 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4567 pub(crate) extern "C" fn Ping_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4568 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePing) })
4571 pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PingDecodeErrorZ {
4572 let res = crate::c_types::deserialize_obj(ser);
4573 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 } }) };
4577 pub extern "C" fn Pong_write(obj: *const Pong) -> crate::c_types::derived::CVec_u8Z {
4578 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4581 pub(crate) extern "C" fn Pong_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4582 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePong) })
4585 pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PongDecodeErrorZ {
4586 let res = crate::c_types::deserialize_obj(ser);
4587 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 } }) };
4591 pub extern "C" fn UnsignedChannelAnnouncement_write(obj: *const UnsignedChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
4592 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4595 pub(crate) extern "C" fn UnsignedChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4596 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelAnnouncement) })
4599 pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelAnnouncementDecodeErrorZ {
4600 let res = crate::c_types::deserialize_obj(ser);
4601 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 } }) };
4605 pub extern "C" fn ChannelAnnouncement_write(obj: *const ChannelAnnouncement) -> crate::c_types::derived::CVec_u8Z {
4606 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4609 pub(crate) extern "C" fn ChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4610 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelAnnouncement) })
4613 pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> ChannelAnnouncement {
4614 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4615 ChannelAnnouncement { inner: Box::into_raw(Box::new(res)), is_owned: true }
4617 ChannelAnnouncement { inner: std::ptr::null_mut(), is_owned: true }
4621 pub extern "C" fn UnsignedChannelUpdate_write(obj: *const UnsignedChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
4622 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4625 pub(crate) extern "C" fn UnsignedChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4626 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelUpdate) })
4629 pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelUpdateDecodeErrorZ {
4630 let res = crate::c_types::deserialize_obj(ser);
4631 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 } }) };
4635 pub extern "C" fn ChannelUpdate_write(obj: *const ChannelUpdate) -> crate::c_types::derived::CVec_u8Z {
4636 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4639 pub(crate) extern "C" fn ChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4640 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdate) })
4643 pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> ChannelUpdate {
4644 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4645 ChannelUpdate { inner: Box::into_raw(Box::new(res)), is_owned: true }
4647 ChannelUpdate { inner: std::ptr::null_mut(), is_owned: true }
4651 pub extern "C" fn ErrorMessage_write(obj: *const ErrorMessage) -> crate::c_types::derived::CVec_u8Z {
4652 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4655 pub(crate) extern "C" fn ErrorMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4656 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeErrorMessage) })
4659 pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ErrorMessageDecodeErrorZ {
4660 let res = crate::c_types::deserialize_obj(ser);
4661 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 } }) };
4665 pub extern "C" fn UnsignedNodeAnnouncement_write(obj: *const UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
4666 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4669 pub(crate) extern "C" fn UnsignedNodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4670 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedNodeAnnouncement) })
4673 pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedNodeAnnouncementDecodeErrorZ {
4674 let res = crate::c_types::deserialize_obj(ser);
4675 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 } }) };
4679 pub extern "C" fn NodeAnnouncement_write(obj: *const NodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
4680 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4683 pub(crate) extern "C" fn NodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4684 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncement) })
4687 pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> NodeAnnouncement {
4688 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
4689 NodeAnnouncement { inner: Box::into_raw(Box::new(res)), is_owned: true }
4691 NodeAnnouncement { inner: std::ptr::null_mut(), is_owned: true }
4695 pub extern "C" fn QueryShortChannelIds_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryShortChannelIdsDecodeErrorZ {
4696 let res = crate::c_types::deserialize_obj(ser);
4697 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 } }) };
4701 pub extern "C" fn QueryShortChannelIds_write(obj: *const QueryShortChannelIds) -> crate::c_types::derived::CVec_u8Z {
4702 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4705 pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4706 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) })
4709 pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyShortChannelIdsEndDecodeErrorZ {
4710 let res = crate::c_types::deserialize_obj(ser);
4711 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 } }) };
4715 pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: *const ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z {
4716 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4719 pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4720 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) })
4723 pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ {
4724 let res = crate::c_types::deserialize_obj(ser);
4725 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 } }) };
4729 pub extern "C" fn QueryChannelRange_write(obj: *const QueryChannelRange) -> crate::c_types::derived::CVec_u8Z {
4730 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4733 pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4734 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) })
4737 pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyChannelRangeDecodeErrorZ {
4738 let res = crate::c_types::deserialize_obj(ser);
4739 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 } }) };
4743 pub extern "C" fn ReplyChannelRange_write(obj: *const ReplyChannelRange) -> crate::c_types::derived::CVec_u8Z {
4744 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4747 pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4748 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) })
4751 pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_GossipTimestampFilterDecodeErrorZ {
4752 let res = crate::c_types::deserialize_obj(ser);
4753 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 } }) };
4757 pub extern "C" fn GossipTimestampFilter_write(obj: *const GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z {
4758 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
4761 pub(crate) extern "C" fn GossipTimestampFilter_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
4762 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeGossipTimestampFilter) })