Skip to content

Commit e2dea82

Browse files
authored
Merge pull request #1469 from bitcoinjs/fixPsbt
Fix PsbtOutputExtended address support
2 parents 07a2769 + bc1a019 commit e2dea82

File tree

5 files changed

+26
-6
lines changed

5 files changed

+26
-6
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 5.1.6
2+
__fixed__
3+
- `PsbtOutputExtended` did not support using the address attribute properly. It is now fixed.
4+
15
# 5.1.5
26
__added__
37
- `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.

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bitcoinjs-lib",
3-
"version": "5.1.5",
3+
"version": "5.1.6",
44
"description": "Client-side Bitcoin JavaScript library",
55
"main": "./src/index.js",
66
"types": "./types/index.d.ts",

ts_src/psbt.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
Transaction as ITransaction,
1212
TransactionFromBuffer,
1313
TransactionInput,
14-
TransactionOutput,
1514
} from 'bip174/src/lib/interfaces';
1615
import { checkForInput } from 'bip174/src/lib/utils';
1716
import { toOutputScript } from './address';
@@ -624,7 +623,17 @@ interface PsbtOpts {
624623

625624
interface PsbtInputExtended extends PsbtInput, TransactionInput {}
626625

627-
interface PsbtOutputExtended extends PsbtOutput, TransactionOutput {}
626+
type PsbtOutputExtended = PsbtOutputExtendedAddress | PsbtOutputExtendedScript;
627+
628+
interface PsbtOutputExtendedAddress extends PsbtOutput {
629+
address: string;
630+
value: number;
631+
}
632+
633+
interface PsbtOutputExtendedScript extends PsbtOutput {
634+
script: Buffer;
635+
value: number;
636+
}
628637

629638
interface HDSignerBase {
630639
/**

types/psbt.d.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// <reference types="node" />
22
import { Psbt as PsbtBase } from 'bip174';
3-
import { KeyValue, PsbtGlobalUpdate, PsbtInput, PsbtInputUpdate, PsbtOutput, PsbtOutputUpdate, TransactionInput, TransactionOutput } from 'bip174/src/lib/interfaces';
3+
import { KeyValue, PsbtGlobalUpdate, PsbtInput, PsbtInputUpdate, PsbtOutput, PsbtOutputUpdate, TransactionInput } from 'bip174/src/lib/interfaces';
44
import { Signer, SignerAsync } from './ecpair';
55
import { Network } from './networks';
66
import { Transaction } from './transaction';
@@ -87,7 +87,14 @@ interface PsbtOptsOptional {
8787
}
8888
interface PsbtInputExtended extends PsbtInput, TransactionInput {
8989
}
90-
interface PsbtOutputExtended extends PsbtOutput, TransactionOutput {
90+
declare type PsbtOutputExtended = PsbtOutputExtendedAddress | PsbtOutputExtendedScript;
91+
interface PsbtOutputExtendedAddress extends PsbtOutput {
92+
address: string;
93+
value: number;
94+
}
95+
interface PsbtOutputExtendedScript extends PsbtOutput {
96+
script: Buffer;
97+
value: number;
9198
}
9299
interface HDSignerBase {
93100
/**

0 commit comments

Comments
 (0)