diff --git a/lib/bcoin/script.js b/lib/bcoin/script.js index 7de5034a..7c1245ab 100644 --- a/lib/bcoin/script.js +++ b/lib/bcoin/script.js @@ -1046,6 +1046,9 @@ Script.prototype.execute = function execute(stack, flags, tx, index, version) { for (ip = 0; ip < this.code.length; ip++) { op = this.code[ip]; + if (Script.isBadPush(op)) + throw new ScriptError('BAD_OPCODE', op, ip); + if (Buffer.isBuffer(op)) { if (op.length > constants.script.MAX_PUSH) throw new ScriptError('PUSH_SIZE', op, ip); @@ -1979,17 +1982,17 @@ Script.array = function(value) { Script.prototype.removeData = function removeData(data) { var total = 0; - var op = data.op; - var sig, raw, i, a, b; + var op, sig, raw, i, a, b; if (!this.raw) return this.removeDataFast(data); // We need to reserialize // the signature as minimaldata. + op = data.op; delete data.op; - sig = new Script([data]).encode(); - if (op) + sig = Script.encode([data]); + if (op != null) utils.hidden(data, 'op', op); raw = this.encode();