6 namespace org { namespace ldk { namespace structs {
10 * A simple implementation of [`WriteableEcdsaChannelSigner`] that just keeps the private keys in memory.
12 * This implementation performs no policy checks and is insufficient by itself as
13 * a secure external signer.
15 public class InMemorySigner : CommonBase {
16 internal InMemorySigner(object _dummy, long ptr) : base(ptr) { }
18 if (ptr != 0) { bindings.InMemorySigner_free(ptr); }
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.
25 public byte[] get_funding_key() {
26 long ret = bindings.InMemorySigner_get_funding_key(this.ptr);
28 if (ret >= 0 && ret <= 4096) { return null; }
29 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
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.
37 public void set_funding_key(byte[] val) {
38 bindings.InMemorySigner_set_funding_key(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
44 * Holder secret key for blinded revocation pubkey.
46 public byte[] get_revocation_base_key() {
47 long ret = bindings.InMemorySigner_get_revocation_base_key(this.ptr);
49 if (ret >= 0 && ret <= 4096) { return null; }
50 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
55 * Holder secret key for blinded revocation pubkey.
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)));
64 * Holder secret key used for our balance in counterparty-broadcasted commitment transactions.
66 public byte[] get_payment_key() {
67 long ret = bindings.InMemorySigner_get_payment_key(this.ptr);
69 if (ret >= 0 && ret <= 4096) { return null; }
70 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
75 * Holder secret key used for our balance in counterparty-broadcasted commitment transactions.
77 public void set_payment_key(byte[] val) {
78 bindings.InMemorySigner_set_payment_key(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
84 * Holder secret key used in an HTLC transaction.
86 public byte[] get_delayed_payment_base_key() {
87 long ret = bindings.InMemorySigner_get_delayed_payment_base_key(this.ptr);
89 if (ret >= 0 && ret <= 4096) { return null; }
90 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
95 * Holder secret key used in an HTLC transaction.
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)));
104 * Holder HTLC secret key used in commitment transaction HTLC outputs.
106 public byte[] get_htlc_base_key() {
107 long ret = bindings.InMemorySigner_get_htlc_base_key(this.ptr);
109 if (ret >= 0 && ret <= 4096) { return null; }
110 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
115 * Holder HTLC secret key used in commitment transaction HTLC outputs.
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)));
126 public byte[] get_commitment_seed() {
127 long ret = bindings.InMemorySigner_get_commitment_seed(this.ptr);
129 if (ret >= 0 && ret <= 4096) { return null; }
130 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
137 public void set_commitment_seed(byte[] val) {
138 bindings.InMemorySigner_set_commitment_seed(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
143 internal long clone_ptr() {
144 long ret = bindings.InMemorySigner_clone_ptr(this.ptr);
150 * Creates a copy of the InMemorySigner
152 public InMemorySigner clone() {
153 long ret = bindings.InMemorySigner_clone(this.ptr);
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); };
162 * Creates a new [`InMemorySigner`].
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); };
182 * Returns the counterparty's pubkeys.
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.
187 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
189 public ChannelPublicKeys counterparty_pubkeys() {
190 long ret = bindings.InMemorySigner_counterparty_pubkeys(this.ptr);
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); };
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.
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.
206 public Option_u16Z counterparty_selected_contest_delay() {
207 long ret = bindings.InMemorySigner_counterparty_selected_contest_delay(this.ptr);
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); };
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.
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.
223 public Option_u16Z holder_selected_contest_delay() {
224 long ret = bindings.InMemorySigner_holder_selected_contest_delay(this.ptr);
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); };
233 * Returns whether the holder is the initiator.
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.
238 public Option_boolZ is_outbound() {
239 long ret = bindings.InMemorySigner_is_outbound(this.ptr);
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); };
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.
253 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
255 public OutPoint funding_outpoint() {
256 long ret = bindings.InMemorySigner_funding_outpoint(this.ptr);
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); };
265 * Returns a [`ChannelTransactionParameters`] for this channel, to be used when verifying or
266 * building transactions.
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.
271 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
273 public ChannelTransactionParameters get_channel_parameters() {
274 long ret = bindings.InMemorySigner_get_channel_parameters(this.ptr);
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); };
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.
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.
289 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
291 public ChannelTypeFeatures channel_type_features() {
292 long ret = bindings.InMemorySigner_channel_type_features(this.ptr);
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); };
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.
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.
308 * [`descriptor.outpoint`]: StaticPaymentOutputDescriptor::outpoint
310 public Result_WitnessNoneZ 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.ptr);
313 GC.KeepAlive(spend_tx);
314 GC.KeepAlive(input_idx);
315 GC.KeepAlive(descriptor);
316 if (ret >= 0 && ret <= 4096) { return null; }
317 Result_WitnessNoneZ ret_hu_conv = Result_WitnessNoneZ.constr_from_ptr(ret);
318 if (this != null) { this.ptrs_to.AddLast(descriptor); };
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.
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.
331 * [`descriptor.outpoint`]: DelayedPaymentOutputDescriptor::outpoint
332 * [`descriptor.to_self_delay`]: DelayedPaymentOutputDescriptor::to_self_delay
334 public Result_WitnessNoneZ 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.ptr);
337 GC.KeepAlive(spend_tx);
338 GC.KeepAlive(input_idx);
339 GC.KeepAlive(descriptor);
340 if (ret >= 0 && ret <= 4096) { return null; }
341 Result_WitnessNoneZ ret_hu_conv = Result_WitnessNoneZ.constr_from_ptr(ret);
342 if (this != null) { this.ptrs_to.AddLast(descriptor); };
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
350 public EntropySource as_EntropySource() {
351 long ret = bindings.InMemorySigner_as_EntropySource(this.ptr);
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); };
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
363 public ChannelSigner as_ChannelSigner() {
364 long ret = bindings.InMemorySigner_as_ChannelSigner(this.ptr);
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); };
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
376 public EcdsaChannelSigner as_EcdsaChannelSigner() {
377 long ret = bindings.InMemorySigner_as_EcdsaChannelSigner(this.ptr);
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); };
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
389 public WriteableEcdsaChannelSigner as_WriteableEcdsaChannelSigner() {
390 long ret = bindings.InMemorySigner_as_WriteableEcdsaChannelSigner(this.ptr);
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); };
399 * Serialize the InMemorySigner object into a byte array which can be read by InMemorySigner_read
401 public byte[] write() {
402 long ret = bindings.InMemorySigner_write(this.ptr);
404 if (ret >= 0 && ret <= 4096) { return null; }
405 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
410 * Read a InMemorySigner from a byte array, created by InMemorySigner_write
412 public static Result_InMemorySignerDecodeErrorZ read(byte[] ser, org.ldk.structs.EntropySource arg) {
413 long ret = bindings.InMemorySigner_read(InternalUtils.encodeUint8Array(ser), arg.ptr);
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); };