Script: rename toScriptHash to getHash and add tests

This commit is contained in:
Daniel Cousens 2014-05-09 12:56:51 +10:00
parent cace8316e4
commit f8e662e495
3 changed files with 13 additions and 17 deletions

View file

@ -184,19 +184,7 @@ function isSmallIntOp(opcode) {
((opcode >= Opcode.map.OP_1) && (opcode <= Opcode.map.OP_16)))
}
/**
* Returns the address corresponding to this output in hash160 form.
* Assumes strange scripts are P2SH
*/
Script.prototype.toScriptHash = function() {
if(isPubkeyhash.call(this)) {
return this.chunks[2]
}
if(isScripthash.call(this)) {
return crypto.hash160(this.buffer)
}
Script.prototype.getHash = function() {
return crypto.hash160(this.buffer)
}