lint: no implicit casting.
This commit is contained in:
parent
6ba8eb9951
commit
88ef28d837
@ -52,7 +52,7 @@
|
|||||||
"no-extra-semi": "off",
|
"no-extra-semi": "off",
|
||||||
"no-fallthrough": "off",
|
"no-fallthrough": "off",
|
||||||
"no-func-assign": "off",
|
"no-func-assign": "off",
|
||||||
"no-implicit-coercion": "off",
|
"no-implicit-coercion": "error",
|
||||||
"no-multi-assign": "error",
|
"no-multi-assign": "error",
|
||||||
"no-multiple-empty-lines": ["error", {
|
"no-multiple-empty-lines": ["error", {
|
||||||
"max": 1
|
"max": 1
|
||||||
|
|||||||
4
bin/cli
4
bin/cli
@ -173,7 +173,7 @@ CLI.prototype.getBlock = async function getBlock() {
|
|||||||
let hash = this.config.str(0);
|
let hash = this.config.str(0);
|
||||||
|
|
||||||
if (hash.length !== 64)
|
if (hash.length !== 64)
|
||||||
hash = +hash;
|
hash = parseInt(hash, 10);
|
||||||
|
|
||||||
const block = await this.client.getBlock(hash);
|
const block = await this.client.getBlock(hash);
|
||||||
|
|
||||||
@ -386,7 +386,7 @@ CLI.prototype.reset = async function reset() {
|
|||||||
let hash = this.config.str(0);
|
let hash = this.config.str(0);
|
||||||
|
|
||||||
if (hash.length !== 64)
|
if (hash.length !== 64)
|
||||||
hash = +hash;
|
hash = parseInt(hash, 10);
|
||||||
|
|
||||||
await this.client.reset(hash);
|
await this.client.reset(hash);
|
||||||
|
|
||||||
|
|||||||
@ -49,7 +49,7 @@ const layout = {
|
|||||||
vv: function vv(key) {
|
vv: function vv(key) {
|
||||||
assert(typeof key === 'string');
|
assert(typeof key === 'string');
|
||||||
assert(key.length === 36);
|
assert(key.length === 36);
|
||||||
return [+key.slice(1, 4), key.slice(4, 36)];
|
return [parseInt(key.slice(1, 4), 10), key.slice(4, 36)];
|
||||||
},
|
},
|
||||||
T: function T(addr, hash) {
|
T: function T(addr, hash) {
|
||||||
addr = hex(addr);
|
addr = hex(addr);
|
||||||
@ -80,10 +80,10 @@ const layout = {
|
|||||||
let hash, index;
|
let hash, index;
|
||||||
if (key.length === 139) {
|
if (key.length === 139) {
|
||||||
hash = key.slice(65, 129);
|
hash = key.slice(65, 129);
|
||||||
index = +key.slice(129);
|
index = parseInt(key.slice(129), 10);
|
||||||
} else if (key.length === 115) {
|
} else if (key.length === 115) {
|
||||||
hash = key.slice(41, 105);
|
hash = key.slice(41, 105);
|
||||||
index = +key.slice(105);
|
index = parseInt(key.slice(105), 10);
|
||||||
} else {
|
} else {
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -365,7 +365,7 @@ Amount.serialize = function serialize(value, exp, num) {
|
|||||||
result = '-' + result;
|
result = '-' + result;
|
||||||
|
|
||||||
if (num)
|
if (num)
|
||||||
return +result;
|
return Number(result);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
@ -385,7 +385,7 @@ Amount.serializeUnsafe = function serializeUnsafe(value, exp, num) {
|
|||||||
value = value.toFixed(exp);
|
value = value.toFixed(exp);
|
||||||
|
|
||||||
if (num)
|
if (num)
|
||||||
return +value;
|
return Number(value);
|
||||||
|
|
||||||
if (exp !== 0) {
|
if (exp !== 0) {
|
||||||
value = value.replace(/0+$/, '');
|
value = value.replace(/0+$/, '');
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
let native;
|
let native;
|
||||||
|
|
||||||
if (+process.env.BCOIN_NO_SECP256K1 !== 1) {
|
if (Number(process.env.BCOIN_NO_SECP256K1) !== 1) {
|
||||||
try {
|
try {
|
||||||
native = require('secp256k1/bindings');
|
native = require('secp256k1/bindings');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@ -1495,7 +1495,7 @@ Response.prototype.send = function send(code, msg, type) {
|
|||||||
|
|
||||||
if (typeof msg === 'string') {
|
if (typeof msg === 'string') {
|
||||||
const len = Buffer.byteLength(msg, 'utf8');
|
const len = Buffer.byteLength(msg, 'utf8');
|
||||||
this.setHeader('Content-Length', len + '');
|
this.setHeader('Content-Length', len.toString(10));
|
||||||
try {
|
try {
|
||||||
this.write(msg, 'utf8');
|
this.write(msg, 'utf8');
|
||||||
this.end();
|
this.end();
|
||||||
@ -1506,7 +1506,7 @@ Response.prototype.send = function send(code, msg, type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Buffer.isBuffer(msg)) {
|
if (Buffer.isBuffer(msg)) {
|
||||||
this.setHeader('Content-Length', msg.length + '');
|
this.setHeader('Content-Length', msg.length.toString(10));
|
||||||
try {
|
try {
|
||||||
this.write(msg);
|
this.write(msg);
|
||||||
this.end();
|
this.end();
|
||||||
|
|||||||
@ -234,7 +234,7 @@ RequestOptions.prototype.getHeaders = function getHeaders() {
|
|||||||
headers['Content-Type'] = getType(this.type);
|
headers['Content-Type'] = getType(this.type);
|
||||||
|
|
||||||
if (this.body)
|
if (this.body)
|
||||||
headers['Content-Length'] = this.body.length + '';
|
headers['Content-Length'] = this.body.length.toString(10);
|
||||||
|
|
||||||
if (this.auth) {
|
if (this.auth) {
|
||||||
const auth = `${this.auth.username}:${this.auth.password}`;
|
const auth = `${this.auth.username}:${this.auth.password}`;
|
||||||
|
|||||||
@ -2184,7 +2184,7 @@ RPC.prototype.handleLongpoll = async function handleLongpoll(lpid) {
|
|||||||
throw new RPCError(errs.INVALID_PARAMETER, 'Invalid longpoll ID.');
|
throw new RPCError(errs.INVALID_PARAMETER, 'Invalid longpoll ID.');
|
||||||
|
|
||||||
const watched = lpid.slice(0, 64);
|
const watched = lpid.slice(0, 64);
|
||||||
const lastTX = +lpid.slice(64, 74);
|
const lastTX = parseInt(lpid.slice(64, 74), 10);
|
||||||
|
|
||||||
if (!util.isHex(watched) || !util.isUInt32(lastTX))
|
if (!util.isHex(watched) || !util.isUInt32(lastTX))
|
||||||
throw new RPCError(errs.INVALID_PARAMETER, 'Invalid longpoll ID.');
|
throw new RPCError(errs.INVALID_PARAMETER, 'Invalid longpoll ID.');
|
||||||
@ -2450,7 +2450,7 @@ RPC.prototype.getHashRate = async function getHashRate(lookup, height) {
|
|||||||
|
|
||||||
const workDiff = tip.chainwork.sub(entry.chainwork);
|
const workDiff = tip.chainwork.sub(entry.chainwork);
|
||||||
const timeDiff = maxTime - minTime;
|
const timeDiff = maxTime - minTime;
|
||||||
const ps = +workDiff.toString(10) / timeDiff;
|
const ps = parseInt(workDiff.toString(10), 10) / timeDiff;
|
||||||
|
|
||||||
return ps;
|
return ps;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -86,7 +86,7 @@ function RPCError(msg, code) {
|
|||||||
Error.call(this);
|
Error.call(this);
|
||||||
|
|
||||||
this.type = 'RPCError';
|
this.type = 'RPCError';
|
||||||
this.message = msg + '';
|
this.message = String(msg);
|
||||||
this.code = code >>> 0;
|
this.code = code >>> 0;
|
||||||
|
|
||||||
if (Error.captureStackTrace)
|
if (Error.captureStackTrace)
|
||||||
|
|||||||
@ -262,7 +262,7 @@ HTTPServer.prototype.initRouter = function initRouter() {
|
|||||||
if (hash.length === 64)
|
if (hash.length === 64)
|
||||||
hash = util.revHex(hash);
|
hash = util.revHex(hash);
|
||||||
else
|
else
|
||||||
hash = +hash;
|
hash = parseInt(hash, 10);
|
||||||
|
|
||||||
const block = await this.chain.db.getBlock(hash);
|
const block = await this.chain.db.getBlock(hash);
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
exports.binding = null;
|
exports.binding = null;
|
||||||
|
|
||||||
if (+process.env.BCOIN_NO_NATIVE !== 1) {
|
if (Number(process.env.BCOIN_NO_NATIVE) !== 1) {
|
||||||
try {
|
try {
|
||||||
exports.binding = require('bcoin-native');
|
exports.binding = require('bcoin-native');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@ -1536,7 +1536,7 @@ RejectPacket.prototype.getCode = function getCode() {
|
|||||||
const code = RejectPacket.codesByVal[this.code];
|
const code = RejectPacket.codesByVal[this.code];
|
||||||
|
|
||||||
if (!code)
|
if (!code)
|
||||||
return this.code + '';
|
return this.code.toString(10);
|
||||||
|
|
||||||
return code.toLowerCase();
|
return code.toLowerCase();
|
||||||
};
|
};
|
||||||
|
|||||||
@ -374,7 +374,7 @@ UPNPService.prototype.soapRequest = async function soapRequest(action, args) {
|
|||||||
expect: 'xml',
|
expect: 'xml',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'text/xml; charset="utf-8"',
|
'Content-Type': 'text/xml; charset="utf-8"',
|
||||||
'Content-Length': Buffer.byteLength(req, 'utf8') + '',
|
'Content-Length': Buffer.byteLength(req, 'utf8').toString(10),
|
||||||
'Connection': 'close',
|
'Connection': 'close',
|
||||||
'SOAPAction': JSON.stringify(`${type}#${action}`)
|
'SOAPAction': JSON.stringify(`${type}#${action}`)
|
||||||
},
|
},
|
||||||
@ -683,7 +683,7 @@ function findError(el) {
|
|||||||
const ccode = child.find('errorCode');
|
const ccode = child.find('errorCode');
|
||||||
|
|
||||||
if (ccode && /^\d+$/.test(ccode.text))
|
if (ccode && /^\d+$/.test(ccode.text))
|
||||||
code = +ccode.text;
|
code = parseInt(ccode.text, 10);
|
||||||
|
|
||||||
let desc = 'Unknown';
|
let desc = 'Unknown';
|
||||||
const cdesc = child.find('errorDescription');
|
const cdesc = child.find('errorDescription');
|
||||||
|
|||||||
@ -45,7 +45,7 @@ function Logger(options) {
|
|||||||
* @const {Boolean}
|
* @const {Boolean}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Logger.HAS_TTY = !!(process.stdout && process.stdout.isTTY);
|
Logger.HAS_TTY = Boolean(process.stdout && process.stdout.isTTY);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maximum file size.
|
* Maximum file size.
|
||||||
@ -625,7 +625,7 @@ Logger.prototype.logError = function logError(level, module, err) {
|
|||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
let msg = (err.message + '').replace(/^ *Error: */, '');
|
let msg = String(err.message).replace(/^ *Error: */, '');
|
||||||
|
|
||||||
if (level !== Logger.levels.ERROR)
|
if (level !== Logger.levels.ERROR)
|
||||||
msg = `Error: ${msg}`;
|
msg = `Error: ${msg}`;
|
||||||
|
|||||||
@ -72,7 +72,7 @@ AbstractBlock.prototype.parseOptions = function parseOptions(options) {
|
|||||||
this.nonce = options.nonce;
|
this.nonce = options.nonce;
|
||||||
|
|
||||||
if (options.mutable != null)
|
if (options.mutable != null)
|
||||||
this.mutable = !!options.mutable;
|
this.mutable = Boolean(options.mutable);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -163,7 +163,7 @@ Coin.prototype.toKey = function toKey() {
|
|||||||
Coin.prototype.fromKey = function fromKey(key) {
|
Coin.prototype.fromKey = function fromKey(key) {
|
||||||
assert(key.length > 64);
|
assert(key.length > 64);
|
||||||
this.hash = key.slice(0, 64);
|
this.hash = key.slice(0, 64);
|
||||||
this.index = +key.slice(64);
|
this.index = parseInt(key.slice(64), 10);
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -110,7 +110,7 @@ Outpoint.prototype.toKey = function toKey() {
|
|||||||
Outpoint.prototype.fromKey = function fromKey(key) {
|
Outpoint.prototype.fromKey = function fromKey(key) {
|
||||||
assert(key.length > 64);
|
assert(key.length > 64);
|
||||||
this.hash = key.slice(0, 64);
|
this.hash = key.slice(0, 64);
|
||||||
this.index = +key.slice(64);
|
this.index = parseInt(key.slice(64), 10);
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -100,7 +100,7 @@ Network.prototype._init = function _init() {
|
|||||||
|
|
||||||
for (const key of Object.keys(this.checkpointMap)) {
|
for (const key of Object.keys(this.checkpointMap)) {
|
||||||
const hash = this.checkpointMap[key];
|
const hash = this.checkpointMap[key];
|
||||||
const height = +key;
|
const height = Number(key);
|
||||||
|
|
||||||
this.checkpoints.push({ hash: hash, height: height });
|
this.checkpoints.push({ hash: hash, height: height });
|
||||||
}
|
}
|
||||||
|
|||||||
@ -115,7 +115,7 @@ LRU.prototype.set = function set(key, value) {
|
|||||||
if (this.capacity === 0)
|
if (this.capacity === 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
key = key + '';
|
key = String(key);
|
||||||
|
|
||||||
let item = this.map.get(key);
|
let item = this.map.get(key);
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ LRU.prototype.get = function get(key) {
|
|||||||
if (this.capacity === 0)
|
if (this.capacity === 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
key = key + '';
|
key = String(key);
|
||||||
|
|
||||||
const item = this.map.get(key);
|
const item = this.map.get(key);
|
||||||
|
|
||||||
@ -173,7 +173,7 @@ LRU.prototype.get = function get(key) {
|
|||||||
LRU.prototype.has = function has(key) {
|
LRU.prototype.has = function has(key) {
|
||||||
if (this.capacity === 0)
|
if (this.capacity === 0)
|
||||||
return false;
|
return false;
|
||||||
return this.map.has(key + '');
|
return this.map.has(String(key));
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -186,7 +186,7 @@ LRU.prototype.remove = function remove(key) {
|
|||||||
if (this.capacity === 0)
|
if (this.capacity === 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
key = key + '';
|
key = String(key);
|
||||||
|
|
||||||
const item = this.map.get(key);
|
const item = this.map.get(key);
|
||||||
|
|
||||||
|
|||||||
@ -315,7 +315,7 @@ util.fmt = nodeUtil.format;
|
|||||||
util.format = function format(args, color) {
|
util.format = function format(args, color) {
|
||||||
if (args.length > 0 && args[0] && typeof args[0] === 'object') {
|
if (args.length > 0 && args[0] && typeof args[0] === 'object') {
|
||||||
if (color == null)
|
if (color == null)
|
||||||
color = !!(process.stdout && process.stdout.isTTY);
|
color = Boolean(process.stdout && process.stdout.isTTY);
|
||||||
return util.inspectify(args[0], color);
|
return util.inspectify(args[0], color);
|
||||||
}
|
}
|
||||||
return util.fmt(...args);
|
return util.fmt(...args);
|
||||||
@ -540,7 +540,7 @@ util.pad8 = function pad8(num) {
|
|||||||
assert(typeof num === 'number');
|
assert(typeof num === 'number');
|
||||||
assert(num >= 0);
|
assert(num >= 0);
|
||||||
|
|
||||||
num = num + '';
|
num = num.toString(10);
|
||||||
|
|
||||||
switch (num.length) {
|
switch (num.length) {
|
||||||
case 1:
|
case 1:
|
||||||
@ -565,7 +565,7 @@ util.pad32 = function pad32(num) {
|
|||||||
assert(typeof num === 'number');
|
assert(typeof num === 'number');
|
||||||
assert(num >= 0);
|
assert(num >= 0);
|
||||||
|
|
||||||
num = num + '';
|
num = num.toString(10);
|
||||||
|
|
||||||
switch (num.length) {
|
switch (num.length) {
|
||||||
case 1:
|
case 1:
|
||||||
|
|||||||
@ -187,7 +187,7 @@ Account.prototype.fromOptions = function fromOptions(options) {
|
|||||||
this.type = Account.types.MULTISIG;
|
this.type = Account.types.MULTISIG;
|
||||||
|
|
||||||
if (!this.name)
|
if (!this.name)
|
||||||
this.name = this.accountIndex + '';
|
this.name = this.accountIndex.toString(10);
|
||||||
|
|
||||||
if (this.m < 1 || this.m > this.n)
|
if (this.m < 1 || this.m > this.n)
|
||||||
throw new Error('m ranges between 1 and n');
|
throw new Error('m ranges between 1 and n');
|
||||||
|
|||||||
@ -42,7 +42,7 @@ layouts.walletdb = {
|
|||||||
},
|
},
|
||||||
ww: function ww(key) {
|
ww: function ww(key) {
|
||||||
assert(typeof key === 'string');
|
assert(typeof key === 'string');
|
||||||
return +key.slice(1);
|
return parseInt(key.slice(1), 10);
|
||||||
},
|
},
|
||||||
l: function l(id) {
|
l: function l(id) {
|
||||||
assert(typeof id === 'string');
|
assert(typeof id === 'string');
|
||||||
@ -61,7 +61,7 @@ layouts.walletdb = {
|
|||||||
},
|
},
|
||||||
ii: function ii(key) {
|
ii: function ii(key) {
|
||||||
assert(typeof key === 'string');
|
assert(typeof key === 'string');
|
||||||
return [+key.slice(1, 11), key.slice(11)];
|
return [parseInt(key.slice(1, 11), 10), key.slice(11)];
|
||||||
},
|
},
|
||||||
n: function n(wid, index) {
|
n: function n(wid, index) {
|
||||||
return 'n' + pad32(wid) + pad32(index);
|
return 'n' + pad32(wid) + pad32(index);
|
||||||
@ -75,14 +75,14 @@ layouts.walletdb = {
|
|||||||
},
|
},
|
||||||
bb: function bb(key) {
|
bb: function bb(key) {
|
||||||
assert(typeof key === 'string');
|
assert(typeof key === 'string');
|
||||||
return +key.slice(1);
|
return parseInt(key.slice(1), 10);
|
||||||
},
|
},
|
||||||
o: function o(hash, index) {
|
o: function o(hash, index) {
|
||||||
assert(typeof hash === 'string');
|
assert(typeof hash === 'string');
|
||||||
return 'o' + hash + pad32(index);
|
return 'o' + hash + pad32(index);
|
||||||
},
|
},
|
||||||
oo: function oo(key) {
|
oo: function oo(key) {
|
||||||
return [key.slice(1, 65), +key.slice(65)];
|
return [key.slice(1, 65), parseInt(key.slice(65), 10)];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ layouts.txdb = {
|
|||||||
},
|
},
|
||||||
pre: function pre(key) {
|
pre: function pre(key) {
|
||||||
assert(typeof key === 'string');
|
assert(typeof key === 'string');
|
||||||
return +key.slice(1, 11);
|
return parseInt(key.slice(1, 11), 10);
|
||||||
},
|
},
|
||||||
R: 'R',
|
R: 'R',
|
||||||
hi: function hi(ch, hash, index) {
|
hi: function hi(ch, hash, index) {
|
||||||
@ -104,7 +104,7 @@ layouts.txdb = {
|
|||||||
hii: function hii(key) {
|
hii: function hii(key) {
|
||||||
assert(typeof key === 'string');
|
assert(typeof key === 'string');
|
||||||
key = key.slice(12);
|
key = key.slice(12);
|
||||||
return [key.slice(0, 64), +key.slice(64)];
|
return [key.slice(0, 64), parseInt(key.slice(64), 10)];
|
||||||
},
|
},
|
||||||
ih: function ih(ch, index, hash) {
|
ih: function ih(ch, index, hash) {
|
||||||
assert(typeof hash === 'string');
|
assert(typeof hash === 'string');
|
||||||
@ -113,7 +113,7 @@ layouts.txdb = {
|
|||||||
ihh: function ihh(key) {
|
ihh: function ihh(key) {
|
||||||
assert(typeof key === 'string');
|
assert(typeof key === 'string');
|
||||||
key = key.slice(12);
|
key = key.slice(12);
|
||||||
return [+key.slice(0, 10), key.slice(10)];
|
return [parseInt(key.slice(0, 10), 10), key.slice(10)];
|
||||||
},
|
},
|
||||||
iih: function iih(ch, index, num, hash) {
|
iih: function iih(ch, index, num, hash) {
|
||||||
assert(typeof hash === 'string');
|
assert(typeof hash === 'string');
|
||||||
@ -122,7 +122,11 @@ layouts.txdb = {
|
|||||||
iihh: function iihh(key) {
|
iihh: function iihh(key) {
|
||||||
assert(typeof key === 'string');
|
assert(typeof key === 'string');
|
||||||
key = key.slice(12);
|
key = key.slice(12);
|
||||||
return [+key.slice(0, 10), +key.slice(10, 20), key.slice(20)];
|
return [
|
||||||
|
parseInt(key.slice(0, 10), 10),
|
||||||
|
parseInt(key.slice(10, 20), 10),
|
||||||
|
key.slice(20)
|
||||||
|
];
|
||||||
},
|
},
|
||||||
ihi: function ihi(ch, index, hash, num) {
|
ihi: function ihi(ch, index, hash, num) {
|
||||||
assert(typeof hash === 'string');
|
assert(typeof hash === 'string');
|
||||||
@ -131,7 +135,11 @@ layouts.txdb = {
|
|||||||
ihii: function ihii(key) {
|
ihii: function ihii(key) {
|
||||||
assert(typeof key === 'string');
|
assert(typeof key === 'string');
|
||||||
key = key.slice(12);
|
key = key.slice(12);
|
||||||
return [+key.slice(0, 10), key.slice(10, 74), +key.slice(74)];
|
return [
|
||||||
|
parseInt(key.slice(0, 10), 10),
|
||||||
|
key.slice(10, 74),
|
||||||
|
parseInt(key.slice(74), 10)
|
||||||
|
];
|
||||||
},
|
},
|
||||||
ha: function ha(ch, hash) {
|
ha: function ha(ch, hash) {
|
||||||
assert(typeof hash === 'string');
|
assert(typeof hash === 'string');
|
||||||
@ -229,6 +237,6 @@ layouts.txdb = {
|
|||||||
bb: function bb(key) {
|
bb: function bb(key) {
|
||||||
assert(typeof key === 'string');
|
assert(typeof key === 'string');
|
||||||
key = key.slice(12);
|
key = key.slice(12);
|
||||||
return +key.slice(0);
|
return parseInt(key.slice(0), 10);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -671,7 +671,7 @@ Wallet.prototype._createAccount = async function _createAccount(options, passphr
|
|||||||
let name = options.name;
|
let name = options.name;
|
||||||
|
|
||||||
if (!name)
|
if (!name)
|
||||||
name = this.accountDepth + '';
|
name = this.accountDepth.toString(10);
|
||||||
|
|
||||||
if (await this.hasAccount(name))
|
if (await this.hasAccount(name))
|
||||||
throw new Error('Account already exists.');
|
throw new Error('Account already exists.');
|
||||||
|
|||||||
@ -149,9 +149,9 @@ function listenExit(handler) {
|
|||||||
|
|
||||||
const onError = (err) => {
|
const onError = (err) => {
|
||||||
if (err && err.stack)
|
if (err && err.stack)
|
||||||
console.error(err.stack + '');
|
console.error(String(err.stack));
|
||||||
else
|
else
|
||||||
console.error(err + '');
|
console.error(String(err));
|
||||||
|
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -176,8 +176,8 @@ ErrorPacket.prototype.cmd = packetTypes.ERROR;
|
|||||||
ErrorPacket.prototype.getSize = function getSize() {
|
ErrorPacket.prototype.getSize = function getSize() {
|
||||||
let size = 0;
|
let size = 0;
|
||||||
|
|
||||||
size += encoding.sizeVarString(this.error.message + '', 'utf8');
|
size += encoding.sizeVarString(String(this.error.message), 'utf8');
|
||||||
size += encoding.sizeVarString(this.error.stack + '', 'utf8');
|
size += encoding.sizeVarString(String(this.error.stack), 'utf8');
|
||||||
size += encoding.sizeVarString(this.error.type || '', 'utf8');
|
size += encoding.sizeVarString(this.error.type || '', 'utf8');
|
||||||
|
|
||||||
switch (typeof this.error.code) {
|
switch (typeof this.error.code) {
|
||||||
@ -198,8 +198,8 @@ ErrorPacket.prototype.getSize = function getSize() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ErrorPacket.prototype.toWriter = function toWriter(bw) {
|
ErrorPacket.prototype.toWriter = function toWriter(bw) {
|
||||||
bw.writeVarString(this.error.message + '', 'utf8');
|
bw.writeVarString(String(this.error.message), 'utf8');
|
||||||
bw.writeVarString(this.error.stack + '', 'utf8');
|
bw.writeVarString(String(this.error.stack), 'utf8');
|
||||||
bw.writeVarString(this.error.type || '', 'utf8');
|
bw.writeVarString(this.error.type || '', 'utf8');
|
||||||
|
|
||||||
switch (typeof this.error.code) {
|
switch (typeof this.error.code) {
|
||||||
@ -319,7 +319,7 @@ CheckResultPacket.prototype.getSize = function getSize() {
|
|||||||
size += 1;
|
size += 1;
|
||||||
size += encoding.sizeVarString(err.code, 'utf8');
|
size += encoding.sizeVarString(err.code, 'utf8');
|
||||||
size += encoding.sizeVarString(err.message, 'utf8');
|
size += encoding.sizeVarString(err.message, 'utf8');
|
||||||
size += encoding.sizeVarString(err.stack + '', 'utf8');
|
size += encoding.sizeVarString(String(err.stack), 'utf8');
|
||||||
size += 1;
|
size += 1;
|
||||||
size += 4;
|
size += 4;
|
||||||
|
|
||||||
@ -337,7 +337,7 @@ CheckResultPacket.prototype.toWriter = function toWriter(bw) {
|
|||||||
bw.writeU8(1);
|
bw.writeU8(1);
|
||||||
bw.writeVarString(err.code, 'utf8');
|
bw.writeVarString(err.code, 'utf8');
|
||||||
bw.writeVarString(err.message, 'utf8');
|
bw.writeVarString(err.message, 'utf8');
|
||||||
bw.writeVarString(err.stack + '', 'utf8');
|
bw.writeVarString(String(err.stack), 'utf8');
|
||||||
bw.writeU8(err.op === -1 ? 0xff : err.op);
|
bw.writeU8(err.op === -1 ? 0xff : err.op);
|
||||||
bw.writeU32(err.ip === -1 ? 0xffffffff : err.ip);
|
bw.writeU32(err.ip === -1 ? 0xffffffff : err.ip);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -73,7 +73,7 @@ async function updatePathMap() {
|
|||||||
const keys = Object.keys(oldPaths);
|
const keys = Object.keys(oldPaths);
|
||||||
|
|
||||||
for (let i = 0; i < keys.length; i++) {
|
for (let i = 0; i < keys.length; i++) {
|
||||||
keys[i] = +keys[i];
|
keys[i] = Number(keys[i]);
|
||||||
const key = keys[i];
|
const key = keys[i];
|
||||||
const oldPath = oldPaths[key];
|
const oldPath = oldPaths[key];
|
||||||
const path = new Path(oldPath);
|
const path = new Path(oldPath);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user