6 namespace org { namespace ldk { namespace structs {
10 * A transaction output watched by a [`ChannelMonitor`] for spends on-chain.
12 * Used to convey to a [`Filter`] such an output with a given spending condition. Any transaction
13 * spending the output must be given to [`ChannelMonitor::block_connected`] either directly or via
14 * [`Confirm::transactions_confirmed`].
16 * If `block_hash` is `Some`, this indicates the output was created in the corresponding block and
17 * may have been spent there. See [`Filter::register_output`] for details.
19 * Depending on your block source, you may need one or both of either [`Self::outpoint`] or
20 * [`Self::script_pubkey`].
22 * [`ChannelMonitor`]: channelmonitor::ChannelMonitor
23 * [`ChannelMonitor::block_connected`]: channelmonitor::ChannelMonitor::block_connected
25 public class WatchedOutput : CommonBase {
26 internal WatchedOutput(object _dummy, long ptr) : base(ptr) { }
28 if (ptr != 0) { bindings.WatchedOutput_free(ptr); }
32 * First block where the transaction output may have been spent.
34 public Option_ThirtyTwoBytesZ get_block_hash() {
35 long ret = bindings.WatchedOutput_get_block_hash(this.ptr);
37 if (ret >= 0 && ret <= 4096) { return null; }
38 org.ldk.structs.Option_ThirtyTwoBytesZ ret_hu_conv = org.ldk.structs.Option_ThirtyTwoBytesZ.constr_from_ptr(ret);
39 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
44 * First block where the transaction output may have been spent.
46 public void set_block_hash(org.ldk.structs.Option_ThirtyTwoBytesZ val) {
47 bindings.WatchedOutput_set_block_hash(this.ptr, val.ptr);
53 * Outpoint identifying the transaction output.
55 public OutPoint get_outpoint() {
56 long ret = bindings.WatchedOutput_get_outpoint(this.ptr);
58 if (ret >= 0 && ret <= 4096) { return null; }
59 org.ldk.structs.OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OutPoint(null, ret); }
60 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
65 * Outpoint identifying the transaction output.
67 public void set_outpoint(org.ldk.structs.OutPoint val) {
68 bindings.WatchedOutput_set_outpoint(this.ptr, val.ptr);
74 * Spending condition of the transaction output.
76 public byte[] get_script_pubkey() {
77 long ret = bindings.WatchedOutput_get_script_pubkey(this.ptr);
79 if (ret >= 0 && ret <= 4096) { return null; }
80 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
85 * Spending condition of the transaction output.
87 public void set_script_pubkey(byte[] val) {
88 bindings.WatchedOutput_set_script_pubkey(this.ptr, InternalUtils.encodeUint8Array(val));
94 * Constructs a new WatchedOutput given each field
96 public static WatchedOutput of(org.ldk.structs.Option_ThirtyTwoBytesZ block_hash_arg, org.ldk.structs.OutPoint outpoint_arg, byte[] script_pubkey_arg) {
97 long ret = bindings.WatchedOutput_new(block_hash_arg.ptr, outpoint_arg.ptr, InternalUtils.encodeUint8Array(script_pubkey_arg));
98 GC.KeepAlive(block_hash_arg);
99 GC.KeepAlive(outpoint_arg);
100 GC.KeepAlive(script_pubkey_arg);
101 if (ret >= 0 && ret <= 4096) { return null; }
102 org.ldk.structs.WatchedOutput ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.WatchedOutput(null, ret); }
103 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
107 internal long clone_ptr() {
108 long ret = bindings.WatchedOutput_clone_ptr(this.ptr);
114 * Creates a copy of the WatchedOutput
116 public WatchedOutput clone() {
117 long ret = bindings.WatchedOutput_clone(this.ptr);
119 if (ret >= 0 && ret <= 4096) { return null; }
120 org.ldk.structs.WatchedOutput ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.WatchedOutput(null, ret); }
121 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
126 * Checks if two WatchedOutputs contain equal inner contents.
127 * This ignores pointers and is_owned flags and looks at the values in fields.
128 * Two objects with NULL inner values will be considered "equal" here.
130 public bool eq(org.ldk.structs.WatchedOutput b) {
131 bool ret = bindings.WatchedOutput_eq(this.ptr, b.ptr);
134 if (this != null) { this.ptrs_to.AddLast(b); };
138 public override bool Equals(object o) {
139 if (!(o is WatchedOutput)) return false;
140 return this.eq((WatchedOutput)o);
143 * Generates a non-cryptographic 64-bit hash of the WatchedOutput.
146 long ret = bindings.WatchedOutput_hash(this.ptr);
151 public override int GetHashCode() {
152 return (int)this.hash();