X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FOutPoint.java;h=edb136126a7d606f93cd3f0b8e3e3e83c589d591;hb=c6bac88847b7c09560af81f00ba8dd3c2ebe3a19;hp=42a79f04e686da3ca2603b6c48f1bcc13e003cb3;hpb=17113550a5fefab21f39f27fbfe02646b8db53ae;p=ldk-java diff --git a/src/main/java/org/ldk/structs/OutPoint.java b/src/main/java/org/ldk/structs/OutPoint.java index 42a79f04..edb13612 100644 --- a/src/main/java/org/ldk/structs/OutPoint.java +++ b/src/main/java/org/ldk/structs/OutPoint.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; /** @@ -54,9 +55,10 @@ public class OutPoint extends CommonBase { /** * Constructs a new OutPoint given each field */ - public static OutPoint constructor_new(byte[] txid_arg, short index_arg) { + public static OutPoint of(byte[] txid_arg, short index_arg) { long ret = bindings.OutPoint_new(txid_arg, index_arg); - OutPoint ret_hu_conv = new OutPoint(null, ret); + if (ret >= 0 && ret <= 4096) { return null; } + OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new OutPoint(null, ret); } ret_hu_conv.ptrs_to.add(ret_hu_conv); return ret_hu_conv; } @@ -66,11 +68,31 @@ public class OutPoint extends CommonBase { */ public OutPoint clone() { long ret = bindings.OutPoint_clone(this.ptr); - OutPoint ret_hu_conv = new OutPoint(null, ret); + if (ret >= 0 && ret <= 4096) { return null; } + OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new OutPoint(null, ret); } ret_hu_conv.ptrs_to.add(this); return ret_hu_conv; } + /** + * Checks if two OutPoints 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(OutPoint b) { + boolean ret = bindings.OutPoint_eq(this.ptr, b == null ? 0 : b.ptr & ~1); + this.ptrs_to.add(b); + return ret; + } + + /** + * Checks if two OutPoints contain equal inner contents. + */ + public long hash() { + long ret = bindings.OutPoint_hash(this.ptr); + return ret; + } + /** * Convert an `OutPoint` to a lightning channel id. */ @@ -90,8 +112,9 @@ public class OutPoint extends CommonBase { /** * Read a OutPoint from a byte array, created by OutPoint_write */ - public static Result_OutPointDecodeErrorZ constructor_read(byte[] ser) { + public static Result_OutPointDecodeErrorZ read(byte[] ser) { long ret = bindings.OutPoint_read(ser); + if (ret >= 0 && ret <= 4096) { return null; } Result_OutPointDecodeErrorZ ret_hu_conv = Result_OutPointDecodeErrorZ.constr_from_ptr(ret); return ret_hu_conv; }