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