Handle non-standard output types in Psbt.txOutputs

This commit is contained in:
Luke Childs 2020-05-29 13:40:53 +07:00 committed by junderw
parent 85ee2a3c5d
commit 48967652ca
No known key found for this signature in database
GPG key ID: B256185D3A971908
3 changed files with 26 additions and 10 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)

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 {