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 * [`ChannelMonitor`]: channelmonitor::ChannelMonitor
20 * [`ChannelMonitor::block_connected`]: channelmonitor::ChannelMonitor::block_connected
22 public class WatchedOutput : CommonBase {
23 internal WatchedOutput(object _dummy, long ptr) : base(ptr) { }
25 if (ptr != 0) { bindings.WatchedOutput_free(ptr); }
29 * First block where the transaction output may have been spent.
31 public Option_BlockHashZ get_block_hash() {
32 long ret = bindings.WatchedOutput_get_block_hash(this.ptr);
34 if (ret >= 0 && ret <= 4096) { return null; }
35 org.ldk.structs.Option_BlockHashZ ret_hu_conv = org.ldk.structs.Option_BlockHashZ.constr_from_ptr(ret);
36 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
41 * First block where the transaction output may have been spent.
43 public void set_block_hash(org.ldk.structs.Option_BlockHashZ val) {
44 bindings.WatchedOutput_set_block_hash(this.ptr, val.ptr);
47 if (this != null) { this.ptrs_to.AddLast(val); };
51 * Outpoint identifying the transaction output.
53 public OutPoint get_outpoint() {
54 long ret = bindings.WatchedOutput_get_outpoint(this.ptr);
56 if (ret >= 0 && ret <= 4096) { return null; }
57 org.ldk.structs.OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OutPoint(null, ret); }
58 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
63 * Outpoint identifying the transaction output.
65 public void set_outpoint(org.ldk.structs.OutPoint val) {
66 bindings.WatchedOutput_set_outpoint(this.ptr, val == null ? 0 : val.ptr);
69 if (this != null) { this.ptrs_to.AddLast(val); };
73 * Spending condition of the transaction output.
75 public byte[] get_script_pubkey() {
76 byte[] ret = bindings.WatchedOutput_get_script_pubkey(this.ptr);
82 * Spending condition of the transaction output.
84 public void set_script_pubkey(byte[] val) {
85 bindings.WatchedOutput_set_script_pubkey(this.ptr, val);
91 * Constructs a new WatchedOutput given each field
93 public static WatchedOutput of(org.ldk.structs.Option_BlockHashZ block_hash_arg, org.ldk.structs.OutPoint outpoint_arg, byte[] script_pubkey_arg) {
94 long ret = bindings.WatchedOutput_new(block_hash_arg.ptr, outpoint_arg == null ? 0 : outpoint_arg.ptr, script_pubkey_arg);
95 GC.KeepAlive(block_hash_arg);
96 GC.KeepAlive(outpoint_arg);
97 GC.KeepAlive(script_pubkey_arg);
98 if (ret >= 0 && ret <= 4096) { return null; }
99 org.ldk.structs.WatchedOutput ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.WatchedOutput(null, ret); }
100 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
101 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(block_hash_arg); };
102 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(outpoint_arg); };
106 internal long clone_ptr() {
107 long ret = bindings.WatchedOutput_clone_ptr(this.ptr);
113 * Creates a copy of the WatchedOutput
115 public WatchedOutput clone() {
116 long ret = bindings.WatchedOutput_clone(this.ptr);
118 if (ret >= 0 && ret <= 4096) { return null; }
119 org.ldk.structs.WatchedOutput ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.WatchedOutput(null, ret); }
120 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
125 * Checks if two WatchedOutputs contain equal inner contents.
126 * This ignores pointers and is_owned flags and looks at the values in fields.
127 * Two objects with NULL inner values will be considered "equal" here.
129 public bool eq(org.ldk.structs.WatchedOutput b) {
130 bool ret = bindings.WatchedOutput_eq(this.ptr, b == null ? 0 : b.ptr);
133 if (this != null) { this.ptrs_to.AddLast(b); };
137 public override bool Equals(object o) {
138 if (!(o is WatchedOutput)) return false;
139 return this.eq((WatchedOutput)o);
142 * Generates a non-cryptographic 64-bit hash of the WatchedOutput.
145 long ret = bindings.WatchedOutput_hash(this.ptr);
150 public override int GetHashCode() {
151 return (int)this.hash();