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
8
9 /**
10  * A transaction output watched by a [`ChannelMonitor`] for spends on-chain.
11  * 
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  * the return value of [`Filter::register_output`].
15  * 
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.
18  * 
19  * [`ChannelMonitor`]: channelmonitor::ChannelMonitor
20  * [`ChannelMonitor::block_connected`]: channelmonitor::ChannelMonitor::block_connected
21  */
22 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
23 public class WatchedOutput extends CommonBase {
24         WatchedOutput(Object _dummy, long ptr) { super(ptr); }
25         @Override @SuppressWarnings("deprecation")
26         protected void finalize() throws Throwable {
27                 super.finalize();
28                 if (ptr != 0) { bindings.WatchedOutput_free(ptr); }
29         }
30
31         /**
32          * First block where the transaction output may have been spent.
33          * 
34          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
35          */
36         @Nullable
37         public byte[] get_block_hash() {
38                 byte[] ret = bindings.WatchedOutput_get_block_hash(this.ptr);
39                 return ret;
40         }
41
42         /**
43          * First block where the transaction output may have been spent.
44          * 
45          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
46          */
47         public void set_block_hash(@Nullable byte[] val) {
48                 bindings.WatchedOutput_set_block_hash(this.ptr, val);
49         }
50
51         /**
52          * Outpoint identifying the transaction output.
53          */
54         public OutPoint get_outpoint() {
55                 long ret = bindings.WatchedOutput_get_outpoint(this.ptr);
56                 if (ret < 1024) { return null; }
57                 OutPoint ret_hu_conv = new OutPoint(null, ret);
58                 ret_hu_conv.ptrs_to.add(this);
59                 return ret_hu_conv;
60         }
61
62         /**
63          * Outpoint identifying the transaction output.
64          */
65         public void set_outpoint(OutPoint val) {
66                 bindings.WatchedOutput_set_outpoint(this.ptr, val == null ? 0 : val.ptr & ~1);
67                 this.ptrs_to.add(val);
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(block_hash_arg, outpoint_arg == null ? 0 : outpoint_arg.ptr & ~1, script_pubkey_arg);
90                 if (ret < 1024) { return null; }
91                 WatchedOutput ret_hu_conv = new WatchedOutput(null, ret);
92                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
93                 ret_hu_conv.ptrs_to.add(outpoint_arg);
94                 return ret_hu_conv;
95         }
96
97         /**
98          * Creates a copy of the WatchedOutput
99          */
100         public WatchedOutput clone() {
101                 long ret = bindings.WatchedOutput_clone(this.ptr);
102                 if (ret < 1024) { return null; }
103                 WatchedOutput ret_hu_conv = new WatchedOutput(null, ret);
104                 ret_hu_conv.ptrs_to.add(this);
105                 return ret_hu_conv;
106         }
107
108         /**
109          * Checks if two WatchedOutputs contain equal inner contents.
110          */
111         public long hash() {
112                 long ret = bindings.WatchedOutput_hash(this.ptr);
113                 return ret;
114         }
115
116 }