From ea26a0e70a567f1ccc8a49722a2fac1d35914915 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Thu, 15 Jun 2017 22:33:57 -0700 Subject: [PATCH] tx: minor. --- lib/primitives/tx.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/primitives/tx.js b/lib/primitives/tx.js index 14b6ce53..6b7a3f19 100644 --- a/lib/primitives/tx.js +++ b/lib/primitives/tx.js @@ -735,9 +735,6 @@ TX.prototype.signatureHashV1 = function signatureHashV1(index, prev, value, type TX.prototype.checksig = function checksig(index, prev, value, sig, key, version) { var type, hash; - if (type == null) - type = Script.hashType.ALL; - if (sig.length === 0) return false; @@ -754,6 +751,7 @@ TX.prototype.checksig = function checksig(index, prev, value, sig, key, version) * (in the case of witnesspubkeyhash, this should be the generated * p2pkh script). * @param {Amount} value - Previous output value. + * @param {Buffer} key * @param {SighashType} type * @param {Number} version - Sighash version (0=legacy, 1=segwit). * @returns {Buffer} Signature in DER format. @@ -765,6 +763,9 @@ TX.prototype.signature = function signature(index, prev, value, key, type, versi if (type == null) type = Script.hashType.ALL; + if (version == null) + version = 0; + hash = this.signatureHash(index, prev, value, type, version); sig = ec.sign(hash, key);