X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=ldk-c-bindings;a=blobdiff_plain;f=lightning-c-bindings%2Fsrc%2Flightning%2Foffers%2Fmerkle.rs;fp=lightning-c-bindings%2Fsrc%2Flightning%2Foffers%2Fmerkle.rs;h=24e0ec3ff3a33a33e0f0f3bcc2cdb8b2d96d0844;hp=106169c2d2988ec398c2ef170baae9b04f854adb;hb=00ed41fad818748a795634e82040b04c1ea4455d;hpb=c14513fd07359c39e2e27c2e7d475ca522f03db5 diff --git a/lightning-c-bindings/src/lightning/offers/merkle.rs b/lightning-c-bindings/src/lightning/offers/merkle.rs index 106169c..24e0ec3 100644 --- a/lightning-c-bindings/src/lightning/offers/merkle.rs +++ b/lightning-c-bindings/src/lightning/offers/merkle.rs @@ -72,3 +72,49 @@ impl TaggedHash { ret } } +impl Clone for TaggedHash { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeTaggedHash>::is_null(self.inner) { core::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 TaggedHash_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTaggedHash)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the TaggedHash +pub extern "C" fn TaggedHash_clone(orig: &TaggedHash) -> TaggedHash { + orig.clone() +} +/// Get a string which allows debug introspection of a TaggedHash object +pub extern "C" fn TaggedHash_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::offers::merkle::TaggedHash }).into()} +/// Returns the digest to sign. +#[must_use] +#[no_mangle] +pub extern "C" fn TaggedHash_as_digest(this_arg: &crate::lightning::offers::merkle::TaggedHash) -> *const [u8; 32] { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.as_digest(); + ret.as_ref() +} + +/// Returns the tag used in the tagged hash. +#[must_use] +#[no_mangle] +pub extern "C" fn TaggedHash_tag(this_arg: &crate::lightning::offers::merkle::TaggedHash) -> crate::c_types::Str { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.tag(); + ret.into() +} + +/// Returns the merkle root used in the tagged hash. +#[must_use] +#[no_mangle] +pub extern "C" fn TaggedHash_merkle_root(this_arg: &crate::lightning::offers::merkle::TaggedHash) -> crate::c_types::ThirtyTwoBytes { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.merkle_root(); + crate::c_types::ThirtyTwoBytes { data: *ret.as_ref() } +} +