scripts: add falsy classifications and fix multisig

This commit is contained in:
Daniel Cousens 2014-06-26 16:22:29 +10:00
parent 5c53178c3c
commit 759bba5c21
3 changed files with 49 additions and 15 deletions

View file

@ -136,31 +136,30 @@ function isMultisigOutput() {
if (this.chunks < 4) return false
if (this.chunks[this.chunks.length - 1] !== opcodes.OP_CHECKMULTISIG) return false
var mS = this.chunks[0]
if (!isSmallIntOp(mS)) return false
var mOp = this.chunks[0]
if (mOp === opcodes.OP_0) return false
if (mOp < opcodes.OP_1) return false
if (mOp > opcodes.OP_16) return false
var nS = this.chunks[this.chunks.length - 2]
if (!isSmallIntOp(nS)) return false
var nOp = this.chunks[this.chunks.length - 2]
if (nOp === opcodes.OP_0) return false
if (nOp < opcodes.OP_1) return false
if (nOp > opcodes.OP_16) return false
var m = mS - (opcodes.OP_1 - 1)
var n = nS - (opcodes.OP_1 - 1)
var m = mOp - (opcodes.OP_1 - 1)
var n = nOp - (opcodes.OP_1 - 1)
if (n < m) return false
if (n === 0) return false
if (m > (this.chunks.length - 3)) return false
return this.chunks.slice(1, -2).every(isCanonicalPubKey)
var pubKeys = this.chunks.slice(1, -2)
if (n < pubKeys.length) return false
return pubKeys.every(isCanonicalPubKey)
}
function isNulldataOutput() {
return this.chunks[0] === opcodes.OP_RETURN
}
function isSmallIntOp(opcode) {
if (Buffer.isBuffer(opcode)) return false
return ((opcode === opcodes.OP_0) || ((opcode >= opcodes.OP_1) && (opcode <= opcodes.OP_16)))
}
// Standard Script Templates
// {pubKey} OP_CHECKSIG
function pubKeyOutput(pubKey) {