diff --git a/lib/bcoin/script.js b/lib/bcoin/script.js index 284cbd3c..8d3ed316 100644 --- a/lib/bcoin/script.js +++ b/lib/bcoin/script.js @@ -25,7 +25,7 @@ script.decode = function decode(s) { // Raw number if (b >= 0x51 && b <= 0x60) { - opcodes.push([ b - 0x50 ]); + opcodes.push(b - 0x50); continue; } @@ -63,8 +63,6 @@ script.encode = function encode(s) { if (Array.isArray(instr)) { if (instr.length === 0) { res.push(0); - } else if (instr.length === 1 && 0 < instr[0] && instr[0] <= 16) { - res.push(0x50 + instr[0]); } else if (1 <= instr.length && instr.length <= 0x4b) { res = res.concat(instr.length, instr); } else if (instr.length <= 0xff) { diff --git a/test/script-test.js b/test/script-test.js index 40b581ed..5ec732ce 100644 --- a/test/script-test.js +++ b/test/script-test.js @@ -24,7 +24,7 @@ describe('Script', function() { }); it('should encode/decode numbers', function() { - var script = [ [], [1], [2], [16] ]; + var script = [ [], 1, 2, 16 ]; var encoded = bcoin.script.encode(script); assert.deepEqual(encoded, [ 0, 0x51, 0x52, 0x60 ]); var decoded = bcoin.script.decode(encoded);