[Java] Update auto-generated bindings to 0.0.117
[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 details of the HTLC as it appears in the commitment transaction.
91          */
92         public HTLCOutputInCommitment get_htlc() {
93                 long ret = bindings.HTLCDescriptor_get_htlc(this.ptr);
94                 Reference.reachabilityFence(this);
95                 if (ret >= 0 && ret <= 4096) { return null; }
96                 org.ldk.structs.HTLCOutputInCommitment ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.HTLCOutputInCommitment(null, ret); }
97                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
98                 return ret_hu_conv;
99         }
100
101         /**
102          * The details of the HTLC as it appears in the commitment transaction.
103          */
104         public void set_htlc(org.ldk.structs.HTLCOutputInCommitment val) {
105                 bindings.HTLCDescriptor_set_htlc(this.ptr, val == null ? 0 : val.ptr);
106                 Reference.reachabilityFence(this);
107                 Reference.reachabilityFence(val);
108                 if (this != null) { this.ptrs_to.add(val); };
109         }
110
111         /**
112          * The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be
113          * taken.
114          */
115         public Option_ThirtyTwoBytesZ get_preimage() {
116                 long ret = bindings.HTLCDescriptor_get_preimage(this.ptr);
117                 Reference.reachabilityFence(this);
118                 if (ret >= 0 && ret <= 4096) { return null; }
119                 org.ldk.structs.Option_ThirtyTwoBytesZ ret_hu_conv = org.ldk.structs.Option_ThirtyTwoBytesZ.constr_from_ptr(ret);
120                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
121                 return ret_hu_conv;
122         }
123
124         /**
125          * The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be
126          * taken.
127          */
128         public void set_preimage(org.ldk.structs.Option_ThirtyTwoBytesZ val) {
129                 bindings.HTLCDescriptor_set_preimage(this.ptr, val.ptr);
130                 Reference.reachabilityFence(this);
131                 Reference.reachabilityFence(val);
132                 if (this != null) { this.ptrs_to.add(val); };
133         }
134
135         /**
136          * The counterparty's signature required to spend the HTLC output.
137          */
138         public byte[] get_counterparty_sig() {
139                 byte[] ret = bindings.HTLCDescriptor_get_counterparty_sig(this.ptr);
140                 Reference.reachabilityFence(this);
141                 return ret;
142         }
143
144         /**
145          * The counterparty's signature required to spend the HTLC output.
146          */
147         public void set_counterparty_sig(byte[] val) {
148                 bindings.HTLCDescriptor_set_counterparty_sig(this.ptr, InternalUtils.check_arr_len(val, 64));
149                 Reference.reachabilityFence(this);
150                 Reference.reachabilityFence(val);
151         }
152
153         long clone_ptr() {
154                 long ret = bindings.HTLCDescriptor_clone_ptr(this.ptr);
155                 Reference.reachabilityFence(this);
156                 return ret;
157         }
158
159         /**
160          * Creates a copy of the HTLCDescriptor
161          */
162         public HTLCDescriptor clone() {
163                 long ret = bindings.HTLCDescriptor_clone(this.ptr);
164                 Reference.reachabilityFence(this);
165                 if (ret >= 0 && ret <= 4096) { return null; }
166                 org.ldk.structs.HTLCDescriptor ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.HTLCDescriptor(null, ret); }
167                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
168                 return ret_hu_conv;
169         }
170
171         /**
172          * Checks if two HTLCDescriptors contain equal inner contents.
173          * This ignores pointers and is_owned flags and looks at the values in fields.
174          * Two objects with NULL inner values will be considered "equal" here.
175          */
176         public boolean eq(org.ldk.structs.HTLCDescriptor b) {
177                 boolean ret = bindings.HTLCDescriptor_eq(this.ptr, b == null ? 0 : b.ptr);
178                 Reference.reachabilityFence(this);
179                 Reference.reachabilityFence(b);
180                 if (this != null) { this.ptrs_to.add(b); };
181                 return ret;
182         }
183
184         @Override public boolean equals(Object o) {
185                 if (!(o instanceof HTLCDescriptor)) return false;
186                 return this.eq((HTLCDescriptor)o);
187         }
188         /**
189          * Serialize the HTLCDescriptor object into a byte array which can be read by HTLCDescriptor_read
190          */
191         public byte[] write() {
192                 byte[] ret = bindings.HTLCDescriptor_write(this.ptr);
193                 Reference.reachabilityFence(this);
194                 return ret;
195         }
196
197         /**
198          * Read a HTLCDescriptor from a byte array, created by HTLCDescriptor_write
199          */
200         public static Result_HTLCDescriptorDecodeErrorZ read(byte[] ser) {
201                 long ret = bindings.HTLCDescriptor_read(ser);
202                 Reference.reachabilityFence(ser);
203                 if (ret >= 0 && ret <= 4096) { return null; }
204                 Result_HTLCDescriptorDecodeErrorZ ret_hu_conv = Result_HTLCDescriptorDecodeErrorZ.constr_from_ptr(ret);
205                 return ret_hu_conv;
206         }
207
208         /**
209          * Returns the outpoint of the HTLC output in the commitment transaction. This is the outpoint
210          * being spent by the HTLC input in the HTLC transaction.
211          */
212         public OutPoint outpoint() {
213                 long ret = bindings.HTLCDescriptor_outpoint(this.ptr);
214                 Reference.reachabilityFence(this);
215                 if (ret >= 0 && ret <= 4096) { return null; }
216                 org.ldk.structs.OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OutPoint(null, ret); }
217                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
218                 return ret_hu_conv;
219         }
220
221         /**
222          * Returns the UTXO to be spent by the HTLC input, which can be obtained via
223          * [`Self::unsigned_tx_input`].
224          */
225         public TxOut previous_utxo() {
226                 long ret = bindings.HTLCDescriptor_previous_utxo(this.ptr);
227                 Reference.reachabilityFence(this);
228                 if (ret >= 0 && ret <= 4096) { return null; }
229                 TxOut ret_conv = new TxOut(null, ret);
230                 return ret_conv;
231         }
232
233         /**
234          * Returns the unsigned transaction input spending the HTLC output in the commitment
235          * transaction.
236          */
237         public TxIn unsigned_tx_input() {
238                 long ret = bindings.HTLCDescriptor_unsigned_tx_input(this.ptr);
239                 Reference.reachabilityFence(this);
240                 if (ret >= 0 && ret <= 4096) { return null; }
241                 TxIn ret_conv = new TxIn(null, ret);
242                 return ret_conv;
243         }
244
245         /**
246          * Returns the delayed output created as a result of spending the HTLC output in the commitment
247          * transaction.
248          */
249         public TxOut tx_output() {
250                 long ret = bindings.HTLCDescriptor_tx_output(this.ptr);
251                 Reference.reachabilityFence(this);
252                 if (ret >= 0 && ret <= 4096) { return null; }
253                 TxOut ret_conv = new TxOut(null, ret);
254                 return ret_conv;
255         }
256
257         /**
258          * Returns the witness script of the HTLC output in the commitment transaction.
259          */
260         public byte[] witness_script() {
261                 byte[] ret = bindings.HTLCDescriptor_witness_script(this.ptr);
262                 Reference.reachabilityFence(this);
263                 return ret;
264         }
265
266         /**
267          * Returns the fully signed witness required to spend the HTLC output in the commitment
268          * transaction.
269          */
270         public byte[] tx_input_witness(byte[] signature, byte[] witness_script) {
271                 byte[] ret = bindings.HTLCDescriptor_tx_input_witness(this.ptr, InternalUtils.check_arr_len(signature, 64), witness_script);
272                 Reference.reachabilityFence(this);
273                 Reference.reachabilityFence(signature);
274                 Reference.reachabilityFence(witness_script);
275                 return ret;
276         }
277
278         /**
279          * Derives the channel signer required to sign the HTLC input.
280          */
281         public WriteableEcdsaChannelSigner derive_channel_signer(org.ldk.structs.SignerProvider signer_provider) {
282                 long ret = bindings.HTLCDescriptor_derive_channel_signer(this.ptr, signer_provider.ptr);
283                 Reference.reachabilityFence(this);
284                 Reference.reachabilityFence(signer_provider);
285                 if (ret >= 0 && ret <= 4096) { return null; }
286                 WriteableEcdsaChannelSigner ret_hu_conv = new WriteableEcdsaChannelSigner(null, ret);
287                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
288                 if (this != null) { this.ptrs_to.add(signer_provider); };
289                 return ret_hu_conv;
290         }
291
292 }