Don't expose witness on Psbt.txInputs

This commit is contained in:
Luke Childs 2020-04-26 18:15:06 +07:00
parent e7345d5446
commit 2d4a3b9354
3 changed files with 8 additions and 9 deletions

View file

@ -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() {

View file

@ -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,

8
types/psbt.d.ts vendored
View file

@ -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;