|
@ -137,6 +137,8 @@ Script.prototype.fromString = function(str) { |
|
|
throw new Error('Invalid script'); |
|
|
throw new Error('Invalid script'); |
|
|
} |
|
|
} |
|
|
} else if (opcodenum === Opcode.map.OP_PUSHDATA1 || opcodenum === Opcode.map.OP_PUSHDATA2 || opcodenum === Opcode.map.OP_PUSHDATA4) { |
|
|
} else if (opcodenum === Opcode.map.OP_PUSHDATA1 || opcodenum === Opcode.map.OP_PUSHDATA2 || opcodenum === Opcode.map.OP_PUSHDATA4) { |
|
|
|
|
|
if (tokens[i + 2].slice(0, 2) != '0x') |
|
|
|
|
|
throw new Error('Pushdata data must start with 0x'); |
|
|
this.chunks.push({ |
|
|
this.chunks.push({ |
|
|
buf: new Buffer(tokens[i + 2].slice(2), 'hex'), |
|
|
buf: new Buffer(tokens[i + 2].slice(2), 'hex'), |
|
|
len: parseInt(tokens[i + 1]), |
|
|
len: parseInt(tokens[i + 1]), |
|
@ -171,4 +173,18 @@ Script.prototype.toString = function() { |
|
|
return str.substr(0, str.length - 1); |
|
|
return str.substr(0, str.length - 1); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
Script.prototype.isOpReturn = function() { |
|
|
|
|
|
if (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; |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
module.exports = Script; |
|
|
module.exports = Script; |
|
|