import * as bindings from '../bindings.mjs'
+/**
+ * This class tracks the per-transaction information needed to build a closing transaction and will
+ * actually build it and sign.
+ *
+ * This class can be used inside a signer implementation to generate a signature given the relevant
+ * secret key.
+ */
export class ClosingTransaction extends CommonBase {
/* @internal */
public constructor(_dummy: object, ptr: number) {
return ret;
}
+ /**
+ * Creates a copy of the ClosingTransaction
+ */
public clone(): ClosingTransaction {
const ret: number = bindings.ClosingTransaction_clone(this.ptr);
const ret_hu_conv: ClosingTransaction = new ClosingTransaction(null, ret);
return ret_hu_conv;
}
+ /**
+ * Checks if two ClosingTransactions contain equal inner contents.
+ */
public hash(): bigint {
const ret: bigint = bindings.ClosingTransaction_hash(this.ptr);
return ret;
}
+ /**
+ * Construct an object of the class
+ */
public static constructor_new(to_holder_value_sat: bigint, to_counterparty_value_sat: bigint, to_holder_script: Uint8Array, to_counterparty_script: Uint8Array, funding_outpoint: OutPoint): ClosingTransaction {
const ret: number = bindings.ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, bindings.encodeUint8Array(to_holder_script), bindings.encodeUint8Array(to_counterparty_script), funding_outpoint == null ? 0 : CommonBase.get_ptr_of(funding_outpoint) & ~1);
const ret_hu_conv: ClosingTransaction = new ClosingTransaction(null, ret);
return ret_hu_conv;
}
+ /**
+ * Trust our pre-built transaction.
+ *
+ * Applies a wrapper which allows access to the transaction.
+ *
+ * This should only be used if you fully trust the builder of this object. It should not
+ * be used by an external signer - instead use the verify function.
+ */
public trust(): TrustedClosingTransaction {
const ret: number = bindings.ClosingTransaction_trust(this.ptr);
const ret_hu_conv: TrustedClosingTransaction = new TrustedClosingTransaction(null, ret);
return ret_hu_conv;
}
+ /**
+ * Verify our pre-built transaction.
+ *
+ * Applies a wrapper which allows access to the transaction.
+ *
+ * An external validating signer must call this method before signing
+ * or using the built transaction.
+ */
public verify(funding_outpoint: OutPoint): Result_TrustedClosingTransactionNoneZ {
const ret: number = bindings.ClosingTransaction_verify(this.ptr, funding_outpoint == null ? 0 : CommonBase.get_ptr_of(funding_outpoint) & ~1);
const ret_hu_conv: Result_TrustedClosingTransactionNoneZ = Result_TrustedClosingTransactionNoneZ.constr_from_ptr(ret);
return ret_hu_conv;
}
+ /**
+ * The value to be sent to the holder, or zero if the output will be omitted
+ */
public to_holder_value_sat(): bigint {
const ret: bigint = bindings.ClosingTransaction_to_holder_value_sat(this.ptr);
return ret;
}
+ /**
+ * The value to be sent to the counterparty, or zero if the output will be omitted
+ */
public to_counterparty_value_sat(): bigint {
const ret: bigint = bindings.ClosingTransaction_to_counterparty_value_sat(this.ptr);
return ret;
}
+ /**
+ * The destination of the holder's output
+ */
public to_holder_script(): Uint8Array {
const ret: number = bindings.ClosingTransaction_to_holder_script(this.ptr);
const ret_conv: Uint8Array = bindings.decodeUint8Array(ret);
return ret_conv;
}
+ /**
+ * The destination of the counterparty's output
+ */
public to_counterparty_script(): Uint8Array {
const ret: number = bindings.ClosingTransaction_to_counterparty_script(this.ptr);
const ret_conv: Uint8Array = bindings.decodeUint8Array(ret);