Merge pull request #1578 from bitcoinjs/psbt-nonstandard-output-fix

Handle non-standard output types in Psbt.txOutputs
This commit is contained in:
Jonathan Underwood 2020-05-29 16:10:05 +09:00 committed by GitHub
commit 9e2a8fe45a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 12 deletions

View file

@ -1,3 +1,7 @@
# 5.1.9
__fixed__
- Fixed errors for psbt.txOutputs getter (#1578)
# 5.1.8 # 5.1.8
__fixed__ __fixed__
- Throw errors when p2wsh or p2wpkh contain uncompressed pubkeys (#1573) - Throw errors when p2wsh or p2wpkh contain uncompressed pubkeys (#1573)

2
package-lock.json generated
View file

@ -1,6 +1,6 @@
{ {
"name": "bitcoinjs-lib", "name": "bitcoinjs-lib",
"version": "5.1.8", "version": "5.1.9",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View file

@ -1,6 +1,6 @@
{ {
"name": "bitcoinjs-lib", "name": "bitcoinjs-lib",
"version": "5.1.8", "version": "5.1.9",
"description": "Client-side Bitcoin JavaScript library", "description": "Client-side Bitcoin JavaScript library",
"main": "./src/index.js", "main": "./src/index.js",
"types": "./types/index.d.ts", "types": "./types/index.d.ts",

View file

@ -117,11 +117,17 @@ class Psbt {
})); }));
} }
get txOutputs() { get txOutputs() {
return this.__CACHE.__TX.outs.map(output => ({ return this.__CACHE.__TX.outs.map(output => {
script: bufferutils_1.cloneBuffer(output.script), let address;
value: output.value, try {
address: address_1.fromOutputScript(output.script, this.opts.network), address = address_1.fromOutputScript(output.script, this.opts.network);
})); } catch (_) {}
return {
script: bufferutils_1.cloneBuffer(output.script),
value: output.value,
address,
};
});
} }
combine(...those) { combine(...those) {
this.data.combine(...those.map(o => o.data)); this.data.combine(...those.map(o => o.data));

View file

@ -155,11 +155,17 @@ export class Psbt {
} }
get txOutputs(): TransactionOutput[] { get txOutputs(): TransactionOutput[] {
return this.__CACHE.__TX.outs.map(output => ({ return this.__CACHE.__TX.outs.map(output => {
script: cloneBuffer(output.script), let address;
value: output.value, try {
address: fromOutputScript(output.script, this.opts.network), address = fromOutputScript(output.script, this.opts.network);
})); } catch (_) {}
return {
script: cloneBuffer(output.script),
value: output.value,
address,
};
});
} }
combine(...those: Psbt[]): this { combine(...those: Psbt[]): this {