import * as bindings from '../bindings.mjs'
+/**
+ * A simple implementation of Sign that just keeps the private keys in memory.
+ *
+ * This implementation performs no policy checks and is insufficient by itself as
+ * a secure external signer.
+ */
export class InMemorySigner extends CommonBase {
/* @internal */
public constructor(_dummy: object, ptr: number) {
super(ptr, bindings.InMemorySigner_free);
}
+ /**
+ * Private key of anchor tx
+ */
public get_funding_key(): Uint8Array {
const ret: number = bindings.InMemorySigner_get_funding_key(this.ptr);
const ret_conv: Uint8Array = bindings.decodeUint8Array(ret);
return ret_conv;
}
+ /**
+ * Private key of anchor tx
+ */
public set_funding_key(val: Uint8Array): void {
bindings.InMemorySigner_set_funding_key(this.ptr, bindings.encodeUint8Array(bindings.check_arr_len(val, 32)));
}
+ /**
+ * Holder secret key for blinded revocation pubkey
+ */
public get_revocation_base_key(): Uint8Array {
const ret: number = bindings.InMemorySigner_get_revocation_base_key(this.ptr);
const ret_conv: Uint8Array = bindings.decodeUint8Array(ret);
return ret_conv;
}
+ /**
+ * Holder secret key for blinded revocation pubkey
+ */
public set_revocation_base_key(val: Uint8Array): void {
bindings.InMemorySigner_set_revocation_base_key(this.ptr, bindings.encodeUint8Array(bindings.check_arr_len(val, 32)));
}
+ /**
+ * Holder secret key used for our balance in counterparty-broadcasted commitment transactions
+ */
public get_payment_key(): Uint8Array {
const ret: number = bindings.InMemorySigner_get_payment_key(this.ptr);
const ret_conv: Uint8Array = bindings.decodeUint8Array(ret);
return ret_conv;
}
+ /**
+ * Holder secret key used for our balance in counterparty-broadcasted commitment transactions
+ */
public set_payment_key(val: Uint8Array): void {
bindings.InMemorySigner_set_payment_key(this.ptr, bindings.encodeUint8Array(bindings.check_arr_len(val, 32)));
}
+ /**
+ * Holder secret key used in HTLC tx
+ */
public get_delayed_payment_base_key(): Uint8Array {
const ret: number = bindings.InMemorySigner_get_delayed_payment_base_key(this.ptr);
const ret_conv: Uint8Array = bindings.decodeUint8Array(ret);
return ret_conv;
}
+ /**
+ * Holder secret key used in HTLC tx
+ */
public set_delayed_payment_base_key(val: Uint8Array): void {
bindings.InMemorySigner_set_delayed_payment_base_key(this.ptr, bindings.encodeUint8Array(bindings.check_arr_len(val, 32)));
}
+ /**
+ * Holder htlc secret key used in commitment tx htlc outputs
+ */
public get_htlc_base_key(): Uint8Array {
const ret: number = bindings.InMemorySigner_get_htlc_base_key(this.ptr);
const ret_conv: Uint8Array = bindings.decodeUint8Array(ret);
return ret_conv;
}
+ /**
+ * Holder htlc secret key used in commitment tx htlc outputs
+ */
public set_htlc_base_key(val: Uint8Array): void {
bindings.InMemorySigner_set_htlc_base_key(this.ptr, bindings.encodeUint8Array(bindings.check_arr_len(val, 32)));
}
+ /**
+ * Commitment seed
+ */
public get_commitment_seed(): Uint8Array {
const ret: number = bindings.InMemorySigner_get_commitment_seed(this.ptr);
const ret_conv: Uint8Array = bindings.decodeUint8Array(ret);
return ret_conv;
}
+ /**
+ * Commitment seed
+ */
public set_commitment_seed(val: Uint8Array): void {
bindings.InMemorySigner_set_commitment_seed(this.ptr, bindings.encodeUint8Array(bindings.check_arr_len(val, 32)));
}
return ret;
}
+ /**
+ * Creates a copy of the InMemorySigner
+ */
public clone(): InMemorySigner {
const ret: number = bindings.InMemorySigner_clone(this.ptr);
const ret_hu_conv: InMemorySigner = new InMemorySigner(null, ret);
return ret_hu_conv;
}
+ /**
+ * Create a new InMemorySigner
+ */
public static constructor_new(funding_key: Uint8Array, revocation_base_key: Uint8Array, payment_key: Uint8Array, delayed_payment_base_key: Uint8Array, htlc_base_key: Uint8Array, commitment_seed: Uint8Array, channel_value_satoshis: bigint, channel_keys_id: Uint8Array): InMemorySigner {
const ret: number = bindings.InMemorySigner_new(bindings.encodeUint8Array(bindings.check_arr_len(funding_key, 32)), bindings.encodeUint8Array(bindings.check_arr_len(revocation_base_key, 32)), bindings.encodeUint8Array(bindings.check_arr_len(payment_key, 32)), bindings.encodeUint8Array(bindings.check_arr_len(delayed_payment_base_key, 32)), bindings.encodeUint8Array(bindings.check_arr_len(htlc_base_key, 32)), bindings.encodeUint8Array(bindings.check_arr_len(commitment_seed, 32)), channel_value_satoshis, bindings.encodeUint8Array(bindings.check_arr_len(channel_keys_id, 32)));
const ret_hu_conv: InMemorySigner = new InMemorySigner(null, ret);
return ret_hu_conv;
}
+ /**
+ * Counterparty pubkeys.
+ * Will panic if ready_channel wasn't called.
+ */
public counterparty_pubkeys(): ChannelPublicKeys {
const ret: number = bindings.InMemorySigner_counterparty_pubkeys(this.ptr);
const ret_hu_conv: ChannelPublicKeys = new ChannelPublicKeys(null, ret);
return ret_hu_conv;
}
+ /**
+ * The contest_delay value specified by our counterparty and applied on holder-broadcastable
+ * transactions, ie the amount of time that we have to wait to recover our funds if we
+ * broadcast a transaction.
+ * Will panic if ready_channel wasn't called.
+ */
public counterparty_selected_contest_delay(): number {
const ret: number = bindings.InMemorySigner_counterparty_selected_contest_delay(this.ptr);
return ret;
}
+ /**
+ * The contest_delay value specified by us and applied on transactions broadcastable
+ * by our counterparty, ie the amount of time that they have to wait to recover their funds
+ * if they broadcast a transaction.
+ * Will panic if ready_channel wasn't called.
+ */
public holder_selected_contest_delay(): number {
const ret: number = bindings.InMemorySigner_holder_selected_contest_delay(this.ptr);
return ret;
}
+ /**
+ * Whether the holder is the initiator
+ * Will panic if ready_channel wasn't called.
+ */
public is_outbound(): boolean {
const ret: boolean = bindings.InMemorySigner_is_outbound(this.ptr);
return ret;
}
+ /**
+ * Funding outpoint
+ * Will panic if ready_channel wasn't called.
+ */
public funding_outpoint(): OutPoint {
const ret: number = bindings.InMemorySigner_funding_outpoint(this.ptr);
const ret_hu_conv: OutPoint = new OutPoint(null, ret);
return ret_hu_conv;
}
+ /**
+ * Obtain a ChannelTransactionParameters for this channel, to be used when verifying or
+ * building transactions.
+ *
+ * Will panic if ready_channel wasn't called.
+ */
public get_channel_parameters(): ChannelTransactionParameters {
const ret: number = bindings.InMemorySigner_get_channel_parameters(this.ptr);
const ret_hu_conv: ChannelTransactionParameters = new ChannelTransactionParameters(null, ret);
return ret_hu_conv;
}
+ /**
+ * Whether anchors should be used.
+ * Will panic if ready_channel wasn't called.
+ */
public opt_anchors(): boolean {
const ret: boolean = bindings.InMemorySigner_opt_anchors(this.ptr);
return ret;
}
+ /**
+ * Sign the single input of spend_tx at index `input_idx` which spends the output
+ * described by descriptor, returning the witness stack for the input.
+ *
+ * Returns an Err if the input at input_idx does not exist, has a non-empty script_sig,
+ * or is not spending the outpoint described by `descriptor.outpoint`.
+ */
public sign_counterparty_payment_input(spend_tx: Uint8Array, input_idx: number, descriptor: StaticPaymentOutputDescriptor): Result_CVec_CVec_u8ZZNoneZ {
const ret: number = bindings.InMemorySigner_sign_counterparty_payment_input(this.ptr, bindings.encodeUint8Array(spend_tx), input_idx, descriptor == null ? 0 : CommonBase.get_ptr_of(descriptor) & ~1);
const ret_hu_conv: Result_CVec_CVec_u8ZZNoneZ = Result_CVec_CVec_u8ZZNoneZ.constr_from_ptr(ret);
return ret_hu_conv;
}
+ /**
+ * Sign the single input of spend_tx at index `input_idx` which spends the output
+ * described by descriptor, returning the witness stack for the input.
+ *
+ * Returns an Err if the input at input_idx does not exist, has a non-empty script_sig,
+ * is not spending the outpoint described by `descriptor.outpoint`, or does not have a
+ * sequence set to `descriptor.to_self_delay`.
+ */
public sign_dynamic_p2wsh_input(spend_tx: Uint8Array, input_idx: number, descriptor: DelayedPaymentOutputDescriptor): Result_CVec_CVec_u8ZZNoneZ {
const ret: number = bindings.InMemorySigner_sign_dynamic_p2wsh_input(this.ptr, bindings.encodeUint8Array(spend_tx), input_idx, descriptor == null ? 0 : CommonBase.get_ptr_of(descriptor) & ~1);
const ret_hu_conv: Result_CVec_CVec_u8ZZNoneZ = Result_CVec_CVec_u8ZZNoneZ.constr_from_ptr(ret);
return ret_hu_conv;
}
+ /**
+ * Constructs a new BaseSign which calls the relevant methods on this_arg.
+ * This copies the `inner` pointer in this_arg and thus the returned BaseSign must be freed before this_arg is
+ */
public as_BaseSign(): BaseSign {
const ret: number = bindings.InMemorySigner_as_BaseSign(this.ptr);
const ret_hu_conv: BaseSign = new BaseSign(null, ret);
return ret_hu_conv;
}
+ /**
+ * Constructs a new Sign which calls the relevant methods on this_arg.
+ * This copies the `inner` pointer in this_arg and thus the returned Sign must be freed before this_arg is
+ */
public as_Sign(): Sign {
const ret: number = bindings.InMemorySigner_as_Sign(this.ptr);
const ret_hu_conv: Sign = new Sign(null, ret);
return ret_hu_conv;
}
+ /**
+ * Serialize the InMemorySigner object into a byte array which can be read by InMemorySigner_read
+ */
public write(): Uint8Array {
const ret: number = bindings.InMemorySigner_write(this.ptr);
const ret_conv: Uint8Array = bindings.decodeUint8Array(ret);
return ret_conv;
}
+ /**
+ * Read a InMemorySigner from a byte array, created by InMemorySigner_write
+ */
public static constructor_read(ser: Uint8Array): Result_InMemorySignerDecodeErrorZ {
const ret: number = bindings.InMemorySigner_read(bindings.encodeUint8Array(ser));
const ret_hu_conv: Result_InMemorySignerDecodeErrorZ = Result_InMemorySignerDecodeErrorZ.constr_from_ptr(ret);