parent
64e15c8f82
commit
7655ad12c7
@ -25,7 +25,7 @@ script.decode = function decode(s) {
|
|||||||
|
|
||||||
// Raw number
|
// Raw number
|
||||||
if (b >= 0x51 && b <= 0x60) {
|
if (b >= 0x51 && b <= 0x60) {
|
||||||
opcodes.push([ b - 0x50 ]);
|
opcodes.push(b - 0x50);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,8 +63,6 @@ script.encode = function encode(s) {
|
|||||||
if (Array.isArray(instr)) {
|
if (Array.isArray(instr)) {
|
||||||
if (instr.length === 0) {
|
if (instr.length === 0) {
|
||||||
res.push(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) {
|
} else if (1 <= instr.length && instr.length <= 0x4b) {
|
||||||
res = res.concat(instr.length, instr);
|
res = res.concat(instr.length, instr);
|
||||||
} else if (instr.length <= 0xff) {
|
} else if (instr.length <= 0xff) {
|
||||||
|
|||||||
@ -24,7 +24,7 @@ describe('Script', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should encode/decode numbers', function() {
|
it('should encode/decode numbers', function() {
|
||||||
var script = [ [], [1], [2], [16] ];
|
var script = [ [], 1, 2, 16 ];
|
||||||
var encoded = bcoin.script.encode(script);
|
var encoded = bcoin.script.encode(script);
|
||||||
assert.deepEqual(encoded, [ 0, 0x51, 0x52, 0x60 ]);
|
assert.deepEqual(encoded, [ 0, 0x51, 0x52, 0x60 ]);
|
||||||
var decoded = bcoin.script.decode(encoded);
|
var decoded = bcoin.script.decode(encoded);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user