Skip to content

Commit

Permalink
Merge pull request bitcoinjs#1578 from bitcoinjs/psbt-nonstandard-out…
Browse files Browse the repository at this point in the history
…put-fix

Handle non-standard output types in Psbt.txOutputs
  • Loading branch information
junderw authored May 29, 2020
2 parents 85ee2a3 + afba17e commit 9e2a8fe
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 5.1.9
__fixed__
- Fixed errors for psbt.txOutputs getter (#1578)

# 5.1.8
__fixed__
- Throw errors when p2wsh or p2wpkh contain uncompressed pubkeys (#1573)
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bitcoinjs-lib",
"version": "5.1.8",
"version": "5.1.9",
"description": "Client-side Bitcoin JavaScript library",
"main": "./src/index.js",
"types": "./types/index.d.ts",
Expand Down
16 changes: 11 additions & 5 deletions src/psbt.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,17 @@ class Psbt {
}));
}
get txOutputs() {
return this.__CACHE.__TX.outs.map(output => ({
script: bufferutils_1.cloneBuffer(output.script),
value: output.value,
address: address_1.fromOutputScript(output.script, this.opts.network),
}));
return this.__CACHE.__TX.outs.map(output => {
let address;
try {
address = address_1.fromOutputScript(output.script, this.opts.network);
} catch (_) {}
return {
script: bufferutils_1.cloneBuffer(output.script),
value: output.value,
address,
};
});
}
combine(...those) {
this.data.combine(...those.map(o => o.data));
Expand Down
16 changes: 11 additions & 5 deletions ts_src/psbt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,17 @@ export class Psbt {
}

get txOutputs(): TransactionOutput[] {
return this.__CACHE.__TX.outs.map(output => ({
script: cloneBuffer(output.script),
value: output.value,
address: fromOutputScript(output.script, this.opts.network),
}));
return this.__CACHE.__TX.outs.map(output => {
let address;
try {
address = fromOutputScript(output.script, this.opts.network);
} catch (_) {}
return {
script: cloneBuffer(output.script),
value: output.value,
address,
};
});
}

combine(...those: Psbt[]): this {
Expand Down

0 comments on commit 9e2a8fe

Please sign in to comment.