From d2d368b8cd169516b84deaae0d770f6420836029 Mon Sep 17 00:00:00 2001 From: junderw Date: Mon, 2 Sep 2019 18:41:31 +0900 Subject: [PATCH 1/3] 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 { /** From 893a85e2104b885f9daa2c09473355f34afe87ef Mon Sep 17 00:00:00 2001 From: junderw Date: Mon, 2 Sep 2019 18:47:52 +0900 Subject: [PATCH 2/3] Update CHANGELOG --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37e097f..f0f1e66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 5.1.6 +__fixed__ +- `PsbtOutputExtended` did not support using the address attribute properly. It is now fixed. + # 5.1.5 __added__ - `Psbt` now has `getFee(): number` for use when all inputs are finalized. It returns the satoshi fee of the transaction. Calling getFee, getFeeRate, or extractTransaction will cache these values so if you call one after the other, the second call will return immediately. From bc1a01987be968dd9600a92560f757b4f4c4bf2b Mon Sep 17 00:00:00 2001 From: junderw Date: Mon, 2 Sep 2019 18:47:57 +0900 Subject: [PATCH 3/3] 5.1.6 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index c2966f8..7f92fcd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "bitcoinjs-lib", - "version": "5.1.5", + "version": "5.1.6", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index d701877..81ecd1b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bitcoinjs-lib", - "version": "5.1.5", + "version": "5.1.6", "description": "Client-side Bitcoin JavaScript library", "main": "./src/index.js", "types": "./types/index.d.ts",