From 24d541d0ed13afaeaf866f262fc5a7b592b64572 Mon Sep 17 00:00:00 2001 From: junderw Date: Tue, 28 Aug 2018 14:21:18 +0900 Subject: [PATCH] Fix default assignment of validate key for payments Fixes problems with p2ms experienced in issue below. Related: #1194 --- src/payments/embed.js | 2 +- src/payments/p2ms.js | 2 +- src/payments/p2pk.js | 2 +- src/payments/p2pkh.js | 2 +- src/payments/p2sh.js | 2 +- src/payments/p2wpkh.js | 2 +- src/payments/p2wsh.js | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/payments/embed.js b/src/payments/embed.js index c636c80..ea2c8e9 100644 --- a/src/payments/embed.js +++ b/src/payments/embed.js @@ -19,7 +19,7 @@ function p2data (a, opts) { !a.data && !a.output ) throw new TypeError('Not enough data') - opts = opts || { validate: true } + opts = Object.assign({ validate: true }, opts || {}) typef({ network: typef.maybe(typef.Object), diff --git a/src/payments/p2ms.js b/src/payments/p2ms.js index 15de44e..5c90a4d 100644 --- a/src/payments/p2ms.js +++ b/src/payments/p2ms.js @@ -24,7 +24,7 @@ function p2ms (a, opts) { !(a.pubkeys && a.m !== undefined) && !a.signatures ) throw new TypeError('Not enough data') - opts = opts || { validate: true } + opts = Object.assign({ validate: true }, opts || {}) function isAcceptableSignature (x) { return bscript.isCanonicalScriptSignature(x) || (opts.allowIncomplete && (x === OPS.OP_0)) diff --git a/src/payments/p2pk.js b/src/payments/p2pk.js index 4073d52..b930612 100644 --- a/src/payments/p2pk.js +++ b/src/payments/p2pk.js @@ -16,7 +16,7 @@ function p2pk (a, opts) { !a.input && !a.signature ) throw new TypeError('Not enough data') - opts = opts || { validate: true } + opts = Object.assign({ validate: true }, opts || {}) typef({ network: typef.maybe(typef.Object), diff --git a/src/payments/p2pkh.js b/src/payments/p2pkh.js index 0ab9fa0..e9248a2 100644 --- a/src/payments/p2pkh.js +++ b/src/payments/p2pkh.js @@ -18,7 +18,7 @@ function p2pkh (a, opts) { !a.pubkey && !a.input ) throw new TypeError('Not enough data') - opts = opts || { validate: true } + opts = Object.assign({ validate: true }, opts || {}) typef({ network: typef.maybe(typef.Object), diff --git a/src/payments/p2sh.js b/src/payments/p2sh.js index b642154..4741936 100644 --- a/src/payments/p2sh.js +++ b/src/payments/p2sh.js @@ -26,7 +26,7 @@ function p2sh (a, opts) { !a.redeem && !a.input ) throw new TypeError('Not enough data') - opts = opts || { validate: true } + opts = Object.assign({ validate: true }, opts || {}) typef({ network: typef.maybe(typef.Object), diff --git a/src/payments/p2wpkh.js b/src/payments/p2wpkh.js index c47c354..1483bd8 100644 --- a/src/payments/p2wpkh.js +++ b/src/payments/p2wpkh.js @@ -21,7 +21,7 @@ function p2wpkh (a, opts) { !a.pubkey && !a.witness ) throw new TypeError('Not enough data') - opts = opts || { validate: true } + opts = Object.assign({ validate: true }, opts || {}) typef({ address: typef.maybe(typef.String), diff --git a/src/payments/p2wsh.js b/src/payments/p2wsh.js index 8c45022..a26e706 100644 --- a/src/payments/p2wsh.js +++ b/src/payments/p2wsh.js @@ -28,7 +28,7 @@ function p2wsh (a, opts) { !a.redeem && !a.witness ) throw new TypeError('Not enough data') - opts = opts || { validate: true } + opts = Object.assign({ validate: true }, opts || {}) typef({ network: typef.maybe(typef.Object),