Skip to content

Commit b3746ef

Browse files
committed
JS will not provide strings longer than 2^30, so there is no need to throw an exception.
Signed-off-by: Long Li <[email protected]>
1 parent 70427e4 commit b3746ef

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

packages/bitcore-lib/lib/script/script.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,6 @@ Script.fromASM = function(str) {
167167
opcodenum=Opcode.OP_PUSHDATA2
168168
}else if(buf.length <= 0x100000000){
169169
opcodenum=Opcode.OP_PUSHDATA4
170-
}else{
171-
throw new Error('Pushdata data is too long');
172170
}
173171
script.chunks.push({
174172
buf: buf,

packages/bitcore-lib/test/script/script.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ describe('Script', function() {
211211
const data3 = '01'.repeat(0x100+1)
212212
const data4 = '01'.repeat(0x10000)
213213
const data5 = '01'.repeat(0x10000+1)
214-
var asm = `${data0} ${data1} ${data2} ${data3} ${data4} ${data5}`;
214+
const data6 = '01'.repeat(1)
215+
var asm = `${data0} ${data1} ${data2} ${data3} ${data4} ${data5} ${data6}`;
215216
var script = Script.fromASM(asm);
216217
script.chunks[0].opcodenum.should.equal(0x4b);
217218
script.chunks[1].opcodenum.should.equal(Opcode.OP_PUSHDATA1);
@@ -224,6 +225,8 @@ describe('Script', function() {
224225
script.chunks[4].len.should.equal(0x10000);
225226
script.chunks[5].opcodenum.should.equal(Opcode.OP_PUSHDATA4);
226227
script.chunks[5].len.should.equal(0x10000+1);
228+
script.chunks[6].opcodenum.should.equal(1);
229+
script.chunks[6].len.should.equal(1);
227230
});
228231
});
229232

0 commit comments

Comments
 (0)