Skip to content

Commit

Permalink
JS will not provide strings longer than 2^30, so there is no need to …
Browse files Browse the repository at this point in the history
…throw an exception.

Signed-off-by: Long Li <[email protected]>
  • Loading branch information
baryon committed Oct 10, 2024
1 parent 70427e4 commit ad2071d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 0 additions & 2 deletions packages/bitcore-lib/lib/script/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion packages/bitcore-lib/test/script/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
});
});

Expand Down

0 comments on commit ad2071d

Please sign in to comment.