diff --git a/.eslintrc.json b/.eslintrc.json index 80a4f000..4b45ace9 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,8 +1,6 @@ { "env": { - "browser": true, "es6": true, - "mocha": true, "node": true }, "extends": "eslint:recommended", diff --git a/bin/cli b/bin/cli index e5d0abaa..661b46c0 100755 --- a/bin/cli +++ b/bin/cli @@ -433,7 +433,7 @@ CLI.prototype.importKey = async function importKey() { throw new Error('Bad key for import.'); }; -CLI.prototype.importAddress = async function importKey() { +CLI.prototype.importAddress = async function importAddress() { const address = this.config.str(0); const account = this.config.str('account'); await this.wallet.importAddress(account, address); diff --git a/lib/bcoin.js b/lib/bcoin.js index b6b37b2d..cb221862 100644 --- a/lib/bcoin.js +++ b/lib/bcoin.js @@ -130,7 +130,7 @@ const bcoin = exports; * @param {String} path */ -bcoin.define = function _require(name, path) { +bcoin.define = function define(name, path) { let cache; bcoin.__defineGetter__(name, function() { if (!cache) diff --git a/lib/blockchain/chain.js b/lib/blockchain/chain.js index 3a4647fd..0ad2dc3d 100644 --- a/lib/blockchain/chain.js +++ b/lib/blockchain/chain.js @@ -96,7 +96,7 @@ util.inherits(Chain, AsyncObject); * @returns {Promise} */ -Chain.prototype._open = async function open() { +Chain.prototype._open = async function _open() { this.logger.info('Chain is loading.'); if (this.options.checkpoints) @@ -141,7 +141,7 @@ Chain.prototype._open = async function open() { * @returns {Promise} */ -Chain.prototype._close = function close() { +Chain.prototype._close = function _close() { return this.db.close(); }; @@ -194,7 +194,7 @@ Chain.prototype.verifyBlock = async function verifyBlock(block) { * @returns {Promise} */ -Chain.prototype._verifyBlock = async function verifyBlock(block) { +Chain.prototype._verifyBlock = async function _verifyBlock(block) { const flags = common.flags.DEFAULT_FLAGS & ~common.flags.VERIFY_POW; return await this.verifyContext(block, this.tip, flags); }; @@ -1078,7 +1078,7 @@ Chain.prototype.reset = async function reset(block) { * @returns {Promise} */ -Chain.prototype._reset = async function reset(block, silent) { +Chain.prototype._reset = async function _reset(block, silent) { const tip = await this.db.reset(block); // Reset state. @@ -1129,7 +1129,7 @@ Chain.prototype.replay = async function replay(block) { * @returns {Promise} */ -Chain.prototype._replay = async function replay(block, silent) { +Chain.prototype._replay = async function _replay(block, silent) { const entry = await this.db.getEntry(block); if (!entry) @@ -1234,7 +1234,7 @@ Chain.prototype.add = async function add(block, flags, id) { * @returns {Promise} */ -Chain.prototype._add = async function add(block, flags, id) { +Chain.prototype._add = async function _add(block, flags, id) { const hash = block.hash('hex'); if (flags == null) @@ -1861,7 +1861,7 @@ Chain.prototype.getLocator = async function getLocator(start) { * @returns {Promise} */ -Chain.prototype._getLocator = async function getLocator(start) { +Chain.prototype._getLocator = async function _getLocator(start) { if (start == null) start = this.tip.hash; diff --git a/lib/blockchain/chaindb.js b/lib/blockchain/chaindb.js index 8dc842fb..f7253772 100644 --- a/lib/blockchain/chaindb.js +++ b/lib/blockchain/chaindb.js @@ -1159,7 +1159,7 @@ ChainDB.prototype.getTXByAddress = async function getTXByAddress(addrs) { * @returns {Promise} - Returns {@link TXMeta}[]. */ -ChainDB.prototype.getMetaByAddress = async function getTXByAddress(addrs) { +ChainDB.prototype.getMetaByAddress = async function getMetaByAddress(addrs) { if (!this.options.indexTX || !this.options.indexAddress) return []; @@ -1299,7 +1299,7 @@ ChainDB.prototype.save = async function save(entry, block, view) { * @returns {Promise} */ -ChainDB.prototype._save = async function save(entry, block, view) { +ChainDB.prototype._save = async function _save(entry, block, view) { const hash = block.hash(); // Hash->height index. @@ -1367,7 +1367,7 @@ ChainDB.prototype.reconnect = async function reconnect(entry, block, view) { * @returns {Promise} */ -ChainDB.prototype._reconnect = async function reconnect(entry, block, view) { +ChainDB.prototype._reconnect = async function _reconnect(entry, block, view) { const hash = block.hash(); assert(!entry.isGenesis()); @@ -1425,7 +1425,7 @@ ChainDB.prototype.disconnect = async function disconnect(entry, block) { * @returns {Promise} - Returns {@link CoinView}. */ -ChainDB.prototype._disconnect = async function disconnect(entry, block) { +ChainDB.prototype._disconnect = async function _disconnect(entry, block) { // Remove hash->next-block index. this.del(layout.n(entry.prevBlock)); @@ -1574,7 +1574,7 @@ ChainDB.prototype.removeChains = async function removeChains() { * @returns {Promise} */ -ChainDB.prototype._removeChain = async function removeChain(hash) { +ChainDB.prototype._removeChain = async function _removeChain(hash) { let tip = await this.getEntry(hash); if (!tip) @@ -2070,7 +2070,7 @@ ChainState.prototype.connect = function connect(block) { this.tx += block.txs.length; }; -ChainState.prototype.disconnect = function connect(block) { +ChainState.prototype.disconnect = function disconnect(block) { this.tx -= block.txs.length; }; diff --git a/lib/blockchain/layout-browser.js b/lib/blockchain/layout-browser.js index e26b4082..7eb90bad 100644 --- a/lib/blockchain/layout-browser.js +++ b/lib/blockchain/layout-browser.js @@ -69,7 +69,7 @@ const layout = { assert(addr.length === 40); return 'C' + addr + hex(hash) + pad32(index); }, - pp: function aa(key) { + pp: function pp(key) { assert(typeof key === 'string'); assert(key.length === 65); return key.slice(1, 65); diff --git a/lib/blockchain/layout.js b/lib/blockchain/layout.js index 677b2fe3..5a232962 100644 --- a/lib/blockchain/layout.js +++ b/lib/blockchain/layout.js @@ -124,7 +124,7 @@ const layout = { return key; }, - pp: function aa(key) { + pp: function pp(key) { assert(Buffer.isBuffer(key)); assert(key.length === 33); return key.toString('hex', 1, 33); diff --git a/lib/crypto/sha256.js b/lib/crypto/sha256.js index 5262faca..9a25ade1 100644 --- a/lib/crypto/sha256.js +++ b/lib/crypto/sha256.js @@ -103,7 +103,7 @@ SHA256.prototype.finish = function finish() { * @param {Number} len */ -SHA256.prototype._update = function update(data, len) { +SHA256.prototype._update = function _update(data, len) { let size = this.bytes & 0x3f; let pos = 0; diff --git a/lib/db/level.js b/lib/db/level.js index de003600..a3010317 100644 --- a/lib/db/level.js +++ b/lib/db/level.js @@ -22,7 +22,7 @@ DB.prototype.get = function get(key, options, callback) { this.level.get(key, options, callback); }; -DB.prototype.put = function get(key, value, options, callback) { +DB.prototype.put = function put(key, value, options, callback) { if (this.bufferKeys && Buffer.isBuffer(key)) key = key.toString('hex'); this.level.put(key, value, options, callback); diff --git a/lib/db/lowlevelup.js b/lib/db/lowlevelup.js index 8c3ec862..d1f2fd93 100644 --- a/lib/db/lowlevelup.js +++ b/lib/db/lowlevelup.js @@ -108,7 +108,7 @@ LowlevelUp.prototype.open = async function open() { * @returns {Promise} */ -LowlevelUp.prototype._open = async function open() { +LowlevelUp.prototype._open = async function _open() { if (this.loaded) throw new Error('Database is already open.'); @@ -150,7 +150,7 @@ LowlevelUp.prototype.close = async function close() { * @returns {Promise} */ -LowlevelUp.prototype._close = async function close() { +LowlevelUp.prototype._close = async function _close() { if (!this.loaded) throw new Error('Database is already closed.'); diff --git a/lib/http/base.js b/lib/http/base.js index b5532e40..011eae98 100644 --- a/lib/http/base.js +++ b/lib/http/base.js @@ -354,15 +354,8 @@ HTTPBase.prototype._readBody = function _readBody(req, enc, options, resolve, re let total = 0; let body = ''; - let timer = setTimeout(() => { - timer = null; - cleanup(); - reject(new Error('Request body timed out.')); - }, options.timeout); - - /* eslint no-use-before-define: "off" */ - const cleanup = () => { + /* eslint-disable */ req.removeListener('data', onData); req.removeListener('error', onError); req.removeListener('end', onEnd); @@ -371,6 +364,7 @@ HTTPBase.prototype._readBody = function _readBody(req, enc, options, resolve, re timer = null; clearTimeout(timer); } + /* eslint-enable */ }; const onData = (data) => { @@ -401,6 +395,12 @@ HTTPBase.prototype._readBody = function _readBody(req, enc, options, resolve, re resolve(null); }; + let timer = setTimeout(() => { + timer = null; + cleanup(); + reject(new Error('Request body timed out.')); + }, options.timeout); + req.on('data', onData); req.on('error', onError); req.on('end', onEnd); @@ -689,7 +689,7 @@ HTTPBase.prototype.channel = function channel(name) { * @returns {Promise} */ -HTTPBase.prototype._open = function open() { +HTTPBase.prototype._open = function _open() { return this.listen(this.config.port, this.config.host); }; @@ -699,7 +699,7 @@ HTTPBase.prototype._open = function open() { * @returns {Promise} */ -HTTPBase.prototype._close = function close() { +HTTPBase.prototype._close = function _close() { return new Promise((resolve, reject) => { if (this.io) { this.server.once('close', resolve); diff --git a/lib/http/client.js b/lib/http/client.js index c5f850dc..48e1e935 100644 --- a/lib/http/client.js +++ b/lib/http/client.js @@ -115,7 +115,7 @@ HTTPClient.prototype._open = async function _open() { * @returns {Promise} */ -HTTPClient.prototype._close = function close() { +HTTPClient.prototype._close = function _close() { if (!this.socket) return Promise.resolve(); diff --git a/lib/http/rpc.js b/lib/http/rpc.js index 2f3aba88..7e1441bb 100644 --- a/lib/http/rpc.js +++ b/lib/http/rpc.js @@ -1597,7 +1597,7 @@ RPC.prototype.generate = async function generate(args, help) { return await this.mineBlocks(blocks, null, tries); }; -RPC.prototype.generateToAddress = async function _generateToAddress(args, help) { +RPC.prototype.generateToAddress = async function generateToAddress(args, help) { if (help || args.length < 2 || args.length > 3) { throw new RPCError(errs.MISC_ERROR, 'generatetoaddress numblocks address ( maxtries )'); diff --git a/lib/mempool/mempool.js b/lib/mempool/mempool.js index 7f82faa1..5f26260b 100644 --- a/lib/mempool/mempool.js +++ b/lib/mempool/mempool.js @@ -104,7 +104,7 @@ util.inherits(Mempool, AsyncObject); * @returns {Promise} */ -Mempool.prototype._open = async function open() { +Mempool.prototype._open = async function _open() { await this.chain.open(); await this.cache.open(); @@ -152,7 +152,7 @@ Mempool.prototype._open = async function open() { * @returns {Promise} */ -Mempool.prototype._close = async function close() { +Mempool.prototype._close = async function _close() { await this.cache.close(); }; @@ -184,7 +184,7 @@ Mempool.prototype.addBlock = async function addBlock(block, txs) { * @returns {Promise} */ -Mempool.prototype._addBlock = async function addBlock(block, txs) { +Mempool.prototype._addBlock = async function _addBlock(block, txs) { if (this.map.size === 0) { this.tip = block.hash; return; @@ -262,7 +262,7 @@ Mempool.prototype.removeBlock = async function removeBlock(block, txs) { * @returns {Promise} */ -Mempool.prototype._removeBlock = async function removeBlock(block, txs) { +Mempool.prototype._removeBlock = async function _removeBlock(block, txs) { if (this.map.size === 0) { this.tip = block.prevBlock; return; @@ -324,7 +324,7 @@ Mempool.prototype.reset = async function reset() { * @private */ -Mempool.prototype._reset = async function reset() { +Mempool.prototype._reset = async function _reset() { this.logger.info('Mempool reset (%d txs removed).', this.map.size); this.size = 0; @@ -1165,7 +1165,7 @@ Mempool.prototype.updateAncestors = function updateAncestors(entry, map) { * @returns {Number} */ -Mempool.prototype._countAncestors = function countAncestors(entry, set, child, map) { +Mempool.prototype._countAncestors = function _countAncestors(entry, set, child, map) { const tx = entry.tx; for (const input of tx.inputs) { @@ -1214,7 +1214,7 @@ Mempool.prototype.countDescendants = function countDescendants(entry) { * @returns {Number} */ -Mempool.prototype._countDescendants = function countDescendants(entry, set) { +Mempool.prototype._countDescendants = function _countDescendants(entry, set) { const tx = entry.tx; const hash = tx.hash('hex'); @@ -1256,7 +1256,7 @@ Mempool.prototype.getAncestors = function getAncestors(entry) { * @returns {MempoolEntry[]} */ -Mempool.prototype._getAncestors = function getAncestors(entry, entries, set) { +Mempool.prototype._getAncestors = function _getAncestors(entry, entries, set) { const tx = entry.tx; for (const input of tx.inputs) { @@ -1296,7 +1296,7 @@ Mempool.prototype.getDescendants = function getDescendants(entry) { * @returns {MempoolEntry[]} */ -Mempool.prototype._getDescendants = function getDescendants(entry, entries, set) { +Mempool.prototype._getDescendants = function _getDescendants(entry, entries, set) { const tx = entry.tx; const hash = tx.hash('hex'); diff --git a/lib/mining/cpuminer.js b/lib/mining/cpuminer.js index 15cd3a7d..0ea901eb 100644 --- a/lib/mining/cpuminer.js +++ b/lib/mining/cpuminer.js @@ -76,7 +76,7 @@ CPUMiner.prototype._init = function _init() { * @returns {Promise} */ -CPUMiner.prototype._open = async function open() { +CPUMiner.prototype._open = async function _open() { }; /** @@ -86,7 +86,7 @@ CPUMiner.prototype._open = async function open() { * @returns {Promise} */ -CPUMiner.prototype._close = async function close() { +CPUMiner.prototype._close = async function _close() { await this.stop(); }; @@ -107,7 +107,7 @@ CPUMiner.prototype.start = function start() { * @returns {Promise} */ -CPUMiner.prototype._start = async function start() { +CPUMiner.prototype._start = async function _start() { assert(!this.running, 'Miner is already running.'); this.running = true; diff --git a/lib/mining/miner.js b/lib/mining/miner.js index 496f4f38..22585274 100644 --- a/lib/mining/miner.js +++ b/lib/mining/miner.js @@ -68,7 +68,7 @@ Miner.prototype.init = function init() { * @returns {Promise} */ -Miner.prototype._open = async function open() { +Miner.prototype._open = async function _open() { await this.chain.open(); if (this.mempool) @@ -90,7 +90,7 @@ Miner.prototype._open = async function open() { * @returns {Promise} */ -Miner.prototype._close = async function close() { +Miner.prototype._close = async function _close() { await this.cpu.close(); }; @@ -120,7 +120,7 @@ Miner.prototype.createBlock = async function createBlock(tip, address) { * @returns {Promise} - Returns {@link BlockTemplate}. */ -Miner.prototype._createBlock = async function createBlock(tip, address) { +Miner.prototype._createBlock = async function _createBlock(tip, address) { let version = this.options.version; if (!tip) diff --git a/lib/net/bip150.js b/lib/net/bip150.js index 469b2cd5..001842ce 100644 --- a/lib/net/bip150.js +++ b/lib/net/bip150.js @@ -407,7 +407,7 @@ BIP150.prototype.wait = function wait(timeout) { * @param {Function} reject */ -BIP150.prototype._wait = function wait(timeout, resolve, reject) { +BIP150.prototype._wait = function _wait(timeout, resolve, reject) { assert(!this.auth, 'Cannot wait for init after handshake.'); this.job = co.job(resolve, reject); diff --git a/lib/net/bip151.js b/lib/net/bip151.js index 22d7139b..50938f1b 100644 --- a/lib/net/bip151.js +++ b/lib/net/bip151.js @@ -527,7 +527,7 @@ BIP151.prototype.wait = function wait(timeout) { * @param {Function} reject */ -BIP151.prototype._wait = function wait(timeout, resolve, reject) { +BIP151.prototype._wait = function _wait(timeout, resolve, reject) { assert(!this.handshake, 'Cannot wait for init after handshake.'); this.job = co.job(resolve, reject); diff --git a/lib/net/hostlist.js b/lib/net/hostlist.js index 15fb9dd2..d7d1029b 100644 --- a/lib/net/hostlist.js +++ b/lib/net/hostlist.js @@ -133,7 +133,7 @@ HostList.scores = { * @private */ -HostList.prototype._init = function init() { +HostList.prototype._init = function _init() { const options = this.options; const scores = HostList.scores; const hosts = IP.getPublic(); diff --git a/lib/net/peer.js b/lib/net/peer.js index 43a9390c..e719286d 100644 --- a/lib/net/peer.js +++ b/lib/net/peer.js @@ -262,7 +262,7 @@ Peer.fromOptions = function fromOptions(options) { * @private */ -Peer.prototype._init = function init() { +Peer.prototype._init = function _init() { this.parser.on('packet', async (packet) => { try { await this.readPacket(packet); @@ -484,7 +484,7 @@ Peer.prototype.open = async function open() { * @returns {Promise} */ -Peer.prototype._open = async function open() { +Peer.prototype._open = async function _open() { this.opened = true; // Connect to peer. @@ -515,13 +515,12 @@ Peer.prototype.initConnect = function initConnect() { } return new Promise((resolve, reject) => { - /* eslint no-use-before-define: "off" */ - const cleanup = () => { if (this.connectTimeout != null) { clearTimeout(this.connectTimeout); this.connectTimeout = null; } + // eslint-disable-next-line no-use-before-define this.socket.removeListener('error', onError); }; @@ -2018,7 +2017,7 @@ Peer.prototype.sendGetHeaders = function sendGetHeaders(locator, stop) { * @param {Hash?} stop - Hash to stop at. */ -Peer.prototype.sendGetBlocks = function getBlocks(locator, stop) { +Peer.prototype.sendGetBlocks = function sendGetBlocks(locator, stop) { const packet = new packets.GetBlocksPacket(locator, stop); let hash = null; diff --git a/lib/net/pool.js b/lib/net/pool.js index 58033f2b..7e258135 100644 --- a/lib/net/pool.js +++ b/lib/net/pool.js @@ -271,7 +271,7 @@ Pool.prototype.resetChain = function resetChain() { * @returns {Promise} */ -Pool.prototype._close = async function close() { +Pool.prototype._close = async function _close() { await this.disconnect(); }; @@ -296,7 +296,7 @@ Pool.prototype.connect = async function connect() { * @returns {Promise} */ -Pool.prototype._connect = async function connect() { +Pool.prototype._connect = async function _connect() { assert(this.loaded, 'Pool is not loaded.'); if (this.connected) @@ -339,7 +339,7 @@ Pool.prototype.disconnect = async function disconnect() { * @returns {Promise} */ -Pool.prototype._disconnect = async function disconnect() { +Pool.prototype._disconnect = async function _disconnect() { assert(this.loaded, 'Pool is not loaded.'); if (!this.connected) @@ -1622,7 +1622,7 @@ Pool.prototype.handleInv = async function handleInv(peer, packet) { * @param {InvPacket} packet */ -Pool.prototype._handleInv = async function handleInv(peer, packet) { +Pool.prototype._handleInv = async function _handleInv(peer, packet) { const items = packet.items; if (items.length > 50000) { @@ -2075,7 +2075,7 @@ Pool.prototype.handleHeaders = async function handleHeaders(peer, packet) { * @returns {Promise} */ -Pool.prototype._handleHeaders = async function handleHeaders(peer, packet) { +Pool.prototype._handleHeaders = async function _handleHeaders(peer, packet) { const headers = packet.items; if (!this.checkpoints) @@ -2244,7 +2244,7 @@ Pool.prototype.addBlock = async function addBlock(peer, block, flags) { * @returns {Promise} */ -Pool.prototype._addBlock = async function addBlock(peer, block, flags) { +Pool.prototype._addBlock = async function _addBlock(peer, block, flags) { if (!this.syncing) return; @@ -2476,7 +2476,7 @@ Pool.prototype.handleTX = async function handleTX(peer, packet) { * @returns {Promise} */ -Pool.prototype._handleTX = async function handleTX(peer, packet) { +Pool.prototype._handleTX = async function _handleTX(peer, packet) { const tx = packet.tx; const hash = tx.hash('hex'); const flags = chainCommon.flags.VERIFY_NONE; @@ -2673,7 +2673,7 @@ Pool.prototype.handleMerkleBlock = async function handleMerkleBlock(peer, packet * @param {MerkleBlockPacket} block */ -Pool.prototype._handleMerkleBlock = async function handleMerkleBlock(peer, packet) { +Pool.prototype._handleMerkleBlock = async function _handleMerkleBlock(peer, packet) { if (!this.syncing) return; @@ -4048,7 +4048,7 @@ PoolOptions.prototype.getRate = function getRate(hash) { * @returns {net.Socket} */ -PoolOptions.prototype._createSocket = function createSocket(port, host) { +PoolOptions.prototype._createSocket = function _createSocket(port, host) { return tcp.createSocket(port, host, this.proxy); }; @@ -4059,7 +4059,7 @@ PoolOptions.prototype._createSocket = function createSocket(port, host) { * @returns {String[]} */ -PoolOptions.prototype._resolve = function resolve(name) { +PoolOptions.prototype._resolve = function _resolve(name) { if (this.onion) return dns.lookup(name, this.proxy); diff --git a/lib/net/upnp.js b/lib/net/upnp.js index 806c2671..57a2274a 100644 --- a/lib/net/upnp.js +++ b/lib/net/upnp.js @@ -151,7 +151,7 @@ UPNP.prototype.discover = async function discover() { * @returns {Promise} Location string. */ -UPNP.prototype._discover = async function discover() { +UPNP.prototype._discover = async function _discover() { const socket = dgram.createSocket('udp4'); socket.on('error', (err) => { diff --git a/lib/node/fullnode.js b/lib/node/fullnode.js index 96de2d57..68b66dc0 100644 --- a/lib/node/fullnode.js +++ b/lib/node/fullnode.js @@ -217,7 +217,7 @@ FullNode.prototype._init = function _init() { * @returns {Promise} */ -FullNode.prototype._open = async function open() { +FullNode.prototype._open = async function _open() { await this.chain.open(); await this.mempool.open(); await this.miner.open(); @@ -237,7 +237,7 @@ FullNode.prototype._open = async function open() { * @returns {Promise} */ -FullNode.prototype._close = async function close() { +FullNode.prototype._close = async function _close() { if (this.http) await this.http.close(); @@ -425,7 +425,7 @@ FullNode.prototype.getCoinsByAddress = async function getCoinsByAddress(addrs) { * @returns {Promise} - Returns {@link TXMeta}[]. */ -FullNode.prototype.getMetaByAddress = async function getTXByAddress(addrs) { +FullNode.prototype.getMetaByAddress = async function getMetaByAddress(addrs) { const mempool = this.mempool.getMetaByAddress(addrs); const chain = await this.chain.db.getMetaByAddress(addrs); return chain.concat(mempool); diff --git a/lib/node/logger.js b/lib/node/logger.js index 215b5a28..a0692ed3 100644 --- a/lib/node/logger.js +++ b/lib/node/logger.js @@ -175,7 +175,7 @@ Logger.prototype.open = async function open() { * @returns {Promise} */ -Logger.prototype._open = async function open() { +Logger.prototype._open = async function _open() { if (!this.filename) { this.closed = false; return; @@ -220,7 +220,7 @@ Logger.prototype.close = async function close() { * @returns {Promise} */ -Logger.prototype._close = async function close() { +Logger.prototype._close = async function _close() { if (this.timer != null) { co.clearTimeout(this.timer); this.timer = null; @@ -325,7 +325,7 @@ Logger.prototype.reopen = async function reopen() { * @returns {Promise} */ -Logger.prototype._reopen = async function reopen() { +Logger.prototype._reopen = async function _reopen() { if (this.stream) return; @@ -838,10 +838,15 @@ Logger.global = new Logger(); function openStream(filename) { return new Promise((resolve, reject) => { - /* eslint no-use-before-define: "off" */ - const stream = fs.createWriteStream(filename, { flags: 'a' }); + const cleanup = () => { + /* eslint-disable */ + stream.removeListener('error', onError); + stream.removeListener('open', onOpen); + /* eslint-enable */ + }; + const onError = (err) => { try { stream.close(); @@ -857,11 +862,6 @@ function openStream(filename) { resolve(stream); }; - const cleanup = () => { - stream.removeListener('error', onError); - stream.removeListener('open', onOpen); - }; - stream.once('error', onError); stream.once('open', onOpen); }); @@ -869,7 +869,12 @@ function openStream(filename) { function closeStream(stream) { return new Promise((resolve, reject) => { - /* eslint no-use-before-define: "off" */ + const cleanup = () => { + /* eslint-disable */ + stream.removeListener('error', onError); + stream.removeListener('close', onClose); + /* eslint-enable */ + }; const onError = (err) => { cleanup(); @@ -881,11 +886,6 @@ function closeStream(stream) { resolve(stream); }; - const cleanup = () => { - stream.removeListener('error', onError); - stream.removeListener('close', onClose); - }; - stream.removeAllListeners('error'); stream.removeAllListeners('close'); stream.once('error', onError); diff --git a/lib/node/spvnode.js b/lib/node/spvnode.js index 8275bc5b..966dce16 100644 --- a/lib/node/spvnode.js +++ b/lib/node/spvnode.js @@ -161,7 +161,7 @@ SPVNode.prototype._init = function _init() { * @returns {Promise} */ -SPVNode.prototype._open = async function open(callback) { +SPVNode.prototype._open = async function _open(callback) { await this.chain.open(); await this.pool.open(); @@ -179,7 +179,7 @@ SPVNode.prototype._open = async function open(callback) { * @returns {Promise} */ -SPVNode.prototype._close = async function close() { +SPVNode.prototype._close = async function _close() { if (this.http) await this.http.close(); diff --git a/lib/primitives/abstractblock.js b/lib/primitives/abstractblock.js index 29249490..5f3a50f6 100644 --- a/lib/primitives/abstractblock.js +++ b/lib/primitives/abstractblock.js @@ -115,7 +115,7 @@ AbstractBlock.prototype.isMemory = function isMemory() { * Clear any cached values (abstract). */ -AbstractBlock.prototype._refresh = function refresh() { +AbstractBlock.prototype._refresh = function _refresh() { this._hash = null; this._hhash = null; }; diff --git a/lib/primitives/keyring.js b/lib/primitives/keyring.js index 9234e42b..20fe4f8a 100644 --- a/lib/primitives/keyring.js +++ b/lib/primitives/keyring.js @@ -496,7 +496,7 @@ KeyRing.prototype.getScriptHash = function getScriptHash(enc) { * @returns {Buffer} */ -KeyRing.prototype.getScriptHash160 = function getScriptHash256(enc) { +KeyRing.prototype.getScriptHash160 = function getScriptHash160(enc) { if (!this.script) return null; diff --git a/lib/primitives/tx.js b/lib/primitives/tx.js index 7e7fca5d..5f175d08 100644 --- a/lib/primitives/tx.js +++ b/lib/primitives/tx.js @@ -1001,7 +1001,7 @@ TX.prototype.getOutputValue = function getOutputValue() { * @returns {Array} [addrs, table] */ -TX.prototype._getInputAddresses = function getInputAddresses(view) { +TX.prototype._getInputAddresses = function _getInputAddresses(view) { const table = Object.create(null); const addrs = []; @@ -1032,7 +1032,7 @@ TX.prototype._getInputAddresses = function getInputAddresses(view) { * @returns {Array} [addrs, table] */ -TX.prototype._getOutputAddresses = function getOutputAddresses() { +TX.prototype._getOutputAddresses = function _getOutputAddresses() { const table = Object.create(null); const addrs = []; @@ -1060,7 +1060,7 @@ TX.prototype._getOutputAddresses = function getOutputAddresses() { * @returns {Array} [addrs, table] */ -TX.prototype._getAddresses = function getAddresses(view) { +TX.prototype._getAddresses = function _getAddresses(view) { const [addrs, table] = this._getInputAddresses(view); const output = this.getOutputAddresses(); diff --git a/lib/script/script.js b/lib/script/script.js index 616b9fd2..265b60dc 100644 --- a/lib/script/script.js +++ b/lib/script/script.js @@ -2376,7 +2376,7 @@ Script.prototype.shift = function shift() { * @returns {Buffer} */ -Script.prototype.pop = function push(data) { +Script.prototype.pop = function pop(data) { const op = this.code.pop(); if (!op) diff --git a/lib/script/scriptnum.js b/lib/script/scriptnum.js index 89b71fc2..94c4f347 100644 --- a/lib/script/scriptnum.js +++ b/lib/script/scriptnum.js @@ -87,22 +87,22 @@ ScriptNum.prototype.ushrn = function ushrn(value) { return this.clone().iushrn(value); }; -ScriptNum.prototype.iaddn = function addn(value) { +ScriptNum.prototype.iaddn = function iaddn(value) { this.value += value; return this; }; -ScriptNum.prototype.isubn = function subn(value) { +ScriptNum.prototype.isubn = function isubn(value) { this.value -= value; return this; }; -ScriptNum.prototype.imuln = function muln(value) { +ScriptNum.prototype.imuln = function imuln(value) { this.value *= value; return this; }; -ScriptNum.prototype.idivn = function divn(value) { +ScriptNum.prototype.idivn = function idivn(value) { this.value = Math.floor(this.value / value); return this; }; diff --git a/lib/script/witness.js b/lib/script/witness.js index 6e4defa3..86f632e7 100644 --- a/lib/script/witness.js +++ b/lib/script/witness.js @@ -434,7 +434,7 @@ Witness.prototype.shift = function shift() { * @returns {Buffer} */ -Witness.prototype.pop = function push(data) { +Witness.prototype.pop = function pop(data) { return this.items.pop(); }; diff --git a/lib/utils/asyncobject.js b/lib/utils/asyncobject.js index eb11befb..1ee2286a 100644 --- a/lib/utils/asyncobject.js +++ b/lib/utils/asyncobject.js @@ -58,7 +58,7 @@ AsyncObject.prototype.open = async function open() { * @returns {Promise} */ -AsyncObject.prototype.__open = async function open() { +AsyncObject.prototype.__open = async function __open() { if (this.loaded) return; @@ -102,7 +102,7 @@ AsyncObject.prototype.close = async function close() { * @returns {Promise} */ -AsyncObject.prototype.__close = async function close() { +AsyncObject.prototype.__close = async function __close() { if (!this.loaded) return; diff --git a/lib/utils/co.js b/lib/utils/co.js index b1d44ea5..8d22657b 100644 --- a/lib/utils/co.js +++ b/lib/utils/co.js @@ -21,8 +21,6 @@ const assert = require('assert'); function exec(gen) { return new Promise((resolve, reject) => { - /* eslint no-use-before-define: "off" */ - const step = (value, rejection) => { let next; @@ -46,6 +44,7 @@ function exec(gen) { return; } + // eslint-disable-next-line no-use-before-define next.value.then(succeed, fail); }; diff --git a/lib/utils/gcs.js b/lib/utils/gcs.js index 29e7efaa..4b6cc133 100644 --- a/lib/utils/gcs.js +++ b/lib/utils/gcs.js @@ -491,7 +491,7 @@ BitReader.prototype.readBits = function readBits(count) { return num; }; -BitReader.prototype.readBits64 = function readBits(count) { +BitReader.prototype.readBits64 = function readBits64(count) { assert(count >= 0); assert(count <= 64); diff --git a/lib/utils/ip.js b/lib/utils/ip.js index 18937391..59b124f4 100644 --- a/lib/utils/ip.js +++ b/lib/utils/ip.js @@ -969,7 +969,7 @@ IP.isEqual = function isEqual(a, b) { * @returns {String} */ -IP.getInterfaces = function _getInterfaces(name, family) { +IP.getInterfaces = function getInterfaces(name, family) { const interfaces = os.networkInterfaces(); const result = []; diff --git a/lib/utils/lru.js b/lib/utils/lru.js index 4c0b2ef0..e3378e97 100644 --- a/lib/utils/lru.js +++ b/lib/utils/lru.js @@ -170,7 +170,7 @@ LRU.prototype.get = function get(key) { * @returns {Boolean} */ -LRU.prototype.has = function get(key) { +LRU.prototype.has = function has(key) { if (this.capacity === 0) return false; return this.map.has(key + ''); @@ -209,7 +209,7 @@ LRU.prototype.remove = function remove(key) { * @param {LRUItem} */ -LRU.prototype._prependList = function prependList(item) { +LRU.prototype._prependList = function _prependList(item) { this._insertList(null, item); }; @@ -219,7 +219,7 @@ LRU.prototype._prependList = function prependList(item) { * @param {LRUItem} */ -LRU.prototype._appendList = function appendList(item) { +LRU.prototype._appendList = function _appendList(item) { this._insertList(this.tail, item); }; @@ -230,7 +230,7 @@ LRU.prototype._appendList = function appendList(item) { * @param {LRUItem} item */ -LRU.prototype._insertList = function insertList(ref, item) { +LRU.prototype._insertList = function _insertList(ref, item) { assert(!item.next); assert(!item.prev); @@ -260,7 +260,7 @@ LRU.prototype._insertList = function insertList(ref, item) { * @param {LRUItem} */ -LRU.prototype._removeList = function removeList(item) { +LRU.prototype._removeList = function _removeList(item) { if (item.prev) item.prev.next = item.next; diff --git a/lib/utils/reader.js b/lib/utils/reader.js index d6c534b6..6fa6de89 100644 --- a/lib/utils/reader.js +++ b/lib/utils/reader.js @@ -101,13 +101,12 @@ BufferReader.prototype.start = function start() { * @throws on empty stack. */ -BufferReader.prototype.end = function _end() { +BufferReader.prototype.end = function end() { assert(this.stack.length > 0); const start = this.stack.pop(); - const end = this.offset; - return end - start; + return this.offset - start; }; /** diff --git a/lib/utils/util.js b/lib/utils/util.js index 11c45c67..bc6f5b4a 100644 --- a/lib/utils/util.js +++ b/lib/utils/util.js @@ -762,7 +762,7 @@ util.isUpperCase = function isUpperCase(str) { * @returns {Boolean} */ -util.startsWith = function startsWiths(str, prefix) { +util.startsWith = function startsWith(str, prefix) { return str.startsWith(prefix); }; diff --git a/lib/wallet/client.js b/lib/wallet/client.js index 6bb25f86..38256902 100644 --- a/lib/wallet/client.js +++ b/lib/wallet/client.js @@ -141,7 +141,7 @@ WalletClient.prototype._open = async function _open() { * @returns {Promise} */ -WalletClient.prototype._close = function close() { +WalletClient.prototype._close = function _close() { if (!this.socket) return Promise.resolve(); diff --git a/lib/wallet/layout-browser.js b/lib/wallet/layout-browser.js index e1617bf9..440dcf1b 100644 --- a/lib/wallet/layout-browser.js +++ b/lib/wallet/layout-browser.js @@ -67,7 +67,7 @@ layouts.walletdb = { return 'n' + pad32(wid) + pad32(index); }, R: 'R', - h: function c(height) { + h: function h(height) { return 'h' + pad32(height); }, b: function b(height) { @@ -92,7 +92,7 @@ layouts.txdb = { assert(typeof key === 'string'); return 't' + pad32(wid) + key; }, - pre: function prefix(key) { + pre: function pre(key) { assert(typeof key === 'string'); return +key.slice(1, 11); }, diff --git a/lib/wallet/layout.js b/lib/wallet/layout.js index fa81f6e2..3db12b2a 100644 --- a/lib/wallet/layout.js +++ b/lib/wallet/layout.js @@ -195,7 +195,7 @@ layouts.txdb = { key.copy(out, 5); return out; }, - pre: function prefix(key) { + pre: function pre(key) { assert(Buffer.isBuffer(key)); assert(key.length >= 5); return key.readUInt32BE(1, true); diff --git a/lib/wallet/masterkey.js b/lib/wallet/masterkey.js index e17d4a92..55200c2d 100644 --- a/lib/wallet/masterkey.js +++ b/lib/wallet/masterkey.js @@ -325,7 +325,7 @@ MasterKey.prototype.lock = async function _lock() { * the timer if there is one. */ -MasterKey.prototype._lock = function lock() { +MasterKey.prototype._lock = function _lock() { if (!this.encrypted) { assert(this.timer == null); assert(this.key); @@ -376,7 +376,7 @@ MasterKey.prototype.decrypt = async function decrypt(passphrase, clean) { * @returns {Promise} */ -MasterKey.prototype._decrypt = async function decrypt(passphrase, clean) { +MasterKey.prototype._decrypt = async function _decrypt(passphrase, clean) { if (!this.encrypted) throw new Error('Master key is not encrypted.'); @@ -423,7 +423,7 @@ MasterKey.prototype.encrypt = async function encrypt(passphrase, clean) { * @returns {Promise} */ -MasterKey.prototype._encrypt = async function encrypt(passphrase, clean) { +MasterKey.prototype._encrypt = async function _encrypt(passphrase, clean) { if (this.encrypted) throw new Error('Master key is already encrypted.'); diff --git a/lib/wallet/nodeclient.js b/lib/wallet/nodeclient.js index 08063c67..5df73938 100644 --- a/lib/wallet/nodeclient.js +++ b/lib/wallet/nodeclient.js @@ -37,7 +37,7 @@ util.inherits(NodeClient, AsyncObject); * @returns {Promise} */ -NodeClient.prototype._init = function init() { +NodeClient.prototype._init = function _init() { this.node.on('connect', (entry, block) => { if (!this.listen) return; @@ -72,7 +72,7 @@ NodeClient.prototype._init = function init() { * @returns {Promise} */ -NodeClient.prototype._open = function open(options) { +NodeClient.prototype._open = function _open(options) { this.listen = true; return Promise.resolve(); }; @@ -82,7 +82,7 @@ NodeClient.prototype._open = function open(options) { * @returns {Promise} */ -NodeClient.prototype._close = function close() { +NodeClient.prototype._close = function _close() { this.listen = false; return Promise.resolve(); }; diff --git a/lib/wallet/rpc.js b/lib/wallet/rpc.js index 2ece9778..7ba9310b 100644 --- a/lib/wallet/rpc.js +++ b/lib/wallet/rpc.js @@ -216,12 +216,12 @@ RPC.prototype.addWitnessAddress = async function addWitnessAddress(args, help) { }; RPC.prototype.backupWallet = async function backupWallet(args, help) { - if (help || args.length !== 1 || !dest) - throw new RPCError(errs.MISC_ERROR, 'backupwallet "destination"'); - const valid = new Validator([args]); const dest = valid.str(0); + if (help || args.length !== 1 || !dest) + throw new RPCError(errs.MISC_ERROR, 'backupwallet "destination"'); + await this.wdb.backup(dest); return null; diff --git a/lib/wallet/txdb.js b/lib/wallet/txdb.js index bbbab793..a487ed1c 100644 --- a/lib/wallet/txdb.js +++ b/lib/wallet/txdb.js @@ -734,7 +734,7 @@ TXDB.prototype.add = async function add(tx, block) { * @returns {Promise} */ -TXDB.prototype._add = async function add(tx, block) { +TXDB.prototype._add = async function _add(tx, block) { const hash = tx.hash('hex'); const existing = await this.getTX(hash); @@ -1011,7 +1011,7 @@ TXDB.prototype.confirm = async function confirm(hash, block) { * @returns {Promise} */ -TXDB.prototype._confirm = async function confirm(wtx, block) { +TXDB.prototype._confirm = async function _confirm(wtx, block) { const tx = wtx.tx; const hash = wtx.hash; const height = block.height; @@ -1333,7 +1333,7 @@ TXDB.prototype.unconfirm = async function unconfirm(hash) { * @returns {Promise} */ -TXDB.prototype._unconfirm = async function unconfirm(hash) { +TXDB.prototype._unconfirm = async function _unconfirm(hash) { const wtx = await this.getTX(hash); if (!wtx) @@ -1650,7 +1650,7 @@ TXDB.prototype.getLocked = function getLocked() { * @returns {Promise} - Returns {@link Hash}[]. */ -TXDB.prototype.getAccountHistoryHashes = function getHistoryHashes(account) { +TXDB.prototype.getAccountHistoryHashes = function getAccountHistoryHashes(account) { return this.keys({ gte: layout.T(account, encoding.NULL_HASH), lte: layout.T(account, encoding.HIGH_HASH), diff --git a/lib/wallet/wallet.js b/lib/wallet/wallet.js index eeee26e4..4e5ccc4e 100644 --- a/lib/wallet/wallet.js +++ b/lib/wallet/wallet.js @@ -274,7 +274,7 @@ Wallet.prototype.addSharedKey = async function addSharedKey(acct, key) { * @returns {Promise} */ -Wallet.prototype._addSharedKey = async function addSharedKey(acct, key) { +Wallet.prototype._addSharedKey = async function _addSharedKey(acct, key) { if (!key) { key = acct; acct = null; @@ -327,7 +327,7 @@ Wallet.prototype.removeSharedKey = async function removeSharedKey(acct, key) { * @returns {Promise} */ -Wallet.prototype._removeSharedKey = async function removeSharedKey(acct, key) { +Wallet.prototype._removeSharedKey = async function _removeSharedKey(acct, key) { if (!key) { key = acct; acct = null; @@ -398,7 +398,7 @@ Wallet.prototype.encrypt = async function encrypt(passphrase) { * @returns {Promise} */ -Wallet.prototype._encrypt = async function encrypt(passphrase) { +Wallet.prototype._encrypt = async function _encrypt(passphrase) { const key = await this.master.encrypt(passphrase, true); this.start(); @@ -440,7 +440,7 @@ Wallet.prototype.decrypt = async function decrypt(passphrase) { * @returns {Promise} */ -Wallet.prototype._decrypt = async function decrypt(passphrase) { +Wallet.prototype._decrypt = async function _decrypt(passphrase) { const key = await this.master.decrypt(passphrase, true); this.start(); @@ -482,7 +482,7 @@ Wallet.prototype.retoken = async function retoken(passphrase) { * @returns {Promise} */ -Wallet.prototype._retoken = async function retoken(passphrase) { +Wallet.prototype._retoken = async function _retoken(passphrase) { await this.unlock(passphrase); this.tokenDepth++; @@ -667,7 +667,7 @@ Wallet.prototype.createAccount = async function createAccount(options, passphras * @returns {Promise} - Returns {@link Account}. */ -Wallet.prototype._createAccount = async function createAccount(options, passphrase) { +Wallet.prototype._createAccount = async function _createAccount(options, passphrase) { let name = options.name; if (!name) @@ -815,7 +815,7 @@ Wallet.prototype.getAccount = async function getAccount(acct) { * @returns {Promise} - Returns {@link Account}. */ -Wallet.prototype._getAccount = async function getAccount(index) { +Wallet.prototype._getAccount = async function _getAccount(index) { const cache = this.accountCache.get(index); if (cache) @@ -958,7 +958,7 @@ Wallet.prototype.createKey = async function createKey(acct, branch) { * @returns {Promise} - Returns {@link WalletKey}. */ -Wallet.prototype._createKey = async function createKey(acct, branch) { +Wallet.prototype._createKey = async function _createKey(acct, branch) { if (branch == null) { branch = acct; acct = null; @@ -1190,7 +1190,7 @@ Wallet.prototype.importKey = async function importKey(acct, ring, passphrase) { * @returns {Promise} */ -Wallet.prototype._importKey = async function importKey(acct, ring, passphrase) { +Wallet.prototype._importKey = async function _importKey(acct, ring, passphrase) { if (acct && typeof acct === 'object') { passphrase = ring; ring = acct; @@ -1274,7 +1274,7 @@ Wallet.prototype.importAddress = async function importAddress(acct, address) { * @returns {Promise} */ -Wallet.prototype._importAddress = async function importAddress(acct, address) { +Wallet.prototype._importAddress = async function _importAddress(acct, address) { if (!address) { address = acct; acct = null; @@ -1354,7 +1354,7 @@ Wallet.prototype.fund = async function fund(mtx, options, force) { * @see MTX#fill */ -Wallet.prototype._fund = async function fund(mtx, options) { +Wallet.prototype._fund = async function _fund(mtx, options) { if (!options) options = {}; @@ -1583,7 +1583,7 @@ Wallet.prototype.send = async function send(options, passphrase) { * @returns {Promise} - Returns {@link TX}. */ -Wallet.prototype._send = async function send(options, passphrase) { +Wallet.prototype._send = async function _send(options, passphrase) { const mtx = await this.createTX(options, true); await this.sign(mtx, passphrase); @@ -1883,7 +1883,7 @@ Wallet.prototype.setLookahead = async function setLookahead(acct, lookahead) { * @returns {Promise} */ -Wallet.prototype._setLookahead = async function setLookahead(acct, lookahead) { +Wallet.prototype._setLookahead = async function _setLookahead(acct, lookahead) { if (lookahead == null) { lookahead = acct; acct = null; @@ -2130,7 +2130,7 @@ Wallet.prototype.add = async function add(tx, block) { * @returns {Promise} */ -Wallet.prototype._add = async function add(tx, block) { +Wallet.prototype._add = async function _add(tx, block) { this.txdb.start(); let details, derived; @@ -2207,7 +2207,7 @@ Wallet.prototype.zap = async function zap(acct, age) { * @returns {Promise} */ -Wallet.prototype._zap = async function zap(acct, age) { +Wallet.prototype._zap = async function _zap(acct, age) { const account = await this.ensureIndex(acct); return await this.txdb.zap(account, age); }; @@ -2234,7 +2234,7 @@ Wallet.prototype.abandon = async function abandon(hash) { * @returns {Promise} */ -Wallet.prototype._abandon = function abandon(hash) { +Wallet.prototype._abandon = function _abandon(hash) { return this.txdb.abandon(hash); }; diff --git a/lib/wallet/walletdb.js b/lib/wallet/walletdb.js index a1aff965..4b585ea7 100644 --- a/lib/wallet/walletdb.js +++ b/lib/wallet/walletdb.js @@ -138,7 +138,7 @@ WalletDB.prototype._init = function _init() { * @returns {Promise} */ -WalletDB.prototype._open = async function open() { +WalletDB.prototype._open = async function _open() { if (this.options.listen) await this.logger.open(); @@ -179,7 +179,7 @@ WalletDB.prototype._open = async function open() { * @returns {Promise} */ -WalletDB.prototype._close = async function close() { +WalletDB.prototype._close = async function _close() { await this.disconnect(); if (this.http && this.options.listen) @@ -487,7 +487,7 @@ WalletDB.prototype.rescan = async function rescan(height) { * @returns {Promise} */ -WalletDB.prototype._rescan = async function rescan(height) { +WalletDB.prototype._rescan = async function _rescan(height) { return await this.scan(height); }; @@ -864,7 +864,7 @@ WalletDB.prototype.get = async function get(id) { * @returns {Promise} - Returns {@link Wallet}. */ -WalletDB.prototype._get = async function get(wid) { +WalletDB.prototype._get = async function _get(wid) { const cache = this.wallets.get(wid); if (cache) @@ -1020,7 +1020,7 @@ WalletDB.prototype.create = async function create(options) { * @returns {Promise} - Returns {@link Wallet}. */ -WalletDB.prototype._create = async function create(options) { +WalletDB.prototype._create = async function _create(options) { const exists = await this.has(options.id); if (exists) @@ -1891,7 +1891,7 @@ WalletDB.prototype.addBlock = async function addBlock(entry, txs) { * @returns {Promise} */ -WalletDB.prototype._addBlock = async function addBlock(entry, txs) { +WalletDB.prototype._addBlock = async function _addBlock(entry, txs) { const tip = BlockMeta.fromEntry(entry); let total = 0; @@ -1958,7 +1958,7 @@ WalletDB.prototype.removeBlock = async function removeBlock(entry) { * @returns {Promise} */ -WalletDB.prototype._removeBlock = async function removeBlock(entry) { +WalletDB.prototype._removeBlock = async function _removeBlock(entry) { const tip = BlockMeta.fromEntry(entry); if (tip.height > this.state.height) { @@ -2048,7 +2048,7 @@ WalletDB.prototype.addTX = async function addTX(tx) { * @returns {Promise} */ -WalletDB.prototype._insert = async function insert(tx, block) { +WalletDB.prototype._insert = async function _insert(tx, block) { const wids = await this.getWalletsByTX(tx); let result = false; @@ -2095,7 +2095,7 @@ WalletDB.prototype._insert = async function insert(tx, block) { * @returns {Promise} */ -WalletDB.prototype._unconfirm = async function unconfirm(tx) { +WalletDB.prototype._unconfirm = async function _unconfirm(tx) { for (const wid of tx.wids) { const wallet = await this.get(wid); assert(wallet); @@ -2125,7 +2125,7 @@ WalletDB.prototype.resetChain = async function resetChain(entry) { * @returns {Promise} */ -WalletDB.prototype._resetChain = async function resetChain(entry) { +WalletDB.prototype._resetChain = async function _resetChain(entry) { if (entry.height > this.state.height) throw new Error('WDB: Bad reset height.'); diff --git a/test/aes-test.js b/test/aes-test.js index 867187c1..828089d2 100644 --- a/test/aes-test.js +++ b/test/aes-test.js @@ -1,3 +1,5 @@ +/* eslint-env mocha */ + 'use strict'; const assert = require('assert'); diff --git a/test/bech32-test.js b/test/bech32-test.js index c79e7a69..520deeb3 100644 --- a/test/bech32-test.js +++ b/test/bech32-test.js @@ -21,6 +21,8 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +/* eslint-env mocha */ + 'use strict'; const assert = require('assert'); diff --git a/test/bip150-test.js b/test/bip150-test.js index 018a528e..6122f60a 100644 --- a/test/bip150-test.js +++ b/test/bip150-test.js @@ -1,3 +1,5 @@ +/* eslint-env mocha */ + 'use strict'; const assert = require('assert'); diff --git a/test/bip151-test.js b/test/bip151-test.js index 9c76d868..7af51e93 100644 --- a/test/bip151-test.js +++ b/test/bip151-test.js @@ -1,3 +1,5 @@ +/* eslint-env mocha */ + 'use strict'; const assert = require('assert'); diff --git a/test/bip70-test.js b/test/bip70-test.js index 2f9ab66b..4d29c450 100644 --- a/test/bip70-test.js +++ b/test/bip70-test.js @@ -1,3 +1,5 @@ +/* eslint-env mocha */ + 'use strict'; const assert = require('assert'); diff --git a/test/block-test.js b/test/block-test.js index a4cafe8d..9745d8fe 100644 --- a/test/block-test.js +++ b/test/block-test.js @@ -1,3 +1,5 @@ +/* eslint-env mocha */ + 'use strict'; const assert = require('assert'); diff --git a/test/bloom-test.js b/test/bloom-test.js index 141a77a9..7bbe8262 100644 --- a/test/bloom-test.js +++ b/test/bloom-test.js @@ -1,3 +1,5 @@ +/* eslint-env mocha */ + 'use strict'; const assert = require('assert'); diff --git a/test/chachapoly-test.js b/test/chachapoly-test.js index bbc8d822..7c1783cb 100644 --- a/test/chachapoly-test.js +++ b/test/chachapoly-test.js @@ -1,3 +1,5 @@ +/* eslint-env mocha */ + 'use strict'; const assert = require('assert'); diff --git a/test/chain-test.js b/test/chain-test.js index d1903d40..648eeea7 100644 --- a/test/chain-test.js +++ b/test/chain-test.js @@ -1,3 +1,5 @@ +/* eslint-env mocha */ + 'use strict'; const assert = require('assert'); diff --git a/test/coins-test.js b/test/coins-test.js index 6409813f..91073e52 100644 --- a/test/coins-test.js +++ b/test/coins-test.js @@ -1,3 +1,5 @@ +/* eslint-env mocha */ + 'use strict'; const assert = require('assert'); diff --git a/test/gcs-test.js b/test/gcs-test.js index 3dcd083d..5de93c52 100644 --- a/test/gcs-test.js +++ b/test/gcs-test.js @@ -1,3 +1,5 @@ +/* eslint-env mocha */ + 'use strict'; const assert = require('assert'); diff --git a/test/hd-test.js b/test/hd-test.js index ba1d87df..4202370a 100644 --- a/test/hd-test.js +++ b/test/hd-test.js @@ -1,3 +1,5 @@ +/* eslint-env mocha */ + 'use strict'; const assert = require('assert'); diff --git a/test/http-test.js b/test/http-test.js index 89b7b267..160d7dc7 100644 --- a/test/http-test.js +++ b/test/http-test.js @@ -1,3 +1,5 @@ +/* eslint-env mocha */ + 'use strict'; const assert = require('assert'); diff --git a/test/key-address-test.js b/test/key-address-test.js index fc0a3a6a..d1c23655 100644 --- a/test/key-address-test.js +++ b/test/key-address-test.js @@ -1,3 +1,5 @@ +/* eslint-env mocha */ + 'use strict'; const assert = require('assert'); diff --git a/test/mempool-test.js b/test/mempool-test.js index f3fcefb5..db1fd93b 100644 --- a/test/mempool-test.js +++ b/test/mempool-test.js @@ -1,3 +1,5 @@ +/* eslint-env mocha */ + 'use strict'; const assert = require('assert'); diff --git a/test/mnemonic-test.js b/test/mnemonic-test.js index 4c606b60..20a6d26d 100644 --- a/test/mnemonic-test.js +++ b/test/mnemonic-test.js @@ -1,3 +1,5 @@ +/* eslint-env mocha */ + 'use strict'; const assert = require('assert'); diff --git a/test/node-test.js b/test/node-test.js index 310d4cba..d44ce2ba 100644 --- a/test/node-test.js +++ b/test/node-test.js @@ -1,3 +1,5 @@ +/* eslint-env mocha */ + 'use strict'; const assert = require('assert'); diff --git a/test/protocol-test.js b/test/protocol-test.js index ff3dc7c1..0e7db3c6 100644 --- a/test/protocol-test.js +++ b/test/protocol-test.js @@ -1,3 +1,5 @@ +/* eslint-env mocha */ + 'use strict'; const assert = require('assert'); diff --git a/test/script-test.js b/test/script-test.js index 4a1a43ec..802d9a83 100644 --- a/test/script-test.js +++ b/test/script-test.js @@ -1,3 +1,5 @@ +/* eslint-env mocha */ + 'use strict'; const assert = require('assert'); diff --git a/test/scrypt-test.js b/test/scrypt-test.js index c50bd536..5685bf07 100644 --- a/test/scrypt-test.js +++ b/test/scrypt-test.js @@ -1,3 +1,5 @@ +/* eslint-env mocha */ + 'use strict'; const assert = require('assert'); diff --git a/test/siphash-test.js b/test/siphash-test.js index da05caad..64f5316d 100644 --- a/test/siphash-test.js +++ b/test/siphash-test.js @@ -1,3 +1,5 @@ +/* eslint-env mocha */ + 'use strict'; const assert = require('assert'); diff --git a/test/tx-test.js b/test/tx-test.js index 42e199a9..4e900206 100644 --- a/test/tx-test.js +++ b/test/tx-test.js @@ -1,3 +1,5 @@ +/* eslint-env mocha */ + 'use strict'; const assert = require('assert'); diff --git a/test/utils-test.js b/test/utils-test.js index ba2d4f55..9738ee64 100644 --- a/test/utils-test.js +++ b/test/utils-test.js @@ -1,3 +1,5 @@ +/* eslint-env mocha */ + 'use strict'; const assert = require('assert'); diff --git a/test/wallet-test.js b/test/wallet-test.js index 747c0c69..0cd5ff15 100644 --- a/test/wallet-test.js +++ b/test/wallet-test.js @@ -1,3 +1,5 @@ +/* eslint-env mocha */ + 'use strict'; const assert = require('assert');