From: Matt Corallo Date: Sat, 1 May 2021 00:06:18 +0000 (+0000) Subject: Regenerate with ChannelMonitor (and more) clone patch X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=ldk-c-bindings;a=commitdiff_plain;h=refs%2Fheads%2F2021-03-java-bindings-base Regenerate with ChannelMonitor (and more) clone patch --- diff --git a/lightning-c-bindings/Cargo.toml b/lightning-c-bindings/Cargo.toml index d06861d..394902a 100644 --- a/lightning-c-bindings/Cargo.toml +++ b/lightning-c-bindings/Cargo.toml @@ -18,10 +18,10 @@ crate-type = ["staticlib" bitcoin = "0.26" secp256k1 = { version = "0.20.1", features = ["global-context-less-secure"] } # Note that the following line is matched by genbindings to update the path -lightning = { git = "https://git.bitcoin.ninja/rust-lightning", rev = "a8038a8234b70bc261f633a9e2b40adebebcd8d4", features = ["allow_wallclock_use"] } -lightning-persister = { git = "https://git.bitcoin.ninja/rust-lightning", rev = "a8038a8234b70bc261f633a9e2b40adebebcd8d4" } -lightning-invoice = { git = "https://git.bitcoin.ninja/rust-lightning", rev = "a8038a8234b70bc261f633a9e2b40adebebcd8d4" } -lightning-background-processor = { git = "https://git.bitcoin.ninja/rust-lightning", rev = "a8038a8234b70bc261f633a9e2b40adebebcd8d4" } +lightning = { git = "https://git.bitcoin.ninja/rust-lightning", rev = "800dc06dbb39f6c421adb81e6ba3508ded3d7d74", features = ["allow_wallclock_use"] } +lightning-persister = { git = "https://git.bitcoin.ninja/rust-lightning", rev = "800dc06dbb39f6c421adb81e6ba3508ded3d7d74" } +lightning-invoice = { git = "https://git.bitcoin.ninja/rust-lightning", rev = "800dc06dbb39f6c421adb81e6ba3508ded3d7d74" } +lightning-background-processor = { git = "https://git.bitcoin.ninja/rust-lightning", rev = "800dc06dbb39f6c421adb81e6ba3508ded3d7d74" } [patch.crates-io] # Rust-Secp256k1 upstream to get PR 279 until it is released. diff --git a/lightning-c-bindings/include/lightning.h b/lightning-c-bindings/include/lightning.h index 8d27f34..1689dcd 100644 --- a/lightning-c-bindings/include/lightning.h +++ b/lightning-c-bindings/include/lightning.h @@ -12308,6 +12308,11 @@ struct LDKCResult_HTLCUpdateDecodeErrorZ HTLCUpdate_read(struct LDKu8slice ser); */ void ChannelMonitor_free(struct LDKChannelMonitor this_obj); +/** + * Creates a copy of the ChannelMonitor + */ +struct LDKChannelMonitor ChannelMonitor_clone(const struct LDKChannelMonitor *NONNULL_PTR orig); + /** * Serialize the ChannelMonitor object into a byte array which can be read by ChannelMonitor_read */ diff --git a/lightning-c-bindings/src/lightning/chain/channelmonitor.rs b/lightning-c-bindings/src/lightning/chain/channelmonitor.rs index 1331506..dccc80d 100644 --- a/lightning-c-bindings/src/lightning/chain/channelmonitor.rs +++ b/lightning-c-bindings/src/lightning/chain/channelmonitor.rs @@ -544,6 +544,25 @@ impl ChannelMonitor { ret } } +impl Clone for ChannelMonitor { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeChannelMonitor>::is_null(self.inner) { std::ptr::null_mut() } else { + Box::into_raw(Box::new(unsafe { &*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 ChannelMonitor_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelMonitor)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the ChannelMonitor +pub extern "C" fn ChannelMonitor_clone(orig: &ChannelMonitor) -> ChannelMonitor { + orig.clone() +} #[no_mangle] /// Serialize the ChannelMonitor object into a byte array which can be read by ChannelMonitor_read pub extern "C" fn ChannelMonitor_write(obj: &ChannelMonitor) -> crate::c_types::derived::CVec_u8Z {