From 6fc3c15c77e01a6f722bbe0b25c3736e646257cc Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sun, 17 Apr 2016 21:16:44 -0700 Subject: [PATCH] minimaldata. --- lib/bcoin/script.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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) {