[Java] Update auto-generated bindings to LDK 0.0.118
[ldk-java] / src / main / java / org / ldk / structs / HTLCDescriptor.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 descriptor used to sign for a commitment transaction's HTLC output.
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class HTLCDescriptor extends CommonBase {
16         HTLCDescriptor(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.HTLCDescriptor_free(ptr); }
21         }
22
23         /**
24          * The parameters required to derive the signer for the HTLC input.
25          */
26         public ChannelDerivationParameters get_channel_derivation_parameters() {
27                 long ret = bindings.HTLCDescriptor_get_channel_derivation_parameters(this.ptr);
28                 Reference.reachabilityFence(this);
29                 if (ret >= 0 && ret <= 4096) { return null; }
30                 org.ldk.structs.ChannelDerivationParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelDerivationParameters(null, ret); }
31                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
32                 return ret_hu_conv;
33         }
34
35         /**
36          * The parameters required to derive the signer for the HTLC input.
37          */
38         public void set_channel_derivation_parameters(org.ldk.structs.ChannelDerivationParameters val) {
39                 bindings.HTLCDescriptor_set_channel_derivation_parameters(this.ptr, val == null ? 0 : val.ptr);
40                 Reference.reachabilityFence(this);
41                 Reference.reachabilityFence(val);
42                 if (this != null) { this.ptrs_to.add(val); };
43         }
44
45         /**
46          * The number of the commitment transaction in which the HTLC output lives.
47          */
48         public long get_per_commitment_number() {
49                 long ret = bindings.HTLCDescriptor_get_per_commitment_number(this.ptr);
50                 Reference.reachabilityFence(this);
51                 return ret;
52         }
53
54         /**
55          * The number of the commitment transaction in which the HTLC output lives.
56          */
57         public void set_per_commitment_number(long val) {
58                 bindings.HTLCDescriptor_set_per_commitment_number(this.ptr, val);
59                 Reference.reachabilityFence(this);
60                 Reference.reachabilityFence(val);
61         }
62
63         /**
64          * The key tweak corresponding to the number of the commitment transaction in which the HTLC
65          * output lives. This tweak is applied to all the basepoints for both parties in the channel to
66          * arrive at unique keys per commitment.
67          * 
68          * See <https://github.com/lightning/bolts/blob/master/03-transactions.md#keys> for more info.
69          */
70         public byte[] get_per_commitment_point() {
71                 byte[] ret = bindings.HTLCDescriptor_get_per_commitment_point(this.ptr);
72                 Reference.reachabilityFence(this);
73                 return ret;
74         }
75
76         /**
77          * The key tweak corresponding to the number of the commitment transaction in which the HTLC
78          * output lives. This tweak is applied to all the basepoints for both parties in the channel to
79          * arrive at unique keys per commitment.
80          * 
81          * See <https://github.com/lightning/bolts/blob/master/03-transactions.md#keys> for more info.
82          */
83         public void set_per_commitment_point(byte[] val) {
84                 bindings.HTLCDescriptor_set_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
85                 Reference.reachabilityFence(this);
86                 Reference.reachabilityFence(val);
87         }
88
89         /**
90          * The feerate to use on the HTLC claiming transaction. This is always `0` for HTLCs
91          * originating from a channel supporting anchor outputs, otherwise it is the channel's
92          * negotiated feerate at the time the commitment transaction was built.
93          */
94         public int get_feerate_per_kw() {
95                 int ret = bindings.HTLCDescriptor_get_feerate_per_kw(this.ptr);
96                 Reference.reachabilityFence(this);
97                 return ret;
98         }
99
100         /**
101          * The feerate to use on the HTLC claiming transaction. This is always `0` for HTLCs
102          * originating from a channel supporting anchor outputs, otherwise it is the channel's
103          * negotiated feerate at the time the commitment transaction was built.
104          */
105         public void set_feerate_per_kw(int val) {
106                 bindings.HTLCDescriptor_set_feerate_per_kw(this.ptr, val);
107                 Reference.reachabilityFence(this);
108                 Reference.reachabilityFence(val);
109         }
110
111         /**
112          * The details of the HTLC as it appears in the commitment transaction.
113          */
114         public HTLCOutputInCommitment get_htlc() {
115                 long ret = bindings.HTLCDescriptor_get_htlc(this.ptr);
116                 Reference.reachabilityFence(this);
117                 if (ret >= 0 && ret <= 4096) { return null; }
118                 org.ldk.structs.HTLCOutputInCommitment ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.HTLCOutputInCommitment(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 details of the HTLC as it appears in the commitment transaction.
125          */
126         public void set_htlc(org.ldk.structs.HTLCOutputInCommitment val) {
127                 bindings.HTLCDescriptor_set_htlc(this.ptr, val == null ? 0 : val.ptr);
128                 Reference.reachabilityFence(this);
129                 Reference.reachabilityFence(val);
130                 if (this != null) { this.ptrs_to.add(val); };
131         }
132
133         /**
134          * The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be
135          * taken.
136          */
137         public Option_ThirtyTwoBytesZ get_preimage() {
138                 long ret = bindings.HTLCDescriptor_get_preimage(this.ptr);
139                 Reference.reachabilityFence(this);
140                 if (ret >= 0 && ret <= 4096) { return null; }
141                 org.ldk.structs.Option_ThirtyTwoBytesZ ret_hu_conv = org.ldk.structs.Option_ThirtyTwoBytesZ.constr_from_ptr(ret);
142                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
143                 return ret_hu_conv;
144         }
145
146         /**
147          * The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be
148          * taken.
149          */
150         public void set_preimage(org.ldk.structs.Option_ThirtyTwoBytesZ val) {
151                 bindings.HTLCDescriptor_set_preimage(this.ptr, val.ptr);
152                 Reference.reachabilityFence(this);
153                 Reference.reachabilityFence(val);
154                 if (this != null) { this.ptrs_to.add(val); };
155         }
156
157         /**
158          * The counterparty's signature required to spend the HTLC output.
159          */
160         public byte[] get_counterparty_sig() {
161                 byte[] ret = bindings.HTLCDescriptor_get_counterparty_sig(this.ptr);
162                 Reference.reachabilityFence(this);
163                 return ret;
164         }
165
166         /**
167          * The counterparty's signature required to spend the HTLC output.
168          */
169         public void set_counterparty_sig(byte[] val) {
170                 bindings.HTLCDescriptor_set_counterparty_sig(this.ptr, InternalUtils.check_arr_len(val, 64));
171                 Reference.reachabilityFence(this);
172                 Reference.reachabilityFence(val);
173         }
174
175         long clone_ptr() {
176                 long ret = bindings.HTLCDescriptor_clone_ptr(this.ptr);
177                 Reference.reachabilityFence(this);
178                 return ret;
179         }
180
181         /**
182          * Creates a copy of the HTLCDescriptor
183          */
184         public HTLCDescriptor clone() {
185                 long ret = bindings.HTLCDescriptor_clone(this.ptr);
186                 Reference.reachabilityFence(this);
187                 if (ret >= 0 && ret <= 4096) { return null; }
188                 org.ldk.structs.HTLCDescriptor ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.HTLCDescriptor(null, ret); }
189                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
190                 return ret_hu_conv;
191         }
192
193         /**
194          * Checks if two HTLCDescriptors contain equal inner contents.
195          * This ignores pointers and is_owned flags and looks at the values in fields.
196          * Two objects with NULL inner values will be considered "equal" here.
197          */
198         public boolean eq(org.ldk.structs.HTLCDescriptor b) {
199                 boolean ret = bindings.HTLCDescriptor_eq(this.ptr, b == null ? 0 : b.ptr);
200                 Reference.reachabilityFence(this);
201                 Reference.reachabilityFence(b);
202                 if (this != null) { this.ptrs_to.add(b); };
203                 return ret;
204         }
205
206         @Override public boolean equals(Object o) {
207                 if (!(o instanceof HTLCDescriptor)) return false;
208                 return this.eq((HTLCDescriptor)o);
209         }
210         /**
211          * Serialize the HTLCDescriptor object into a byte array which can be read by HTLCDescriptor_read
212          */
213         public byte[] write() {
214                 byte[] ret = bindings.HTLCDescriptor_write(this.ptr);
215                 Reference.reachabilityFence(this);
216                 return ret;
217         }
218
219         /**
220          * Read a HTLCDescriptor from a byte array, created by HTLCDescriptor_write
221          */
222         public static Result_HTLCDescriptorDecodeErrorZ read(byte[] ser) {
223                 long ret = bindings.HTLCDescriptor_read(ser);
224                 Reference.reachabilityFence(ser);
225                 if (ret >= 0 && ret <= 4096) { return null; }
226                 Result_HTLCDescriptorDecodeErrorZ ret_hu_conv = Result_HTLCDescriptorDecodeErrorZ.constr_from_ptr(ret);
227                 return ret_hu_conv;
228         }
229
230         /**
231          * Returns the outpoint of the HTLC output in the commitment transaction. This is the outpoint
232          * being spent by the HTLC input in the HTLC transaction.
233          */
234         public OutPoint outpoint() {
235                 long ret = bindings.HTLCDescriptor_outpoint(this.ptr);
236                 Reference.reachabilityFence(this);
237                 if (ret >= 0 && ret <= 4096) { return null; }
238                 org.ldk.structs.OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OutPoint(null, ret); }
239                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
240                 return ret_hu_conv;
241         }
242
243         /**
244          * Returns the UTXO to be spent by the HTLC input, which can be obtained via
245          * [`Self::unsigned_tx_input`].
246          */
247         public TxOut previous_utxo() {
248                 long ret = bindings.HTLCDescriptor_previous_utxo(this.ptr);
249                 Reference.reachabilityFence(this);
250                 if (ret >= 0 && ret <= 4096) { return null; }
251                 TxOut ret_conv = new TxOut(null, ret);
252                 return ret_conv;
253         }
254
255         /**
256          * Returns the unsigned transaction input spending the HTLC output in the commitment
257          * transaction.
258          */
259         public TxIn unsigned_tx_input() {
260                 long ret = bindings.HTLCDescriptor_unsigned_tx_input(this.ptr);
261                 Reference.reachabilityFence(this);
262                 if (ret >= 0 && ret <= 4096) { return null; }
263                 TxIn ret_conv = new TxIn(null, ret);
264                 return ret_conv;
265         }
266
267         /**
268          * Returns the delayed output created as a result of spending the HTLC output in the commitment
269          * transaction.
270          */
271         public TxOut tx_output() {
272                 long ret = bindings.HTLCDescriptor_tx_output(this.ptr);
273                 Reference.reachabilityFence(this);
274                 if (ret >= 0 && ret <= 4096) { return null; }
275                 TxOut ret_conv = new TxOut(null, ret);
276                 return ret_conv;
277         }
278
279         /**
280          * Returns the witness script of the HTLC output in the commitment transaction.
281          */
282         public byte[] witness_script() {
283                 byte[] ret = bindings.HTLCDescriptor_witness_script(this.ptr);
284                 Reference.reachabilityFence(this);
285                 return ret;
286         }
287
288         /**
289          * Returns the fully signed witness required to spend the HTLC output in the commitment
290          * transaction.
291          */
292         public byte[] tx_input_witness(byte[] signature, byte[] witness_script) {
293                 byte[] ret = bindings.HTLCDescriptor_tx_input_witness(this.ptr, InternalUtils.check_arr_len(signature, 64), witness_script);
294                 Reference.reachabilityFence(this);
295                 Reference.reachabilityFence(signature);
296                 Reference.reachabilityFence(witness_script);
297                 return ret;
298         }
299
300         /**
301          * Derives the channel signer required to sign the HTLC input.
302          */
303         public WriteableEcdsaChannelSigner derive_channel_signer(org.ldk.structs.SignerProvider signer_provider) {
304                 long ret = bindings.HTLCDescriptor_derive_channel_signer(this.ptr, signer_provider.ptr);
305                 Reference.reachabilityFence(this);
306                 Reference.reachabilityFence(signer_provider);
307                 if (ret >= 0 && ret <= 4096) { return null; }
308                 WriteableEcdsaChannelSigner ret_hu_conv = new WriteableEcdsaChannelSigner(null, ret);
309                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
310                 if (this != null) { this.ptrs_to.add(signer_provider); };
311                 return ret_hu_conv;
312         }
313
314 }