[Java] Update auto-generated bindings to 0.0.117
[ldk-java] / src / main / java / org / ldk / structs / WatchedOutput.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * A transaction output watched by a [`ChannelMonitor`] for spends on-chain.
13  * 
14  * Used to convey to a [`Filter`] such an output with a given spending condition. Any transaction
15  * spending the output must be given to [`ChannelMonitor::block_connected`] either directly or via
16  * [`Confirm::transactions_confirmed`].
17  * 
18  * If `block_hash` is `Some`, this indicates the output was created in the corresponding block and
19  * may have been spent there. See [`Filter::register_output`] for details.
20  * 
21  * [`ChannelMonitor`]: channelmonitor::ChannelMonitor
22  * [`ChannelMonitor::block_connected`]: channelmonitor::ChannelMonitor::block_connected
23  */
24 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
25 public class WatchedOutput extends CommonBase {
26         WatchedOutput(Object _dummy, long ptr) { super(ptr); }
27         @Override @SuppressWarnings("deprecation")
28         protected void finalize() throws Throwable {
29                 super.finalize();
30                 if (ptr != 0) { bindings.WatchedOutput_free(ptr); }
31         }
32
33         /**
34          * First block where the transaction output may have been spent.
35          */
36         public Option_ThirtyTwoBytesZ get_block_hash() {
37                 long ret = bindings.WatchedOutput_get_block_hash(this.ptr);
38                 Reference.reachabilityFence(this);
39                 if (ret >= 0 && ret <= 4096) { return null; }
40                 org.ldk.structs.Option_ThirtyTwoBytesZ ret_hu_conv = org.ldk.structs.Option_ThirtyTwoBytesZ.constr_from_ptr(ret);
41                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
42                 return ret_hu_conv;
43         }
44
45         /**
46          * First block where the transaction output may have been spent.
47          */
48         public void set_block_hash(org.ldk.structs.Option_ThirtyTwoBytesZ val) {
49                 bindings.WatchedOutput_set_block_hash(this.ptr, val.ptr);
50                 Reference.reachabilityFence(this);
51                 Reference.reachabilityFence(val);
52                 if (this != null) { this.ptrs_to.add(val); };
53         }
54
55         /**
56          * Outpoint identifying the transaction output.
57          */
58         public OutPoint get_outpoint() {
59                 long ret = bindings.WatchedOutput_get_outpoint(this.ptr);
60                 Reference.reachabilityFence(this);
61                 if (ret >= 0 && ret <= 4096) { return null; }
62                 org.ldk.structs.OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OutPoint(null, ret); }
63                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
64                 return ret_hu_conv;
65         }
66
67         /**
68          * Outpoint identifying the transaction output.
69          */
70         public void set_outpoint(org.ldk.structs.OutPoint val) {
71                 bindings.WatchedOutput_set_outpoint(this.ptr, val == null ? 0 : val.ptr);
72                 Reference.reachabilityFence(this);
73                 Reference.reachabilityFence(val);
74                 if (this != null) { this.ptrs_to.add(val); };
75         }
76
77         /**
78          * Spending condition of the transaction output.
79          */
80         public byte[] get_script_pubkey() {
81                 byte[] ret = bindings.WatchedOutput_get_script_pubkey(this.ptr);
82                 Reference.reachabilityFence(this);
83                 return ret;
84         }
85
86         /**
87          * Spending condition of the transaction output.
88          */
89         public void set_script_pubkey(byte[] val) {
90                 bindings.WatchedOutput_set_script_pubkey(this.ptr, val);
91                 Reference.reachabilityFence(this);
92                 Reference.reachabilityFence(val);
93         }
94
95         /**
96          * Constructs a new WatchedOutput given each field
97          */
98         public static WatchedOutput of(org.ldk.structs.Option_ThirtyTwoBytesZ block_hash_arg, org.ldk.structs.OutPoint outpoint_arg, byte[] script_pubkey_arg) {
99                 long ret = bindings.WatchedOutput_new(block_hash_arg.ptr, outpoint_arg == null ? 0 : outpoint_arg.ptr, script_pubkey_arg);
100                 Reference.reachabilityFence(block_hash_arg);
101                 Reference.reachabilityFence(outpoint_arg);
102                 Reference.reachabilityFence(script_pubkey_arg);
103                 if (ret >= 0 && ret <= 4096) { return null; }
104                 org.ldk.structs.WatchedOutput ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.WatchedOutput(null, ret); }
105                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
106                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(block_hash_arg); };
107                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(outpoint_arg); };
108                 return ret_hu_conv;
109         }
110
111         long clone_ptr() {
112                 long ret = bindings.WatchedOutput_clone_ptr(this.ptr);
113                 Reference.reachabilityFence(this);
114                 return ret;
115         }
116
117         /**
118          * Creates a copy of the WatchedOutput
119          */
120         public WatchedOutput clone() {
121                 long ret = bindings.WatchedOutput_clone(this.ptr);
122                 Reference.reachabilityFence(this);
123                 if (ret >= 0 && ret <= 4096) { return null; }
124                 org.ldk.structs.WatchedOutput ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.WatchedOutput(null, ret); }
125                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
126                 return ret_hu_conv;
127         }
128
129         /**
130          * Checks if two WatchedOutputs contain equal inner contents.
131          * This ignores pointers and is_owned flags and looks at the values in fields.
132          * Two objects with NULL inner values will be considered "equal" here.
133          */
134         public boolean eq(org.ldk.structs.WatchedOutput b) {
135                 boolean ret = bindings.WatchedOutput_eq(this.ptr, b == null ? 0 : b.ptr);
136                 Reference.reachabilityFence(this);
137                 Reference.reachabilityFence(b);
138                 if (this != null) { this.ptrs_to.add(b); };
139                 return ret;
140         }
141
142         @Override public boolean equals(Object o) {
143                 if (!(o instanceof WatchedOutput)) return false;
144                 return this.eq((WatchedOutput)o);
145         }
146         /**
147          * Generates a non-cryptographic 64-bit hash of the WatchedOutput.
148          */
149         public long hash() {
150                 long ret = bindings.WatchedOutput_hash(this.ptr);
151                 Reference.reachabilityFence(this);
152                 return ret;
153         }
154
155         @Override public int hashCode() {
156                 return (int)this.hash();
157         }
158 }