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