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