From da49e389c41cb0c0925309b6e3af6a8936aa7d69 Mon Sep 17 00:00:00 2001 From: Thomas Kerin Date: Wed, 6 Sep 2017 14:26:23 +0200 Subject: [PATCH] multisig.input.encodestack - replace OP_0 (permitted by partialSignature) with EMPTY_BUFFER --- src/templates/multisig/input.js | 7 ++++++- src/transaction_builder.js | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/templates/multisig/input.js b/src/templates/multisig/input.js index 79cad91..fbf7a3f 100644 --- a/src/templates/multisig/input.js +++ b/src/templates/multisig/input.js @@ -39,7 +39,12 @@ function encodeStack (signatures, scriptPubKey) { } } - return [].concat(EMPTY_BUFFER, signatures) + return [].concat(EMPTY_BUFFER, signatures.map(function (sig) { + if (sig === OPS.OP_0) { + return EMPTY_BUFFER + } + return sig + })) } function encode (signatures, scriptPubKey) { diff --git a/src/transaction_builder.js b/src/transaction_builder.js index e2a4d86..e6adfd1 100644 --- a/src/transaction_builder.js +++ b/src/transaction_builder.js @@ -389,14 +389,14 @@ function buildStack (type, signatures, pubKeys, allowIncomplete) { } else if (type === scriptTypes.MULTISIG) { if (signatures.length > 0) { signatures = signatures.map(function (signature) { - return signature || Buffer.from('', 'hex') + return signature || ops.OP_0 }) if (!allowIncomplete) { // remove blank signatures - signatures = signatures.filter(function (x) { return x.length !== 0 }) + signatures = signatures.filter(function (x) { return x !== ops.OP_0 }) } - return [].concat(Buffer.from('', 'hex'), signatures) + return bscript.multisig.input.encodeStack(signatures) } } else { throw new Error('Not yet supported')