diff --git a/lib/bcoin/script.js b/lib/bcoin/script.js index 8b9db1e7..5d658343 100644 --- a/lib/bcoin/script.js +++ b/lib/bcoin/script.js @@ -3921,6 +3921,18 @@ Script.encode = function encode(code, writer) { if (op.length === 0) { p.writeU8(opcodes.OP_0); } else if (op.length <= 0x4b) { + if (op.length === 1) { + if (op[0] === 0) { + p.writeU8(opcodes.OP_0); + continue; + } else if (op[0] >= 1 && op[0] <= 16) { + p.writeU8(op[0] + 0x50); + continue; + } else if (op[0] === 0xff) { + p.writeU8(opcodes.OP_1NEGATE); + continue; + } + } p.writeU8(op.length); p.writeBytes(op); } else if (op.length <= 0xff) {