[Java] Print error stack trace when tests fail
[ldk-java] / src / main / java / org / ldk / structs / DelayedPaymentOutputDescriptor.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 a P2WSH script.
13  * 
14  * See [`SpendableOutputDescriptor::DelayedPaymentOutput`] for more details on how to spend this.
15  */
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class DelayedPaymentOutputDescriptor extends CommonBase {
18         DelayedPaymentOutputDescriptor(Object _dummy, long ptr) { super(ptr); }
19         @Override @SuppressWarnings("deprecation")
20         protected void finalize() throws Throwable {
21                 super.finalize();
22                 if (ptr != 0) { bindings.DelayedPaymentOutputDescriptor_free(ptr); }
23         }
24
25         /**
26          * The outpoint which is spendable.
27          */
28         public OutPoint get_outpoint() {
29                 long ret = bindings.DelayedPaymentOutputDescriptor_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.DelayedPaymentOutputDescriptor_set_outpoint(this.ptr, val.ptr);
42                 Reference.reachabilityFence(this);
43                 Reference.reachabilityFence(val);
44                 if (this != null) { this.ptrs_to.add(val); };
45         }
46
47         /**
48          * Per commitment point to derive the delayed payment key by key holder.
49          */
50         public byte[] get_per_commitment_point() {
51                 byte[] ret = bindings.DelayedPaymentOutputDescriptor_get_per_commitment_point(this.ptr);
52                 Reference.reachabilityFence(this);
53                 return ret;
54         }
55
56         /**
57          * Per commitment point to derive the delayed payment key by key holder.
58          */
59         public void set_per_commitment_point(byte[] val) {
60                 bindings.DelayedPaymentOutputDescriptor_set_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
61                 Reference.reachabilityFence(this);
62                 Reference.reachabilityFence(val);
63         }
64
65         /**
66          * The `nSequence` value which must be set in the spending input to satisfy the `OP_CSV` in
67          * the witness_script.
68          */
69         public short get_to_self_delay() {
70                 short ret = bindings.DelayedPaymentOutputDescriptor_get_to_self_delay(this.ptr);
71                 Reference.reachabilityFence(this);
72                 return ret;
73         }
74
75         /**
76          * The `nSequence` value which must be set in the spending input to satisfy the `OP_CSV` in
77          * the witness_script.
78          */
79         public void set_to_self_delay(short val) {
80                 bindings.DelayedPaymentOutputDescriptor_set_to_self_delay(this.ptr, val);
81                 Reference.reachabilityFence(this);
82                 Reference.reachabilityFence(val);
83         }
84
85         /**
86          * The output which is referenced by the given outpoint.
87          */
88         public TxOut get_output() {
89                 long ret = bindings.DelayedPaymentOutputDescriptor_get_output(this.ptr);
90                 Reference.reachabilityFence(this);
91                 if (ret >= 0 && ret <= 4096) { return null; }
92                 TxOut ret_conv = new TxOut(null, ret);
93                 return ret_conv;
94         }
95
96         /**
97          * The output which is referenced by the given outpoint.
98          */
99         public void set_output(org.ldk.structs.TxOut val) {
100                 bindings.DelayedPaymentOutputDescriptor_set_output(this.ptr, val.ptr);
101                 Reference.reachabilityFence(this);
102                 Reference.reachabilityFence(val);
103         }
104
105         /**
106          * The revocation point specific to the commitment transaction which was broadcast. Used to
107          * derive the witnessScript for this output.
108          */
109         public RevocationKey get_revocation_pubkey() {
110                 long ret = bindings.DelayedPaymentOutputDescriptor_get_revocation_pubkey(this.ptr);
111                 Reference.reachabilityFence(this);
112                 if (ret >= 0 && ret <= 4096) { return null; }
113                 org.ldk.structs.RevocationKey ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RevocationKey(null, ret); }
114                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
115                 return ret_hu_conv;
116         }
117
118         /**
119          * The revocation point specific to the commitment transaction which was broadcast. Used to
120          * derive the witnessScript for this output.
121          */
122         public void set_revocation_pubkey(org.ldk.structs.RevocationKey val) {
123                 bindings.DelayedPaymentOutputDescriptor_set_revocation_pubkey(this.ptr, val.ptr);
124                 Reference.reachabilityFence(this);
125                 Reference.reachabilityFence(val);
126                 if (this != null) { this.ptrs_to.add(val); };
127         }
128
129         /**
130          * Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`].
131          * This may be useful in re-deriving keys used in the channel to spend the output.
132          */
133         public byte[] get_channel_keys_id() {
134                 byte[] ret = bindings.DelayedPaymentOutputDescriptor_get_channel_keys_id(this.ptr);
135                 Reference.reachabilityFence(this);
136                 return ret;
137         }
138
139         /**
140          * Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`].
141          * This may be useful in re-deriving keys used in the channel to spend the output.
142          */
143         public void set_channel_keys_id(byte[] val) {
144                 bindings.DelayedPaymentOutputDescriptor_set_channel_keys_id(this.ptr, InternalUtils.check_arr_len(val, 32));
145                 Reference.reachabilityFence(this);
146                 Reference.reachabilityFence(val);
147         }
148
149         /**
150          * The value of the channel which this output originated from, possibly indirectly.
151          */
152         public long get_channel_value_satoshis() {
153                 long ret = bindings.DelayedPaymentOutputDescriptor_get_channel_value_satoshis(this.ptr);
154                 Reference.reachabilityFence(this);
155                 return ret;
156         }
157
158         /**
159          * The value of the channel which this output originated from, possibly indirectly.
160          */
161         public void set_channel_value_satoshis(long val) {
162                 bindings.DelayedPaymentOutputDescriptor_set_channel_value_satoshis(this.ptr, val);
163                 Reference.reachabilityFence(this);
164                 Reference.reachabilityFence(val);
165         }
166
167         /**
168          * The channel public keys and other parameters needed to generate a spending transaction or
169          * to provide to a re-derived signer through [`ChannelSigner::provide_channel_parameters`].
170          * 
171          * Added as optional, but always `Some` if the descriptor was produced in v0.0.123 or later.
172          * 
173          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
174          */
175         @Nullable
176         public ChannelTransactionParameters get_channel_transaction_parameters() {
177                 long ret = bindings.DelayedPaymentOutputDescriptor_get_channel_transaction_parameters(this.ptr);
178                 Reference.reachabilityFence(this);
179                 if (ret >= 0 && ret <= 4096) { return null; }
180                 org.ldk.structs.ChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTransactionParameters(null, ret); }
181                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
182                 return ret_hu_conv;
183         }
184
185         /**
186          * The channel public keys and other parameters needed to generate a spending transaction or
187          * to provide to a re-derived signer through [`ChannelSigner::provide_channel_parameters`].
188          * 
189          * Added as optional, but always `Some` if the descriptor was produced in v0.0.123 or later.
190          * 
191          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
192          */
193         public void set_channel_transaction_parameters(@Nullable org.ldk.structs.ChannelTransactionParameters val) {
194                 bindings.DelayedPaymentOutputDescriptor_set_channel_transaction_parameters(this.ptr, val == null ? 0 : val.ptr);
195                 Reference.reachabilityFence(this);
196                 Reference.reachabilityFence(val);
197                 if (this != null) { this.ptrs_to.add(val); };
198         }
199
200         /**
201          * Constructs a new DelayedPaymentOutputDescriptor given each field
202          * 
203          * Note that channel_transaction_parameters_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
204          */
205         public static DelayedPaymentOutputDescriptor of(org.ldk.structs.OutPoint outpoint_arg, byte[] per_commitment_point_arg, short to_self_delay_arg, org.ldk.structs.TxOut output_arg, org.ldk.structs.RevocationKey revocation_pubkey_arg, byte[] channel_keys_id_arg, long channel_value_satoshis_arg, @Nullable org.ldk.structs.ChannelTransactionParameters channel_transaction_parameters_arg) {
206                 long ret = bindings.DelayedPaymentOutputDescriptor_new(outpoint_arg.ptr, InternalUtils.check_arr_len(per_commitment_point_arg, 33), to_self_delay_arg, output_arg.ptr, revocation_pubkey_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);
207                 Reference.reachabilityFence(outpoint_arg);
208                 Reference.reachabilityFence(per_commitment_point_arg);
209                 Reference.reachabilityFence(to_self_delay_arg);
210                 Reference.reachabilityFence(output_arg);
211                 Reference.reachabilityFence(revocation_pubkey_arg);
212                 Reference.reachabilityFence(channel_keys_id_arg);
213                 Reference.reachabilityFence(channel_value_satoshis_arg);
214                 Reference.reachabilityFence(channel_transaction_parameters_arg);
215                 if (ret >= 0 && ret <= 4096) { return null; }
216                 org.ldk.structs.DelayedPaymentOutputDescriptor ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.DelayedPaymentOutputDescriptor(null, ret); }
217                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
218                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(outpoint_arg); };
219                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(revocation_pubkey_arg); };
220                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_transaction_parameters_arg); };
221                 return ret_hu_conv;
222         }
223
224         long clone_ptr() {
225                 long ret = bindings.DelayedPaymentOutputDescriptor_clone_ptr(this.ptr);
226                 Reference.reachabilityFence(this);
227                 return ret;
228         }
229
230         /**
231          * Creates a copy of the DelayedPaymentOutputDescriptor
232          */
233         public DelayedPaymentOutputDescriptor clone() {
234                 long ret = bindings.DelayedPaymentOutputDescriptor_clone(this.ptr);
235                 Reference.reachabilityFence(this);
236                 if (ret >= 0 && ret <= 4096) { return null; }
237                 org.ldk.structs.DelayedPaymentOutputDescriptor ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.DelayedPaymentOutputDescriptor(null, ret); }
238                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
239                 return ret_hu_conv;
240         }
241
242         /**
243          * Generates a non-cryptographic 64-bit hash of the DelayedPaymentOutputDescriptor.
244          */
245         public long hash() {
246                 long ret = bindings.DelayedPaymentOutputDescriptor_hash(this.ptr);
247                 Reference.reachabilityFence(this);
248                 return ret;
249         }
250
251         @Override public int hashCode() {
252                 return (int)this.hash();
253         }
254         /**
255          * Checks if two DelayedPaymentOutputDescriptors contain equal inner contents.
256          * This ignores pointers and is_owned flags and looks at the values in fields.
257          * Two objects with NULL inner values will be considered "equal" here.
258          */
259         public boolean eq(org.ldk.structs.DelayedPaymentOutputDescriptor b) {
260                 boolean ret = bindings.DelayedPaymentOutputDescriptor_eq(this.ptr, b.ptr);
261                 Reference.reachabilityFence(this);
262                 Reference.reachabilityFence(b);
263                 if (this != null) { this.ptrs_to.add(b); };
264                 return ret;
265         }
266
267         @Override public boolean equals(Object o) {
268                 if (!(o instanceof DelayedPaymentOutputDescriptor)) return false;
269                 return this.eq((DelayedPaymentOutputDescriptor)o);
270         }
271         /**
272          * Serialize the DelayedPaymentOutputDescriptor object into a byte array which can be read by DelayedPaymentOutputDescriptor_read
273          */
274         public byte[] write() {
275                 byte[] ret = bindings.DelayedPaymentOutputDescriptor_write(this.ptr);
276                 Reference.reachabilityFence(this);
277                 return ret;
278         }
279
280         /**
281          * Read a DelayedPaymentOutputDescriptor from a byte array, created by DelayedPaymentOutputDescriptor_write
282          */
283         public static Result_DelayedPaymentOutputDescriptorDecodeErrorZ read(byte[] ser) {
284                 long ret = bindings.DelayedPaymentOutputDescriptor_read(ser);
285                 Reference.reachabilityFence(ser);
286                 if (ret >= 0 && ret <= 4096) { return null; }
287                 Result_DelayedPaymentOutputDescriptorDecodeErrorZ ret_hu_conv = Result_DelayedPaymentOutputDescriptorDecodeErrorZ.constr_from_ptr(ret);
288                 return ret_hu_conv;
289         }
290
291 }