6 namespace org { namespace ldk { namespace structs {
10 * A simple implementation of [`Sign`] 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 byte[] ret = bindings.InMemorySigner_get_funding_key(this.ptr);
32 * Holder secret key in the 2-of-2 multisig script of a channel. This key also backs the
33 * holder's anchor output in a commitment transaction, if one is present.
35 public void set_funding_key(byte[] val) {
36 bindings.InMemorySigner_set_funding_key(this.ptr, InternalUtils.check_arr_len(val, 32));
42 * Holder secret key for blinded revocation pubkey.
44 public byte[] get_revocation_base_key() {
45 byte[] ret = bindings.InMemorySigner_get_revocation_base_key(this.ptr);
51 * Holder secret key for blinded revocation pubkey.
53 public void set_revocation_base_key(byte[] val) {
54 bindings.InMemorySigner_set_revocation_base_key(this.ptr, InternalUtils.check_arr_len(val, 32));
60 * Holder secret key used for our balance in counterparty-broadcasted commitment transactions.
62 public byte[] get_payment_key() {
63 byte[] ret = bindings.InMemorySigner_get_payment_key(this.ptr);
69 * Holder secret key used for our balance in counterparty-broadcasted commitment transactions.
71 public void set_payment_key(byte[] val) {
72 bindings.InMemorySigner_set_payment_key(this.ptr, InternalUtils.check_arr_len(val, 32));
78 * Holder secret key used in an HTLC transaction.
80 public byte[] get_delayed_payment_base_key() {
81 byte[] ret = bindings.InMemorySigner_get_delayed_payment_base_key(this.ptr);
87 * Holder secret key used in an HTLC transaction.
89 public void set_delayed_payment_base_key(byte[] val) {
90 bindings.InMemorySigner_set_delayed_payment_base_key(this.ptr, InternalUtils.check_arr_len(val, 32));
96 * Holder HTLC secret key used in commitment transaction HTLC outputs.
98 public byte[] get_htlc_base_key() {
99 byte[] ret = bindings.InMemorySigner_get_htlc_base_key(this.ptr);
105 * Holder HTLC secret key used in commitment transaction HTLC outputs.
107 public void set_htlc_base_key(byte[] val) {
108 bindings.InMemorySigner_set_htlc_base_key(this.ptr, InternalUtils.check_arr_len(val, 32));
116 public byte[] get_commitment_seed() {
117 byte[] ret = bindings.InMemorySigner_get_commitment_seed(this.ptr);
125 public void set_commitment_seed(byte[] val) {
126 bindings.InMemorySigner_set_commitment_seed(this.ptr, InternalUtils.check_arr_len(val, 32));
131 internal long clone_ptr() {
132 long ret = bindings.InMemorySigner_clone_ptr(this.ptr);
138 * Creates a copy of the InMemorySigner
140 public InMemorySigner clone() {
141 long ret = bindings.InMemorySigner_clone(this.ptr);
143 if (ret >= 0 && ret <= 4096) { return null; }
144 org.ldk.structs.InMemorySigner ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InMemorySigner(null, ret); }
145 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
150 * Creates a new [`InMemorySigner`].
152 public static InMemorySigner of(byte[] node_secret, 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) {
153 long ret = bindings.InMemorySigner_new(InternalUtils.check_arr_len(node_secret, 32), InternalUtils.check_arr_len(funding_key, 32), InternalUtils.check_arr_len(revocation_base_key, 32), InternalUtils.check_arr_len(payment_key, 32), InternalUtils.check_arr_len(delayed_payment_base_key, 32), InternalUtils.check_arr_len(htlc_base_key, 32), InternalUtils.check_arr_len(commitment_seed, 32), channel_value_satoshis, InternalUtils.check_arr_len(channel_keys_id, 32));
154 GC.KeepAlive(node_secret);
155 GC.KeepAlive(funding_key);
156 GC.KeepAlive(revocation_base_key);
157 GC.KeepAlive(payment_key);
158 GC.KeepAlive(delayed_payment_base_key);
159 GC.KeepAlive(htlc_base_key);
160 GC.KeepAlive(commitment_seed);
161 GC.KeepAlive(channel_value_satoshis);
162 GC.KeepAlive(channel_keys_id);
163 if (ret >= 0 && ret <= 4096) { return null; }
164 org.ldk.structs.InMemorySigner ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InMemorySigner(null, ret); }
165 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
170 * Returns the counterparty's pubkeys.
172 * Will panic if [`BaseSign::provide_channel_parameters`] has not been called before.
174 public ChannelPublicKeys counterparty_pubkeys() {
175 long ret = bindings.InMemorySigner_counterparty_pubkeys(this.ptr);
177 if (ret >= 0 && ret <= 4096) { return null; }
178 org.ldk.structs.ChannelPublicKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelPublicKeys(null, ret); }
179 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
184 * Returns the `contest_delay` value specified by our counterparty and applied on holder-broadcastable
185 * transactions, i.e., the amount of time that we have to wait to recover our funds if we
186 * broadcast a transaction.
188 * Will panic if [`BaseSign::provide_channel_parameters`] has not been called before.
190 public short counterparty_selected_contest_delay() {
191 short ret = bindings.InMemorySigner_counterparty_selected_contest_delay(this.ptr);
197 * Returns the `contest_delay` value specified by us and applied on transactions broadcastable
198 * by our counterparty, i.e., the amount of time that they have to wait to recover their funds
199 * if they broadcast a transaction.
201 * Will panic if [`BaseSign::provide_channel_parameters`] has not been called before.
203 public short holder_selected_contest_delay() {
204 short ret = bindings.InMemorySigner_holder_selected_contest_delay(this.ptr);
210 * Returns whether the holder is the initiator.
212 * Will panic if [`BaseSign::provide_channel_parameters`] has not been called before.
214 public bool is_outbound() {
215 bool ret = bindings.InMemorySigner_is_outbound(this.ptr);
223 * Will panic if [`BaseSign::provide_channel_parameters`] has not been called before.
225 public OutPoint funding_outpoint() {
226 long ret = bindings.InMemorySigner_funding_outpoint(this.ptr);
228 if (ret >= 0 && ret <= 4096) { return null; }
229 org.ldk.structs.OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OutPoint(null, ret); }
230 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
235 * Returns a [`ChannelTransactionParameters`] for this channel, to be used when verifying or
236 * building transactions.
238 * Will panic if [`BaseSign::provide_channel_parameters`] has not been called before.
240 public ChannelTransactionParameters get_channel_parameters() {
241 long ret = bindings.InMemorySigner_get_channel_parameters(this.ptr);
243 if (ret >= 0 && ret <= 4096) { return null; }
244 org.ldk.structs.ChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTransactionParameters(null, ret); }
245 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
250 * Returns whether anchors should be used.
252 * Will panic if [`BaseSign::provide_channel_parameters`] has not been called before.
254 public bool opt_anchors() {
255 bool ret = bindings.InMemorySigner_opt_anchors(this.ptr);
261 * Sign the single input of `spend_tx` at index `input_idx`, which spends the output described
262 * by `descriptor`, returning the witness stack for the input.
264 * Returns an error if the input at `input_idx` does not exist, has a non-empty `script_sig`,
265 * is not spending the outpoint described by [`descriptor.outpoint`],
266 * or if an output descriptor `script_pubkey` does not match the one we can spend.
268 * [`descriptor.outpoint`]: StaticPaymentOutputDescriptor::outpoint
270 public Result_CVec_CVec_u8ZZNoneZ sign_counterparty_payment_input(byte[] spend_tx, long input_idx, org.ldk.structs.StaticPaymentOutputDescriptor descriptor) {
271 long ret = bindings.InMemorySigner_sign_counterparty_payment_input(this.ptr, spend_tx, input_idx, descriptor == null ? 0 : descriptor.ptr);
273 GC.KeepAlive(spend_tx);
274 GC.KeepAlive(input_idx);
275 GC.KeepAlive(descriptor);
276 if (ret >= 0 && ret <= 4096) { return null; }
277 Result_CVec_CVec_u8ZZNoneZ ret_hu_conv = Result_CVec_CVec_u8ZZNoneZ.constr_from_ptr(ret);
278 if (this != null) { this.ptrs_to.AddLast(descriptor); };
283 * Sign the single input of `spend_tx` at index `input_idx` which spends the output
284 * described by `descriptor`, returning the witness stack for the input.
286 * Returns an error if the input at `input_idx` does not exist, has a non-empty `script_sig`,
287 * is not spending the outpoint described by [`descriptor.outpoint`], does not have a
288 * sequence set to [`descriptor.to_self_delay`], or if an output descriptor
289 * `script_pubkey` does not match the one we can spend.
291 * [`descriptor.outpoint`]: DelayedPaymentOutputDescriptor::outpoint
292 * [`descriptor.to_self_delay`]: DelayedPaymentOutputDescriptor::to_self_delay
294 public Result_CVec_CVec_u8ZZNoneZ sign_dynamic_p2wsh_input(byte[] spend_tx, long input_idx, org.ldk.structs.DelayedPaymentOutputDescriptor descriptor) {
295 long ret = bindings.InMemorySigner_sign_dynamic_p2wsh_input(this.ptr, spend_tx, input_idx, descriptor == null ? 0 : descriptor.ptr);
297 GC.KeepAlive(spend_tx);
298 GC.KeepAlive(input_idx);
299 GC.KeepAlive(descriptor);
300 if (ret >= 0 && ret <= 4096) { return null; }
301 Result_CVec_CVec_u8ZZNoneZ ret_hu_conv = Result_CVec_CVec_u8ZZNoneZ.constr_from_ptr(ret);
302 if (this != null) { this.ptrs_to.AddLast(descriptor); };
307 * Constructs a new BaseSign which calls the relevant methods on this_arg.
308 * This copies the `inner` pointer in this_arg and thus the returned BaseSign must be freed before this_arg is
310 public BaseSign as_BaseSign() {
311 long ret = bindings.InMemorySigner_as_BaseSign(this.ptr);
313 if (ret >= 0 && ret <= 4096) { return null; }
314 BaseSign ret_hu_conv = new BaseSign(null, ret);
315 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
320 * Constructs a new Sign which calls the relevant methods on this_arg.
321 * This copies the `inner` pointer in this_arg and thus the returned Sign must be freed before this_arg is
323 public Sign as_Sign() {
324 long ret = bindings.InMemorySigner_as_Sign(this.ptr);
326 if (ret >= 0 && ret <= 4096) { return null; }
327 Sign ret_hu_conv = new Sign(null, ret);
328 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
333 * Serialize the InMemorySigner object into a byte array which can be read by InMemorySigner_read
335 public byte[] write() {
336 byte[] ret = bindings.InMemorySigner_write(this.ptr);
342 * Read a InMemorySigner from a byte array, created by InMemorySigner_write
344 public static Result_InMemorySignerDecodeErrorZ read(byte[] ser, byte[] arg) {
345 long ret = bindings.InMemorySigner_read(ser, InternalUtils.check_arr_len(arg, 32));
348 if (ret >= 0 && ret <= 4096) { return null; }
349 Result_InMemorySignerDecodeErrorZ ret_hu_conv = Result_InMemorySignerDecodeErrorZ.constr_from_ptr(ret);