From ad2071d50c45b56a927a471670cf3da37956d4ee Mon Sep 17 00:00:00 2001 From: Long Li Date: Thu, 10 Oct 2024 11:37:14 +0900 Subject: [PATCH] JS will not provide strings longer than 2^30, so there is no need to throw an exception. Signed-off-by: Long Li --- packages/bitcore-lib/lib/script/script.js | 2 -- packages/bitcore-lib/test/script/script.js | 5 ++++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/bitcore-lib/lib/script/script.js b/packages/bitcore-lib/lib/script/script.js index 4d0ca41c7ea..fe6a213e9ad 100644 --- a/packages/bitcore-lib/lib/script/script.js +++ b/packages/bitcore-lib/lib/script/script.js @@ -167,8 +167,6 @@ Script.fromASM = function(str) { opcodenum=Opcode.OP_PUSHDATA2 }else if(buf.length <= 0x100000000){ opcodenum=Opcode.OP_PUSHDATA4 - }else{ - throw new Error('Pushdata data is too long'); } script.chunks.push({ buf: buf, diff --git a/packages/bitcore-lib/test/script/script.js b/packages/bitcore-lib/test/script/script.js index 1503f345d43..b4371016712 100644 --- a/packages/bitcore-lib/test/script/script.js +++ b/packages/bitcore-lib/test/script/script.js @@ -211,7 +211,8 @@ describe('Script', function() { const data3 = '01'.repeat(0x100+1) const data4 = '01'.repeat(0x10000) const data5 = '01'.repeat(0x10000+1) - var asm = `${data0} ${data1} ${data2} ${data3} ${data4} ${data5}`; + const data6 = '01'.repeat(1) + var asm = `${data0} ${data1} ${data2} ${data3} ${data4} ${data5} ${data6}`; var script = Script.fromASM(asm); script.chunks[0].opcodenum.should.equal(0x4b); script.chunks[1].opcodenum.should.equal(Opcode.OP_PUSHDATA1); @@ -224,6 +225,8 @@ describe('Script', function() { script.chunks[4].len.should.equal(0x10000); script.chunks[5].opcodenum.should.equal(Opcode.OP_PUSHDATA4); script.chunks[5].len.should.equal(0x10000+1); + script.chunks[6].opcodenum.should.equal(1); + script.chunks[6].len.should.equal(1); }); });