X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FSha256.java;h=011cd86130d5d3dd1c804eda24a1415c60c5d489;hb=f3e670e9341decac613d33fc52febf19cea32f20;hp=b630026ac3d852e3426f13aa809d4efcaaa5dcdb;hpb=b0c50b891cbca28d3bd1d86276c132ff5221d8e4;p=ldk-java diff --git a/src/main/java/org/ldk/structs/Sha256.java b/src/main/java/org/ldk/structs/Sha256.java index b630026a..011cd861 100644 --- a/src/main/java/org/ldk/structs/Sha256.java +++ b/src/main/java/org/ldk/structs/Sha256.java @@ -4,6 +4,7 @@ import org.ldk.impl.bindings; import org.ldk.enums.*; import org.ldk.util.*; import java.util.Arrays; +import javax.annotation.Nullable; /** @@ -18,14 +19,8 @@ public class Sha256 extends CommonBase { if (ptr != 0) { bindings.Sha256_free(ptr); } } - /** - * Checks if two Sha256s contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. - */ - public boolean eq(Sha256 b) { - boolean ret = bindings.Sha256_eq(this.ptr, b == null ? 0 : b.ptr & ~1); - this.ptrs_to.add(b); + long clone_ptr() { + long ret = bindings.Sha256_clone_ptr(this.ptr); return ret; } @@ -34,9 +29,29 @@ public class Sha256 extends CommonBase { */ public Sha256 clone() { long ret = bindings.Sha256_clone(this.ptr); - Sha256 ret_hu_conv = new Sha256(null, ret); + if (ret >= 0 && ret <= 4096) { return null; } + Sha256 ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Sha256(null, ret); } ret_hu_conv.ptrs_to.add(this); return ret_hu_conv; } + /** + * Checks if two Sha256s contain equal inner contents. + */ + public long hash() { + long ret = bindings.Sha256_hash(this.ptr); + return ret; + } + + /** + * Checks if two Sha256s contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ + public boolean eq(Sha256 b) { + boolean ret = bindings.Sha256_eq(this.ptr, b == null ? 0 : b.ptr & ~1); + this.ptrs_to.add(b); + return ret; + } + }