From f545ed1279a5f2834cf879a7ad3e274979e3ed9a Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Sat, 24 May 2014 13:45:52 +1000 Subject: [PATCH 1/2] remove crypto hash transition code --- src/crypto.js | 7 ------- src/script.js | 2 +- test/script.js | 2 +- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/crypto.js b/src/crypto.js index 3e35da0..38dd569 100644 --- a/src/crypto.js +++ b/src/crypto.js @@ -5,7 +5,6 @@ var crypto = require('crypto') var convert = require('./convert') function hash160(buffer) { - if (!Buffer.isBuffer(buffer)) buffer = new Buffer(buffer) // FIXME: transitionary var step1 = sha256(buffer) @@ -16,20 +15,14 @@ function hash160(buffer) { } function hash256(buffer) { - if (!Buffer.isBuffer(buffer)) buffer = new Buffer(buffer) // FIXME: transitionary - return sha256(sha256(buffer)) } function sha1(buffer) { - if (!Buffer.isBuffer(buffer)) buffer = new Buffer(buffer) // FIXME: transitionary - return crypto.createHash('sha1').update(buffer).digest() } function sha256(buffer) { - if (!Buffer.isBuffer(buffer)) buffer = new Buffer(buffer) // FIXME: transitionary - return crypto.createHash('sha256').update(buffer).digest() } diff --git a/src/script.js b/src/script.js index 2e47f7c..24e8e56 100644 --- a/src/script.js +++ b/src/script.js @@ -184,7 +184,7 @@ function isSmallIntOp(opcode) { } Script.prototype.getHash = function() { - return crypto.hash160(this.buffer) + return crypto.hash160(new Buffer(this.buffer)) } /** diff --git a/test/script.js b/test/script.js index 9c18e4b..1de6cbd 100644 --- a/test/script.js +++ b/test/script.js @@ -102,7 +102,7 @@ describe('Script', function() { it('should create valid redeemScript', function() { var redeemScript = Script.createMultisigScriptPubKey(2, pubKeys) - var hash160 = crypto.hash160(redeemScript.buffer) + var hash160 = crypto.hash160(new Buffer(redeemScript.buffer)) var multisigAddress = new Address(hash160, networks.bitcoin.scriptHash) assert.equal(multisigAddress.toString(), '32vYjxBb7pHJJyXgNk8UoK3BdRDxBzny2v') From 4e3cb6762b49101d485e56274a282a0571eba9cc Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Sun, 25 May 2014 09:55:56 +1000 Subject: [PATCH 2/2] fix for hash160 in integration test --- test/integration/p2sh.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/p2sh.js b/test/integration/p2sh.js index 474dd9a..b3708ca 100644 --- a/test/integration/p2sh.js +++ b/test/integration/p2sh.js @@ -28,7 +28,7 @@ describe('p2sh', function() { return eck.pub }) var redeemScript = Script.createMultisigScriptPubKey(2, pubKeys) - var hash160 = crypto.hash160(redeemScript.buffer) + var hash160 = crypto.hash160(new Buffer(redeemScript.buffer)) var multisigAddress = new Address(hash160, networks.testnet.scriptHash) // Check what our target address's starting value is