Update auto-generated bindings
[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 javax.annotation.Nullable;
8
9
10 /**
11  * A simple implementation of Sign that just keeps the private keys in memory.
12  * 
13  * This implementation performs no policy checks and is insufficient by itself as
14  * a secure external signer.
15  */
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class InMemorySigner extends CommonBase {
18         InMemorySigner(Object _dummy, long ptr) { super(ptr); }
19         @Override @SuppressWarnings("deprecation")
20         protected void finalize() throws Throwable {
21                 super.finalize();
22                 if (ptr != 0) { bindings.InMemorySigner_free(ptr); }
23         }
24
25         /**
26          * Private key of anchor tx
27          */
28         public byte[] get_funding_key() {
29                 byte[] ret = bindings.InMemorySigner_get_funding_key(this.ptr);
30                 return ret;
31         }
32
33         /**
34          * Private key of anchor tx
35          */
36         public void set_funding_key(byte[] val) {
37                 bindings.InMemorySigner_set_funding_key(this.ptr, InternalUtils.check_arr_len(val, 32));
38         }
39
40         /**
41          * Holder secret key for blinded revocation pubkey
42          */
43         public byte[] get_revocation_base_key() {
44                 byte[] ret = bindings.InMemorySigner_get_revocation_base_key(this.ptr);
45                 return ret;
46         }
47
48         /**
49          * Holder secret key for blinded revocation pubkey
50          */
51         public void set_revocation_base_key(byte[] val) {
52                 bindings.InMemorySigner_set_revocation_base_key(this.ptr, InternalUtils.check_arr_len(val, 32));
53         }
54
55         /**
56          * Holder secret key used for our balance in counterparty-broadcasted commitment transactions
57          */
58         public byte[] get_payment_key() {
59                 byte[] ret = bindings.InMemorySigner_get_payment_key(this.ptr);
60                 return ret;
61         }
62
63         /**
64          * Holder secret key used for our balance in counterparty-broadcasted commitment transactions
65          */
66         public void set_payment_key(byte[] val) {
67                 bindings.InMemorySigner_set_payment_key(this.ptr, InternalUtils.check_arr_len(val, 32));
68         }
69
70         /**
71          * Holder secret key used in HTLC tx
72          */
73         public byte[] get_delayed_payment_base_key() {
74                 byte[] ret = bindings.InMemorySigner_get_delayed_payment_base_key(this.ptr);
75                 return ret;
76         }
77
78         /**
79          * Holder secret key used in HTLC tx
80          */
81         public void set_delayed_payment_base_key(byte[] val) {
82                 bindings.InMemorySigner_set_delayed_payment_base_key(this.ptr, InternalUtils.check_arr_len(val, 32));
83         }
84
85         /**
86          * Holder htlc secret key used in commitment tx htlc outputs
87          */
88         public byte[] get_htlc_base_key() {
89                 byte[] ret = bindings.InMemorySigner_get_htlc_base_key(this.ptr);
90                 return ret;
91         }
92
93         /**
94          * Holder htlc secret key used in commitment tx htlc outputs
95          */
96         public void set_htlc_base_key(byte[] val) {
97                 bindings.InMemorySigner_set_htlc_base_key(this.ptr, InternalUtils.check_arr_len(val, 32));
98         }
99
100         /**
101          * Commitment seed
102          */
103         public byte[] get_commitment_seed() {
104                 byte[] ret = bindings.InMemorySigner_get_commitment_seed(this.ptr);
105                 return ret;
106         }
107
108         /**
109          * Commitment seed
110          */
111         public void set_commitment_seed(byte[] val) {
112                 bindings.InMemorySigner_set_commitment_seed(this.ptr, InternalUtils.check_arr_len(val, 32));
113         }
114
115         long clone_ptr() {
116                 long ret = bindings.InMemorySigner_clone_ptr(this.ptr);
117                 return ret;
118         }
119
120         /**
121          * Creates a copy of the InMemorySigner
122          */
123         public InMemorySigner clone() {
124                 long ret = bindings.InMemorySigner_clone(this.ptr);
125                 if (ret >= 0 && ret <= 4096) { return null; }
126                 InMemorySigner ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InMemorySigner(null, ret); }
127                 ret_hu_conv.ptrs_to.add(this);
128                 return ret_hu_conv;
129         }
130
131         /**
132          * Create a new InMemorySigner
133          */
134         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) {
135                 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));
136                 if (ret >= 0 && ret <= 4096) { return null; }
137                 InMemorySigner ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InMemorySigner(null, ret); }
138                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
139                 return ret_hu_conv;
140         }
141
142         /**
143          * Counterparty pubkeys.
144          * Will panic if ready_channel wasn't called.
145          */
146         public ChannelPublicKeys counterparty_pubkeys() {
147                 long ret = bindings.InMemorySigner_counterparty_pubkeys(this.ptr);
148                 if (ret >= 0 && ret <= 4096) { return null; }
149                 ChannelPublicKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelPublicKeys(null, ret); }
150                 ret_hu_conv.ptrs_to.add(this);
151                 return ret_hu_conv;
152         }
153
154         /**
155          * The contest_delay value specified by our counterparty and applied on holder-broadcastable
156          * transactions, ie the amount of time that we have to wait to recover our funds if we
157          * broadcast a transaction.
158          * Will panic if ready_channel wasn't called.
159          */
160         public short counterparty_selected_contest_delay() {
161                 short ret = bindings.InMemorySigner_counterparty_selected_contest_delay(this.ptr);
162                 return ret;
163         }
164
165         /**
166          * The contest_delay value specified by us and applied on transactions broadcastable
167          * by our counterparty, ie the amount of time that they have to wait to recover their funds
168          * if they broadcast a transaction.
169          * Will panic if ready_channel wasn't called.
170          */
171         public short holder_selected_contest_delay() {
172                 short ret = bindings.InMemorySigner_holder_selected_contest_delay(this.ptr);
173                 return ret;
174         }
175
176         /**
177          * Whether the holder is the initiator
178          * Will panic if ready_channel wasn't called.
179          */
180         public boolean is_outbound() {
181                 boolean ret = bindings.InMemorySigner_is_outbound(this.ptr);
182                 return ret;
183         }
184
185         /**
186          * Funding outpoint
187          * Will panic if ready_channel wasn't called.
188          */
189         public OutPoint funding_outpoint() {
190                 long ret = bindings.InMemorySigner_funding_outpoint(this.ptr);
191                 if (ret >= 0 && ret <= 4096) { return null; }
192                 OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new OutPoint(null, ret); }
193                 ret_hu_conv.ptrs_to.add(this);
194                 return ret_hu_conv;
195         }
196
197         /**
198          * Obtain a ChannelTransactionParameters for this channel, to be used when verifying or
199          * building transactions.
200          * 
201          * Will panic if ready_channel wasn't called.
202          */
203         public ChannelTransactionParameters get_channel_parameters() {
204                 long ret = bindings.InMemorySigner_get_channel_parameters(this.ptr);
205                 if (ret >= 0 && ret <= 4096) { return null; }
206                 ChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelTransactionParameters(null, ret); }
207                 ret_hu_conv.ptrs_to.add(this);
208                 return ret_hu_conv;
209         }
210
211         /**
212          * Sign the single input of spend_tx at index `input_idx` which spends the output
213          * described by descriptor, returning the witness stack for the input.
214          * 
215          * Returns an Err if the input at input_idx does not exist, has a non-empty script_sig,
216          * or is not spending the outpoint described by `descriptor.outpoint`.
217          */
218         public Result_CVec_CVec_u8ZZNoneZ sign_counterparty_payment_input(byte[] spend_tx, long input_idx, StaticPaymentOutputDescriptor descriptor) {
219                 long ret = bindings.InMemorySigner_sign_counterparty_payment_input(this.ptr, spend_tx, input_idx, descriptor == null ? 0 : descriptor.ptr & ~1);
220                 if (ret >= 0 && ret <= 4096) { return null; }
221                 Result_CVec_CVec_u8ZZNoneZ ret_hu_conv = Result_CVec_CVec_u8ZZNoneZ.constr_from_ptr(ret);
222                 this.ptrs_to.add(descriptor);
223                 return ret_hu_conv;
224         }
225
226         /**
227          * Sign the single input of spend_tx at index `input_idx` which spends the output
228          * described by descriptor, returning the witness stack for the input.
229          * 
230          * Returns an Err if the input at input_idx does not exist, has a non-empty script_sig,
231          * is not spending the outpoint described by `descriptor.outpoint`, or does not have a
232          * sequence set to `descriptor.to_self_delay`.
233          */
234         public Result_CVec_CVec_u8ZZNoneZ sign_dynamic_p2wsh_input(byte[] spend_tx, long input_idx, DelayedPaymentOutputDescriptor descriptor) {
235                 long ret = bindings.InMemorySigner_sign_dynamic_p2wsh_input(this.ptr, spend_tx, input_idx, descriptor == null ? 0 : descriptor.ptr & ~1);
236                 if (ret >= 0 && ret <= 4096) { return null; }
237                 Result_CVec_CVec_u8ZZNoneZ ret_hu_conv = Result_CVec_CVec_u8ZZNoneZ.constr_from_ptr(ret);
238                 this.ptrs_to.add(descriptor);
239                 return ret_hu_conv;
240         }
241
242         /**
243          * Constructs a new BaseSign which calls the relevant methods on this_arg.
244          * This copies the `inner` pointer in this_arg and thus the returned BaseSign must be freed before this_arg is
245          */
246         public BaseSign as_BaseSign() {
247                 long ret = bindings.InMemorySigner_as_BaseSign(this.ptr);
248                 if (ret >= 0 && ret <= 4096) { return null; }
249                 BaseSign ret_hu_conv = new BaseSign(null, ret);
250                 ret_hu_conv.ptrs_to.add(this);
251                 return ret_hu_conv;
252         }
253
254         /**
255          * Constructs a new Sign which calls the relevant methods on this_arg.
256          * This copies the `inner` pointer in this_arg and thus the returned Sign must be freed before this_arg is
257          */
258         public Sign as_Sign() {
259                 long ret = bindings.InMemorySigner_as_Sign(this.ptr);
260                 if (ret >= 0 && ret <= 4096) { return null; }
261                 Sign ret_hu_conv = new Sign(null, ret);
262                 ret_hu_conv.ptrs_to.add(this);
263                 return ret_hu_conv;
264         }
265
266         /**
267          * Serialize the InMemorySigner object into a byte array which can be read by InMemorySigner_read
268          */
269         public byte[] write() {
270                 byte[] ret = bindings.InMemorySigner_write(this.ptr);
271                 return ret;
272         }
273
274         /**
275          * Read a InMemorySigner from a byte array, created by InMemorySigner_write
276          */
277         public static Result_InMemorySignerDecodeErrorZ read(byte[] ser) {
278                 long ret = bindings.InMemorySigner_read(ser);
279                 if (ret >= 0 && ret <= 4096) { return null; }
280                 Result_InMemorySignerDecodeErrorZ ret_hu_conv = Result_InMemorySignerDecodeErrorZ.constr_from_ptr(ret);
281                 return ret_hu_conv;
282         }
283
284 }