[Java] Update auto-generated bindings to 0.0.117
[ldk-java] / src / main / java / org / ldk / structs / StaticPaymentOutputDescriptor.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  * Information about a spendable output to our \"payment key\".
13  * 
14  * See [`SpendableOutputDescriptor::StaticPaymentOutput`] for more details on how to spend this.
15  */
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class StaticPaymentOutputDescriptor extends CommonBase {
18         StaticPaymentOutputDescriptor(Object _dummy, long ptr) { super(ptr); }
19         @Override @SuppressWarnings("deprecation")
20         protected void finalize() throws Throwable {
21                 super.finalize();
22                 if (ptr != 0) { bindings.StaticPaymentOutputDescriptor_free(ptr); }
23         }
24
25         /**
26          * The outpoint which is spendable.
27          */
28         public OutPoint get_outpoint() {
29                 long ret = bindings.StaticPaymentOutputDescriptor_get_outpoint(this.ptr);
30                 Reference.reachabilityFence(this);
31                 if (ret >= 0 && ret <= 4096) { return null; }
32                 org.ldk.structs.OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OutPoint(null, ret); }
33                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
34                 return ret_hu_conv;
35         }
36
37         /**
38          * The outpoint which is spendable.
39          */
40         public void set_outpoint(org.ldk.structs.OutPoint val) {
41                 bindings.StaticPaymentOutputDescriptor_set_outpoint(this.ptr, val == null ? 0 : val.ptr);
42                 Reference.reachabilityFence(this);
43                 Reference.reachabilityFence(val);
44                 if (this != null) { this.ptrs_to.add(val); };
45         }
46
47         /**
48          * The output which is referenced by the given outpoint.
49          */
50         public TxOut get_output() {
51                 long ret = bindings.StaticPaymentOutputDescriptor_get_output(this.ptr);
52                 Reference.reachabilityFence(this);
53                 if (ret >= 0 && ret <= 4096) { return null; }
54                 TxOut ret_conv = new TxOut(null, ret);
55                 return ret_conv;
56         }
57
58         /**
59          * The output which is referenced by the given outpoint.
60          */
61         public void set_output(org.ldk.structs.TxOut val) {
62                 bindings.StaticPaymentOutputDescriptor_set_output(this.ptr, val.ptr);
63                 Reference.reachabilityFence(this);
64                 Reference.reachabilityFence(val);
65         }
66
67         /**
68          * Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`].
69          * This may be useful in re-deriving keys used in the channel to spend the output.
70          */
71         public byte[] get_channel_keys_id() {
72                 byte[] ret = bindings.StaticPaymentOutputDescriptor_get_channel_keys_id(this.ptr);
73                 Reference.reachabilityFence(this);
74                 return ret;
75         }
76
77         /**
78          * Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`].
79          * This may be useful in re-deriving keys used in the channel to spend the output.
80          */
81         public void set_channel_keys_id(byte[] val) {
82                 bindings.StaticPaymentOutputDescriptor_set_channel_keys_id(this.ptr, InternalUtils.check_arr_len(val, 32));
83                 Reference.reachabilityFence(this);
84                 Reference.reachabilityFence(val);
85         }
86
87         /**
88          * The value of the channel which this transactions spends.
89          */
90         public long get_channel_value_satoshis() {
91                 long ret = bindings.StaticPaymentOutputDescriptor_get_channel_value_satoshis(this.ptr);
92                 Reference.reachabilityFence(this);
93                 return ret;
94         }
95
96         /**
97          * The value of the channel which this transactions spends.
98          */
99         public void set_channel_value_satoshis(long val) {
100                 bindings.StaticPaymentOutputDescriptor_set_channel_value_satoshis(this.ptr, val);
101                 Reference.reachabilityFence(this);
102                 Reference.reachabilityFence(val);
103         }
104
105         /**
106          * The necessary channel parameters that need to be provided to the re-derived signer through
107          * [`ChannelSigner::provide_channel_parameters`].
108          * 
109          * Added as optional, but always `Some` if the descriptor was produced in v0.0.117 or later.
110          * 
111          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
112          */
113         @Nullable
114         public ChannelTransactionParameters get_channel_transaction_parameters() {
115                 long ret = bindings.StaticPaymentOutputDescriptor_get_channel_transaction_parameters(this.ptr);
116                 Reference.reachabilityFence(this);
117                 if (ret >= 0 && ret <= 4096) { return null; }
118                 org.ldk.structs.ChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTransactionParameters(null, ret); }
119                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
120                 return ret_hu_conv;
121         }
122
123         /**
124          * The necessary channel parameters that need to be provided to the re-derived signer through
125          * [`ChannelSigner::provide_channel_parameters`].
126          * 
127          * Added as optional, but always `Some` if the descriptor was produced in v0.0.117 or later.
128          * 
129          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
130          */
131         public void set_channel_transaction_parameters(@Nullable org.ldk.structs.ChannelTransactionParameters val) {
132                 bindings.StaticPaymentOutputDescriptor_set_channel_transaction_parameters(this.ptr, val == null ? 0 : val.ptr);
133                 Reference.reachabilityFence(this);
134                 Reference.reachabilityFence(val);
135                 if (this != null) { this.ptrs_to.add(val); };
136         }
137
138         /**
139          * Constructs a new StaticPaymentOutputDescriptor given each field
140          * 
141          * Note that channel_transaction_parameters_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
142          */
143         public static StaticPaymentOutputDescriptor of(org.ldk.structs.OutPoint outpoint_arg, org.ldk.structs.TxOut output_arg, byte[] channel_keys_id_arg, long channel_value_satoshis_arg, @Nullable org.ldk.structs.ChannelTransactionParameters channel_transaction_parameters_arg) {
144                 long ret = bindings.StaticPaymentOutputDescriptor_new(outpoint_arg == null ? 0 : outpoint_arg.ptr, output_arg.ptr, InternalUtils.check_arr_len(channel_keys_id_arg, 32), channel_value_satoshis_arg, channel_transaction_parameters_arg == null ? 0 : channel_transaction_parameters_arg.ptr);
145                 Reference.reachabilityFence(outpoint_arg);
146                 Reference.reachabilityFence(output_arg);
147                 Reference.reachabilityFence(channel_keys_id_arg);
148                 Reference.reachabilityFence(channel_value_satoshis_arg);
149                 Reference.reachabilityFence(channel_transaction_parameters_arg);
150                 if (ret >= 0 && ret <= 4096) { return null; }
151                 org.ldk.structs.StaticPaymentOutputDescriptor ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.StaticPaymentOutputDescriptor(null, ret); }
152                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
153                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(outpoint_arg); };
154                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_transaction_parameters_arg); };
155                 return ret_hu_conv;
156         }
157
158         long clone_ptr() {
159                 long ret = bindings.StaticPaymentOutputDescriptor_clone_ptr(this.ptr);
160                 Reference.reachabilityFence(this);
161                 return ret;
162         }
163
164         /**
165          * Creates a copy of the StaticPaymentOutputDescriptor
166          */
167         public StaticPaymentOutputDescriptor clone() {
168                 long ret = bindings.StaticPaymentOutputDescriptor_clone(this.ptr);
169                 Reference.reachabilityFence(this);
170                 if (ret >= 0 && ret <= 4096) { return null; }
171                 org.ldk.structs.StaticPaymentOutputDescriptor ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.StaticPaymentOutputDescriptor(null, ret); }
172                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
173                 return ret_hu_conv;
174         }
175
176         /**
177          * Generates a non-cryptographic 64-bit hash of the StaticPaymentOutputDescriptor.
178          */
179         public long hash() {
180                 long ret = bindings.StaticPaymentOutputDescriptor_hash(this.ptr);
181                 Reference.reachabilityFence(this);
182                 return ret;
183         }
184
185         @Override public int hashCode() {
186                 return (int)this.hash();
187         }
188         /**
189          * Checks if two StaticPaymentOutputDescriptors contain equal inner contents.
190          * This ignores pointers and is_owned flags and looks at the values in fields.
191          * Two objects with NULL inner values will be considered "equal" here.
192          */
193         public boolean eq(org.ldk.structs.StaticPaymentOutputDescriptor b) {
194                 boolean ret = bindings.StaticPaymentOutputDescriptor_eq(this.ptr, b == null ? 0 : b.ptr);
195                 Reference.reachabilityFence(this);
196                 Reference.reachabilityFence(b);
197                 if (this != null) { this.ptrs_to.add(b); };
198                 return ret;
199         }
200
201         @Override public boolean equals(Object o) {
202                 if (!(o instanceof StaticPaymentOutputDescriptor)) return false;
203                 return this.eq((StaticPaymentOutputDescriptor)o);
204         }
205         /**
206          * Returns the `witness_script` of the spendable output.
207          * 
208          * Note that this will only return `Some` for [`StaticPaymentOutputDescriptor`]s that
209          * originated from an anchor outputs channel, as they take the form of a P2WSH script.
210          */
211         public Option_CVec_u8ZZ witness_script() {
212                 long ret = bindings.StaticPaymentOutputDescriptor_witness_script(this.ptr);
213                 Reference.reachabilityFence(this);
214                 if (ret >= 0 && ret <= 4096) { return null; }
215                 org.ldk.structs.Option_CVec_u8ZZ ret_hu_conv = org.ldk.structs.Option_CVec_u8ZZ.constr_from_ptr(ret);
216                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
217                 return ret_hu_conv;
218         }
219
220         /**
221          * The maximum length a well-formed witness spending one of these should have.
222          * Note: If you have the grind_signatures feature enabled, this will be at least 1 byte
223          * shorter.
224          */
225         public long max_witness_length() {
226                 long ret = bindings.StaticPaymentOutputDescriptor_max_witness_length(this.ptr);
227                 Reference.reachabilityFence(this);
228                 return ret;
229         }
230
231         /**
232          * Serialize the StaticPaymentOutputDescriptor object into a byte array which can be read by StaticPaymentOutputDescriptor_read
233          */
234         public byte[] write() {
235                 byte[] ret = bindings.StaticPaymentOutputDescriptor_write(this.ptr);
236                 Reference.reachabilityFence(this);
237                 return ret;
238         }
239
240         /**
241          * Read a StaticPaymentOutputDescriptor from a byte array, created by StaticPaymentOutputDescriptor_write
242          */
243         public static Result_StaticPaymentOutputDescriptorDecodeErrorZ read(byte[] ser) {
244                 long ret = bindings.StaticPaymentOutputDescriptor_read(ser);
245                 Reference.reachabilityFence(ser);
246                 if (ret >= 0 && ret <= 4096) { return null; }
247                 Result_StaticPaymentOutputDescriptorDecodeErrorZ ret_hu_conv = Result_StaticPaymentOutputDescriptorDecodeErrorZ.constr_from_ptr(ret);
248                 return ret_hu_conv;
249         }
250
251 }