fix classify tests

This commit is contained in:
Manuel Araoz 2014-11-28 18:58:39 -03:00
parent 901d55d129
commit ed0fc6298c
1 changed files with 11 additions and 3 deletions

View File

@ -191,7 +191,9 @@ Script.prototype.isPublicKeyHashOut = function() {
Script.prototype.isPublicKeyHashIn = function() {
return !!(this.chunks.length === 2 &&
this.chunks[0].buf &&
this.chunks[1].buf);
this.chunks[0].buf.length === 0x47 &&
this.chunks[1].buf &&
this.chunks[1].buf.length === 0x21);
};
/**
@ -225,6 +227,9 @@ Script.prototype.isScriptHashOut = function() {
* Note that these are frequently indistinguishable from pubkeyhashin
*/
Script.prototype.isScriptHashIn = function() {
if (this.chunks.length === 0) {
return false;
}
var chunk = this.chunks[this.chunks.length - 1];
if (!chunk) {
return false;
@ -233,8 +238,11 @@ Script.prototype.isScriptHashIn = function() {
if (!scriptBuf) {
return false;
}
console.log(this.toString());
var redeemScript = new Script(scriptBuf);
var type = redeemScript.classify();
console.log(redeemScript.toString());
console.log(redeemScript.classify());
return type !== Script.types.UNKNOWN;
};
@ -294,11 +302,11 @@ Script.identifiers.PUBKEY_OUT = Script.prototype.isPublicKeyOut;
Script.identifiers.PUBKEY_IN = Script.prototype.isPublicKeyIn;
Script.identifiers.PUBKEYHASH_OUT = Script.prototype.isPublicKeyHashOut;
Script.identifiers.PUBKEYHASH_IN = Script.prototype.isPublicKeyHashIn;
Script.identifiers.SCRIPTHASH_OUT = Script.prototype.isScriptHashOut;
Script.identifiers.SCRIPTHASH_IN = Script.prototype.isScriptHashIn;
Script.identifiers.MULTISIG_OUT = Script.prototype.isMultisigOut;
Script.identifiers.MULTISIG_IN = Script.prototype.isMultisigIn;
Script.identifiers.OP_RETURN = Script.prototype.isOpReturn;
Script.identifiers.SCRIPTHASH_OUT = Script.prototype.isScriptHashOut;
Script.identifiers.SCRIPTHASH_IN = Script.prototype.isScriptHashIn;
/**
* @returns {object} The Script type if it is a known form,