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