[Java] Update auto-generated bindings to 0.0.105.0
[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 Sign 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          * Private key of anchor tx
28          */
29         public byte[] get_funding_key() {
30                 byte[] ret = bindings.InMemorySigner_get_funding_key(this.ptr);
31                 Reference.reachabilityFence(this);
32                 return ret;
33         }
34
35         /**
36          * Private key of anchor tx
37          */
38         public void set_funding_key(byte[] val) {
39                 bindings.InMemorySigner_set_funding_key(this.ptr, InternalUtils.check_arr_len(val, 32));
40                 Reference.reachabilityFence(this);
41                 Reference.reachabilityFence(val);
42         }
43
44         /**
45          * Holder secret key for blinded revocation pubkey
46          */
47         public byte[] get_revocation_base_key() {
48                 byte[] ret = bindings.InMemorySigner_get_revocation_base_key(this.ptr);
49                 Reference.reachabilityFence(this);
50                 return ret;
51         }
52
53         /**
54          * Holder secret key for blinded revocation pubkey
55          */
56         public void set_revocation_base_key(byte[] val) {
57                 bindings.InMemorySigner_set_revocation_base_key(this.ptr, InternalUtils.check_arr_len(val, 32));
58                 Reference.reachabilityFence(this);
59                 Reference.reachabilityFence(val);
60         }
61
62         /**
63          * Holder secret key used for our balance in counterparty-broadcasted commitment transactions
64          */
65         public byte[] get_payment_key() {
66                 byte[] ret = bindings.InMemorySigner_get_payment_key(this.ptr);
67                 Reference.reachabilityFence(this);
68                 return ret;
69         }
70
71         /**
72          * Holder secret key used for our balance in counterparty-broadcasted commitment transactions
73          */
74         public void set_payment_key(byte[] val) {
75                 bindings.InMemorySigner_set_payment_key(this.ptr, InternalUtils.check_arr_len(val, 32));
76                 Reference.reachabilityFence(this);
77                 Reference.reachabilityFence(val);
78         }
79
80         /**
81          * Holder secret key used in HTLC tx
82          */
83         public byte[] get_delayed_payment_base_key() {
84                 byte[] ret = bindings.InMemorySigner_get_delayed_payment_base_key(this.ptr);
85                 Reference.reachabilityFence(this);
86                 return ret;
87         }
88
89         /**
90          * Holder secret key used in HTLC tx
91          */
92         public void set_delayed_payment_base_key(byte[] val) {
93                 bindings.InMemorySigner_set_delayed_payment_base_key(this.ptr, InternalUtils.check_arr_len(val, 32));
94                 Reference.reachabilityFence(this);
95                 Reference.reachabilityFence(val);
96         }
97
98         /**
99          * Holder htlc secret key used in commitment tx htlc outputs
100          */
101         public byte[] get_htlc_base_key() {
102                 byte[] ret = bindings.InMemorySigner_get_htlc_base_key(this.ptr);
103                 Reference.reachabilityFence(this);
104                 return ret;
105         }
106
107         /**
108          * Holder htlc secret key used in commitment tx htlc outputs
109          */
110         public void set_htlc_base_key(byte[] val) {
111                 bindings.InMemorySigner_set_htlc_base_key(this.ptr, InternalUtils.check_arr_len(val, 32));
112                 Reference.reachabilityFence(this);
113                 Reference.reachabilityFence(val);
114         }
115
116         /**
117          * Commitment seed
118          */
119         public byte[] get_commitment_seed() {
120                 byte[] ret = bindings.InMemorySigner_get_commitment_seed(this.ptr);
121                 Reference.reachabilityFence(this);
122                 return ret;
123         }
124
125         /**
126          * Commitment seed
127          */
128         public void set_commitment_seed(byte[] val) {
129                 bindings.InMemorySigner_set_commitment_seed(this.ptr, InternalUtils.check_arr_len(val, 32));
130                 Reference.reachabilityFence(this);
131                 Reference.reachabilityFence(val);
132         }
133
134         long clone_ptr() {
135                 long ret = bindings.InMemorySigner_clone_ptr(this.ptr);
136                 Reference.reachabilityFence(this);
137                 return ret;
138         }
139
140         /**
141          * Creates a copy of the InMemorySigner
142          */
143         public InMemorySigner clone() {
144                 long ret = bindings.InMemorySigner_clone(this.ptr);
145                 Reference.reachabilityFence(this);
146                 if (ret >= 0 && ret <= 4096) { return null; }
147                 InMemorySigner ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InMemorySigner(null, ret); }
148                 ret_hu_conv.ptrs_to.add(this);
149                 return ret_hu_conv;
150         }
151
152         /**
153          * Create a new InMemorySigner
154          */
155         public static InMemorySigner of(byte[] node_secret, 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) {
156                 long ret = bindings.InMemorySigner_new(InternalUtils.check_arr_len(node_secret, 32), 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));
157                 Reference.reachabilityFence(node_secret);
158                 Reference.reachabilityFence(funding_key);
159                 Reference.reachabilityFence(revocation_base_key);
160                 Reference.reachabilityFence(payment_key);
161                 Reference.reachabilityFence(delayed_payment_base_key);
162                 Reference.reachabilityFence(htlc_base_key);
163                 Reference.reachabilityFence(commitment_seed);
164                 Reference.reachabilityFence(channel_value_satoshis);
165                 Reference.reachabilityFence(channel_keys_id);
166                 if (ret >= 0 && ret <= 4096) { return null; }
167                 InMemorySigner ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InMemorySigner(null, ret); }
168                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
169                 return ret_hu_conv;
170         }
171
172         /**
173          * Counterparty pubkeys.
174          * Will panic if ready_channel wasn't called.
175          */
176         public ChannelPublicKeys counterparty_pubkeys() {
177                 long ret = bindings.InMemorySigner_counterparty_pubkeys(this.ptr);
178                 Reference.reachabilityFence(this);
179                 if (ret >= 0 && ret <= 4096) { return null; }
180                 ChannelPublicKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelPublicKeys(null, ret); }
181                 ret_hu_conv.ptrs_to.add(this);
182                 return ret_hu_conv;
183         }
184
185         /**
186          * The contest_delay value specified by our counterparty and applied on holder-broadcastable
187          * transactions, ie the amount of time that we have to wait to recover our funds if we
188          * broadcast a transaction.
189          * Will panic if ready_channel wasn't called.
190          */
191         public short counterparty_selected_contest_delay() {
192                 short ret = bindings.InMemorySigner_counterparty_selected_contest_delay(this.ptr);
193                 Reference.reachabilityFence(this);
194                 return ret;
195         }
196
197         /**
198          * The contest_delay value specified by us and applied on transactions broadcastable
199          * by our counterparty, ie the amount of time that they have to wait to recover their funds
200          * if they broadcast a transaction.
201          * Will panic if ready_channel wasn't called.
202          */
203         public short holder_selected_contest_delay() {
204                 short ret = bindings.InMemorySigner_holder_selected_contest_delay(this.ptr);
205                 Reference.reachabilityFence(this);
206                 return ret;
207         }
208
209         /**
210          * Whether the holder is the initiator
211          * Will panic if ready_channel wasn't called.
212          */
213         public boolean is_outbound() {
214                 boolean ret = bindings.InMemorySigner_is_outbound(this.ptr);
215                 Reference.reachabilityFence(this);
216                 return ret;
217         }
218
219         /**
220          * Funding outpoint
221          * Will panic if ready_channel wasn't called.
222          */
223         public OutPoint funding_outpoint() {
224                 long ret = bindings.InMemorySigner_funding_outpoint(this.ptr);
225                 Reference.reachabilityFence(this);
226                 if (ret >= 0 && ret <= 4096) { return null; }
227                 OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new OutPoint(null, ret); }
228                 ret_hu_conv.ptrs_to.add(this);
229                 return ret_hu_conv;
230         }
231
232         /**
233          * Obtain a ChannelTransactionParameters for this channel, to be used when verifying or
234          * building transactions.
235          * 
236          * Will panic if ready_channel wasn't called.
237          */
238         public ChannelTransactionParameters get_channel_parameters() {
239                 long ret = bindings.InMemorySigner_get_channel_parameters(this.ptr);
240                 Reference.reachabilityFence(this);
241                 if (ret >= 0 && ret <= 4096) { return null; }
242                 ChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelTransactionParameters(null, ret); }
243                 ret_hu_conv.ptrs_to.add(this);
244                 return ret_hu_conv;
245         }
246
247         /**
248          * Whether anchors should be used.
249          * Will panic if ready_channel wasn't called.
250          */
251         public boolean opt_anchors() {
252                 boolean ret = bindings.InMemorySigner_opt_anchors(this.ptr);
253                 Reference.reachabilityFence(this);
254                 return ret;
255         }
256
257         /**
258          * Sign the single input of spend_tx at index `input_idx` which spends the output
259          * described by descriptor, returning the witness stack for the input.
260          * 
261          * Returns an Err if the input at input_idx does not exist, has a non-empty script_sig,
262          * is not spending the outpoint described by `descriptor.outpoint`,
263          * or if an output descriptor script_pubkey does not match the one we can spend.
264          */
265         public Result_CVec_CVec_u8ZZNoneZ sign_counterparty_payment_input(byte[] spend_tx, long input_idx, StaticPaymentOutputDescriptor descriptor) {
266                 long ret = bindings.InMemorySigner_sign_counterparty_payment_input(this.ptr, spend_tx, input_idx, descriptor == null ? 0 : descriptor.ptr & ~1);
267                 Reference.reachabilityFence(this);
268                 Reference.reachabilityFence(spend_tx);
269                 Reference.reachabilityFence(input_idx);
270                 Reference.reachabilityFence(descriptor);
271                 if (ret >= 0 && ret <= 4096) { return null; }
272                 Result_CVec_CVec_u8ZZNoneZ ret_hu_conv = Result_CVec_CVec_u8ZZNoneZ.constr_from_ptr(ret);
273                 this.ptrs_to.add(descriptor);
274                 return ret_hu_conv;
275         }
276
277         /**
278          * Sign the single input of spend_tx at index `input_idx` which spends the output
279          * described by descriptor, returning the witness stack for the input.
280          * 
281          * Returns an Err if the input at input_idx does not exist, has a non-empty script_sig,
282          * is not spending the outpoint described by `descriptor.outpoint`, does not have a
283          * sequence set to `descriptor.to_self_delay`, or if an output descriptor
284          * script_pubkey does not match the one we can spend.
285          */
286         public Result_CVec_CVec_u8ZZNoneZ sign_dynamic_p2wsh_input(byte[] spend_tx, long input_idx, DelayedPaymentOutputDescriptor descriptor) {
287                 long ret = bindings.InMemorySigner_sign_dynamic_p2wsh_input(this.ptr, spend_tx, input_idx, descriptor == null ? 0 : descriptor.ptr & ~1);
288                 Reference.reachabilityFence(this);
289                 Reference.reachabilityFence(spend_tx);
290                 Reference.reachabilityFence(input_idx);
291                 Reference.reachabilityFence(descriptor);
292                 if (ret >= 0 && ret <= 4096) { return null; }
293                 Result_CVec_CVec_u8ZZNoneZ ret_hu_conv = Result_CVec_CVec_u8ZZNoneZ.constr_from_ptr(ret);
294                 this.ptrs_to.add(descriptor);
295                 return ret_hu_conv;
296         }
297
298         /**
299          * Constructs a new BaseSign which calls the relevant methods on this_arg.
300          * This copies the `inner` pointer in this_arg and thus the returned BaseSign must be freed before this_arg is
301          */
302         public BaseSign as_BaseSign() {
303                 long ret = bindings.InMemorySigner_as_BaseSign(this.ptr);
304                 Reference.reachabilityFence(this);
305                 if (ret >= 0 && ret <= 4096) { return null; }
306                 BaseSign ret_hu_conv = new BaseSign(null, ret);
307                 ret_hu_conv.ptrs_to.add(this);
308                 return ret_hu_conv;
309         }
310
311         /**
312          * Constructs a new Sign which calls the relevant methods on this_arg.
313          * This copies the `inner` pointer in this_arg and thus the returned Sign must be freed before this_arg is
314          */
315         public Sign as_Sign() {
316                 long ret = bindings.InMemorySigner_as_Sign(this.ptr);
317                 Reference.reachabilityFence(this);
318                 if (ret >= 0 && ret <= 4096) { return null; }
319                 Sign ret_hu_conv = new Sign(null, ret);
320                 ret_hu_conv.ptrs_to.add(this);
321                 return ret_hu_conv;
322         }
323
324         /**
325          * Serialize the InMemorySigner object into a byte array which can be read by InMemorySigner_read
326          */
327         public byte[] write() {
328                 byte[] ret = bindings.InMemorySigner_write(this.ptr);
329                 Reference.reachabilityFence(this);
330                 return ret;
331         }
332
333         /**
334          * Read a InMemorySigner from a byte array, created by InMemorySigner_write
335          */
336         public static Result_InMemorySignerDecodeErrorZ read(byte[] ser, byte[] arg) {
337                 long ret = bindings.InMemorySigner_read(ser, InternalUtils.check_arr_len(arg, 32));
338                 Reference.reachabilityFence(ser);
339                 Reference.reachabilityFence(arg);
340                 if (ret >= 0 && ret <= 4096) { return null; }
341                 Result_InMemorySignerDecodeErrorZ ret_hu_conv = Result_InMemorySignerDecodeErrorZ.constr_from_ptr(ret);
342                 return ret_hu_conv;
343         }
344
345 }