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                 if (ret < 1024) { return null; }
120                 InMemorySigner ret_hu_conv = new InMemorySigner(null, ret);
121                 ret_hu_conv.ptrs_to.add(this);
122                 return ret_hu_conv;
123         }
124
125         /**
126          * Create a new InMemorySigner
127          */
128         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) {
129                 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);
130                 if (ret < 1024) { return null; }
131                 InMemorySigner ret_hu_conv = new InMemorySigner(null, ret);
132                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
133                 return ret_hu_conv;
134         }
135
136         /**
137          * Counterparty pubkeys.
138          * Will panic if ready_channel wasn't called.
139          */
140         public ChannelPublicKeys counterparty_pubkeys() {
141                 long ret = bindings.InMemorySigner_counterparty_pubkeys(this.ptr);
142                 if (ret < 1024) { return null; }
143                 ChannelPublicKeys ret_hu_conv = new ChannelPublicKeys(null, ret);
144                 ret_hu_conv.ptrs_to.add(this);
145                 return ret_hu_conv;
146         }
147
148         /**
149          * The contest_delay value specified by our counterparty and applied on holder-broadcastable
150          * transactions, ie the amount of time that we have to wait to recover our funds if we
151          * broadcast a transaction.
152          * Will panic if ready_channel wasn't called.
153          */
154         public short counterparty_selected_contest_delay() {
155                 short ret = bindings.InMemorySigner_counterparty_selected_contest_delay(this.ptr);
156                 return ret;
157         }
158
159         /**
160          * The contest_delay value specified by us and applied on transactions broadcastable
161          * by our counterparty, ie the amount of time that they have to wait to recover their funds
162          * if they broadcast a transaction.
163          * Will panic if ready_channel wasn't called.
164          */
165         public short holder_selected_contest_delay() {
166                 short ret = bindings.InMemorySigner_holder_selected_contest_delay(this.ptr);
167                 return ret;
168         }
169
170         /**
171          * Whether the holder is the initiator
172          * Will panic if ready_channel wasn't called.
173          */
174         public boolean is_outbound() {
175                 boolean ret = bindings.InMemorySigner_is_outbound(this.ptr);
176                 return ret;
177         }
178
179         /**
180          * Funding outpoint
181          * Will panic if ready_channel wasn't called.
182          */
183         public OutPoint funding_outpoint() {
184                 long ret = bindings.InMemorySigner_funding_outpoint(this.ptr);
185                 if (ret < 1024) { return null; }
186                 OutPoint ret_hu_conv = new OutPoint(null, ret);
187                 ret_hu_conv.ptrs_to.add(this);
188                 return ret_hu_conv;
189         }
190
191         /**
192          * Obtain a ChannelTransactionParameters for this channel, to be used when verifying or
193          * building transactions.
194          * 
195          * Will panic if ready_channel wasn't called.
196          */
197         public ChannelTransactionParameters get_channel_parameters() {
198                 long ret = bindings.InMemorySigner_get_channel_parameters(this.ptr);
199                 if (ret < 1024) { return null; }
200                 ChannelTransactionParameters ret_hu_conv = new ChannelTransactionParameters(null, ret);
201                 ret_hu_conv.ptrs_to.add(this);
202                 return ret_hu_conv;
203         }
204
205         /**
206          * Sign the single input of spend_tx at index `input_idx` which spends the output
207          * described by descriptor, returning the witness stack for the input.
208          * 
209          * Returns an Err if the input at input_idx does not exist, has a non-empty script_sig,
210          * or is not spending the outpoint described by `descriptor.outpoint`.
211          */
212         public Result_CVec_CVec_u8ZZNoneZ sign_counterparty_payment_input(byte[] spend_tx, long input_idx, StaticPaymentOutputDescriptor descriptor) {
213                 long ret = bindings.InMemorySigner_sign_counterparty_payment_input(this.ptr, spend_tx, input_idx, descriptor == null ? 0 : descriptor.ptr & ~1);
214                 if (ret < 1024) { return null; }
215                 Result_CVec_CVec_u8ZZNoneZ ret_hu_conv = Result_CVec_CVec_u8ZZNoneZ.constr_from_ptr(ret);
216                 this.ptrs_to.add(descriptor);
217                 return ret_hu_conv;
218         }
219
220         /**
221          * Sign the single input of spend_tx at index `input_idx` which spends the output
222          * described by descriptor, returning the witness stack for the input.
223          * 
224          * Returns an Err if the input at input_idx does not exist, has a non-empty script_sig,
225          * is not spending the outpoint described by `descriptor.outpoint`, or does not have a
226          * sequence set to `descriptor.to_self_delay`.
227          */
228         public Result_CVec_CVec_u8ZZNoneZ sign_dynamic_p2wsh_input(byte[] spend_tx, long input_idx, DelayedPaymentOutputDescriptor descriptor) {
229                 long ret = bindings.InMemorySigner_sign_dynamic_p2wsh_input(this.ptr, spend_tx, input_idx, descriptor == null ? 0 : descriptor.ptr & ~1);
230                 if (ret < 1024) { return null; }
231                 Result_CVec_CVec_u8ZZNoneZ ret_hu_conv = Result_CVec_CVec_u8ZZNoneZ.constr_from_ptr(ret);
232                 this.ptrs_to.add(descriptor);
233                 return ret_hu_conv;
234         }
235
236         /**
237          * Constructs a new BaseSign which calls the relevant methods on this_arg.
238          * This copies the `inner` pointer in this_arg and thus the returned BaseSign must be freed before this_arg is
239          */
240         public BaseSign as_BaseSign() {
241                 long ret = bindings.InMemorySigner_as_BaseSign(this.ptr);
242                 if (ret < 1024) { return null; }
243                 BaseSign ret_hu_conv = new BaseSign(null, ret);
244                 ret_hu_conv.ptrs_to.add(this);
245                 return ret_hu_conv;
246         }
247
248         /**
249          * Constructs a new Sign which calls the relevant methods on this_arg.
250          * This copies the `inner` pointer in this_arg and thus the returned Sign must be freed before this_arg is
251          */
252         public Sign as_Sign() {
253                 long ret = bindings.InMemorySigner_as_Sign(this.ptr);
254                 if (ret < 1024) { return null; }
255                 Sign ret_hu_conv = new Sign(null, ret);
256                 ret_hu_conv.ptrs_to.add(this);
257                 return ret_hu_conv;
258         }
259
260         /**
261          * Serialize the InMemorySigner object into a byte array which can be read by InMemorySigner_read
262          */
263         public byte[] write() {
264                 byte[] ret = bindings.InMemorySigner_write(this.ptr);
265                 return ret;
266         }
267
268         /**
269          * Read a InMemorySigner from a byte array, created by InMemorySigner_write
270          */
271         public static Result_InMemorySignerDecodeErrorZ read(byte[] ser) {
272                 long ret = bindings.InMemorySigner_read(ser);
273                 if (ret < 1024) { return null; }
274                 Result_InMemorySignerDecodeErrorZ ret_hu_conv = Result_InMemorySignerDecodeErrorZ.constr_from_ptr(ret);
275                 return ret_hu_conv;
276         }
277
278 }