X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FWatchedOutput.java;h=4319efec8d5906f22cc0dab6fbbbf01ad29a400e;hb=07d5d868dfe064aadb28a7f7ca6002c16be9723d;hp=0b03993585c9708b70f2af81cceaa0bc963e20ba;hpb=47341beaeecf907f422f126500baf586d54a0d41;p=ldk-java diff --git a/src/main/java/org/ldk/structs/WatchedOutput.java b/src/main/java/org/ldk/structs/WatchedOutput.java index 0b039935..4319efec 100644 --- a/src/main/java/org/ldk/structs/WatchedOutput.java +++ b/src/main/java/org/ldk/structs/WatchedOutput.java @@ -13,7 +13,7 @@ import javax.annotation.Nullable; * * Used to convey to a [`Filter`] such an output with a given spending condition. Any transaction * spending the output must be given to [`ChannelMonitor::block_connected`] either directly or via - * the return value of [`Filter::register_output`]. + * [`Confirm::transactions_confirmed`]. * * If `block_hash` is `Some`, this indicates the output was created in the corresponding block and * may have been spent there. See [`Filter::register_output`] for details. @@ -32,25 +32,24 @@ public class WatchedOutput extends CommonBase { /** * First block where the transaction output may have been spent. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ - @Nullable - public byte[] get_block_hash() { - byte[] ret = bindings.WatchedOutput_get_block_hash(this.ptr); + public Option_ThirtyTwoBytesZ get_block_hash() { + long ret = bindings.WatchedOutput_get_block_hash(this.ptr); Reference.reachabilityFence(this); - return ret; + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.Option_ThirtyTwoBytesZ ret_hu_conv = org.ldk.structs.Option_ThirtyTwoBytesZ.constr_from_ptr(ret); + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); }; + return ret_hu_conv; } /** * First block where the transaction output may have been spent. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ - public void set_block_hash(@Nullable byte[] val) { - bindings.WatchedOutput_set_block_hash(this.ptr, InternalUtils.check_arr_len(val, 32)); + public void set_block_hash(org.ldk.structs.Option_ThirtyTwoBytesZ val) { + bindings.WatchedOutput_set_block_hash(this.ptr, val.ptr); Reference.reachabilityFence(this); Reference.reachabilityFence(val); + if (this != null) { this.ptrs_to.add(val); }; } /** @@ -61,17 +60,18 @@ public class WatchedOutput extends CommonBase { Reference.reachabilityFence(this); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OutPoint(null, ret); } - ret_hu_conv.ptrs_to.add(this); + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); }; return ret_hu_conv; } /** * Outpoint identifying the transaction output. */ - public void set_outpoint(OutPoint val) { - bindings.WatchedOutput_set_outpoint(this.ptr, val == null ? 0 : val.ptr & ~1); + public void set_outpoint(org.ldk.structs.OutPoint val) { + bindings.WatchedOutput_set_outpoint(this.ptr, val == null ? 0 : val.ptr); Reference.reachabilityFence(this); Reference.reachabilityFence(val); + if (this != null) { this.ptrs_to.add(val); }; } /** @@ -95,14 +95,16 @@ public class WatchedOutput extends CommonBase { /** * Constructs a new WatchedOutput given each field */ - public static WatchedOutput of(byte[] block_hash_arg, OutPoint outpoint_arg, byte[] script_pubkey_arg) { - long ret = bindings.WatchedOutput_new(InternalUtils.check_arr_len(block_hash_arg, 32), outpoint_arg == null ? 0 : outpoint_arg.ptr & ~1, script_pubkey_arg); + public static WatchedOutput of(org.ldk.structs.Option_ThirtyTwoBytesZ block_hash_arg, org.ldk.structs.OutPoint outpoint_arg, byte[] script_pubkey_arg) { + long ret = bindings.WatchedOutput_new(block_hash_arg.ptr, outpoint_arg == null ? 0 : outpoint_arg.ptr, script_pubkey_arg); Reference.reachabilityFence(block_hash_arg); Reference.reachabilityFence(outpoint_arg); Reference.reachabilityFence(script_pubkey_arg); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.WatchedOutput ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.WatchedOutput(null, ret); } - ret_hu_conv.ptrs_to.add(ret_hu_conv); + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(block_hash_arg); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(outpoint_arg); }; return ret_hu_conv; } @@ -120,12 +122,29 @@ public class WatchedOutput extends CommonBase { Reference.reachabilityFence(this); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.WatchedOutput ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.WatchedOutput(null, ret); } - ret_hu_conv.ptrs_to.add(this); + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); }; return ret_hu_conv; } /** * Checks if two WatchedOutputs 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(org.ldk.structs.WatchedOutput b) { + boolean ret = bindings.WatchedOutput_eq(this.ptr, b == null ? 0 : b.ptr); + Reference.reachabilityFence(this); + Reference.reachabilityFence(b); + if (this != null) { this.ptrs_to.add(b); }; + return ret; + } + + @Override public boolean equals(Object o) { + if (!(o instanceof WatchedOutput)) return false; + return this.eq((WatchedOutput)o); + } + /** + * Generates a non-cryptographic 64-bit hash of the WatchedOutput. */ public long hash() { long ret = bindings.WatchedOutput_hash(this.ptr);