diff --git a/ts_src/index.ts b/ts_src/index.ts index 505407f..b9aa49c 100644 --- a/ts_src/index.ts +++ b/ts_src/index.ts @@ -9,7 +9,7 @@ import * as script from './script'; export { ECPair, address, bip32, crypto, networks, payments, script }; export { Block } from './block'; -export { Psbt } from './psbt'; +export { Psbt, PsbtTxInput, PsbtTxOutput } from './psbt'; export { OPS as opcodes } from './script'; export { Transaction } from './transaction'; export { TransactionBuilder } from './transaction_builder'; diff --git a/ts_src/psbt.ts b/ts_src/psbt.ts index 301596a..31d15c7 100644 --- a/ts_src/psbt.ts +++ b/ts_src/psbt.ts @@ -11,7 +11,6 @@ import { Transaction as ITransaction, TransactionFromBuffer, TransactionInput, - TransactionOutput, } from 'bip174/src/lib/interfaces'; import { checkForInput, checkForOutput } from 'bip174/src/lib/utils'; import { fromOutputScript, toOutputScript } from './address'; @@ -27,6 +26,14 @@ import * as payments from './payments'; import * as bscript from './script'; import { Output, Transaction } from './transaction'; +export interface PsbtTxInput extends TransactionInput { + hash: Buffer; +} + +export interface PsbtTxOutput extends Output { + address: string; +} + /** * These are the default arguments for a Psbt instance. */ @@ -146,7 +153,7 @@ export class Psbt { this.setLocktime(locktime); } - get txInputs(): TransactionInput[] { + get txInputs(): PsbtTxInput[] { return this.__CACHE.__TX.ins.map(input => ({ hash: cloneBuffer(input.hash), index: input.index, @@ -154,7 +161,7 @@ export class Psbt { })); } - get txOutputs(): TransactionOutput[] { + get txOutputs(): PsbtTxOutput[] { return this.__CACHE.__TX.outs.map(output => ({ script: cloneBuffer(output.script), value: output.value, diff --git a/types/index.d.ts b/types/index.d.ts index 68da119..c8f2a00 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -7,7 +7,7 @@ import * as payments from './payments'; import * as script from './script'; export { ECPair, address, bip32, crypto, networks, payments, script }; export { Block } from './block'; -export { Psbt } from './psbt'; +export { Psbt, PsbtTxInput, PsbtTxOutput } from './psbt'; export { OPS as opcodes } from './script'; export { Transaction } from './transaction'; export { TransactionBuilder } from './transaction_builder'; diff --git a/types/psbt.d.ts b/types/psbt.d.ts index c47ce74..127ef0f 100644 --- a/types/psbt.d.ts +++ b/types/psbt.d.ts @@ -1,8 +1,14 @@ import { Psbt as PsbtBase } from 'bip174'; -import { KeyValue, PsbtGlobalUpdate, PsbtInput, PsbtInputUpdate, PsbtOutput, PsbtOutputUpdate, TransactionInput, TransactionOutput } from 'bip174/src/lib/interfaces'; +import { KeyValue, PsbtGlobalUpdate, PsbtInput, PsbtInputUpdate, PsbtOutput, PsbtOutputUpdate, TransactionInput } from 'bip174/src/lib/interfaces'; import { Signer, SignerAsync } from './ecpair'; import { Network } from './networks'; -import { Transaction } from './transaction'; +import { Output, Transaction } from './transaction'; +export interface PsbtTxInput extends TransactionInput { + hash: Buffer; +} +export interface PsbtTxOutput extends Output { + address: string; +} /** * 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 +52,8 @@ export declare class Psbt { readonly inputCount: number; version: number; locktime: number; - readonly txInputs: TransactionInput[]; - readonly txOutputs: TransactionOutput[]; + readonly txInputs: PsbtTxInput[]; + readonly txOutputs: PsbtTxOutput[]; combine(...those: Psbt[]): this; clone(): Psbt; setMaximumFeeRate(satoshiPerByte: number): void;