X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FWatchedOutput.java;fp=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FWatchedOutput.java;h=e8c4f8654abf2413b4455be4f7031650b70cc6a0;hb=c3ae2d6897e5a809459c8d9a72a4b3aa0052c8c8;hp=0000000000000000000000000000000000000000;hpb=a9a6f1747f8466e99abd5972bf675d310f6d7222;p=ldk-java diff --git a/src/main/java/org/ldk/structs/WatchedOutput.java b/src/main/java/org/ldk/structs/WatchedOutput.java new file mode 100644 index 00000000..e8c4f865 --- /dev/null +++ b/src/main/java/org/ldk/structs/WatchedOutput.java @@ -0,0 +1,90 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; + + +/** + * A transaction output watched by a [`ChannelMonitor`] for spends on-chain. + * + * 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`]. + * + * 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. + * + * [`ChannelMonitor`]: channelmonitor::ChannelMonitor + * [`ChannelMonitor::block_connected`]: channelmonitor::ChannelMonitor::block_connected + */ +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class WatchedOutput extends CommonBase { + WatchedOutput(Object _dummy, long ptr) { super(ptr); } + @Override @SuppressWarnings("deprecation") + protected void finalize() throws Throwable { + super.finalize(); + if (ptr != 0) { bindings.WatchedOutput_free(ptr); } + } + + /** + * First block where the transaction output may have been spent. + */ + public byte[] get_block_hash() { + byte[] ret = bindings.WatchedOutput_get_block_hash(this.ptr); + return ret; + } + + /** + * First block where the transaction output may have been spent. + */ + public void set_block_hash(byte[] val) { + bindings.WatchedOutput_set_block_hash(this.ptr, val); + } + + /** + * Outpoint identifying the transaction output. + */ + public OutPoint get_outpoint() { + long ret = bindings.WatchedOutput_get_outpoint(this.ptr); + OutPoint ret_hu_conv = new OutPoint(null, ret); + 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); + this.ptrs_to.add(val); + } + + /** + * Spending condition of the transaction output. + */ + public byte[] get_script_pubkey() { + byte[] ret = bindings.WatchedOutput_get_script_pubkey(this.ptr); + return ret; + } + + /** + * Spending condition of the transaction output. + */ + public void set_script_pubkey(byte[] val) { + bindings.WatchedOutput_set_script_pubkey(this.ptr, val); + } + + /** + * Constructs a new WatchedOutput given each field + */ + public static WatchedOutput constructor_new(byte[] block_hash_arg, OutPoint outpoint_arg, byte[] script_pubkey_arg) { + long ret = bindings.WatchedOutput_new(block_hash_arg, outpoint_arg == null ? 0 : outpoint_arg.ptr & ~1, script_pubkey_arg); + WatchedOutput ret_hu_conv = new WatchedOutput(null, ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + ret_hu_conv.ptrs_to.add(outpoint_arg); + return ret_hu_conv; + } + +}