X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=ldk-java;a=blobdiff_plain;f=ts%2Fstructs%2FClosingTransaction.mts;h=cd5ff8462655763703e5dd2217922664422a80ff;hp=4dd074556a06879a1f30f99998e2b089c4a112d4;hb=c629a01650402c8e2f9b9db8ced9ed63ce687727;hpb=d1d0121c000b713c10fd0bedd249eb8dda2e4db7 diff --git a/ts/structs/ClosingTransaction.mts b/ts/structs/ClosingTransaction.mts index 4dd07455..cd5ff846 100644 --- a/ts/structs/ClosingTransaction.mts +++ b/ts/structs/ClosingTransaction.mts @@ -281,6 +281,13 @@ import CommonBase from './CommonBase.mjs'; 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) { @@ -292,6 +299,9 @@ export class ClosingTransaction extends CommonBase { 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); @@ -299,11 +309,17 @@ export class ClosingTransaction extends CommonBase { 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); @@ -311,6 +327,14 @@ export class ClosingTransaction extends CommonBase { 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); @@ -318,28 +342,48 @@ export class ClosingTransaction extends CommonBase { 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);