From: Matt Corallo Date: Tue, 28 Sep 2021 01:07:41 +0000 (+0000) Subject: Update auto-generated bindings to latest upstream X-Git-Tag: v0.0.102.0~1^2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=b187ebbabe60d2ef884c5eadce93fef52674923d;p=ldk-c-bindings Update auto-generated bindings to latest upstream --- diff --git a/lightning-c-bindings/include/lightning.h b/lightning-c-bindings/include/lightning.h index 06bd643..dad0072 100644 --- a/lightning-c-bindings/include/lightning.h +++ b/lightning-c-bindings/include/lightning.h @@ -11994,6 +11994,12 @@ struct LDKCResult_NetworkGraphDecodeErrorZ CResult_NetworkGraphDecodeErrorZ_err( */ void CResult_NetworkGraphDecodeErrorZ_free(struct LDKCResult_NetworkGraphDecodeErrorZ _res); +/** + * Creates a new CResult_NetworkGraphDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_NetworkGraphDecodeErrorZ CResult_NetworkGraphDecodeErrorZ_clone(const struct LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR orig); + /** * Creates a new CResult_NetAddressu8Z in the success state. */ @@ -19434,16 +19440,6 @@ struct LDKCVec_u8Z ShutdownScript_write(const struct LDKShutdownScript *NONNULL_ */ struct LDKCResult_ShutdownScriptDecodeErrorZ ShutdownScript_read(struct LDKu8slice ser); -/** - * Generates a P2PKH script pubkey from the given [`PubkeyHash`]. - */ -MUST_USE_RES struct LDKShutdownScript ShutdownScript_new_p2pkh(const uint8_t (*pubkey_hash)[20]); - -/** - * Generates a P2SH script pubkey from the given [`ScriptHash`]. - */ -MUST_USE_RES struct LDKShutdownScript ShutdownScript_new_p2sh(const uint8_t (*script_hash)[20]); - /** * Generates a P2WPKH script pubkey from the given [`WPubkeyHash`]. */ @@ -19821,6 +19817,11 @@ struct LDKCResult_RouteLightningErrorZ get_route(struct LDKPublicKey our_node_id */ void NetworkGraph_free(struct LDKNetworkGraph this_obj); +/** + * Creates a copy of the NetworkGraph + */ +struct LDKNetworkGraph NetworkGraph_clone(const struct LDKNetworkGraph *NONNULL_PTR orig); + /** * Frees any resources used by the ReadOnlyNetworkGraph, if is_owned is set and inner is non-NULL. */ diff --git a/lightning-c-bindings/src/c_types/derived.rs b/lightning-c-bindings/src/c_types/derived.rs index cdc0627..2afa5c2 100644 --- a/lightning-c-bindings/src/c_types/derived.rs +++ b/lightning-c-bindings/src/c_types/derived.rs @@ -8397,6 +8397,23 @@ impl From Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_NetworkGraphDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_NetworkGraphDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_NetworkGraphDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_NetworkGraphDecodeErrorZ_clone(orig: &CResult_NetworkGraphDecodeErrorZ) -> CResult_NetworkGraphDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] /// The contents of CResult_NetAddressu8Z pub union CResult_NetAddressu8ZPtr { diff --git a/lightning-c-bindings/src/lightning/ln/script.rs b/lightning-c-bindings/src/lightning/ln/script.rs index 73c9024..0151ae2 100644 --- a/lightning-c-bindings/src/lightning/ln/script.rs +++ b/lightning-c-bindings/src/lightning/ln/script.rs @@ -176,22 +176,6 @@ pub extern "C" fn ShutdownScript_read(ser: crate::c_types::u8slice) -> crate::c_ let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::script::ShutdownScript { 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 } -/// Generates a P2PKH script pubkey from the given [`PubkeyHash`]. -#[must_use] -#[no_mangle] -pub extern "C" fn ShutdownScript_new_p2pkh(pubkey_hash: *const [u8; 20]) -> ShutdownScript { - let mut ret = lightning::ln::script::ShutdownScript::new_p2pkh(&bitcoin::hash_types::PubkeyHash::from_hash(bitcoin::hashes::Hash::from_inner(unsafe { *pubkey_hash }.clone()))); - ShutdownScript { inner: ObjOps::heap_alloc(ret), is_owned: true } -} - -/// Generates a P2SH script pubkey from the given [`ScriptHash`]. -#[must_use] -#[no_mangle] -pub extern "C" fn ShutdownScript_new_p2sh(script_hash: *const [u8; 20]) -> ShutdownScript { - let mut ret = lightning::ln::script::ShutdownScript::new_p2sh(&bitcoin::hash_types::ScriptHash::from_hash(bitcoin::hashes::Hash::from_inner(unsafe { *script_hash }.clone()))); - ShutdownScript { inner: ObjOps::heap_alloc(ret), is_owned: true } -} - /// Generates a P2WPKH script pubkey from the given [`WPubkeyHash`]. #[must_use] #[no_mangle] diff --git a/lightning-c-bindings/src/lightning/routing/network_graph.rs b/lightning-c-bindings/src/lightning/routing/network_graph.rs index f1e72f1..5aece81 100644 --- a/lightning-c-bindings/src/lightning/routing/network_graph.rs +++ b/lightning-c-bindings/src/lightning/routing/network_graph.rs @@ -65,6 +65,25 @@ impl NetworkGraph { ret } } +impl Clone for NetworkGraph { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeNetworkGraph>::is_null(self.inner) { std::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn NetworkGraph_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNetworkGraph)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the NetworkGraph +pub extern "C" fn NetworkGraph_clone(orig: &NetworkGraph) -> NetworkGraph { + orig.clone() +} use lightning::routing::network_graph::ReadOnlyNetworkGraph as nativeReadOnlyNetworkGraphImport; type nativeReadOnlyNetworkGraph = nativeReadOnlyNetworkGraphImport<'static>;