Update auto-generated bindings
[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 javax.annotation.Nullable;
8
9
10 /**
11  * A transaction output watched by a [`ChannelMonitor`] for spends on-chain.
12  * 
13  * Used to convey to a [`Filter`] such an output with a given spending condition. Any transaction
14  * spending the output must be given to [`ChannelMonitor::block_connected`] either directly or via
15  * the return value of [`Filter::register_output`].
16  * 
17  * If `block_hash` is `Some`, this indicates the output was created in the corresponding block and
18  * may have been spent there. See [`Filter::register_output`] for details.
19  * 
20  * [`ChannelMonitor`]: channelmonitor::ChannelMonitor
21  * [`ChannelMonitor::block_connected`]: channelmonitor::ChannelMonitor::block_connected
22  */
23 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
24 public class WatchedOutput extends CommonBase {
25         WatchedOutput(Object _dummy, long ptr) { super(ptr); }
26         @Override @SuppressWarnings("deprecation")
27         protected void finalize() throws Throwable {
28                 super.finalize();
29                 if (ptr != 0) { bindings.WatchedOutput_free(ptr); }
30         }
31
32         /**
33          * First block where the transaction output may have been spent.
34          * 
35          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
36          */
37         @Nullable
38         public byte[] get_block_hash() {
39                 byte[] ret = bindings.WatchedOutput_get_block_hash(this.ptr);
40                 return ret;
41         }
42
43         /**
44          * First block where the transaction output may have been spent.
45          * 
46          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
47          */
48         public void set_block_hash(@Nullable byte[] val) {
49                 bindings.WatchedOutput_set_block_hash(this.ptr, InternalUtils.check_arr_len(val, 32));
50         }
51
52         /**
53          * Outpoint identifying the transaction output.
54          */
55         public OutPoint get_outpoint() {
56                 long ret = bindings.WatchedOutput_get_outpoint(this.ptr);
57                 if (ret >= 0 && ret <= 4096) { return null; }
58                 OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new OutPoint(null, ret); }
59                 ret_hu_conv.ptrs_to.add(this);
60                 return ret_hu_conv;
61         }
62
63         /**
64          * Outpoint identifying the transaction output.
65          */
66         public void set_outpoint(OutPoint val) {
67                 bindings.WatchedOutput_set_outpoint(this.ptr, val == null ? 0 : val.ptr & ~1);
68         }
69
70         /**
71          * Spending condition of the transaction output.
72          */
73         public byte[] get_script_pubkey() {
74                 byte[] ret = bindings.WatchedOutput_get_script_pubkey(this.ptr);
75                 return ret;
76         }
77
78         /**
79          * Spending condition of the transaction output.
80          */
81         public void set_script_pubkey(byte[] val) {
82                 bindings.WatchedOutput_set_script_pubkey(this.ptr, val);
83         }
84
85         /**
86          * Constructs a new WatchedOutput given each field
87          */
88         public static WatchedOutput of(byte[] block_hash_arg, OutPoint outpoint_arg, byte[] script_pubkey_arg) {
89                 long ret = bindings.WatchedOutput_new(InternalUtils.check_arr_len(block_hash_arg, 32), outpoint_arg == null ? 0 : outpoint_arg.ptr & ~1, script_pubkey_arg);
90                 if (ret >= 0 && ret <= 4096) { return null; }
91                 WatchedOutput ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new WatchedOutput(null, ret); }
92                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
93                 return ret_hu_conv;
94         }
95
96         long clone_ptr() {
97                 long ret = bindings.WatchedOutput_clone_ptr(this.ptr);
98                 return ret;
99         }
100
101         /**
102          * Creates a copy of the WatchedOutput
103          */
104         public WatchedOutput clone() {
105                 long ret = bindings.WatchedOutput_clone(this.ptr);
106                 if (ret >= 0 && ret <= 4096) { return null; }
107                 WatchedOutput ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new WatchedOutput(null, ret); }
108                 ret_hu_conv.ptrs_to.add(this);
109                 return ret_hu_conv;
110         }
111
112         /**
113          * Checks if two WatchedOutputs contain equal inner contents.
114          */
115         public long hash() {
116                 long ret = bindings.WatchedOutput_hash(this.ptr);
117                 return ret;
118         }
119
120 }