X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=ldk-c-bindings;a=blobdiff_plain;f=lightning-c-bindings%2Fsrc%2Flightning%2Fln%2Fmsgs.rs;h=67ca95ff6395366574800d80a477844d7bb2376a;hp=b8a26157a5db230bdf5efa94601b12bc971d13dd;hb=1eaf50a3d9f777b462ff1817678473567a00eb75;hpb=696382c9fbc707aa5226f73910625136adb724fd diff --git a/lightning-c-bindings/src/lightning/ln/msgs.rs b/lightning-c-bindings/src/lightning/ln/msgs.rs index b8a2615..67ca95f 100644 --- a/lightning-c-bindings/src/lightning/ln/msgs.rs +++ b/lightning-c-bindings/src/lightning/ln/msgs.rs @@ -23,14 +23,17 @@ //! raw socket events into your non-internet-facing system and then send routing events back to //! track the network on the less-secure system. -use std::str::FromStr; -use std::ffi::c_void; +use alloc::str::FromStr; +use core::ffi::c_void; +use core::convert::Infallible; use bitcoin::hashes::Hash; use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; use lightning::ln::msgs::DecodeError as nativeDecodeErrorImport; -type nativeDecodeError = nativeDecodeErrorImport; +pub(crate) type nativeDecodeError = nativeDecodeErrorImport; /// An error in decoding a message or struct. #[must_use] @@ -60,7 +63,7 @@ impl Drop for DecodeError { pub extern "C" fn DecodeError_free(this_obj: DecodeError) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn DecodeError_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn DecodeError_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDecodeError); } } #[allow(unused)] @@ -75,14 +78,14 @@ impl DecodeError { pub(crate) fn take_inner(mut self) -> *mut nativeDecodeError { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); - self.inner = std::ptr::null_mut(); + self.inner = core::ptr::null_mut(); ret } } impl Clone for DecodeError { fn clone(&self) -> Self { Self { - inner: if <*mut nativeDecodeError>::is_null(self.inner) { std::ptr::null_mut() } else { + inner: if <*mut nativeDecodeError>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -100,7 +103,7 @@ pub extern "C" fn DecodeError_clone(orig: &DecodeError) -> DecodeError { } use lightning::ln::msgs::Init as nativeInitImport; -type nativeInit = nativeInitImport; +pub(crate) type nativeInit = nativeInitImport; /// An init message to be sent or received from a peer #[must_use] @@ -130,7 +133,7 @@ impl Drop for Init { pub extern "C" fn Init_free(this_obj: Init) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn Init_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn Init_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeInit); } } #[allow(unused)] @@ -145,7 +148,7 @@ impl Init { pub(crate) fn take_inner(mut self) -> *mut nativeInit { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); - self.inner = std::ptr::null_mut(); + self.inner = core::ptr::null_mut(); ret } } @@ -153,7 +156,7 @@ impl Init { #[no_mangle] pub extern "C" fn Init_get_features(this_ptr: &Init) -> crate::lightning::ln::features::InitFeatures { let mut inner_val = &mut this_ptr.get_native_mut_ref().features; - crate::lightning::ln::features::InitFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false } + crate::lightning::ln::features::InitFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::InitFeatures<>) as *mut _) }, is_owned: false } } /// The relevant features which the sender supports #[no_mangle] @@ -171,7 +174,7 @@ pub extern "C" fn Init_new(mut features_arg: crate::lightning::ln::features::Ini impl Clone for Init { fn clone(&self) -> Self { Self { - inner: if <*mut nativeInit>::is_null(self.inner) { std::ptr::null_mut() } else { + inner: if <*mut nativeInit>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -189,7 +192,7 @@ pub extern "C" fn Init_clone(orig: &Init) -> Init { } use lightning::ln::msgs::ErrorMessage as nativeErrorMessageImport; -type nativeErrorMessage = nativeErrorMessageImport; +pub(crate) type nativeErrorMessage = nativeErrorMessageImport; /// An error message to be sent or received from a peer #[must_use] @@ -219,7 +222,7 @@ impl Drop for ErrorMessage { pub extern "C" fn ErrorMessage_free(this_obj: ErrorMessage) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn ErrorMessage_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn ErrorMessage_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeErrorMessage); } } #[allow(unused)] @@ -234,7 +237,7 @@ impl ErrorMessage { pub(crate) fn take_inner(mut self) -> *mut nativeErrorMessage { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); - self.inner = std::ptr::null_mut(); + self.inner = core::ptr::null_mut(); ret } } @@ -278,7 +281,7 @@ pub extern "C" fn ErrorMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwo impl Clone for ErrorMessage { fn clone(&self) -> Self { Self { - inner: if <*mut nativeErrorMessage>::is_null(self.inner) { std::ptr::null_mut() } else { + inner: if <*mut nativeErrorMessage>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -296,7 +299,7 @@ pub extern "C" fn ErrorMessage_clone(orig: &ErrorMessage) -> ErrorMessage { } use lightning::ln::msgs::Ping as nativePingImport; -type nativePing = nativePingImport; +pub(crate) type nativePing = nativePingImport; /// A ping message to be sent or received from a peer #[must_use] @@ -326,7 +329,7 @@ impl Drop for Ping { pub extern "C" fn Ping_free(this_obj: Ping) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn Ping_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn Ping_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativePing); } } #[allow(unused)] @@ -341,7 +344,7 @@ impl Ping { pub(crate) fn take_inner(mut self) -> *mut nativePing { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); - self.inner = std::ptr::null_mut(); + self.inner = core::ptr::null_mut(); ret } } @@ -381,7 +384,7 @@ pub extern "C" fn Ping_new(mut ponglen_arg: u16, mut byteslen_arg: u16) -> Ping impl Clone for Ping { fn clone(&self) -> Self { Self { - inner: if <*mut nativePing>::is_null(self.inner) { std::ptr::null_mut() } else { + inner: if <*mut nativePing>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -399,7 +402,7 @@ pub extern "C" fn Ping_clone(orig: &Ping) -> Ping { } use lightning::ln::msgs::Pong as nativePongImport; -type nativePong = nativePongImport; +pub(crate) type nativePong = nativePongImport; /// A pong message to be sent or received from a peer #[must_use] @@ -429,7 +432,7 @@ impl Drop for Pong { pub extern "C" fn Pong_free(this_obj: Pong) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn Pong_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn Pong_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativePong); } } #[allow(unused)] @@ -444,7 +447,7 @@ impl Pong { pub(crate) fn take_inner(mut self) -> *mut nativePong { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); - self.inner = std::ptr::null_mut(); + self.inner = core::ptr::null_mut(); ret } } @@ -472,7 +475,7 @@ pub extern "C" fn Pong_new(mut byteslen_arg: u16) -> Pong { impl Clone for Pong { fn clone(&self) -> Self { Self { - inner: if <*mut nativePong>::is_null(self.inner) { std::ptr::null_mut() } else { + inner: if <*mut nativePong>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -490,7 +493,7 @@ pub extern "C" fn Pong_clone(orig: &Pong) -> Pong { } use lightning::ln::msgs::OpenChannel as nativeOpenChannelImport; -type nativeOpenChannel = nativeOpenChannelImport; +pub(crate) type nativeOpenChannel = nativeOpenChannelImport; /// An open_channel message to be sent or received from a peer #[must_use] @@ -520,7 +523,7 @@ impl Drop for OpenChannel { pub extern "C" fn OpenChannel_free(this_obj: OpenChannel) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn OpenChannel_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn OpenChannel_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeOpenChannel); } } #[allow(unused)] @@ -535,7 +538,7 @@ impl OpenChannel { pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannel { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); - self.inner = std::ptr::null_mut(); + self.inner = core::ptr::null_mut(); ret } } @@ -737,10 +740,31 @@ pub extern "C" fn OpenChannel_get_channel_flags(this_ptr: &OpenChannel) -> u8 { pub extern "C" fn OpenChannel_set_channel_flags(this_ptr: &mut OpenChannel, mut val: u8) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_flags = val; } +/// The channel type that this channel will represent. If none is set, we derive the channel +/// type from the intersection of our feature bits with our counterparty's feature bits from +/// the Init message. +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn OpenChannel_get_channel_type(this_ptr: &OpenChannel) -> crate::lightning::ln::features::ChannelTypeFeatures { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type; + let mut local_inner_val = crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false }; + local_inner_val +} +/// The channel type that this channel will represent. If none is set, we derive the channel +/// type from the intersection of our feature bits with our counterparty's feature bits from +/// the Init message. +/// +/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn OpenChannel_set_channel_type(this_ptr: &mut OpenChannel, mut val: crate::lightning::ln::features::ChannelTypeFeatures) { + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val; +} impl Clone for OpenChannel { fn clone(&self) -> Self { Self { - inner: if <*mut nativeOpenChannel>::is_null(self.inner) { std::ptr::null_mut() } else { + inner: if <*mut nativeOpenChannel>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -758,7 +782,7 @@ pub extern "C" fn OpenChannel_clone(orig: &OpenChannel) -> OpenChannel { } use lightning::ln::msgs::AcceptChannel as nativeAcceptChannelImport; -type nativeAcceptChannel = nativeAcceptChannelImport; +pub(crate) type nativeAcceptChannel = nativeAcceptChannelImport; /// An accept_channel message to be sent or received from a peer #[must_use] @@ -788,7 +812,7 @@ impl Drop for AcceptChannel { pub extern "C" fn AcceptChannel_free(this_obj: AcceptChannel) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn AcceptChannel_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn AcceptChannel_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeAcceptChannel); } } #[allow(unused)] @@ -803,7 +827,7 @@ impl AcceptChannel { pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannel { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); - self.inner = std::ptr::null_mut(); + self.inner = core::ptr::null_mut(); ret } } @@ -964,7 +988,7 @@ pub extern "C" fn AcceptChannel_set_first_per_commitment_point(this_ptr: &mut Ac impl Clone for AcceptChannel { fn clone(&self) -> Self { Self { - inner: if <*mut nativeAcceptChannel>::is_null(self.inner) { std::ptr::null_mut() } else { + inner: if <*mut nativeAcceptChannel>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -982,7 +1006,7 @@ pub extern "C" fn AcceptChannel_clone(orig: &AcceptChannel) -> AcceptChannel { } use lightning::ln::msgs::FundingCreated as nativeFundingCreatedImport; -type nativeFundingCreated = nativeFundingCreatedImport; +pub(crate) type nativeFundingCreated = nativeFundingCreatedImport; /// A funding_created message to be sent or received from a peer #[must_use] @@ -1012,7 +1036,7 @@ impl Drop for FundingCreated { pub extern "C" fn FundingCreated_free(this_obj: FundingCreated) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn FundingCreated_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn FundingCreated_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingCreated); } } #[allow(unused)] @@ -1027,7 +1051,7 @@ impl FundingCreated { pub(crate) fn take_inner(mut self) -> *mut nativeFundingCreated { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); - self.inner = std::ptr::null_mut(); + self.inner = core::ptr::null_mut(); ret } } @@ -1064,13 +1088,13 @@ pub extern "C" fn FundingCreated_get_funding_output_index(this_ptr: &FundingCrea pub extern "C" fn FundingCreated_set_funding_output_index(this_ptr: &mut FundingCreated, mut val: u16) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_index = val; } -/// The signature of the channel initiator (funder) on the funding transaction +/// The signature of the channel initiator (funder) on the initial commitment transaction #[no_mangle] pub extern "C" fn FundingCreated_get_signature(this_ptr: &FundingCreated) -> crate::c_types::Signature { let mut inner_val = &mut this_ptr.get_native_mut_ref().signature; crate::c_types::Signature::from_rust(&inner_val) } -/// The signature of the channel initiator (funder) on the funding transaction +/// The signature of the channel initiator (funder) on the initial commitment transaction #[no_mangle] pub extern "C" fn FundingCreated_set_signature(this_ptr: &mut FundingCreated, mut val: crate::c_types::Signature) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust(); @@ -1089,7 +1113,7 @@ pub extern "C" fn FundingCreated_new(mut temporary_channel_id_arg: crate::c_type impl Clone for FundingCreated { fn clone(&self) -> Self { Self { - inner: if <*mut nativeFundingCreated>::is_null(self.inner) { std::ptr::null_mut() } else { + inner: if <*mut nativeFundingCreated>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -1107,7 +1131,7 @@ pub extern "C" fn FundingCreated_clone(orig: &FundingCreated) -> FundingCreated } use lightning::ln::msgs::FundingSigned as nativeFundingSignedImport; -type nativeFundingSigned = nativeFundingSignedImport; +pub(crate) type nativeFundingSigned = nativeFundingSignedImport; /// A funding_signed message to be sent or received from a peer #[must_use] @@ -1137,7 +1161,7 @@ impl Drop for FundingSigned { pub extern "C" fn FundingSigned_free(this_obj: FundingSigned) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn FundingSigned_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn FundingSigned_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingSigned); } } #[allow(unused)] @@ -1152,7 +1176,7 @@ impl FundingSigned { pub(crate) fn take_inner(mut self) -> *mut nativeFundingSigned { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); - self.inner = std::ptr::null_mut(); + self.inner = core::ptr::null_mut(); ret } } @@ -1167,13 +1191,13 @@ pub extern "C" fn FundingSigned_get_channel_id(this_ptr: &FundingSigned) -> *con pub extern "C" fn FundingSigned_set_channel_id(this_ptr: &mut FundingSigned, mut val: crate::c_types::ThirtyTwoBytes) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data; } -/// The signature of the channel acceptor (fundee) on the funding transaction +/// The signature of the channel acceptor (fundee) on the initial commitment transaction #[no_mangle] pub extern "C" fn FundingSigned_get_signature(this_ptr: &FundingSigned) -> crate::c_types::Signature { let mut inner_val = &mut this_ptr.get_native_mut_ref().signature; crate::c_types::Signature::from_rust(&inner_val) } -/// The signature of the channel acceptor (fundee) on the funding transaction +/// The signature of the channel acceptor (fundee) on the initial commitment transaction #[no_mangle] pub extern "C" fn FundingSigned_set_signature(this_ptr: &mut FundingSigned, mut val: crate::c_types::Signature) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust(); @@ -1190,7 +1214,7 @@ pub extern "C" fn FundingSigned_new(mut channel_id_arg: crate::c_types::ThirtyTw impl Clone for FundingSigned { fn clone(&self) -> Self { Self { - inner: if <*mut nativeFundingSigned>::is_null(self.inner) { std::ptr::null_mut() } else { + inner: if <*mut nativeFundingSigned>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -1208,7 +1232,7 @@ pub extern "C" fn FundingSigned_clone(orig: &FundingSigned) -> FundingSigned { } use lightning::ln::msgs::FundingLocked as nativeFundingLockedImport; -type nativeFundingLocked = nativeFundingLockedImport; +pub(crate) type nativeFundingLocked = nativeFundingLockedImport; /// A funding_locked message to be sent or received from a peer #[must_use] @@ -1238,7 +1262,7 @@ impl Drop for FundingLocked { pub extern "C" fn FundingLocked_free(this_obj: FundingLocked) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn FundingLocked_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn FundingLocked_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFundingLocked); } } #[allow(unused)] @@ -1253,7 +1277,7 @@ impl FundingLocked { pub(crate) fn take_inner(mut self) -> *mut nativeFundingLocked { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); - self.inner = std::ptr::null_mut(); + self.inner = core::ptr::null_mut(); ret } } @@ -1291,7 +1315,7 @@ pub extern "C" fn FundingLocked_new(mut channel_id_arg: crate::c_types::ThirtyTw impl Clone for FundingLocked { fn clone(&self) -> Self { Self { - inner: if <*mut nativeFundingLocked>::is_null(self.inner) { std::ptr::null_mut() } else { + inner: if <*mut nativeFundingLocked>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -1309,7 +1333,7 @@ pub extern "C" fn FundingLocked_clone(orig: &FundingLocked) -> FundingLocked { } use lightning::ln::msgs::Shutdown as nativeShutdownImport; -type nativeShutdown = nativeShutdownImport; +pub(crate) type nativeShutdown = nativeShutdownImport; /// A shutdown message to be sent or received from a peer #[must_use] @@ -1339,7 +1363,7 @@ impl Drop for Shutdown { pub extern "C" fn Shutdown_free(this_obj: Shutdown) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn Shutdown_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn Shutdown_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeShutdown); } } #[allow(unused)] @@ -1354,7 +1378,7 @@ impl Shutdown { pub(crate) fn take_inner(mut self) -> *mut nativeShutdown { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); - self.inner = std::ptr::null_mut(); + self.inner = core::ptr::null_mut(); ret } } @@ -1394,7 +1418,7 @@ pub extern "C" fn Shutdown_new(mut channel_id_arg: crate::c_types::ThirtyTwoByte impl Clone for Shutdown { fn clone(&self) -> Self { Self { - inner: if <*mut nativeShutdown>::is_null(self.inner) { std::ptr::null_mut() } else { + inner: if <*mut nativeShutdown>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -1412,7 +1436,7 @@ pub extern "C" fn Shutdown_clone(orig: &Shutdown) -> Shutdown { } use lightning::ln::msgs::ClosingSignedFeeRange as nativeClosingSignedFeeRangeImport; -type nativeClosingSignedFeeRange = nativeClosingSignedFeeRangeImport; +pub(crate) type nativeClosingSignedFeeRange = nativeClosingSignedFeeRangeImport; /// The minimum and maximum fees which the sender is willing to place on the closing transaction. /// This is provided in [`ClosingSigned`] by both sides to indicate the fee range they are willing @@ -1444,7 +1468,7 @@ impl Drop for ClosingSignedFeeRange { pub extern "C" fn ClosingSignedFeeRange_free(this_obj: ClosingSignedFeeRange) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn ClosingSignedFeeRange_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn ClosingSignedFeeRange_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeClosingSignedFeeRange); } } #[allow(unused)] @@ -1459,7 +1483,7 @@ impl ClosingSignedFeeRange { pub(crate) fn take_inner(mut self) -> *mut nativeClosingSignedFeeRange { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); - self.inner = std::ptr::null_mut(); + self.inner = core::ptr::null_mut(); ret } } @@ -1501,7 +1525,7 @@ pub extern "C" fn ClosingSignedFeeRange_new(mut min_fee_satoshis_arg: u64, mut m impl Clone for ClosingSignedFeeRange { fn clone(&self) -> Self { Self { - inner: if <*mut nativeClosingSignedFeeRange>::is_null(self.inner) { std::ptr::null_mut() } else { + inner: if <*mut nativeClosingSignedFeeRange>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -1519,7 +1543,7 @@ pub extern "C" fn ClosingSignedFeeRange_clone(orig: &ClosingSignedFeeRange) -> C } use lightning::ln::msgs::ClosingSigned as nativeClosingSignedImport; -type nativeClosingSigned = nativeClosingSignedImport; +pub(crate) type nativeClosingSigned = nativeClosingSignedImport; /// A closing_signed message to be sent or received from a peer #[must_use] @@ -1549,7 +1573,7 @@ impl Drop for ClosingSigned { pub extern "C" fn ClosingSigned_free(this_obj: ClosingSigned) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn ClosingSigned_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn ClosingSigned_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeClosingSigned); } } #[allow(unused)] @@ -1564,7 +1588,7 @@ impl ClosingSigned { pub(crate) fn take_inner(mut self) -> *mut nativeClosingSigned { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); - self.inner = std::ptr::null_mut(); + self.inner = core::ptr::null_mut(); ret } } @@ -1608,7 +1632,7 @@ pub extern "C" fn ClosingSigned_set_signature(this_ptr: &mut ClosingSigned, mut #[no_mangle] pub extern "C" fn ClosingSigned_get_fee_range(this_ptr: &ClosingSigned) -> crate::lightning::ln::msgs::ClosingSignedFeeRange { let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_range; - let mut local_inner_val = crate::lightning::ln::msgs::ClosingSignedFeeRange { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const _) as *mut _ }, is_owned: false }; + let mut local_inner_val = crate::lightning::ln::msgs::ClosingSignedFeeRange { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::msgs::ClosingSignedFeeRange<>) as *mut _ }, is_owned: false }; local_inner_val } /// The minimum and maximum fees which the sender is willing to accept, provided only by new @@ -1635,7 +1659,7 @@ pub extern "C" fn ClosingSigned_new(mut channel_id_arg: crate::c_types::ThirtyTw impl Clone for ClosingSigned { fn clone(&self) -> Self { Self { - inner: if <*mut nativeClosingSigned>::is_null(self.inner) { std::ptr::null_mut() } else { + inner: if <*mut nativeClosingSigned>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -1653,7 +1677,7 @@ pub extern "C" fn ClosingSigned_clone(orig: &ClosingSigned) -> ClosingSigned { } use lightning::ln::msgs::UpdateAddHTLC as nativeUpdateAddHTLCImport; -type nativeUpdateAddHTLC = nativeUpdateAddHTLCImport; +pub(crate) type nativeUpdateAddHTLC = nativeUpdateAddHTLCImport; /// An update_add_htlc message to be sent or received from a peer #[must_use] @@ -1683,7 +1707,7 @@ impl Drop for UpdateAddHTLC { pub extern "C" fn UpdateAddHTLC_free(this_obj: UpdateAddHTLC) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn UpdateAddHTLC_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn UpdateAddHTLC_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateAddHTLC); } } #[allow(unused)] @@ -1698,7 +1722,7 @@ impl UpdateAddHTLC { pub(crate) fn take_inner(mut self) -> *mut nativeUpdateAddHTLC { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); - self.inner = std::ptr::null_mut(); + self.inner = core::ptr::null_mut(); ret } } @@ -1760,7 +1784,7 @@ pub extern "C" fn UpdateAddHTLC_set_cltv_expiry(this_ptr: &mut UpdateAddHTLC, mu impl Clone for UpdateAddHTLC { fn clone(&self) -> Self { Self { - inner: if <*mut nativeUpdateAddHTLC>::is_null(self.inner) { std::ptr::null_mut() } else { + inner: if <*mut nativeUpdateAddHTLC>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -1778,7 +1802,7 @@ pub extern "C" fn UpdateAddHTLC_clone(orig: &UpdateAddHTLC) -> UpdateAddHTLC { } use lightning::ln::msgs::UpdateFulfillHTLC as nativeUpdateFulfillHTLCImport; -type nativeUpdateFulfillHTLC = nativeUpdateFulfillHTLCImport; +pub(crate) type nativeUpdateFulfillHTLC = nativeUpdateFulfillHTLCImport; /// An update_fulfill_htlc message to be sent or received from a peer #[must_use] @@ -1808,7 +1832,7 @@ impl Drop for UpdateFulfillHTLC { pub extern "C" fn UpdateFulfillHTLC_free(this_obj: UpdateFulfillHTLC) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn UpdateFulfillHTLC_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn UpdateFulfillHTLC_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFulfillHTLC); } } #[allow(unused)] @@ -1823,7 +1847,7 @@ impl UpdateFulfillHTLC { pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFulfillHTLC { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); - self.inner = std::ptr::null_mut(); + self.inner = core::ptr::null_mut(); ret } } @@ -1873,7 +1897,7 @@ pub extern "C" fn UpdateFulfillHTLC_new(mut channel_id_arg: crate::c_types::Thir impl Clone for UpdateFulfillHTLC { fn clone(&self) -> Self { Self { - inner: if <*mut nativeUpdateFulfillHTLC>::is_null(self.inner) { std::ptr::null_mut() } else { + inner: if <*mut nativeUpdateFulfillHTLC>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -1891,7 +1915,7 @@ pub extern "C" fn UpdateFulfillHTLC_clone(orig: &UpdateFulfillHTLC) -> UpdateFul } use lightning::ln::msgs::UpdateFailHTLC as nativeUpdateFailHTLCImport; -type nativeUpdateFailHTLC = nativeUpdateFailHTLCImport; +pub(crate) type nativeUpdateFailHTLC = nativeUpdateFailHTLCImport; /// An update_fail_htlc message to be sent or received from a peer #[must_use] @@ -1921,7 +1945,7 @@ impl Drop for UpdateFailHTLC { pub extern "C" fn UpdateFailHTLC_free(this_obj: UpdateFailHTLC) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn UpdateFailHTLC_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn UpdateFailHTLC_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFailHTLC); } } #[allow(unused)] @@ -1936,7 +1960,7 @@ impl UpdateFailHTLC { pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailHTLC { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); - self.inner = std::ptr::null_mut(); + self.inner = core::ptr::null_mut(); ret } } @@ -1965,7 +1989,7 @@ pub extern "C" fn UpdateFailHTLC_set_htlc_id(this_ptr: &mut UpdateFailHTLC, mut impl Clone for UpdateFailHTLC { fn clone(&self) -> Self { Self { - inner: if <*mut nativeUpdateFailHTLC>::is_null(self.inner) { std::ptr::null_mut() } else { + inner: if <*mut nativeUpdateFailHTLC>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -1983,7 +2007,7 @@ pub extern "C" fn UpdateFailHTLC_clone(orig: &UpdateFailHTLC) -> UpdateFailHTLC } use lightning::ln::msgs::UpdateFailMalformedHTLC as nativeUpdateFailMalformedHTLCImport; -type nativeUpdateFailMalformedHTLC = nativeUpdateFailMalformedHTLCImport; +pub(crate) type nativeUpdateFailMalformedHTLC = nativeUpdateFailMalformedHTLCImport; /// An update_fail_malformed_htlc message to be sent or received from a peer #[must_use] @@ -2013,7 +2037,7 @@ impl Drop for UpdateFailMalformedHTLC { pub extern "C" fn UpdateFailMalformedHTLC_free(this_obj: UpdateFailMalformedHTLC) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn UpdateFailMalformedHTLC_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn UpdateFailMalformedHTLC_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFailMalformedHTLC); } } #[allow(unused)] @@ -2028,7 +2052,7 @@ impl UpdateFailMalformedHTLC { pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailMalformedHTLC { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); - self.inner = std::ptr::null_mut(); + self.inner = core::ptr::null_mut(); ret } } @@ -2068,7 +2092,7 @@ pub extern "C" fn UpdateFailMalformedHTLC_set_failure_code(this_ptr: &mut Update impl Clone for UpdateFailMalformedHTLC { fn clone(&self) -> Self { Self { - inner: if <*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) { std::ptr::null_mut() } else { + inner: if <*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -2086,7 +2110,7 @@ pub extern "C" fn UpdateFailMalformedHTLC_clone(orig: &UpdateFailMalformedHTLC) } use lightning::ln::msgs::CommitmentSigned as nativeCommitmentSignedImport; -type nativeCommitmentSigned = nativeCommitmentSignedImport; +pub(crate) type nativeCommitmentSigned = nativeCommitmentSignedImport; /// A commitment_signed message to be sent or received from a peer #[must_use] @@ -2116,7 +2140,7 @@ impl Drop for CommitmentSigned { pub extern "C" fn CommitmentSigned_free(this_obj: CommitmentSigned) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn CommitmentSigned_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn CommitmentSigned_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentSigned); } } #[allow(unused)] @@ -2131,7 +2155,7 @@ impl CommitmentSigned { pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentSigned { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); - self.inner = std::ptr::null_mut(); + self.inner = core::ptr::null_mut(); ret } } @@ -2177,7 +2201,7 @@ pub extern "C" fn CommitmentSigned_new(mut channel_id_arg: crate::c_types::Thirt impl Clone for CommitmentSigned { fn clone(&self) -> Self { Self { - inner: if <*mut nativeCommitmentSigned>::is_null(self.inner) { std::ptr::null_mut() } else { + inner: if <*mut nativeCommitmentSigned>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -2195,7 +2219,7 @@ pub extern "C" fn CommitmentSigned_clone(orig: &CommitmentSigned) -> CommitmentS } use lightning::ln::msgs::RevokeAndACK as nativeRevokeAndACKImport; -type nativeRevokeAndACK = nativeRevokeAndACKImport; +pub(crate) type nativeRevokeAndACK = nativeRevokeAndACKImport; /// A revoke_and_ack message to be sent or received from a peer #[must_use] @@ -2225,7 +2249,7 @@ impl Drop for RevokeAndACK { pub extern "C" fn RevokeAndACK_free(this_obj: RevokeAndACK) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn RevokeAndACK_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn RevokeAndACK_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRevokeAndACK); } } #[allow(unused)] @@ -2240,7 +2264,7 @@ impl RevokeAndACK { pub(crate) fn take_inner(mut self) -> *mut nativeRevokeAndACK { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); - self.inner = std::ptr::null_mut(); + self.inner = core::ptr::null_mut(); ret } } @@ -2290,7 +2314,7 @@ pub extern "C" fn RevokeAndACK_new(mut channel_id_arg: crate::c_types::ThirtyTwo impl Clone for RevokeAndACK { fn clone(&self) -> Self { Self { - inner: if <*mut nativeRevokeAndACK>::is_null(self.inner) { std::ptr::null_mut() } else { + inner: if <*mut nativeRevokeAndACK>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -2308,7 +2332,7 @@ pub extern "C" fn RevokeAndACK_clone(orig: &RevokeAndACK) -> RevokeAndACK { } use lightning::ln::msgs::UpdateFee as nativeUpdateFeeImport; -type nativeUpdateFee = nativeUpdateFeeImport; +pub(crate) type nativeUpdateFee = nativeUpdateFeeImport; /// An update_fee message to be sent or received from a peer #[must_use] @@ -2338,7 +2362,7 @@ impl Drop for UpdateFee { pub extern "C" fn UpdateFee_free(this_obj: UpdateFee) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn UpdateFee_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn UpdateFee_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUpdateFee); } } #[allow(unused)] @@ -2353,7 +2377,7 @@ impl UpdateFee { pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFee { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); - self.inner = std::ptr::null_mut(); + self.inner = core::ptr::null_mut(); ret } } @@ -2391,7 +2415,7 @@ pub extern "C" fn UpdateFee_new(mut channel_id_arg: crate::c_types::ThirtyTwoByt impl Clone for UpdateFee { fn clone(&self) -> Self { Self { - inner: if <*mut nativeUpdateFee>::is_null(self.inner) { std::ptr::null_mut() } else { + inner: if <*mut nativeUpdateFee>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -2409,7 +2433,7 @@ pub extern "C" fn UpdateFee_clone(orig: &UpdateFee) -> UpdateFee { } use lightning::ln::msgs::DataLossProtect as nativeDataLossProtectImport; -type nativeDataLossProtect = nativeDataLossProtectImport; +pub(crate) type nativeDataLossProtect = nativeDataLossProtectImport; /// Proof that the sender knows the per-commitment secret of the previous commitment transaction. /// This is used to convince the recipient that the channel is at a certain commitment @@ -2442,7 +2466,7 @@ impl Drop for DataLossProtect { pub extern "C" fn DataLossProtect_free(this_obj: DataLossProtect) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn DataLossProtect_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn DataLossProtect_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDataLossProtect); } } #[allow(unused)] @@ -2457,7 +2481,7 @@ impl DataLossProtect { pub(crate) fn take_inner(mut self) -> *mut nativeDataLossProtect { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); - self.inner = std::ptr::null_mut(); + self.inner = core::ptr::null_mut(); ret } } @@ -2497,7 +2521,7 @@ pub extern "C" fn DataLossProtect_new(mut your_last_per_commitment_secret_arg: c impl Clone for DataLossProtect { fn clone(&self) -> Self { Self { - inner: if <*mut nativeDataLossProtect>::is_null(self.inner) { std::ptr::null_mut() } else { + inner: if <*mut nativeDataLossProtect>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -2515,7 +2539,7 @@ pub extern "C" fn DataLossProtect_clone(orig: &DataLossProtect) -> DataLossProte } use lightning::ln::msgs::ChannelReestablish as nativeChannelReestablishImport; -type nativeChannelReestablish = nativeChannelReestablishImport; +pub(crate) type nativeChannelReestablish = nativeChannelReestablishImport; /// A channel_reestablish message to be sent or received from a peer #[must_use] @@ -2545,7 +2569,7 @@ impl Drop for ChannelReestablish { pub extern "C" fn ChannelReestablish_free(this_obj: ChannelReestablish) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn ChannelReestablish_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn ChannelReestablish_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelReestablish); } } #[allow(unused)] @@ -2560,7 +2584,7 @@ impl ChannelReestablish { pub(crate) fn take_inner(mut self) -> *mut nativeChannelReestablish { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); - self.inner = std::ptr::null_mut(); + self.inner = core::ptr::null_mut(); ret } } @@ -2600,7 +2624,7 @@ pub extern "C" fn ChannelReestablish_set_next_remote_commitment_number(this_ptr: impl Clone for ChannelReestablish { fn clone(&self) -> Self { Self { - inner: if <*mut nativeChannelReestablish>::is_null(self.inner) { std::ptr::null_mut() } else { + inner: if <*mut nativeChannelReestablish>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -2618,7 +2642,7 @@ pub extern "C" fn ChannelReestablish_clone(orig: &ChannelReestablish) -> Channel } use lightning::ln::msgs::AnnouncementSignatures as nativeAnnouncementSignaturesImport; -type nativeAnnouncementSignatures = nativeAnnouncementSignaturesImport; +pub(crate) type nativeAnnouncementSignatures = nativeAnnouncementSignaturesImport; /// An announcement_signatures message to be sent or received from a peer #[must_use] @@ -2648,7 +2672,7 @@ impl Drop for AnnouncementSignatures { pub extern "C" fn AnnouncementSignatures_free(this_obj: AnnouncementSignatures) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn AnnouncementSignatures_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn AnnouncementSignatures_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeAnnouncementSignatures); } } #[allow(unused)] @@ -2663,7 +2687,7 @@ impl AnnouncementSignatures { pub(crate) fn take_inner(mut self) -> *mut nativeAnnouncementSignatures { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); - self.inner = std::ptr::null_mut(); + self.inner = core::ptr::null_mut(); ret } } @@ -2725,7 +2749,7 @@ pub extern "C" fn AnnouncementSignatures_new(mut channel_id_arg: crate::c_types: impl Clone for AnnouncementSignatures { fn clone(&self) -> Self { Self { - inner: if <*mut nativeAnnouncementSignatures>::is_null(self.inner) { std::ptr::null_mut() } else { + inner: if <*mut nativeAnnouncementSignatures>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -2761,12 +2785,10 @@ pub enum NetAddress { port: u16, }, /// An old-style Tor onion address/port on which the peer is listening. - OnionV2 { - /// The bytes (usually encoded in base32 with \".onion\" appended) - addr: crate::c_types::TenBytes, - /// The port on which the node is listening - port: u16, - }, + /// + /// This field is deprecated and the Tor network generally no longer supports V2 Onion + /// addresses. Thus, the details are not parsed here. + OnionV2(crate::c_types::TwelveBytes), /// A new-style Tor onion address/port on which the peer is listening. /// To create the human-readable \"hostname\", concatenate ed25519_pubkey, checksum, and version, /// wrap as base32 and append \".onion\". @@ -2802,13 +2824,11 @@ impl NetAddress { port: port_nonref, } }, - NetAddress::OnionV2 {ref addr, ref port, } => { - let mut addr_nonref = (*addr).clone(); - let mut port_nonref = (*port).clone(); - nativeNetAddress::OnionV2 { - addr: addr_nonref.data, - port: port_nonref, - } + NetAddress::OnionV2 (ref a, ) => { + let mut a_nonref = (*a).clone(); + nativeNetAddress::OnionV2 ( + a_nonref.data, + ) }, NetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => { let mut ed25519_pubkey_nonref = (*ed25519_pubkey).clone(); @@ -2839,11 +2859,10 @@ impl NetAddress { port: port, } }, - NetAddress::OnionV2 {mut addr, mut port, } => { - nativeNetAddress::OnionV2 { - addr: addr.data, - port: port, - } + NetAddress::OnionV2 (mut a, ) => { + nativeNetAddress::OnionV2 ( + a.data, + ) }, NetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => { nativeNetAddress::OnionV3 { @@ -2874,13 +2893,11 @@ impl NetAddress { port: port_nonref, } }, - nativeNetAddress::OnionV2 {ref addr, ref port, } => { - let mut addr_nonref = (*addr).clone(); - let mut port_nonref = (*port).clone(); - NetAddress::OnionV2 { - addr: crate::c_types::TenBytes { data: addr_nonref }, - port: port_nonref, - } + nativeNetAddress::OnionV2 (ref a, ) => { + let mut a_nonref = (*a).clone(); + NetAddress::OnionV2 ( + crate::c_types::TwelveBytes { data: a_nonref }, + ) }, nativeNetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => { let mut ed25519_pubkey_nonref = (*ed25519_pubkey).clone(); @@ -2911,11 +2928,10 @@ impl NetAddress { port: port, } }, - nativeNetAddress::OnionV2 {mut addr, mut port, } => { - NetAddress::OnionV2 { - addr: crate::c_types::TenBytes { data: addr }, - port: port, - } + nativeNetAddress::OnionV2 (mut a, ) => { + NetAddress::OnionV2 ( + crate::c_types::TwelveBytes { data: a }, + ) }, nativeNetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => { NetAddress::OnionV3 { @@ -2954,11 +2970,8 @@ pub extern "C" fn NetAddress_ipv6(addr: crate::c_types::SixteenBytes, port: u16) } #[no_mangle] /// Utility method to constructs a new OnionV2-variant NetAddress -pub extern "C" fn NetAddress_onion_v2(addr: crate::c_types::TenBytes, port: u16) -> NetAddress { - NetAddress::OnionV2 { - addr, - port, - } +pub extern "C" fn NetAddress_onion_v2(a: crate::c_types::TwelveBytes) -> NetAddress { + NetAddress::OnionV2(a, ) } #[no_mangle] /// Utility method to constructs a new OnionV3-variant NetAddress @@ -2976,22 +2989,15 @@ pub extern "C" fn NetAddress_write(obj: &NetAddress) -> crate::c_types::derived: crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) } #[no_mangle] -/// Read a Result from a byte array, created by Result_write -pub extern "C" fn Result_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CResult_NetAddressu8ZDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = match o { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::NetAddress::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { e }).into() }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; - local_res -} -#[no_mangle] /// Read a NetAddress from a byte array, created by NetAddress_write pub extern "C" fn NetAddress_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NetAddressDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); + let res: Result = crate::c_types::deserialize_obj(ser); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::NetAddress::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_res } use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport; -type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport; +pub(crate) type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport; /// The unsigned part of a node_announcement #[must_use] @@ -3021,7 +3027,7 @@ impl Drop for UnsignedNodeAnnouncement { pub extern "C" fn UnsignedNodeAnnouncement_free(this_obj: UnsignedNodeAnnouncement) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn UnsignedNodeAnnouncement_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn UnsignedNodeAnnouncement_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedNodeAnnouncement); } } #[allow(unused)] @@ -3036,7 +3042,7 @@ impl UnsignedNodeAnnouncement { pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedNodeAnnouncement { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); - self.inner = std::ptr::null_mut(); + self.inner = core::ptr::null_mut(); ret } } @@ -3044,7 +3050,7 @@ impl UnsignedNodeAnnouncement { #[no_mangle] pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::ln::features::NodeFeatures { let mut inner_val = &mut this_ptr.get_native_mut_ref().features; - crate::lightning::ln::features::NodeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false } + crate::lightning::ln::features::NodeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::NodeFeatures<>) as *mut _) }, is_owned: false } } /// The advertised features #[no_mangle] @@ -3108,7 +3114,7 @@ pub extern "C" fn UnsignedNodeAnnouncement_set_addresses(this_ptr: &mut Unsigned impl Clone for UnsignedNodeAnnouncement { fn clone(&self) -> Self { Self { - inner: if <*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else { + inner: if <*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -3126,7 +3132,7 @@ pub extern "C" fn UnsignedNodeAnnouncement_clone(orig: &UnsignedNodeAnnouncement } use lightning::ln::msgs::NodeAnnouncement as nativeNodeAnnouncementImport; -type nativeNodeAnnouncement = nativeNodeAnnouncementImport; +pub(crate) type nativeNodeAnnouncement = nativeNodeAnnouncementImport; /// A node_announcement message to be sent or received from a peer #[must_use] @@ -3156,7 +3162,7 @@ impl Drop for NodeAnnouncement { pub extern "C" fn NodeAnnouncement_free(this_obj: NodeAnnouncement) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn NodeAnnouncement_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn NodeAnnouncement_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeAnnouncement); } } #[allow(unused)] @@ -3171,7 +3177,7 @@ impl NodeAnnouncement { pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncement { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); - self.inner = std::ptr::null_mut(); + self.inner = core::ptr::null_mut(); ret } } @@ -3190,7 +3196,7 @@ pub extern "C" fn NodeAnnouncement_set_signature(this_ptr: &mut NodeAnnouncement #[no_mangle] pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> crate::lightning::ln::msgs::UnsignedNodeAnnouncement { let mut inner_val = &mut this_ptr.get_native_mut_ref().contents; - crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false } + crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::UnsignedNodeAnnouncement<>) as *mut _) }, is_owned: false } } /// The actual content of the announcement #[no_mangle] @@ -3209,7 +3215,7 @@ pub extern "C" fn NodeAnnouncement_new(mut signature_arg: crate::c_types::Signat impl Clone for NodeAnnouncement { fn clone(&self) -> Self { Self { - inner: if <*mut nativeNodeAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else { + inner: if <*mut nativeNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -3227,7 +3233,7 @@ pub extern "C" fn NodeAnnouncement_clone(orig: &NodeAnnouncement) -> NodeAnnounc } use lightning::ln::msgs::UnsignedChannelAnnouncement as nativeUnsignedChannelAnnouncementImport; -type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport; +pub(crate) type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport; /// The unsigned part of a channel_announcement #[must_use] @@ -3257,7 +3263,7 @@ impl Drop for UnsignedChannelAnnouncement { pub extern "C" fn UnsignedChannelAnnouncement_free(this_obj: UnsignedChannelAnnouncement) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn UnsignedChannelAnnouncement_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn UnsignedChannelAnnouncement_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelAnnouncement); } } #[allow(unused)] @@ -3272,7 +3278,7 @@ impl UnsignedChannelAnnouncement { pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelAnnouncement { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); - self.inner = std::ptr::null_mut(); + self.inner = core::ptr::null_mut(); ret } } @@ -3280,7 +3286,7 @@ impl UnsignedChannelAnnouncement { #[no_mangle] pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::ln::features::ChannelFeatures { let mut inner_val = &mut this_ptr.get_native_mut_ref().features; - crate::lightning::ln::features::ChannelFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false } + crate::lightning::ln::features::ChannelFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::ChannelFeatures<>) as *mut _) }, is_owned: false } } /// The advertised channel features #[no_mangle] @@ -3356,7 +3362,7 @@ pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_2(this_ptr: &mut U impl Clone for UnsignedChannelAnnouncement { fn clone(&self) -> Self { Self { - inner: if <*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else { + inner: if <*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -3374,7 +3380,7 @@ pub extern "C" fn UnsignedChannelAnnouncement_clone(orig: &UnsignedChannelAnnoun } use lightning::ln::msgs::ChannelAnnouncement as nativeChannelAnnouncementImport; -type nativeChannelAnnouncement = nativeChannelAnnouncementImport; +pub(crate) type nativeChannelAnnouncement = nativeChannelAnnouncementImport; /// A channel_announcement message to be sent or received from a peer #[must_use] @@ -3404,7 +3410,7 @@ impl Drop for ChannelAnnouncement { pub extern "C" fn ChannelAnnouncement_free(this_obj: ChannelAnnouncement) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn ChannelAnnouncement_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn ChannelAnnouncement_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelAnnouncement); } } #[allow(unused)] @@ -3419,7 +3425,7 @@ impl ChannelAnnouncement { pub(crate) fn take_inner(mut self) -> *mut nativeChannelAnnouncement { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); - self.inner = std::ptr::null_mut(); + self.inner = core::ptr::null_mut(); ret } } @@ -3471,7 +3477,7 @@ pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_2(this_ptr: &mut Cha #[no_mangle] pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncement) -> crate::lightning::ln::msgs::UnsignedChannelAnnouncement { let mut inner_val = &mut this_ptr.get_native_mut_ref().contents; - crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false } + crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::UnsignedChannelAnnouncement<>) as *mut _) }, is_owned: false } } /// The actual announcement #[no_mangle] @@ -3493,7 +3499,7 @@ pub extern "C" fn ChannelAnnouncement_new(mut node_signature_1_arg: crate::c_typ impl Clone for ChannelAnnouncement { fn clone(&self) -> Self { Self { - inner: if <*mut nativeChannelAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else { + inner: if <*mut nativeChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -3511,7 +3517,7 @@ pub extern "C" fn ChannelAnnouncement_clone(orig: &ChannelAnnouncement) -> Chann } use lightning::ln::msgs::UnsignedChannelUpdate as nativeUnsignedChannelUpdateImport; -type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport; +pub(crate) type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport; /// The unsigned part of a channel_update #[must_use] @@ -3541,7 +3547,7 @@ impl Drop for UnsignedChannelUpdate { pub extern "C" fn UnsignedChannelUpdate_free(this_obj: UnsignedChannelUpdate) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn UnsignedChannelUpdate_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn UnsignedChannelUpdate_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUnsignedChannelUpdate); } } #[allow(unused)] @@ -3556,7 +3562,7 @@ impl UnsignedChannelUpdate { pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelUpdate { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); - self.inner = std::ptr::null_mut(); + self.inner = core::ptr::null_mut(); ret } } @@ -3665,7 +3671,7 @@ pub extern "C" fn UnsignedChannelUpdate_set_fee_proportional_millionths(this_ptr impl Clone for UnsignedChannelUpdate { fn clone(&self) -> Self { Self { - inner: if <*mut nativeUnsignedChannelUpdate>::is_null(self.inner) { std::ptr::null_mut() } else { + inner: if <*mut nativeUnsignedChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -3683,7 +3689,7 @@ pub extern "C" fn UnsignedChannelUpdate_clone(orig: &UnsignedChannelUpdate) -> U } use lightning::ln::msgs::ChannelUpdate as nativeChannelUpdateImport; -type nativeChannelUpdate = nativeChannelUpdateImport; +pub(crate) type nativeChannelUpdate = nativeChannelUpdateImport; /// A channel_update message to be sent or received from a peer #[must_use] @@ -3713,7 +3719,7 @@ impl Drop for ChannelUpdate { pub extern "C" fn ChannelUpdate_free(this_obj: ChannelUpdate) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn ChannelUpdate_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn ChannelUpdate_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelUpdate); } } #[allow(unused)] @@ -3728,7 +3734,7 @@ impl ChannelUpdate { pub(crate) fn take_inner(mut self) -> *mut nativeChannelUpdate { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); - self.inner = std::ptr::null_mut(); + self.inner = core::ptr::null_mut(); ret } } @@ -3747,7 +3753,7 @@ pub extern "C" fn ChannelUpdate_set_signature(this_ptr: &mut ChannelUpdate, mut #[no_mangle] pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate::lightning::ln::msgs::UnsignedChannelUpdate { let mut inner_val = &mut this_ptr.get_native_mut_ref().contents; - crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false } + crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::UnsignedChannelUpdate<>) as *mut _) }, is_owned: false } } /// The actual channel update #[no_mangle] @@ -3766,7 +3772,7 @@ pub extern "C" fn ChannelUpdate_new(mut signature_arg: crate::c_types::Signature impl Clone for ChannelUpdate { fn clone(&self) -> Self { Self { - inner: if <*mut nativeChannelUpdate>::is_null(self.inner) { std::ptr::null_mut() } else { + inner: if <*mut nativeChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -3784,7 +3790,7 @@ pub extern "C" fn ChannelUpdate_clone(orig: &ChannelUpdate) -> ChannelUpdate { } use lightning::ln::msgs::QueryChannelRange as nativeQueryChannelRangeImport; -type nativeQueryChannelRange = nativeQueryChannelRangeImport; +pub(crate) type nativeQueryChannelRange = nativeQueryChannelRangeImport; /// A query_channel_range message is used to query a peer for channel /// UTXOs in a range of blocks. The recipient of a query makes a best @@ -3817,7 +3823,7 @@ impl Drop for QueryChannelRange { pub extern "C" fn QueryChannelRange_free(this_obj: QueryChannelRange) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn QueryChannelRange_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryChannelRange); } } #[allow(unused)] @@ -3832,7 +3838,7 @@ impl QueryChannelRange { pub(crate) fn take_inner(mut self) -> *mut nativeQueryChannelRange { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); - self.inner = std::ptr::null_mut(); + self.inner = core::ptr::null_mut(); ret } } @@ -3882,7 +3888,7 @@ pub extern "C" fn QueryChannelRange_new(mut chain_hash_arg: crate::c_types::Thir impl Clone for QueryChannelRange { fn clone(&self) -> Self { Self { - inner: if <*mut nativeQueryChannelRange>::is_null(self.inner) { std::ptr::null_mut() } else { + inner: if <*mut nativeQueryChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -3900,7 +3906,7 @@ pub extern "C" fn QueryChannelRange_clone(orig: &QueryChannelRange) -> QueryChan } use lightning::ln::msgs::ReplyChannelRange as nativeReplyChannelRangeImport; -type nativeReplyChannelRange = nativeReplyChannelRangeImport; +pub(crate) type nativeReplyChannelRange = nativeReplyChannelRangeImport; /// A reply_channel_range message is a reply to a query_channel_range /// message. Multiple reply_channel_range messages can be sent in reply @@ -3936,7 +3942,7 @@ impl Drop for ReplyChannelRange { pub extern "C" fn ReplyChannelRange_free(this_obj: ReplyChannelRange) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn ReplyChannelRange_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyChannelRange); } } #[allow(unused)] @@ -3951,7 +3957,7 @@ impl ReplyChannelRange { pub(crate) fn take_inner(mut self) -> *mut nativeReplyChannelRange { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); - self.inner = std::ptr::null_mut(); + self.inner = core::ptr::null_mut(); ret } } @@ -4021,7 +4027,7 @@ pub extern "C" fn ReplyChannelRange_new(mut chain_hash_arg: crate::c_types::Thir impl Clone for ReplyChannelRange { fn clone(&self) -> Self { Self { - inner: if <*mut nativeReplyChannelRange>::is_null(self.inner) { std::ptr::null_mut() } else { + inner: if <*mut nativeReplyChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -4039,7 +4045,7 @@ pub extern "C" fn ReplyChannelRange_clone(orig: &ReplyChannelRange) -> ReplyChan } use lightning::ln::msgs::QueryShortChannelIds as nativeQueryShortChannelIdsImport; -type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport; +pub(crate) type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport; /// A query_short_channel_ids message is used to query a peer for /// routing gossip messages related to one or more short_channel_ids. @@ -4076,7 +4082,7 @@ impl Drop for QueryShortChannelIds { pub extern "C" fn QueryShortChannelIds_free(this_obj: QueryShortChannelIds) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn QueryShortChannelIds_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeQueryShortChannelIds); } } #[allow(unused)] @@ -4091,7 +4097,7 @@ impl QueryShortChannelIds { pub(crate) fn take_inner(mut self) -> *mut nativeQueryShortChannelIds { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); - self.inner = std::ptr::null_mut(); + self.inner = core::ptr::null_mut(); ret } } @@ -4125,7 +4131,7 @@ pub extern "C" fn QueryShortChannelIds_new(mut chain_hash_arg: crate::c_types::T impl Clone for QueryShortChannelIds { fn clone(&self) -> Self { Self { - inner: if <*mut nativeQueryShortChannelIds>::is_null(self.inner) { std::ptr::null_mut() } else { + inner: if <*mut nativeQueryShortChannelIds>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -4143,7 +4149,7 @@ pub extern "C" fn QueryShortChannelIds_clone(orig: &QueryShortChannelIds) -> Que } use lightning::ln::msgs::ReplyShortChannelIdsEnd as nativeReplyShortChannelIdsEndImport; -type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport; +pub(crate) type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport; /// A reply_short_channel_ids_end message is sent as a reply to a /// query_short_channel_ids message. The query recipient makes a best @@ -4176,7 +4182,7 @@ impl Drop for ReplyShortChannelIdsEnd { pub extern "C" fn ReplyShortChannelIdsEnd_free(this_obj: ReplyShortChannelIdsEnd) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn ReplyShortChannelIdsEnd_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReplyShortChannelIdsEnd); } } #[allow(unused)] @@ -4191,7 +4197,7 @@ impl ReplyShortChannelIdsEnd { pub(crate) fn take_inner(mut self) -> *mut nativeReplyShortChannelIdsEnd { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); - self.inner = std::ptr::null_mut(); + self.inner = core::ptr::null_mut(); ret } } @@ -4231,7 +4237,7 @@ pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types impl Clone for ReplyShortChannelIdsEnd { fn clone(&self) -> Self { Self { - inner: if <*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) { std::ptr::null_mut() } else { + inner: if <*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -4249,7 +4255,7 @@ pub extern "C" fn ReplyShortChannelIdsEnd_clone(orig: &ReplyShortChannelIdsEnd) } use lightning::ln::msgs::GossipTimestampFilter as nativeGossipTimestampFilterImport; -type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport; +pub(crate) type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport; /// A gossip_timestamp_filter message is used by a node to request /// gossip relay for messages in the requested time range when the @@ -4281,7 +4287,7 @@ impl Drop for GossipTimestampFilter { pub extern "C" fn GossipTimestampFilter_free(this_obj: GossipTimestampFilter) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn GossipTimestampFilter_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeGossipTimestampFilter); } } #[allow(unused)] @@ -4296,7 +4302,7 @@ impl GossipTimestampFilter { pub(crate) fn take_inner(mut self) -> *mut nativeGossipTimestampFilter { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); - self.inner = std::ptr::null_mut(); + self.inner = core::ptr::null_mut(); ret } } @@ -4346,7 +4352,7 @@ pub extern "C" fn GossipTimestampFilter_new(mut chain_hash_arg: crate::c_types:: impl Clone for GossipTimestampFilter { fn clone(&self) -> Self { Self { - inner: if <*mut nativeGossipTimestampFilter>::is_null(self.inner) { std::ptr::null_mut() } else { + inner: if <*mut nativeGossipTimestampFilter>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -4379,6 +4385,10 @@ pub enum ErrorAction { /// The peer did something harmless that we weren't able to meaningfully process. /// If the error is logged, log it at the given level. IgnoreAndLog(crate::lightning::util::logger::Level), + /// The peer provided us with a gossip message which we'd already seen. In most cases this + /// should be ignored, but it may result in the message being forwarded if it is a duplicate of + /// our own channel announcements. + IgnoreDuplicateGossip, /// The peer did something incorrect. Tell them. SendErrorMessage { /// The message to send. @@ -4404,6 +4414,7 @@ impl ErrorAction { a_nonref.into_native(), ) }, + ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip, ErrorAction::SendErrorMessage {ref msg, } => { let mut msg_nonref = (*msg).clone(); nativeErrorAction::SendErrorMessage { @@ -4427,6 +4438,7 @@ impl ErrorAction { a.into_native(), ) }, + ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip, ErrorAction::SendErrorMessage {mut msg, } => { nativeErrorAction::SendErrorMessage { msg: *unsafe { Box::from_raw(msg.take_inner()) }, @@ -4439,7 +4451,7 @@ impl ErrorAction { match native { nativeErrorAction::DisconnectPeer {ref msg, } => { let mut msg_nonref = (*msg).clone(); - let mut local_msg_nonref = crate::lightning::ln::msgs::ErrorMessage { inner: if msg_nonref.is_none() { std::ptr::null_mut() } else { { ObjOps::heap_alloc((msg_nonref.unwrap())) } }, is_owned: true }; + let mut local_msg_nonref = crate::lightning::ln::msgs::ErrorMessage { inner: if msg_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((msg_nonref.unwrap())) } }, is_owned: true }; ErrorAction::DisconnectPeer { msg: local_msg_nonref, } @@ -4451,6 +4463,7 @@ impl ErrorAction { crate::lightning::util::logger::Level::native_into(a_nonref), ) }, + nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip, nativeErrorAction::SendErrorMessage {ref msg, } => { let mut msg_nonref = (*msg).clone(); ErrorAction::SendErrorMessage { @@ -4463,7 +4476,7 @@ impl ErrorAction { pub(crate) fn native_into(native: nativeErrorAction) -> Self { match native { nativeErrorAction::DisconnectPeer {mut msg, } => { - let mut local_msg = crate::lightning::ln::msgs::ErrorMessage { inner: if msg.is_none() { std::ptr::null_mut() } else { { ObjOps::heap_alloc((msg.unwrap())) } }, is_owned: true }; + let mut local_msg = crate::lightning::ln::msgs::ErrorMessage { inner: if msg.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((msg.unwrap())) } }, is_owned: true }; ErrorAction::DisconnectPeer { msg: local_msg, } @@ -4474,6 +4487,7 @@ impl ErrorAction { crate::lightning::util::logger::Level::native_into(a), ) }, + nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip, nativeErrorAction::SendErrorMessage {mut msg, } => { ErrorAction::SendErrorMessage { msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg), is_owned: true }, @@ -4507,6 +4521,10 @@ pub extern "C" fn ErrorAction_ignore_and_log(a: crate::lightning::util::logger:: ErrorAction::IgnoreAndLog(a, ) } #[no_mangle] +/// Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction +pub extern "C" fn ErrorAction_ignore_duplicate_gossip() -> ErrorAction { + ErrorAction::IgnoreDuplicateGossip} +#[no_mangle] /// Utility method to constructs a new SendErrorMessage-variant ErrorAction pub extern "C" fn ErrorAction_send_error_message(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction { ErrorAction::SendErrorMessage { @@ -4515,7 +4533,7 @@ pub extern "C" fn ErrorAction_send_error_message(msg: crate::lightning::ln::msgs } use lightning::ln::msgs::LightningError as nativeLightningErrorImport; -type nativeLightningError = nativeLightningErrorImport; +pub(crate) type nativeLightningError = nativeLightningErrorImport; /// An Err type for failure to process messages. #[must_use] @@ -4545,7 +4563,7 @@ impl Drop for LightningError { pub extern "C" fn LightningError_free(this_obj: LightningError) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn LightningError_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn LightningError_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeLightningError); } } #[allow(unused)] @@ -4560,7 +4578,7 @@ impl LightningError { pub(crate) fn take_inner(mut self) -> *mut nativeLightningError { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); - self.inner = std::ptr::null_mut(); + self.inner = core::ptr::null_mut(); ret } } @@ -4598,7 +4616,7 @@ pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::Str, mut actio impl Clone for LightningError { fn clone(&self) -> Self { Self { - inner: if <*mut nativeLightningError>::is_null(self.inner) { std::ptr::null_mut() } else { + inner: if <*mut nativeLightningError>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -4616,7 +4634,7 @@ pub extern "C" fn LightningError_clone(orig: &LightningError) -> LightningError } use lightning::ln::msgs::CommitmentUpdate as nativeCommitmentUpdateImport; -type nativeCommitmentUpdate = nativeCommitmentUpdateImport; +pub(crate) type nativeCommitmentUpdate = nativeCommitmentUpdateImport; /// Struct used to return values from revoke_and_ack messages, containing a bunch of commitment /// transaction updates if they were pending. @@ -4647,7 +4665,7 @@ impl Drop for CommitmentUpdate { pub extern "C" fn CommitmentUpdate_free(this_obj: CommitmentUpdate) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn CommitmentUpdate_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCommitmentUpdate); } } #[allow(unused)] @@ -4662,30 +4680,58 @@ impl CommitmentUpdate { pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentUpdate { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); - self.inner = std::ptr::null_mut(); + self.inner = core::ptr::null_mut(); ret } } /// update_add_htlc messages which should be sent #[no_mangle] +pub extern "C" fn CommitmentUpdate_get_update_add_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateAddHTLCZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().update_add_htlcs; + let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::ln::msgs::UpdateAddHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::ln::msgs::UpdateAddHTLC<>) as *mut _) }, is_owned: false } }); }; + local_inner_val.into() +} +/// update_add_htlc messages which should be sent +#[no_mangle] pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) { let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_add_htlcs = local_val; } /// update_fulfill_htlc messages which should be sent #[no_mangle] +pub extern "C" fn CommitmentUpdate_get_update_fulfill_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFulfillHTLCZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fulfill_htlcs; + let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::ln::msgs::UpdateFulfillHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::ln::msgs::UpdateFulfillHTLC<>) as *mut _) }, is_owned: false } }); }; + local_inner_val.into() +} +/// update_fulfill_htlc messages which should be sent +#[no_mangle] pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) { let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fulfill_htlcs = local_val; } /// update_fail_htlc messages which should be sent #[no_mangle] +pub extern "C" fn CommitmentUpdate_get_update_fail_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailHTLCZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_htlcs; + let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::ln::msgs::UpdateFailHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::ln::msgs::UpdateFailHTLC<>) as *mut _) }, is_owned: false } }); }; + local_inner_val.into() +} +/// update_fail_htlc messages which should be sent +#[no_mangle] pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) { let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_htlcs = local_val; } /// update_fail_malformed_htlc messages which should be sent #[no_mangle] +pub extern "C" fn CommitmentUpdate_get_update_fail_malformed_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_malformed_htlcs; + let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::ln::msgs::UpdateFailMalformedHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::ln::msgs::UpdateFailMalformedHTLC<>) as *mut _) }, is_owned: false } }); }; + local_inner_val.into() +} +/// update_fail_malformed_htlc messages which should be sent +#[no_mangle] pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) { let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_fail_malformed_htlcs = local_val; @@ -4696,7 +4742,7 @@ pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mu #[no_mangle] pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::UpdateFee { let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fee; - let mut local_inner_val = crate::lightning::ln::msgs::UpdateFee { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const _) as *mut _ }, is_owned: false }; + let mut local_inner_val = crate::lightning::ln::msgs::UpdateFee { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::msgs::UpdateFee<>) as *mut _ }, is_owned: false }; local_inner_val } /// An update_fee message which should be sent @@ -4711,7 +4757,7 @@ pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdat #[no_mangle] pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::CommitmentSigned { let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_signed; - crate::lightning::ln::msgs::CommitmentSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false } + crate::lightning::ln::msgs::CommitmentSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::CommitmentSigned<>) as *mut _) }, is_owned: false } } /// Finally, the commitment_signed message which should be sent #[no_mangle] @@ -4739,7 +4785,7 @@ pub extern "C" fn CommitmentUpdate_new(mut update_add_htlcs_arg: crate::c_types: impl Clone for CommitmentUpdate { fn clone(&self) -> Self { Self { - inner: if <*mut nativeCommitmentUpdate>::is_null(self.inner) { std::ptr::null_mut() } else { + inner: if <*mut nativeCommitmentUpdate>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -4755,168 +4801,6 @@ pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const c_void) -> pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentUpdate { orig.clone() } -/// The information we received from a peer along the route of a payment we originated. This is -/// returned by ChannelMessageHandler::handle_update_fail_htlc to be passed into -/// RoutingMessageHandler::handle_htlc_fail_channel_update to update our network map. -#[must_use] -#[derive(Clone)] -#[repr(C)] -pub enum HTLCFailChannelUpdate { - /// We received an error which included a full ChannelUpdate message. - ChannelUpdateMessage { - /// The unwrapped message we received - msg: crate::lightning::ln::msgs::ChannelUpdate, - }, - /// We received an error which indicated only that a channel has been closed - ChannelClosed { - /// The short_channel_id which has now closed. - short_channel_id: u64, - /// when this true, this channel should be permanently removed from the - /// consideration. Otherwise, this channel can be restored as new channel_update is received - is_permanent: bool, - }, - /// We received an error which indicated only that a node has failed - NodeFailure { - /// The node_id that has failed. - node_id: crate::c_types::PublicKey, - /// when this true, node should be permanently removed from the - /// consideration. Otherwise, the channels connected to this node can be - /// restored as new channel_update is received - is_permanent: bool, - }, -} -use lightning::ln::msgs::HTLCFailChannelUpdate as nativeHTLCFailChannelUpdate; -impl HTLCFailChannelUpdate { - #[allow(unused)] - pub(crate) fn to_native(&self) -> nativeHTLCFailChannelUpdate { - match self { - HTLCFailChannelUpdate::ChannelUpdateMessage {ref msg, } => { - let mut msg_nonref = (*msg).clone(); - nativeHTLCFailChannelUpdate::ChannelUpdateMessage { - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - HTLCFailChannelUpdate::ChannelClosed {ref short_channel_id, ref is_permanent, } => { - let mut short_channel_id_nonref = (*short_channel_id).clone(); - let mut is_permanent_nonref = (*is_permanent).clone(); - nativeHTLCFailChannelUpdate::ChannelClosed { - short_channel_id: short_channel_id_nonref, - is_permanent: is_permanent_nonref, - } - }, - HTLCFailChannelUpdate::NodeFailure {ref node_id, ref is_permanent, } => { - let mut node_id_nonref = (*node_id).clone(); - let mut is_permanent_nonref = (*is_permanent).clone(); - nativeHTLCFailChannelUpdate::NodeFailure { - node_id: node_id_nonref.into_rust(), - is_permanent: is_permanent_nonref, - } - }, - } - } - #[allow(unused)] - pub(crate) fn into_native(self) -> nativeHTLCFailChannelUpdate { - match self { - HTLCFailChannelUpdate::ChannelUpdateMessage {mut msg, } => { - nativeHTLCFailChannelUpdate::ChannelUpdateMessage { - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - HTLCFailChannelUpdate::ChannelClosed {mut short_channel_id, mut is_permanent, } => { - nativeHTLCFailChannelUpdate::ChannelClosed { - short_channel_id: short_channel_id, - is_permanent: is_permanent, - } - }, - HTLCFailChannelUpdate::NodeFailure {mut node_id, mut is_permanent, } => { - nativeHTLCFailChannelUpdate::NodeFailure { - node_id: node_id.into_rust(), - is_permanent: is_permanent, - } - }, - } - } - #[allow(unused)] - pub(crate) fn from_native(native: &nativeHTLCFailChannelUpdate) -> Self { - match native { - nativeHTLCFailChannelUpdate::ChannelUpdateMessage {ref msg, } => { - let mut msg_nonref = (*msg).clone(); - HTLCFailChannelUpdate::ChannelUpdateMessage { - msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - } - }, - nativeHTLCFailChannelUpdate::ChannelClosed {ref short_channel_id, ref is_permanent, } => { - let mut short_channel_id_nonref = (*short_channel_id).clone(); - let mut is_permanent_nonref = (*is_permanent).clone(); - HTLCFailChannelUpdate::ChannelClosed { - short_channel_id: short_channel_id_nonref, - is_permanent: is_permanent_nonref, - } - }, - nativeHTLCFailChannelUpdate::NodeFailure {ref node_id, ref is_permanent, } => { - let mut node_id_nonref = (*node_id).clone(); - let mut is_permanent_nonref = (*is_permanent).clone(); - HTLCFailChannelUpdate::NodeFailure { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - is_permanent: is_permanent_nonref, - } - }, - } - } - #[allow(unused)] - pub(crate) fn native_into(native: nativeHTLCFailChannelUpdate) -> Self { - match native { - nativeHTLCFailChannelUpdate::ChannelUpdateMessage {mut msg, } => { - HTLCFailChannelUpdate::ChannelUpdateMessage { - msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg), is_owned: true }, - } - }, - nativeHTLCFailChannelUpdate::ChannelClosed {mut short_channel_id, mut is_permanent, } => { - HTLCFailChannelUpdate::ChannelClosed { - short_channel_id: short_channel_id, - is_permanent: is_permanent, - } - }, - nativeHTLCFailChannelUpdate::NodeFailure {mut node_id, mut is_permanent, } => { - HTLCFailChannelUpdate::NodeFailure { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - is_permanent: is_permanent, - } - }, - } - } -} -/// Frees any resources used by the HTLCFailChannelUpdate -#[no_mangle] -pub extern "C" fn HTLCFailChannelUpdate_free(this_ptr: HTLCFailChannelUpdate) { } -/// Creates a copy of the HTLCFailChannelUpdate -#[no_mangle] -pub extern "C" fn HTLCFailChannelUpdate_clone(orig: &HTLCFailChannelUpdate) -> HTLCFailChannelUpdate { - orig.clone() -} -#[no_mangle] -/// Utility method to constructs a new ChannelUpdateMessage-variant HTLCFailChannelUpdate -pub extern "C" fn HTLCFailChannelUpdate_channel_update_message(msg: crate::lightning::ln::msgs::ChannelUpdate) -> HTLCFailChannelUpdate { - HTLCFailChannelUpdate::ChannelUpdateMessage { - msg, - } -} -#[no_mangle] -/// Utility method to constructs a new ChannelClosed-variant HTLCFailChannelUpdate -pub extern "C" fn HTLCFailChannelUpdate_channel_closed(short_channel_id: u64, is_permanent: bool) -> HTLCFailChannelUpdate { - HTLCFailChannelUpdate::ChannelClosed { - short_channel_id, - is_permanent, - } -} -#[no_mangle] -/// Utility method to constructs a new NodeFailure-variant HTLCFailChannelUpdate -pub extern "C" fn HTLCFailChannelUpdate_node_failure(node_id: crate::c_types::PublicKey, is_permanent: bool) -> HTLCFailChannelUpdate { - HTLCFailChannelUpdate::NodeFailure { - node_id, - is_permanent, - } -} /// A trait to describe an object which can receive channel messages. /// /// Messages MAY be called in parallel when they originate from different their_node_ids, however @@ -5016,70 +4900,70 @@ impl lightning::util::events::MessageSendEventsProvider for ChannelMessageHandle use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler; impl rustChannelMessageHandler for ChannelMessageHandler { fn handle_open_channel(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut their_features: lightning::ln::features::InitFeatures, mut msg: &lightning::ln::msgs::OpenChannel) { - (self.handle_open_channel)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(their_features), is_owned: true }, &crate::lightning::ln::msgs::OpenChannel { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const _) as *mut _) }, is_owned: false }) + (self.handle_open_channel)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(their_features), is_owned: true }, &crate::lightning::ln::msgs::OpenChannel { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::OpenChannel<>) as *mut _) }, is_owned: false }) } fn handle_accept_channel(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut their_features: lightning::ln::features::InitFeatures, mut msg: &lightning::ln::msgs::AcceptChannel) { - (self.handle_accept_channel)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(their_features), is_owned: true }, &crate::lightning::ln::msgs::AcceptChannel { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const _) as *mut _) }, is_owned: false }) + (self.handle_accept_channel)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(their_features), is_owned: true }, &crate::lightning::ln::msgs::AcceptChannel { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::AcceptChannel<>) as *mut _) }, is_owned: false }) } fn handle_funding_created(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::FundingCreated) { - (self.handle_funding_created)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::FundingCreated { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const _) as *mut _) }, is_owned: false }) + (self.handle_funding_created)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::FundingCreated { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::FundingCreated<>) as *mut _) }, is_owned: false }) } fn handle_funding_signed(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::FundingSigned) { - (self.handle_funding_signed)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::FundingSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const _) as *mut _) }, is_owned: false }) + (self.handle_funding_signed)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::FundingSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::FundingSigned<>) as *mut _) }, is_owned: false }) } fn handle_funding_locked(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::FundingLocked) { - (self.handle_funding_locked)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::FundingLocked { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const _) as *mut _) }, is_owned: false }) + (self.handle_funding_locked)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::FundingLocked { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::FundingLocked<>) as *mut _) }, is_owned: false }) } fn handle_shutdown(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut their_features: &lightning::ln::features::InitFeatures, mut msg: &lightning::ln::msgs::Shutdown) { - (self.handle_shutdown)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::features::InitFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((their_features as *const _) as *mut _) }, is_owned: false }, &crate::lightning::ln::msgs::Shutdown { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const _) as *mut _) }, is_owned: false }) + (self.handle_shutdown)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::features::InitFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((their_features as *const lightning::ln::features::InitFeatures<>) as *mut _) }, is_owned: false }, &crate::lightning::ln::msgs::Shutdown { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::Shutdown<>) as *mut _) }, is_owned: false }) } fn handle_closing_signed(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ClosingSigned) { - (self.handle_closing_signed)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ClosingSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const _) as *mut _) }, is_owned: false }) + (self.handle_closing_signed)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ClosingSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ClosingSigned<>) as *mut _) }, is_owned: false }) } fn handle_update_add_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateAddHTLC) { - (self.handle_update_add_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateAddHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const _) as *mut _) }, is_owned: false }) + (self.handle_update_add_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateAddHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateAddHTLC<>) as *mut _) }, is_owned: false }) } fn handle_update_fulfill_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFulfillHTLC) { - (self.handle_update_fulfill_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFulfillHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const _) as *mut _) }, is_owned: false }) + (self.handle_update_fulfill_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFulfillHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateFulfillHTLC<>) as *mut _) }, is_owned: false }) } fn handle_update_fail_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailHTLC) { - (self.handle_update_fail_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFailHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const _) as *mut _) }, is_owned: false }) + (self.handle_update_fail_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFailHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateFailHTLC<>) as *mut _) }, is_owned: false }) } fn handle_update_fail_malformed_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) { - (self.handle_update_fail_malformed_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFailMalformedHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const _) as *mut _) }, is_owned: false }) + (self.handle_update_fail_malformed_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFailMalformedHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateFailMalformedHTLC<>) as *mut _) }, is_owned: false }) } fn handle_commitment_signed(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::CommitmentSigned) { - (self.handle_commitment_signed)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::CommitmentSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const _) as *mut _) }, is_owned: false }) + (self.handle_commitment_signed)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::CommitmentSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::CommitmentSigned<>) as *mut _) }, is_owned: false }) } fn handle_revoke_and_ack(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::RevokeAndACK) { - (self.handle_revoke_and_ack)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::RevokeAndACK { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const _) as *mut _) }, is_owned: false }) + (self.handle_revoke_and_ack)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::RevokeAndACK { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::RevokeAndACK<>) as *mut _) }, is_owned: false }) } fn handle_update_fee(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFee) { - (self.handle_update_fee)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFee { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const _) as *mut _) }, is_owned: false }) + (self.handle_update_fee)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFee { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateFee<>) as *mut _) }, is_owned: false }) } fn handle_announcement_signatures(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::AnnouncementSignatures) { - (self.handle_announcement_signatures)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::AnnouncementSignatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const _) as *mut _) }, is_owned: false }) + (self.handle_announcement_signatures)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::AnnouncementSignatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::AnnouncementSignatures<>) as *mut _) }, is_owned: false }) } fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut no_connection_possible: bool) { (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), no_connection_possible) } fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::Init) { - (self.peer_connected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const _) as *mut _) }, is_owned: false }) + (self.peer_connected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::Init<>) as *mut _) }, is_owned: false }) } fn handle_channel_reestablish(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ChannelReestablish) { - (self.handle_channel_reestablish)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ChannelReestablish { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const _) as *mut _) }, is_owned: false }) + (self.handle_channel_reestablish)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ChannelReestablish { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelReestablish<>) as *mut _) }, is_owned: false }) } fn handle_channel_update(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ChannelUpdate) { - (self.handle_channel_update)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ChannelUpdate { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const _) as *mut _) }, is_owned: false }) + (self.handle_channel_update)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ChannelUpdate { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelUpdate<>) as *mut _) }, is_owned: false }) } fn handle_error(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ErrorMessage) { - (self.handle_error)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ErrorMessage { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const _) as *mut _) }, is_owned: false }) + (self.handle_error)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ErrorMessage { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ErrorMessage<>) as *mut _) }, is_owned: false }) } } // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: -impl std::ops::Deref for ChannelMessageHandler { +impl core::ops::Deref for ChannelMessageHandler { type Target = Self; fn deref(&self) -> &Self { self @@ -5119,8 +5003,6 @@ pub struct RoutingMessageHandler { /// false or returning an Err otherwise. #[must_use] pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ, - /// Handle some updates to the route graph that we learned due to an outbound failed payment. - pub handle_htlc_fail_channel_update: extern "C" fn (this_arg: *const c_void, update: &crate::lightning::ln::msgs::HTLCFailChannelUpdate), /// Gets a subset of the channel announcements and updates required to dump our routing table /// to a remote node, starting at the short_channel_id indicated by starting_point and /// including the batch_amount entries immediately higher in numerical value than starting_point. @@ -5172,7 +5054,6 @@ pub(crate) extern "C" fn RoutingMessageHandler_clone_fields(orig: &RoutingMessag handle_node_announcement: Clone::clone(&orig.handle_node_announcement), handle_channel_announcement: Clone::clone(&orig.handle_channel_announcement), handle_channel_update: Clone::clone(&orig.handle_channel_update), - handle_htlc_fail_channel_update: Clone::clone(&orig.handle_htlc_fail_channel_update), get_next_channel_announcements: Clone::clone(&orig.get_next_channel_announcements), get_next_node_announcements: Clone::clone(&orig.get_next_node_announcements), sync_routing_table: Clone::clone(&orig.sync_routing_table), @@ -5195,23 +5076,20 @@ impl lightning::util::events::MessageSendEventsProvider for RoutingMessageHandle use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler; impl rustRoutingMessageHandler for RoutingMessageHandler { fn handle_node_announcement(&self, mut msg: &lightning::ln::msgs::NodeAnnouncement) -> Result { - let mut ret = (self.handle_node_announcement)(self.this_arg, &crate::lightning::ln::msgs::NodeAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const _) as *mut _) }, is_owned: false }); + let mut ret = (self.handle_node_announcement)(self.this_arg, &crate::lightning::ln::msgs::NodeAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::NodeAnnouncement<>) as *mut _) }, is_owned: false }); 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()) } })}; local_ret } fn handle_channel_announcement(&self, mut msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result { - let mut ret = (self.handle_channel_announcement)(self.this_arg, &crate::lightning::ln::msgs::ChannelAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const _) as *mut _) }, is_owned: false }); + let mut ret = (self.handle_channel_announcement)(self.this_arg, &crate::lightning::ln::msgs::ChannelAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelAnnouncement<>) as *mut _) }, is_owned: false }); 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()) } })}; local_ret } fn handle_channel_update(&self, mut msg: &lightning::ln::msgs::ChannelUpdate) -> Result { - let mut ret = (self.handle_channel_update)(self.this_arg, &crate::lightning::ln::msgs::ChannelUpdate { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const _) as *mut _) }, is_owned: false }); + let mut ret = (self.handle_channel_update)(self.this_arg, &crate::lightning::ln::msgs::ChannelUpdate { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelUpdate<>) as *mut _) }, is_owned: false }); 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()) } })}; local_ret } - fn handle_htlc_fail_channel_update(&self, mut update: &lightning::ln::msgs::HTLCFailChannelUpdate) { - (self.handle_htlc_fail_channel_update)(self.this_arg, &crate::lightning::ln::msgs::HTLCFailChannelUpdate::from_native(update)) - } fn get_next_channel_announcements(&self, mut starting_point: u64, mut batch_amount: u8) -> Vec<(lightning::ln::msgs::ChannelAnnouncement, Option, Option)> { let mut ret = (self.get_next_channel_announcements)(self.this_arg, starting_point, batch_amount); 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 }); }; @@ -5224,7 +5102,7 @@ impl rustRoutingMessageHandler for RoutingMessageHandler { local_ret } fn sync_routing_table(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut init: &lightning::ln::msgs::Init) { - (self.sync_routing_table)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { ObjOps::nonnull_ptr_to_inner((init as *const _) as *mut _) }, is_owned: false }) + (self.sync_routing_table)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { ObjOps::nonnull_ptr_to_inner((init as *const lightning::ln::msgs::Init<>) as *mut _) }, is_owned: false }) } fn handle_reply_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: lightning::ln::msgs::ReplyChannelRange) -> Result<(), lightning::ln::msgs::LightningError> { let mut ret = (self.handle_reply_channel_range)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::msgs::ReplyChannelRange { inner: ObjOps::heap_alloc(msg), is_owned: true }); @@ -5250,7 +5128,7 @@ impl rustRoutingMessageHandler for RoutingMessageHandler { // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: -impl std::ops::Deref for RoutingMessageHandler { +impl core::ops::Deref for RoutingMessageHandler { type Target = Self; fn deref(&self) -> &Self { self @@ -5268,10 +5146,13 @@ impl Drop for RoutingMessageHandler { } mod fuzzy_internal_msgs { -use std::str::FromStr; -use std::ffi::c_void; +use alloc::str::FromStr; +use core::ffi::c_void; +use core::convert::Infallible; use bitcoin::hashes::Hash; use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; } #[no_mangle] @@ -5286,7 +5167,7 @@ pub(crate) extern "C" fn AcceptChannel_write_void(obj: *const c_void) -> crate:: #[no_mangle] /// Read a AcceptChannel from a byte array, created by AcceptChannel_write pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); + let res: Result = crate::c_types::deserialize_obj(ser); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::AcceptChannel { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_res } @@ -5302,7 +5183,7 @@ pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) - #[no_mangle] /// Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write pub extern "C" fn AnnouncementSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AnnouncementSignaturesDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); + let res: Result = crate::c_types::deserialize_obj(ser); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::AnnouncementSignatures { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_res } @@ -5318,7 +5199,7 @@ pub(crate) extern "C" fn ChannelReestablish_write_void(obj: *const c_void) -> cr #[no_mangle] /// Read a ChannelReestablish from a byte array, created by ChannelReestablish_write pub extern "C" fn ChannelReestablish_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelReestablishDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); + let res: Result = crate::c_types::deserialize_obj(ser); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ChannelReestablish { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_res } @@ -5334,7 +5215,7 @@ pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate:: #[no_mangle] /// Read a ClosingSigned from a byte array, created by ClosingSigned_write pub extern "C" fn ClosingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); + let res: Result = crate::c_types::deserialize_obj(ser); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ClosingSigned { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_res } @@ -5350,7 +5231,7 @@ pub(crate) extern "C" fn ClosingSignedFeeRange_write_void(obj: *const c_void) -> #[no_mangle] /// Read a ClosingSignedFeeRange from a byte array, created by ClosingSignedFeeRange_write pub extern "C" fn ClosingSignedFeeRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClosingSignedFeeRangeDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); + let res: Result = crate::c_types::deserialize_obj(ser); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ClosingSignedFeeRange { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_res } @@ -5366,7 +5247,7 @@ pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crat #[no_mangle] /// Read a CommitmentSigned from a byte array, created by CommitmentSigned_write pub extern "C" fn CommitmentSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CommitmentSignedDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); + let res: Result = crate::c_types::deserialize_obj(ser); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::CommitmentSigned { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_res } @@ -5382,7 +5263,7 @@ pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate: #[no_mangle] /// Read a FundingCreated from a byte array, created by FundingCreated_write pub extern "C" fn FundingCreated_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingCreatedDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); + let res: Result = crate::c_types::deserialize_obj(ser); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::FundingCreated { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_res } @@ -5398,7 +5279,7 @@ pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate:: #[no_mangle] /// Read a FundingSigned from a byte array, created by FundingSigned_write pub extern "C" fn FundingSigned_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingSignedDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); + let res: Result = crate::c_types::deserialize_obj(ser); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::FundingSigned { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_res } @@ -5414,7 +5295,7 @@ pub(crate) extern "C" fn FundingLocked_write_void(obj: *const c_void) -> crate:: #[no_mangle] /// Read a FundingLocked from a byte array, created by FundingLocked_write pub extern "C" fn FundingLocked_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingLockedDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); + let res: Result = crate::c_types::deserialize_obj(ser); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::FundingLocked { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_res } @@ -5430,7 +5311,7 @@ pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types:: #[no_mangle] /// Read a Init from a byte array, created by Init_write pub extern "C" fn Init_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); + let res: Result = crate::c_types::deserialize_obj(ser); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::Init { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_res } @@ -5446,7 +5327,7 @@ pub(crate) extern "C" fn OpenChannel_write_void(obj: *const c_void) -> crate::c_ #[no_mangle] /// Read a OpenChannel from a byte array, created by OpenChannel_write pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); + let res: Result = crate::c_types::deserialize_obj(ser); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::OpenChannel { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_res } @@ -5462,7 +5343,7 @@ pub(crate) extern "C" fn RevokeAndACK_write_void(obj: *const c_void) -> crate::c #[no_mangle] /// Read a RevokeAndACK from a byte array, created by RevokeAndACK_write pub extern "C" fn RevokeAndACK_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RevokeAndACKDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); + let res: Result = crate::c_types::deserialize_obj(ser); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::RevokeAndACK { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_res } @@ -5478,7 +5359,7 @@ pub(crate) extern "C" fn Shutdown_write_void(obj: *const c_void) -> crate::c_typ #[no_mangle] /// Read a Shutdown from a byte array, created by Shutdown_write pub extern "C" fn Shutdown_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ShutdownDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); + let res: Result = crate::c_types::deserialize_obj(ser); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::Shutdown { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_res } @@ -5494,7 +5375,7 @@ pub(crate) extern "C" fn UpdateFailHTLC_write_void(obj: *const c_void) -> crate: #[no_mangle] /// Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write pub extern "C" fn UpdateFailHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailHTLCDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); + let res: Result = crate::c_types::deserialize_obj(ser); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UpdateFailHTLC { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_res } @@ -5510,7 +5391,7 @@ pub(crate) extern "C" fn UpdateFailMalformedHTLC_write_void(obj: *const c_void) #[no_mangle] /// Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write pub extern "C" fn UpdateFailMalformedHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFailMalformedHTLCDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); + let res: Result = crate::c_types::deserialize_obj(ser); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UpdateFailMalformedHTLC { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_res } @@ -5526,7 +5407,7 @@ pub(crate) extern "C" fn UpdateFee_write_void(obj: *const c_void) -> crate::c_ty #[no_mangle] /// Read a UpdateFee from a byte array, created by UpdateFee_write pub extern "C" fn UpdateFee_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFeeDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); + let res: Result = crate::c_types::deserialize_obj(ser); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UpdateFee { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_res } @@ -5542,7 +5423,7 @@ pub(crate) extern "C" fn UpdateFulfillHTLC_write_void(obj: *const c_void) -> cra #[no_mangle] /// Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write pub extern "C" fn UpdateFulfillHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateFulfillHTLCDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); + let res: Result = crate::c_types::deserialize_obj(ser); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UpdateFulfillHTLC { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_res } @@ -5558,7 +5439,7 @@ pub(crate) extern "C" fn UpdateAddHTLC_write_void(obj: *const c_void) -> crate:: #[no_mangle] /// Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write pub extern "C" fn UpdateAddHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UpdateAddHTLCDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); + let res: Result = crate::c_types::deserialize_obj(ser); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UpdateAddHTLC { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_res } @@ -5574,7 +5455,7 @@ pub(crate) extern "C" fn Ping_write_void(obj: *const c_void) -> crate::c_types:: #[no_mangle] /// Read a Ping from a byte array, created by Ping_write pub extern "C" fn Ping_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PingDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); + let res: Result = crate::c_types::deserialize_obj(ser); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::Ping { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_res } @@ -5590,7 +5471,7 @@ pub(crate) extern "C" fn Pong_write_void(obj: *const c_void) -> crate::c_types:: #[no_mangle] /// Read a Pong from a byte array, created by Pong_write pub extern "C" fn Pong_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PongDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); + let res: Result = crate::c_types::deserialize_obj(ser); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::Pong { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_res } @@ -5606,7 +5487,7 @@ pub(crate) extern "C" fn UnsignedChannelAnnouncement_write_void(obj: *const c_vo #[no_mangle] /// Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write pub extern "C" fn UnsignedChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelAnnouncementDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); + let res: Result = crate::c_types::deserialize_obj(ser); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_res } @@ -5622,7 +5503,7 @@ pub(crate) extern "C" fn ChannelAnnouncement_write_void(obj: *const c_void) -> c #[no_mangle] /// Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write pub extern "C" fn ChannelAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelAnnouncementDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); + let res: Result = crate::c_types::deserialize_obj(ser); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_res } @@ -5638,7 +5519,7 @@ pub(crate) extern "C" fn UnsignedChannelUpdate_write_void(obj: *const c_void) -> #[no_mangle] /// Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write pub extern "C" fn UnsignedChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedChannelUpdateDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); + let res: Result = crate::c_types::deserialize_obj(ser); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_res } @@ -5654,7 +5535,7 @@ pub(crate) extern "C" fn ChannelUpdate_write_void(obj: *const c_void) -> crate:: #[no_mangle] /// Read a ChannelUpdate from a byte array, created by ChannelUpdate_write pub extern "C" fn ChannelUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelUpdateDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); + let res: Result = crate::c_types::deserialize_obj(ser); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_res } @@ -5670,7 +5551,7 @@ pub(crate) extern "C" fn ErrorMessage_write_void(obj: *const c_void) -> crate::c #[no_mangle] /// Read a ErrorMessage from a byte array, created by ErrorMessage_write pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ErrorMessageDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); + let res: Result = crate::c_types::deserialize_obj(ser); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_res } @@ -5686,7 +5567,7 @@ pub(crate) extern "C" fn UnsignedNodeAnnouncement_write_void(obj: *const c_void) #[no_mangle] /// Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write pub extern "C" fn UnsignedNodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnsignedNodeAnnouncementDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); + let res: Result = crate::c_types::deserialize_obj(ser); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_res } @@ -5702,14 +5583,14 @@ pub(crate) extern "C" fn NodeAnnouncement_write_void(obj: *const c_void) -> crat #[no_mangle] /// Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write pub extern "C" fn NodeAnnouncement_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); + let res: Result = crate::c_types::deserialize_obj(ser); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::NodeAnnouncement { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_res } #[no_mangle] /// Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write pub extern "C" fn QueryShortChannelIds_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryShortChannelIdsDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); + let res: Result = crate::c_types::deserialize_obj(ser); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::QueryShortChannelIds { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_res } @@ -5723,13 +5604,6 @@ pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) -> crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) }) } #[no_mangle] -/// Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write -pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyShortChannelIdsEndDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; - local_res -} -#[no_mangle] /// Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) @@ -5738,6 +5612,13 @@ pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &ReplyShortChannelIdsEnd) - pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) }) } +#[no_mangle] +/// Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write +pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyShortChannelIdsEndDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; + local_res +} ///\n\t * Calculates the overflow safe ending block height for the query.\n\t * Overflow returns `0xffffffff`, otherwise returns `first_blocknum + number_of_blocks`\n\t #[must_use] #[no_mangle] @@ -5746,13 +5627,6 @@ pub extern "C" fn QueryChannelRange_end_blocknum(this_arg: &QueryChannelRange) - ret } -#[no_mangle] -/// Read a QueryChannelRange from a byte array, created by QueryChannelRange_write -pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::QueryChannelRange { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; - local_res -} #[no_mangle] /// Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read pub extern "C" fn QueryChannelRange_write(obj: &QueryChannelRange) -> crate::c_types::derived::CVec_u8Z { @@ -5763,9 +5637,16 @@ pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> cra crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) }) } #[no_mangle] +/// Read a QueryChannelRange from a byte array, created by QueryChannelRange_write +pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::QueryChannelRange { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; + local_res +} +#[no_mangle] /// Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyChannelRangeDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); + let res: Result = crate::c_types::deserialize_obj(ser); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ReplyChannelRange { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_res } @@ -5779,13 +5660,6 @@ pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> cra crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) }) } #[no_mangle] -/// Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write -pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_GossipTimestampFilterDecodeErrorZ { - let res = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::GossipTimestampFilter { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; - local_res -} -#[no_mangle] /// Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read pub extern "C" fn GossipTimestampFilter_write(obj: &GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) @@ -5794,3 +5668,10 @@ pub extern "C" fn GossipTimestampFilter_write(obj: &GossipTimestampFilter) -> cr pub(crate) extern "C" fn GossipTimestampFilter_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeGossipTimestampFilter) }) } +#[no_mangle] +/// Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write +pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_GossipTimestampFilterDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::GossipTimestampFilter { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; + local_res +}