[Java] Update auto-generated Java bindings for 0.0.116
[ldk-java] / src / main / java / org / ldk / structs / InMemorySigner.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 simple implementation of [`WriteableEcdsaChannelSigner`] that just keeps the private keys in memory.
13  * 
14  * This implementation performs no policy checks and is insufficient by itself as
15  * a secure external signer.
16  */
17 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
18 public class InMemorySigner extends CommonBase {
19         InMemorySigner(Object _dummy, long ptr) { super(ptr); }
20         @Override @SuppressWarnings("deprecation")
21         protected void finalize() throws Throwable {
22                 super.finalize();
23                 if (ptr != 0) { bindings.InMemorySigner_free(ptr); }
24         }
25
26         /**
27          * Holder secret key in the 2-of-2 multisig script of a channel. This key also backs the
28          * holder's anchor output in a commitment transaction, if one is present.
29          */
30         public byte[] get_funding_key() {
31                 byte[] ret = bindings.InMemorySigner_get_funding_key(this.ptr);
32                 Reference.reachabilityFence(this);
33                 return ret;
34         }
35
36         /**
37          * Holder secret key in the 2-of-2 multisig script of a channel. This key also backs the
38          * holder's anchor output in a commitment transaction, if one is present.
39          */
40         public void set_funding_key(byte[] val) {
41                 bindings.InMemorySigner_set_funding_key(this.ptr, InternalUtils.check_arr_len(val, 32));
42                 Reference.reachabilityFence(this);
43                 Reference.reachabilityFence(val);
44         }
45
46         /**
47          * Holder secret key for blinded revocation pubkey.
48          */
49         public byte[] get_revocation_base_key() {
50                 byte[] ret = bindings.InMemorySigner_get_revocation_base_key(this.ptr);
51                 Reference.reachabilityFence(this);
52                 return ret;
53         }
54
55         /**
56          * Holder secret key for blinded revocation pubkey.
57          */
58         public void set_revocation_base_key(byte[] val) {
59                 bindings.InMemorySigner_set_revocation_base_key(this.ptr, InternalUtils.check_arr_len(val, 32));
60                 Reference.reachabilityFence(this);
61                 Reference.reachabilityFence(val);
62         }
63
64         /**
65          * Holder secret key used for our balance in counterparty-broadcasted commitment transactions.
66          */
67         public byte[] get_payment_key() {
68                 byte[] ret = bindings.InMemorySigner_get_payment_key(this.ptr);
69                 Reference.reachabilityFence(this);
70                 return ret;
71         }
72
73         /**
74          * Holder secret key used for our balance in counterparty-broadcasted commitment transactions.
75          */
76         public void set_payment_key(byte[] val) {
77                 bindings.InMemorySigner_set_payment_key(this.ptr, InternalUtils.check_arr_len(val, 32));
78                 Reference.reachabilityFence(this);
79                 Reference.reachabilityFence(val);
80         }
81
82         /**
83          * Holder secret key used in an HTLC transaction.
84          */
85         public byte[] get_delayed_payment_base_key() {
86                 byte[] ret = bindings.InMemorySigner_get_delayed_payment_base_key(this.ptr);
87                 Reference.reachabilityFence(this);
88                 return ret;
89         }
90
91         /**
92          * Holder secret key used in an HTLC transaction.
93          */
94         public void set_delayed_payment_base_key(byte[] val) {
95                 bindings.InMemorySigner_set_delayed_payment_base_key(this.ptr, InternalUtils.check_arr_len(val, 32));
96                 Reference.reachabilityFence(this);
97                 Reference.reachabilityFence(val);
98         }
99
100         /**
101          * Holder HTLC secret key used in commitment transaction HTLC outputs.
102          */
103         public byte[] get_htlc_base_key() {
104                 byte[] ret = bindings.InMemorySigner_get_htlc_base_key(this.ptr);
105                 Reference.reachabilityFence(this);
106                 return ret;
107         }
108
109         /**
110          * Holder HTLC secret key used in commitment transaction HTLC outputs.
111          */
112         public void set_htlc_base_key(byte[] val) {
113                 bindings.InMemorySigner_set_htlc_base_key(this.ptr, InternalUtils.check_arr_len(val, 32));
114                 Reference.reachabilityFence(this);
115                 Reference.reachabilityFence(val);
116         }
117
118         /**
119          * Commitment seed.
120          */
121         public byte[] get_commitment_seed() {
122                 byte[] ret = bindings.InMemorySigner_get_commitment_seed(this.ptr);
123                 Reference.reachabilityFence(this);
124                 return ret;
125         }
126
127         /**
128          * Commitment seed.
129          */
130         public void set_commitment_seed(byte[] val) {
131                 bindings.InMemorySigner_set_commitment_seed(this.ptr, InternalUtils.check_arr_len(val, 32));
132                 Reference.reachabilityFence(this);
133                 Reference.reachabilityFence(val);
134         }
135
136         long clone_ptr() {
137                 long ret = bindings.InMemorySigner_clone_ptr(this.ptr);
138                 Reference.reachabilityFence(this);
139                 return ret;
140         }
141
142         /**
143          * Creates a copy of the InMemorySigner
144          */
145         public InMemorySigner clone() {
146                 long ret = bindings.InMemorySigner_clone(this.ptr);
147                 Reference.reachabilityFence(this);
148                 if (ret >= 0 && ret <= 4096) { return null; }
149                 org.ldk.structs.InMemorySigner ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InMemorySigner(null, ret); }
150                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
151                 return ret_hu_conv;
152         }
153
154         /**
155          * Creates a new [`InMemorySigner`].
156          */
157         public static InMemorySigner of(byte[] funding_key, byte[] revocation_base_key, byte[] payment_key, byte[] delayed_payment_base_key, byte[] htlc_base_key, byte[] commitment_seed, long channel_value_satoshis, byte[] channel_keys_id, byte[] rand_bytes_unique_start) {
158                 long ret = bindings.InMemorySigner_new(InternalUtils.check_arr_len(funding_key, 32), InternalUtils.check_arr_len(revocation_base_key, 32), InternalUtils.check_arr_len(payment_key, 32), InternalUtils.check_arr_len(delayed_payment_base_key, 32), InternalUtils.check_arr_len(htlc_base_key, 32), InternalUtils.check_arr_len(commitment_seed, 32), channel_value_satoshis, InternalUtils.check_arr_len(channel_keys_id, 32), InternalUtils.check_arr_len(rand_bytes_unique_start, 32));
159                 Reference.reachabilityFence(funding_key);
160                 Reference.reachabilityFence(revocation_base_key);
161                 Reference.reachabilityFence(payment_key);
162                 Reference.reachabilityFence(delayed_payment_base_key);
163                 Reference.reachabilityFence(htlc_base_key);
164                 Reference.reachabilityFence(commitment_seed);
165                 Reference.reachabilityFence(channel_value_satoshis);
166                 Reference.reachabilityFence(channel_keys_id);
167                 Reference.reachabilityFence(rand_bytes_unique_start);
168                 if (ret >= 0 && ret <= 4096) { return null; }
169                 org.ldk.structs.InMemorySigner ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InMemorySigner(null, ret); }
170                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
171                 return ret_hu_conv;
172         }
173
174         /**
175          * Returns the counterparty's pubkeys.
176          * 
177          * Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before.
178          */
179         public ChannelPublicKeys counterparty_pubkeys() {
180                 long ret = bindings.InMemorySigner_counterparty_pubkeys(this.ptr);
181                 Reference.reachabilityFence(this);
182                 if (ret >= 0 && ret <= 4096) { return null; }
183                 org.ldk.structs.ChannelPublicKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelPublicKeys(null, ret); }
184                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
185                 return ret_hu_conv;
186         }
187
188         /**
189          * Returns the `contest_delay` value specified by our counterparty and applied on holder-broadcastable
190          * transactions, i.e., the amount of time that we have to wait to recover our funds if we
191          * broadcast a transaction.
192          * 
193          * Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before.
194          */
195         public short counterparty_selected_contest_delay() {
196                 short ret = bindings.InMemorySigner_counterparty_selected_contest_delay(this.ptr);
197                 Reference.reachabilityFence(this);
198                 return ret;
199         }
200
201         /**
202          * Returns the `contest_delay` value specified by us and applied on transactions broadcastable
203          * by our counterparty, i.e., the amount of time that they have to wait to recover their funds
204          * if they broadcast a transaction.
205          * 
206          * Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before.
207          */
208         public short holder_selected_contest_delay() {
209                 short ret = bindings.InMemorySigner_holder_selected_contest_delay(this.ptr);
210                 Reference.reachabilityFence(this);
211                 return ret;
212         }
213
214         /**
215          * Returns whether the holder is the initiator.
216          * 
217          * Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before.
218          */
219         public boolean is_outbound() {
220                 boolean ret = bindings.InMemorySigner_is_outbound(this.ptr);
221                 Reference.reachabilityFence(this);
222                 return ret;
223         }
224
225         /**
226          * Funding outpoint
227          * 
228          * Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before.
229          */
230         public OutPoint funding_outpoint() {
231                 long ret = bindings.InMemorySigner_funding_outpoint(this.ptr);
232                 Reference.reachabilityFence(this);
233                 if (ret >= 0 && ret <= 4096) { return null; }
234                 org.ldk.structs.OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OutPoint(null, ret); }
235                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
236                 return ret_hu_conv;
237         }
238
239         /**
240          * Returns a [`ChannelTransactionParameters`] for this channel, to be used when verifying or
241          * building transactions.
242          * 
243          * Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before.
244          */
245         public ChannelTransactionParameters get_channel_parameters() {
246                 long ret = bindings.InMemorySigner_get_channel_parameters(this.ptr);
247                 Reference.reachabilityFence(this);
248                 if (ret >= 0 && ret <= 4096) { return null; }
249                 org.ldk.structs.ChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTransactionParameters(null, ret); }
250                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
251                 return ret_hu_conv;
252         }
253
254         /**
255          * Returns the channel type features of the channel parameters. Should be helpful for
256          * determining a channel's category, i. e. legacy/anchors/taproot/etc.
257          * 
258          * Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before.
259          */
260         public ChannelTypeFeatures channel_type_features() {
261                 long ret = bindings.InMemorySigner_channel_type_features(this.ptr);
262                 Reference.reachabilityFence(this);
263                 if (ret >= 0 && ret <= 4096) { return null; }
264                 org.ldk.structs.ChannelTypeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTypeFeatures(null, ret); }
265                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
266                 return ret_hu_conv;
267         }
268
269         /**
270          * Sign the single input of `spend_tx` at index `input_idx`, which spends the output described
271          * by `descriptor`, returning the witness stack for the input.
272          * 
273          * Returns an error if the input at `input_idx` does not exist, has a non-empty `script_sig`,
274          * is not spending the outpoint described by [`descriptor.outpoint`],
275          * or if an output descriptor `script_pubkey` does not match the one we can spend.
276          * 
277          * [`descriptor.outpoint`]: StaticPaymentOutputDescriptor::outpoint
278          */
279         public Result_CVec_CVec_u8ZZNoneZ sign_counterparty_payment_input(byte[] spend_tx, long input_idx, org.ldk.structs.StaticPaymentOutputDescriptor descriptor) {
280                 long ret = bindings.InMemorySigner_sign_counterparty_payment_input(this.ptr, spend_tx, input_idx, descriptor == null ? 0 : descriptor.ptr);
281                 Reference.reachabilityFence(this);
282                 Reference.reachabilityFence(spend_tx);
283                 Reference.reachabilityFence(input_idx);
284                 Reference.reachabilityFence(descriptor);
285                 if (ret >= 0 && ret <= 4096) { return null; }
286                 Result_CVec_CVec_u8ZZNoneZ ret_hu_conv = Result_CVec_CVec_u8ZZNoneZ.constr_from_ptr(ret);
287                 if (this != null) { this.ptrs_to.add(descriptor); };
288                 return ret_hu_conv;
289         }
290
291         /**
292          * Sign the single input of `spend_tx` at index `input_idx` which spends the output
293          * described by `descriptor`, returning the witness stack for the input.
294          * 
295          * Returns an error if the input at `input_idx` does not exist, has a non-empty `script_sig`,
296          * is not spending the outpoint described by [`descriptor.outpoint`], does not have a
297          * sequence set to [`descriptor.to_self_delay`], or if an output descriptor
298          * `script_pubkey` does not match the one we can spend.
299          * 
300          * [`descriptor.outpoint`]: DelayedPaymentOutputDescriptor::outpoint
301          * [`descriptor.to_self_delay`]: DelayedPaymentOutputDescriptor::to_self_delay
302          */
303         public Result_CVec_CVec_u8ZZNoneZ sign_dynamic_p2wsh_input(byte[] spend_tx, long input_idx, org.ldk.structs.DelayedPaymentOutputDescriptor descriptor) {
304                 long ret = bindings.InMemorySigner_sign_dynamic_p2wsh_input(this.ptr, spend_tx, input_idx, descriptor == null ? 0 : descriptor.ptr);
305                 Reference.reachabilityFence(this);
306                 Reference.reachabilityFence(spend_tx);
307                 Reference.reachabilityFence(input_idx);
308                 Reference.reachabilityFence(descriptor);
309                 if (ret >= 0 && ret <= 4096) { return null; }
310                 Result_CVec_CVec_u8ZZNoneZ ret_hu_conv = Result_CVec_CVec_u8ZZNoneZ.constr_from_ptr(ret);
311                 if (this != null) { this.ptrs_to.add(descriptor); };
312                 return ret_hu_conv;
313         }
314
315         /**
316          * Constructs a new EntropySource which calls the relevant methods on this_arg.
317          * This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is
318          */
319         public EntropySource as_EntropySource() {
320                 long ret = bindings.InMemorySigner_as_EntropySource(this.ptr);
321                 Reference.reachabilityFence(this);
322                 if (ret >= 0 && ret <= 4096) { return null; }
323                 EntropySource ret_hu_conv = new EntropySource(null, ret);
324                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
325                 return ret_hu_conv;
326         }
327
328         /**
329          * Constructs a new ChannelSigner which calls the relevant methods on this_arg.
330          * This copies the `inner` pointer in this_arg and thus the returned ChannelSigner must be freed before this_arg is
331          */
332         public ChannelSigner as_ChannelSigner() {
333                 long ret = bindings.InMemorySigner_as_ChannelSigner(this.ptr);
334                 Reference.reachabilityFence(this);
335                 if (ret >= 0 && ret <= 4096) { return null; }
336                 ChannelSigner ret_hu_conv = new ChannelSigner(null, ret);
337                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
338                 return ret_hu_conv;
339         }
340
341         /**
342          * Constructs a new EcdsaChannelSigner which calls the relevant methods on this_arg.
343          * This copies the `inner` pointer in this_arg and thus the returned EcdsaChannelSigner must be freed before this_arg is
344          */
345         public EcdsaChannelSigner as_EcdsaChannelSigner() {
346                 long ret = bindings.InMemorySigner_as_EcdsaChannelSigner(this.ptr);
347                 Reference.reachabilityFence(this);
348                 if (ret >= 0 && ret <= 4096) { return null; }
349                 EcdsaChannelSigner ret_hu_conv = new EcdsaChannelSigner(null, ret);
350                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
351                 return ret_hu_conv;
352         }
353
354         /**
355          * Constructs a new WriteableEcdsaChannelSigner which calls the relevant methods on this_arg.
356          * This copies the `inner` pointer in this_arg and thus the returned WriteableEcdsaChannelSigner must be freed before this_arg is
357          */
358         public WriteableEcdsaChannelSigner as_WriteableEcdsaChannelSigner() {
359                 long ret = bindings.InMemorySigner_as_WriteableEcdsaChannelSigner(this.ptr);
360                 Reference.reachabilityFence(this);
361                 if (ret >= 0 && ret <= 4096) { return null; }
362                 WriteableEcdsaChannelSigner ret_hu_conv = new WriteableEcdsaChannelSigner(null, ret);
363                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
364                 return ret_hu_conv;
365         }
366
367         /**
368          * Serialize the InMemorySigner object into a byte array which can be read by InMemorySigner_read
369          */
370         public byte[] write() {
371                 byte[] ret = bindings.InMemorySigner_write(this.ptr);
372                 Reference.reachabilityFence(this);
373                 return ret;
374         }
375
376         /**
377          * Read a InMemorySigner from a byte array, created by InMemorySigner_write
378          */
379         public static Result_InMemorySignerDecodeErrorZ read(byte[] ser, org.ldk.structs.EntropySource arg) {
380                 long ret = bindings.InMemorySigner_read(ser, arg.ptr);
381                 Reference.reachabilityFence(ser);
382                 Reference.reachabilityFence(arg);
383                 if (ret >= 0 && ret <= 4096) { return null; }
384                 Result_InMemorySignerDecodeErrorZ ret_hu_conv = Result_InMemorySignerDecodeErrorZ.constr_from_ptr(ret);
385                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(arg); };
386                 return ret_hu_conv;
387         }
388
389 }