X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning-c-bindings%2Fsrc%2Flightning%2Futil%2Ferrors.rs;h=08929c15c065c0a98cc382d223cc24417157726b;hb=5502fccd64611f16f5ebba3759c68b1a4d69b537;hp=ff0f416bd499fb15c0fcd9d68a5661bdad8a0553;hpb=db5b7699744779437a98e17198f502920bfa2e7e;p=ldk-c-bindings diff --git a/lightning-c-bindings/src/lightning/util/errors.rs b/lightning-c-bindings/src/lightning/util/errors.rs index ff0f416..08929c1 100644 --- a/lightning-c-bindings/src/lightning/util/errors.rs +++ b/lightning-c-bindings/src/lightning/util/errors.rs @@ -9,6 +9,7 @@ //! Error types live here. use alloc::str::FromStr; +use alloc::string::String; use core::ffi::c_void; use core::convert::Infallible; use bitcoin::hashes::Hash; @@ -65,7 +66,7 @@ pub enum APIError { /// Using a SegWit v0 script should resolve this issue. If you cannot, you won't be able to open /// a channel or cooperatively close one with this peer (and will have to force-close instead). /// - /// [`SignerProvider::get_shutdown_scriptpubkey`]: crate::chain::keysinterface::SignerProvider::get_shutdown_scriptpubkey + /// [`SignerProvider::get_shutdown_scriptpubkey`]: crate::sign::SignerProvider::get_shutdown_scriptpubkey /// [`InitFeatures`]: crate::ln::features::InitFeatures IncompatibleShutdownScript { /// The incompatible shutdown script. @@ -225,6 +226,16 @@ pub extern "C" fn APIError_free(this_ptr: APIError) { } pub extern "C" fn APIError_clone(orig: &APIError) -> APIError { orig.clone() } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn APIError_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const APIError)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn APIError_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut APIError) }; +} #[no_mangle] /// Utility method to constructs a new APIMisuseError-variant APIError pub extern "C" fn APIError_apimisuse_error(err: crate::c_types::Str) -> APIError { @@ -276,6 +287,10 @@ pub extern "C" fn APIError_eq(a: &APIError, b: &APIError) -> bool { pub extern "C" fn APIError_write(obj: &crate::lightning::util::errors::APIError) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) } +#[allow(unused)] +pub(crate) extern "C" fn APIError_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + APIError_write(unsafe { &*(obj as *const APIError) }) +} #[no_mangle] /// Read a APIError from a byte array, created by APIError_write pub extern "C" fn APIError_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_APIErrorZDecodeErrorZ {