From 2d4a3b9354ef032b7bc62331409567ba9074c4cd Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Sun, 26 Apr 2020 18:15:06 +0700 Subject: [PATCH] Don't expose witness on Psbt.txInputs --- src/psbt.js | 1 - ts_src/psbt.ts | 8 ++++---- types/psbt.d.ts | 8 ++++---- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/psbt.js b/src/psbt.js index 2fe816a..7b2928e 100644 --- a/src/psbt.js +++ b/src/psbt.js @@ -115,7 +115,6 @@ class Psbt { index: input.index, script: bufferutils_1.cloneBuffer(input.script), sequence: input.sequence, - witness: input.witness.map(buffer => bufferutils_1.cloneBuffer(buffer)), })); } get txOutputs() { diff --git a/ts_src/psbt.ts b/ts_src/psbt.ts index d6fc8ea..da19497 100644 --- a/ts_src/psbt.ts +++ b/ts_src/psbt.ts @@ -11,6 +11,7 @@ import { Transaction as ITransaction, TransactionFromBuffer, TransactionInput, + TransactionOutput, } from 'bip174/src/lib/interfaces'; import { checkForInput } from 'bip174/src/lib/utils'; import { fromOutputScript, toOutputScript } from './address'; @@ -24,7 +25,7 @@ import { import { bitcoin as btcNetwork, Network } from './networks'; import * as payments from './payments'; import * as bscript from './script'; -import { Input, Output, Transaction } from './transaction'; +import { Output, Transaction } from './transaction'; /** * These are the default arguments for a Psbt instance. @@ -145,17 +146,16 @@ export class Psbt { this.setLocktime(locktime); } - get txInputs(): Input[] { + get txInputs(): TransactionInput[] { return this.__CACHE.__TX.ins.map(input => ({ hash: cloneBuffer(input.hash), index: input.index, script: cloneBuffer(input.script), sequence: input.sequence, - witness: input.witness.map(buffer => cloneBuffer(buffer)), })); } - get txOutputs(): Output[] { + get txOutputs(): TransactionOutput[] { return this.__CACHE.__TX.outs.map(output => ({ script: cloneBuffer(output.script), value: output.value, diff --git a/types/psbt.d.ts b/types/psbt.d.ts index 66f7202..0a898d8 100644 --- a/types/psbt.d.ts +++ b/types/psbt.d.ts @@ -1,8 +1,8 @@ import { Psbt as PsbtBase } from 'bip174'; -import { KeyValue, PsbtGlobalUpdate, PsbtInput, PsbtInputUpdate, PsbtOutput, PsbtOutputUpdate, TransactionInput } from 'bip174/src/lib/interfaces'; +import { KeyValue, PsbtGlobalUpdate, PsbtInput, PsbtInputUpdate, PsbtOutput, PsbtOutputUpdate, TransactionInput, TransactionOutput } from 'bip174/src/lib/interfaces'; import { Signer, SignerAsync } from './ecpair'; import { Network } from './networks'; -import { Input, Output, Transaction } from './transaction'; +import { Transaction } from './transaction'; /** * Psbt class can parse and generate a PSBT binary based off of the BIP174. * There are 6 roles that this class fulfills. (Explained in BIP174) @@ -46,8 +46,8 @@ export declare class Psbt { readonly inputCount: number; version: number; locktime: number; - readonly txInputs: Input[]; - readonly txOutputs: Output[]; + readonly txInputs: TransactionInput[]; + readonly txOutputs: TransactionOutput[]; combine(...those: Psbt[]): this; clone(): Psbt; setMaximumFeeRate(satoshiPerByte: number): void;