script: fix undefined error.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
This commit is contained in:
Christopher Jeffrey 2014-05-14 15:08:53 -05:00 committed by Fedor Indutny
parent f737532e83
commit d5f29c37b4
2 changed files with 8 additions and 2 deletions

View File

@ -35,12 +35,12 @@ script.decode = function decode(s) {
opcodes.push(s.slice(i, i + len));
i += 2 + len;
} else if (opcode === 'pushdata2') {
var len = readU16(s, i);
var len = utils.readU16(s, i);
i += 2;
opcodes.push(s.slice(i, i + len));
i += len;
} else if (opcode === 'pushdata4') {
var len = readU32(s, i);
var len = utils.readU32(s, i);
i += 4;
opcodes.push(s.slice(i, i + len));
i += len;

View File

@ -134,6 +134,12 @@ utils.dsha256 = function dsha256(data, enc) {
return utils.sha256(utils.sha256(data, enc));
};
utils.readU16 = function readU16(arr, off) {
if (!off)
off = 0;
return arr[off] | (arr[off + 1] << 8);
};
utils.readU32 = function readU32(arr, off) {
if (!off)
off = 0;