Update auto-updated Java files
[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  * the return value of [`Filter::register_output`].
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          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
37          */
38         @Nullable
39         public byte[] get_block_hash() {
40                 byte[] ret = bindings.WatchedOutput_get_block_hash(this.ptr);
41                 Reference.reachabilityFence(this);
42                 return ret;
43         }
44
45         /**
46          * First block where the transaction output may have been spent.
47          * 
48          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
49          */
50         public void set_block_hash(@Nullable byte[] val) {
51                 bindings.WatchedOutput_set_block_hash(this.ptr, InternalUtils.check_arr_len(val, 32));
52                 Reference.reachabilityFence(this);
53                 Reference.reachabilityFence(val);
54         }
55
56         /**
57          * Outpoint identifying the transaction output.
58          */
59         public OutPoint get_outpoint() {
60                 long ret = bindings.WatchedOutput_get_outpoint(this.ptr);
61                 Reference.reachabilityFence(this);
62                 if (ret >= 0 && ret <= 4096) { return null; }
63                 OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new OutPoint(null, ret); }
64                 ret_hu_conv.ptrs_to.add(this);
65                 return ret_hu_conv;
66         }
67
68         /**
69          * Outpoint identifying the transaction output.
70          */
71         public void set_outpoint(OutPoint val) {
72                 bindings.WatchedOutput_set_outpoint(this.ptr, val == null ? 0 : val.ptr & ~1);
73                 Reference.reachabilityFence(this);
74                 Reference.reachabilityFence(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(byte[] block_hash_arg, OutPoint outpoint_arg, byte[] script_pubkey_arg) {
99                 long ret = bindings.WatchedOutput_new(InternalUtils.check_arr_len(block_hash_arg, 32), outpoint_arg == null ? 0 : outpoint_arg.ptr & ~1, 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                 WatchedOutput ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new WatchedOutput(null, ret); }
105                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
106                 return ret_hu_conv;
107         }
108
109         long clone_ptr() {
110                 long ret = bindings.WatchedOutput_clone_ptr(this.ptr);
111                 Reference.reachabilityFence(this);
112                 return ret;
113         }
114
115         /**
116          * Creates a copy of the WatchedOutput
117          */
118         public WatchedOutput clone() {
119                 long ret = bindings.WatchedOutput_clone(this.ptr);
120                 Reference.reachabilityFence(this);
121                 if (ret >= 0 && ret <= 4096) { return null; }
122                 WatchedOutput ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new WatchedOutput(null, ret); }
123                 ret_hu_conv.ptrs_to.add(this);
124                 return ret_hu_conv;
125         }
126
127         /**
128          * Checks if two WatchedOutputs contain equal inner contents.
129          */
130         public long hash() {
131                 long ret = bindings.WatchedOutput_hash(this.ptr);
132                 Reference.reachabilityFence(this);
133                 return ret;
134         }
135
136         @Override public int hashCode() {
137                 return (int)this.hash();
138         }
139 }