Skip to content

Commit 9e2a8fe

Browse files
authored
Merge pull request #1578 from bitcoinjs/psbt-nonstandard-output-fix
Handle non-standard output types in Psbt.txOutputs
2 parents 85ee2a3 + afba17e commit 9e2a8fe

File tree

5 files changed

+28
-12
lines changed

5 files changed

+28
-12
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.9
2+
__fixed__
3+
- Fixed errors for psbt.txOutputs getter (#1578)
4+
15
# 5.1.8
26
__fixed__
37
- Throw errors when p2wsh or p2wpkh contain uncompressed pubkeys (#1573)

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.8",
3+
"version": "5.1.9",
44
"description": "Client-side Bitcoin JavaScript library",
55
"main": "./src/index.js",
66
"types": "./types/index.d.ts",

src/psbt.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,17 @@ class Psbt {
117117
}));
118118
}
119119
get txOutputs() {
120-
return this.__CACHE.__TX.outs.map(output => ({
121-
script: bufferutils_1.cloneBuffer(output.script),
122-
value: output.value,
123-
address: address_1.fromOutputScript(output.script, this.opts.network),
124-
}));
120+
return this.__CACHE.__TX.outs.map(output => {
121+
let address;
122+
try {
123+
address = address_1.fromOutputScript(output.script, this.opts.network);
124+
} catch (_) {}
125+
return {
126+
script: bufferutils_1.cloneBuffer(output.script),
127+
value: output.value,
128+
address,
129+
};
130+
});
125131
}
126132
combine(...those) {
127133
this.data.combine(...those.map(o => o.data));

ts_src/psbt.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,17 @@ export class Psbt {
155155
}
156156

157157
get txOutputs(): TransactionOutput[] {
158-
return this.__CACHE.__TX.outs.map(output => ({
159-
script: cloneBuffer(output.script),
160-
value: output.value,
161-
address: fromOutputScript(output.script, this.opts.network),
162-
}));
158+
return this.__CACHE.__TX.outs.map(output => {
159+
let address;
160+
try {
161+
address = fromOutputScript(output.script, this.opts.network);
162+
} catch (_) {}
163+
return {
164+
script: cloneBuffer(output.script),
165+
value: output.value,
166+
address,
167+
};
168+
});
163169
}
164170

165171
combine(...those: Psbt[]): this {

0 commit comments

Comments
 (0)