[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / InMemorySigner.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8
9 /**
10  * A simple implementation of [`WriteableEcdsaChannelSigner`] 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 public class InMemorySigner : CommonBase {
16         internal InMemorySigner(object _dummy, long ptr) : base(ptr) { }
17         ~InMemorySigner() {
18                 if (ptr != 0) { bindings.InMemorySigner_free(ptr); }
19         }
20
21         /**
22          * Holder secret key in the 2-of-2 multisig script of a channel. This key also backs the
23          * holder's anchor output in a commitment transaction, if one is present.
24          */
25         public byte[] get_funding_key() {
26                 long ret = bindings.InMemorySigner_get_funding_key(this.ptr);
27                 GC.KeepAlive(this);
28                 if (ret >= 0 && ret <= 4096) { return null; }
29                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
30                 return ret_conv;
31         }
32
33         /**
34          * Holder secret key in the 2-of-2 multisig script of a channel. This key also backs the
35          * holder's anchor output in a commitment transaction, if one is present.
36          */
37         public void set_funding_key(byte[] val) {
38                 bindings.InMemorySigner_set_funding_key(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
39                 GC.KeepAlive(this);
40                 GC.KeepAlive(val);
41         }
42
43         /**
44          * Holder secret key for blinded revocation pubkey.
45          */
46         public byte[] get_revocation_base_key() {
47                 long ret = bindings.InMemorySigner_get_revocation_base_key(this.ptr);
48                 GC.KeepAlive(this);
49                 if (ret >= 0 && ret <= 4096) { return null; }
50                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
51                 return ret_conv;
52         }
53
54         /**
55          * Holder secret key for blinded revocation pubkey.
56          */
57         public void set_revocation_base_key(byte[] val) {
58                 bindings.InMemorySigner_set_revocation_base_key(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
59                 GC.KeepAlive(this);
60                 GC.KeepAlive(val);
61         }
62
63         /**
64          * Holder secret key used for our balance in counterparty-broadcasted commitment transactions.
65          */
66         public byte[] get_payment_key() {
67                 long ret = bindings.InMemorySigner_get_payment_key(this.ptr);
68                 GC.KeepAlive(this);
69                 if (ret >= 0 && ret <= 4096) { return null; }
70                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
71                 return ret_conv;
72         }
73
74         /**
75          * Holder secret key used for our balance in counterparty-broadcasted commitment transactions.
76          */
77         public void set_payment_key(byte[] val) {
78                 bindings.InMemorySigner_set_payment_key(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
79                 GC.KeepAlive(this);
80                 GC.KeepAlive(val);
81         }
82
83         /**
84          * Holder secret key used in an HTLC transaction.
85          */
86         public byte[] get_delayed_payment_base_key() {
87                 long ret = bindings.InMemorySigner_get_delayed_payment_base_key(this.ptr);
88                 GC.KeepAlive(this);
89                 if (ret >= 0 && ret <= 4096) { return null; }
90                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
91                 return ret_conv;
92         }
93
94         /**
95          * Holder secret key used in an HTLC transaction.
96          */
97         public void set_delayed_payment_base_key(byte[] val) {
98                 bindings.InMemorySigner_set_delayed_payment_base_key(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
99                 GC.KeepAlive(this);
100                 GC.KeepAlive(val);
101         }
102
103         /**
104          * Holder HTLC secret key used in commitment transaction HTLC outputs.
105          */
106         public byte[] get_htlc_base_key() {
107                 long ret = bindings.InMemorySigner_get_htlc_base_key(this.ptr);
108                 GC.KeepAlive(this);
109                 if (ret >= 0 && ret <= 4096) { return null; }
110                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
111                 return ret_conv;
112         }
113
114         /**
115          * Holder HTLC secret key used in commitment transaction HTLC outputs.
116          */
117         public void set_htlc_base_key(byte[] val) {
118                 bindings.InMemorySigner_set_htlc_base_key(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
119                 GC.KeepAlive(this);
120                 GC.KeepAlive(val);
121         }
122
123         /**
124          * Commitment seed.
125          */
126         public byte[] get_commitment_seed() {
127                 long ret = bindings.InMemorySigner_get_commitment_seed(this.ptr);
128                 GC.KeepAlive(this);
129                 if (ret >= 0 && ret <= 4096) { return null; }
130                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
131                 return ret_conv;
132         }
133
134         /**
135          * Commitment seed.
136          */
137         public void set_commitment_seed(byte[] val) {
138                 bindings.InMemorySigner_set_commitment_seed(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
139                 GC.KeepAlive(this);
140                 GC.KeepAlive(val);
141         }
142
143         internal long clone_ptr() {
144                 long ret = bindings.InMemorySigner_clone_ptr(this.ptr);
145                 GC.KeepAlive(this);
146                 return ret;
147         }
148
149         /**
150          * Creates a copy of the InMemorySigner
151          */
152         public InMemorySigner clone() {
153                 long ret = bindings.InMemorySigner_clone(this.ptr);
154                 GC.KeepAlive(this);
155                 if (ret >= 0 && ret <= 4096) { return null; }
156                 org.ldk.structs.InMemorySigner ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InMemorySigner(null, ret); }
157                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
158                 return ret_hu_conv;
159         }
160
161         /**
162          * Creates a new [`InMemorySigner`].
163          */
164         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, byte[] rand_bytes_unique_start) {
165                 long ret = bindings.InMemorySigner_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(funding_key, 32)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(revocation_base_key, 32)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_key, 32)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(delayed_payment_base_key, 32)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(htlc_base_key, 32)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(commitment_seed, 32)), channel_value_satoshis, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(channel_keys_id, 32)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(rand_bytes_unique_start, 32)));
166                 GC.KeepAlive(funding_key);
167                 GC.KeepAlive(revocation_base_key);
168                 GC.KeepAlive(payment_key);
169                 GC.KeepAlive(delayed_payment_base_key);
170                 GC.KeepAlive(htlc_base_key);
171                 GC.KeepAlive(commitment_seed);
172                 GC.KeepAlive(channel_value_satoshis);
173                 GC.KeepAlive(channel_keys_id);
174                 GC.KeepAlive(rand_bytes_unique_start);
175                 if (ret >= 0 && ret <= 4096) { return null; }
176                 org.ldk.structs.InMemorySigner ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InMemorySigner(null, ret); }
177                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
178                 return ret_hu_conv;
179         }
180
181         /**
182          * Returns the counterparty's pubkeys.
183          * 
184          * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called.
185          * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation.
186          * 
187          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
188          */
189         public ChannelPublicKeys counterparty_pubkeys() {
190                 long ret = bindings.InMemorySigner_counterparty_pubkeys(this.ptr);
191                 GC.KeepAlive(this);
192                 if (ret >= 0 && ret <= 4096) { return null; }
193                 org.ldk.structs.ChannelPublicKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelPublicKeys(null, ret); }
194                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
195                 return ret_hu_conv;
196         }
197
198         /**
199          * Returns the `contest_delay` value specified by our counterparty and applied on holder-broadcastable
200          * transactions, i.e., the amount of time that we have to wait to recover our funds if we
201          * broadcast a transaction.
202          * 
203          * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called.
204          * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation.
205          */
206         public Option_u16Z counterparty_selected_contest_delay() {
207                 long ret = bindings.InMemorySigner_counterparty_selected_contest_delay(this.ptr);
208                 GC.KeepAlive(this);
209                 if (ret >= 0 && ret <= 4096) { return null; }
210                 org.ldk.structs.Option_u16Z ret_hu_conv = org.ldk.structs.Option_u16Z.constr_from_ptr(ret);
211                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
212                 return ret_hu_conv;
213         }
214
215         /**
216          * Returns the `contest_delay` value specified by us and applied on transactions broadcastable
217          * by our counterparty, i.e., the amount of time that they have to wait to recover their funds
218          * if they broadcast a transaction.
219          * 
220          * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called.
221          * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation.
222          */
223         public Option_u16Z holder_selected_contest_delay() {
224                 long ret = bindings.InMemorySigner_holder_selected_contest_delay(this.ptr);
225                 GC.KeepAlive(this);
226                 if (ret >= 0 && ret <= 4096) { return null; }
227                 org.ldk.structs.Option_u16Z ret_hu_conv = org.ldk.structs.Option_u16Z.constr_from_ptr(ret);
228                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
229                 return ret_hu_conv;
230         }
231
232         /**
233          * Returns whether the holder is the initiator.
234          * 
235          * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called.
236          * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation.
237          */
238         public Option_boolZ is_outbound() {
239                 long ret = bindings.InMemorySigner_is_outbound(this.ptr);
240                 GC.KeepAlive(this);
241                 if (ret >= 0 && ret <= 4096) { return null; }
242                 org.ldk.structs.Option_boolZ ret_hu_conv = org.ldk.structs.Option_boolZ.constr_from_ptr(ret);
243                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
244                 return ret_hu_conv;
245         }
246
247         /**
248          * Funding outpoint
249          * 
250          * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called.
251          * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation.
252          * 
253          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
254          */
255         public OutPoint funding_outpoint() {
256                 long ret = bindings.InMemorySigner_funding_outpoint(this.ptr);
257                 GC.KeepAlive(this);
258                 if (ret >= 0 && ret <= 4096) { return null; }
259                 org.ldk.structs.OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OutPoint(null, ret); }
260                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
261                 return ret_hu_conv;
262         }
263
264         /**
265          * Returns a [`ChannelTransactionParameters`] for this channel, to be used when verifying or
266          * building transactions.
267          * 
268          * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called.
269          * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation.
270          * 
271          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
272          */
273         public ChannelTransactionParameters get_channel_parameters() {
274                 long ret = bindings.InMemorySigner_get_channel_parameters(this.ptr);
275                 GC.KeepAlive(this);
276                 if (ret >= 0 && ret <= 4096) { return null; }
277                 org.ldk.structs.ChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTransactionParameters(null, ret); }
278                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
279                 return ret_hu_conv;
280         }
281
282         /**
283          * Returns the channel type features of the channel parameters. Should be helpful for
284          * determining a channel's category, i. e. legacy/anchors/taproot/etc.
285          * 
286          * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called.
287          * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation.
288          * 
289          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
290          */
291         public ChannelTypeFeatures channel_type_features() {
292                 long ret = bindings.InMemorySigner_channel_type_features(this.ptr);
293                 GC.KeepAlive(this);
294                 if (ret >= 0 && ret <= 4096) { return null; }
295                 org.ldk.structs.ChannelTypeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTypeFeatures(null, ret); }
296                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
297                 return ret_hu_conv;
298         }
299
300         /**
301          * Sign the single input of `spend_tx` at index `input_idx`, which spends the output described
302          * by `descriptor`, returning the witness stack for the input.
303          * 
304          * Returns an error if the input at `input_idx` does not exist, has a non-empty `script_sig`,
305          * is not spending the outpoint described by [`descriptor.outpoint`],
306          * or if an output descriptor `script_pubkey` does not match the one we can spend.
307          * 
308          * [`descriptor.outpoint`]: StaticPaymentOutputDescriptor::outpoint
309          */
310         public Result_CVec_CVec_u8ZZNoneZ sign_counterparty_payment_input(byte[] spend_tx, long input_idx, org.ldk.structs.StaticPaymentOutputDescriptor descriptor) {
311                 long ret = bindings.InMemorySigner_sign_counterparty_payment_input(this.ptr, InternalUtils.encodeUint8Array(spend_tx), input_idx, descriptor == null ? 0 : descriptor.ptr);
312                 GC.KeepAlive(this);
313                 GC.KeepAlive(spend_tx);
314                 GC.KeepAlive(input_idx);
315                 GC.KeepAlive(descriptor);
316                 if (ret >= 0 && ret <= 4096) { return null; }
317                 Result_CVec_CVec_u8ZZNoneZ ret_hu_conv = Result_CVec_CVec_u8ZZNoneZ.constr_from_ptr(ret);
318                 if (this != null) { this.ptrs_to.AddLast(descriptor); };
319                 return ret_hu_conv;
320         }
321
322         /**
323          * Sign the single input of `spend_tx` at index `input_idx` which spends the output
324          * described by `descriptor`, returning the witness stack for the input.
325          * 
326          * Returns an error if the input at `input_idx` does not exist, has a non-empty `script_sig`,
327          * is not spending the outpoint described by [`descriptor.outpoint`], does not have a
328          * sequence set to [`descriptor.to_self_delay`], or if an output descriptor
329          * `script_pubkey` does not match the one we can spend.
330          * 
331          * [`descriptor.outpoint`]: DelayedPaymentOutputDescriptor::outpoint
332          * [`descriptor.to_self_delay`]: DelayedPaymentOutputDescriptor::to_self_delay
333          */
334         public Result_CVec_CVec_u8ZZNoneZ sign_dynamic_p2wsh_input(byte[] spend_tx, long input_idx, org.ldk.structs.DelayedPaymentOutputDescriptor descriptor) {
335                 long ret = bindings.InMemorySigner_sign_dynamic_p2wsh_input(this.ptr, InternalUtils.encodeUint8Array(spend_tx), input_idx, descriptor == null ? 0 : descriptor.ptr);
336                 GC.KeepAlive(this);
337                 GC.KeepAlive(spend_tx);
338                 GC.KeepAlive(input_idx);
339                 GC.KeepAlive(descriptor);
340                 if (ret >= 0 && ret <= 4096) { return null; }
341                 Result_CVec_CVec_u8ZZNoneZ ret_hu_conv = Result_CVec_CVec_u8ZZNoneZ.constr_from_ptr(ret);
342                 if (this != null) { this.ptrs_to.AddLast(descriptor); };
343                 return ret_hu_conv;
344         }
345
346         /**
347          * Constructs a new EntropySource which calls the relevant methods on this_arg.
348          * This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is
349          */
350         public EntropySource as_EntropySource() {
351                 long ret = bindings.InMemorySigner_as_EntropySource(this.ptr);
352                 GC.KeepAlive(this);
353                 if (ret >= 0 && ret <= 4096) { return null; }
354                 EntropySource ret_hu_conv = new EntropySource(null, ret);
355                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
356                 return ret_hu_conv;
357         }
358
359         /**
360          * Constructs a new ChannelSigner which calls the relevant methods on this_arg.
361          * This copies the `inner` pointer in this_arg and thus the returned ChannelSigner must be freed before this_arg is
362          */
363         public ChannelSigner as_ChannelSigner() {
364                 long ret = bindings.InMemorySigner_as_ChannelSigner(this.ptr);
365                 GC.KeepAlive(this);
366                 if (ret >= 0 && ret <= 4096) { return null; }
367                 ChannelSigner ret_hu_conv = new ChannelSigner(null, ret);
368                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
369                 return ret_hu_conv;
370         }
371
372         /**
373          * Constructs a new EcdsaChannelSigner which calls the relevant methods on this_arg.
374          * This copies the `inner` pointer in this_arg and thus the returned EcdsaChannelSigner must be freed before this_arg is
375          */
376         public EcdsaChannelSigner as_EcdsaChannelSigner() {
377                 long ret = bindings.InMemorySigner_as_EcdsaChannelSigner(this.ptr);
378                 GC.KeepAlive(this);
379                 if (ret >= 0 && ret <= 4096) { return null; }
380                 EcdsaChannelSigner ret_hu_conv = new EcdsaChannelSigner(null, ret);
381                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
382                 return ret_hu_conv;
383         }
384
385         /**
386          * Constructs a new WriteableEcdsaChannelSigner which calls the relevant methods on this_arg.
387          * This copies the `inner` pointer in this_arg and thus the returned WriteableEcdsaChannelSigner must be freed before this_arg is
388          */
389         public WriteableEcdsaChannelSigner as_WriteableEcdsaChannelSigner() {
390                 long ret = bindings.InMemorySigner_as_WriteableEcdsaChannelSigner(this.ptr);
391                 GC.KeepAlive(this);
392                 if (ret >= 0 && ret <= 4096) { return null; }
393                 WriteableEcdsaChannelSigner ret_hu_conv = new WriteableEcdsaChannelSigner(null, ret);
394                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
395                 return ret_hu_conv;
396         }
397
398         /**
399          * Serialize the InMemorySigner object into a byte array which can be read by InMemorySigner_read
400          */
401         public byte[] write() {
402                 long ret = bindings.InMemorySigner_write(this.ptr);
403                 GC.KeepAlive(this);
404                 if (ret >= 0 && ret <= 4096) { return null; }
405                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
406                 return ret_conv;
407         }
408
409         /**
410          * Read a InMemorySigner from a byte array, created by InMemorySigner_write
411          */
412         public static Result_InMemorySignerDecodeErrorZ read(byte[] ser, org.ldk.structs.EntropySource arg) {
413                 long ret = bindings.InMemorySigner_read(InternalUtils.encodeUint8Array(ser), arg.ptr);
414                 GC.KeepAlive(ser);
415                 GC.KeepAlive(arg);
416                 if (ret >= 0 && ret <= 4096) { return null; }
417                 Result_InMemorySignerDecodeErrorZ ret_hu_conv = Result_InMemorySignerDecodeErrorZ.constr_from_ptr(ret);
418                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(arg); };
419                 return ret_hu_conv;
420         }
421
422 }
423 } } }