fix tests

This commit is contained in:
Manuel Araoz 2014-11-28 11:45:42 -03:00
parent 98be01b207
commit 94f1afbad7
2 changed files with 29 additions and 30 deletions

20
.jsbeautifyrc Normal file
View File

@ -0,0 +1,20 @@
{
"indent_size": 2,
"indent_char": " ",
"indent_level": 0,
"indent_with_tabs": false,
"preserve_newlines": true,
"max_preserve_newlines": 10,
"jslint_happy": false,
"space_after_anon_function": true,
"brace_style": "collapse",
"keep_array_indentation": false,
"keep_function_indentation": false,
"space_before_conditional": true,
"break_chained_methods": false,
"eval_code": false,
"unescape_strings": false,
"wrap_line_length": 0,
"good-stuff": true
}

View File

@ -169,62 +169,41 @@ Script.prototype.toString = function() {
};
Script.prototype.isOpReturn = function() {
if (this.chunks[0] === Opcode('OP_RETURN').toNumber() &&
return (this.chunks[0] === Opcode('OP_RETURN').toNumber() &&
(this.chunks.length === 1 ||
(this.chunks.length === 2 &&
this.chunks[1].buf &&
this.chunks[1].buf.length <= 40 &&
this.chunks[1].length === this.chunks.len))) {
return true;
} else {
return false;
}
this.chunks[1].length === this.chunks.len)));
};
Script.prototype.isPublicKeyHashOut = function() {
if (this.chunks[0] === Opcode('OP_DUP').toNumber() &&
return this.chunks[0] === Opcode('OP_DUP').toNumber() &&
this.chunks[1] === Opcode('OP_HASH160').toNumber() &&
this.chunks[2].buf &&
this.chunks[3] === Opcode('OP_EQUALVERIFY').toNumber() &&
this.chunks[4] === Opcode('OP_CHECKSIG').toNumber()) {
return true;
} else {
return false;
}
this.chunks[4] === Opcode('OP_CHECKSIG').toNumber();
};
Script.prototype.isPublicKeyHashIn = function() {
if (this.chunks.length === 2 &&
return !!(this.chunks.length === 2 &&
this.chunks[0].buf &&
this.chunks[1].buf) {
return true;
} else {
return false;
}
this.chunks[1].buf);
};
Script.prototype.isScriptHashOut = function() {
if (this.chunks.length === 3 &&
return this.chunks.length === 3 &&
this.chunks[0] === Opcode('OP_HASH160').toNumber() &&
this.chunks[1].buf &&
this.chunks[1].buf.length === 20 &&
this.chunks[2] === Opcode('OP_EQUAL').toNumber()) {
return true;
} else {
return false;
}
this.chunks[2] === Opcode('OP_EQUAL').toNumber();
};
//note that these are frequently indistinguishable from pubkeyhashin
Script.prototype.isScriptHashIn = function() {
var allpush = this.chunks.every(function(chunk) {
return this.chunks.every(function(chunk) {
return Buffer.isBuffer(chunk.buf);
});
if (allpush) {
return true;
} else {
return false;
}
};
Script.prototype.add = function(obj) {