Merge pull request #191 from coinpunk/remove-crypto-hash-transistions

Remove crypto hash transistions
This commit is contained in:
Wei Lu 2014-05-25 00:16:37 +00:00
commit 05d0baae7c
4 changed files with 3 additions and 10 deletions

View file

@ -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()
}

View file

@ -184,7 +184,7 @@ function isSmallIntOp(opcode) {
}
Script.prototype.getHash = function() {
return crypto.hash160(this.buffer)
return crypto.hash160(new Buffer(this.buffer))
}
/**

View file

@ -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

View file

@ -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')