From d2d368b8cd169516b84deaae0d770f6420836029 Mon Sep 17 00:00:00 2001 From: junderw Date: Mon, 2 Sep 2019 18:41:31 +0900 Subject: [PATCH] Fix PsbtOutputExtended address support --- ts_src/psbt.ts | 13 +++++++++++-- types/psbt.d.ts | 11 +++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/ts_src/psbt.ts b/ts_src/psbt.ts index 73f7cfc..d35fd4c 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 } from 'bip174/src/lib/utils'; import { toOutputScript } from './address'; @@ -624,7 +623,17 @@ interface PsbtOpts { interface PsbtInputExtended extends PsbtInput, TransactionInput {} -interface PsbtOutputExtended extends PsbtOutput, TransactionOutput {} +type PsbtOutputExtended = PsbtOutputExtendedAddress | PsbtOutputExtendedScript; + +interface PsbtOutputExtendedAddress extends PsbtOutput { + address: string; + value: number; +} + +interface PsbtOutputExtendedScript extends PsbtOutput { + script: Buffer; + value: number; +} interface HDSignerBase { /** diff --git a/types/psbt.d.ts b/types/psbt.d.ts index a0c669d..4db075c 100644 --- a/types/psbt.d.ts +++ b/types/psbt.d.ts @@ -1,6 +1,6 @@ /// 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'; @@ -87,7 +87,14 @@ interface PsbtOptsOptional { } interface PsbtInputExtended extends PsbtInput, TransactionInput { } -interface PsbtOutputExtended extends PsbtOutput, TransactionOutput { +declare type PsbtOutputExtended = PsbtOutputExtendedAddress | PsbtOutputExtendedScript; +interface PsbtOutputExtendedAddress extends PsbtOutput { + address: string; + value: number; +} +interface PsbtOutputExtendedScript extends PsbtOutput { + script: Buffer; + value: number; } interface HDSignerBase { /**