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