From b74bda623f23162fc125a5f9689f7b41982054ca Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Mon, 27 Jun 2016 07:10:26 -0700 Subject: [PATCH] lint. --- lib/bcoin/bip151.js | 5 ++--- lib/bcoin/bip152.js | 5 ++--- lib/bcoin/hd.js | 2 -- lib/bcoin/keypair.js | 5 ++--- lib/bcoin/script.js | 2 +- lib/bcoin/txdb.js | 7 +++---- lib/bcoin/wallet.js | 8 ++++---- lib/bcoin/walletdb.js | 5 ++--- 8 files changed, 16 insertions(+), 23 deletions(-) diff --git a/lib/bcoin/bip151.js b/lib/bcoin/bip151.js index f3930e6f..ec75b88e 100644 --- a/lib/bcoin/bip151.js +++ b/lib/bcoin/bip151.js @@ -9,7 +9,6 @@ var EventEmitter = require('events').EventEmitter; var bcoin = require('./env'); var utils = require('./utils'); -var assert = utils.assert; var constants = bcoin.protocol.constants; var chachapoly = require('./chachapoly'); @@ -63,7 +62,7 @@ BIP151.prototype.init = function init(publicKey) { this.chacha.init(this.k1, this.iv()); this.aead.init(this.k2, this.iv()); this.aead.aad(this.sid); -} +}; BIP151.prototype.rekey = function rekey() { this.mac = utils.hash256(this.mac); @@ -94,7 +93,7 @@ BIP151.prototype.getPublicKey = function getPublicKey() { }; BIP151.prototype.encryptSize = function encryptSize(size) { - var b = new Buffer(4); + var data = new Buffer(4); data.writeUInt32LE(size, 0, true); return this.chacha.encrypt(data); }; diff --git a/lib/bcoin/bip152.js b/lib/bcoin/bip152.js index adc3cf26..2def8834 100644 --- a/lib/bcoin/bip152.js +++ b/lib/bcoin/bip152.js @@ -70,7 +70,6 @@ CompactBlock.fromOptions = function fromOptions(options) { CompactBlock.prototype.fromRaw = function fromRaw(data) { var p = bcoin.reader(data); - var last = 0; var i, count, index, tx; this.version = p.readU32(); // Technically signed @@ -206,7 +205,7 @@ CompactBlock.prototype.fillMempool = function fillMempool(mempool, callback) { CompactBlock.prototype.fillMissing = function fillMissing(missing) { var offset = 0; - var i, tx; + var i; for (i = 0; i < this.available.length; i++) { if (this.available[i]) @@ -440,7 +439,7 @@ BlockTXRequest.prototype.toRaw = function toRaw(writer) { * @constructor */ -function BlockTX() { +function BlockTX(options) { if (!(this instanceof BlockTX)) return new BlockTX(options); diff --git a/lib/bcoin/hd.js b/lib/bcoin/hd.js index 45ee4ef7..2bcc6c15 100644 --- a/lib/bcoin/hd.js +++ b/lib/bcoin/hd.js @@ -971,8 +971,6 @@ HDPrivateKey.fromSeed = function fromSeed(seed, network) { */ HDPrivateKey.prototype.fromMnemonic = function fromMnemonic(mnemonic, network) { - var key; - if (!(mnemonic instanceof Mnemonic)) mnemonic = new Mnemonic(mnemonic); diff --git a/lib/bcoin/keypair.js b/lib/bcoin/keypair.js index fb23d154..47461594 100644 --- a/lib/bcoin/keypair.js +++ b/lib/bcoin/keypair.js @@ -201,8 +201,7 @@ KeyPair.prototype.toSecret = function toSecret(network) { KeyPair.prototype.fromRaw = function fromRaw(data) { var p = new BufferReader(data, true); - var compressed = false; - var i, prefix, version, type, privateKey; + var i, prefix, version, type; version = p.readU8(); @@ -301,7 +300,7 @@ KeyPair.prototype.fromJSON = function fromJSON(json) { * @returns {KeyPair} */ -KeyPair.fromJSON = function fromJSON(passphrase) { +KeyPair.fromJSON = function fromJSON(json) { return new KeyPair().fromJSON(json); }; diff --git a/lib/bcoin/script.js b/lib/bcoin/script.js index a5291dc7..66ec48f8 100644 --- a/lib/bcoin/script.js +++ b/lib/bcoin/script.js @@ -4069,7 +4069,7 @@ Script.verifyProgram = function verifyProgram(witness, output, flags, tx, i) { var program = output.toProgram(); var stack = witness.toStack(); var witnessScript, redeem, j; - var hash, pathdata, depth, path, posdata, pos, depth, root; + var hash, pathdata, depth, path, posdata, pos, root; assert(program, 'verifyProgram called on non-witness-program.'); assert((flags & constants.flags.VERIFY_WITNESS) !== 0); diff --git a/lib/bcoin/txdb.js b/lib/bcoin/txdb.js index c1aea19e..d0425551 100644 --- a/lib/bcoin/txdb.js +++ b/lib/bcoin/txdb.js @@ -117,9 +117,8 @@ TXDB.prototype._testFilter = function _testFilter(addresses) { */ TXDB.prototype.getMap = function getMap(tx, callback) { - var i, input, output, address, addresses, map; - - addresses = tx.getHashes('hex'); + var addresses = tx.getHashes('hex'); + var map; if (!this._testFilter(addresses)) return callback(); @@ -1939,7 +1938,7 @@ MapMember.prototype.toJSON = function toJSON() { }; MapMember.prototype.fromJSON = function fromJSON(json) { - var i, account, path; + var i, path; this.id = json.id; this.name = json.name; diff --git a/lib/bcoin/wallet.js b/lib/bcoin/wallet.js index 6207338e..90875e83 100644 --- a/lib/bcoin/wallet.js +++ b/lib/bcoin/wallet.js @@ -737,7 +737,7 @@ Wallet.prototype.getInputPaths = function getInputPaths(tx, callback) { if (tx instanceof bcoin.input) { if (!tx.coin) return callback(new Error('Not all coins available.')); - hash = tx.coin.getHash('hex') + hash = tx.coin.getHash('hex'); if (hash) hashes.push(hash); return done(); @@ -1543,8 +1543,6 @@ Wallet.isWallet = function isWallet(obj) { */ function Account(db, options) { - var i; - if (!(this instanceof Account)) return new Account(db, options); @@ -1587,6 +1585,8 @@ utils.inherits(Account, EventEmitter); */ Account.prototype.fromOptions = function fromOptions(options) { + var i; + assert(options, 'Options are required.'); assert(options.id, 'Wallet ID is required.'); assert(options.accountKey, 'Account key is required.'); @@ -2245,7 +2245,7 @@ Account.prototype.fromJSON = function fromJSON(json) { this.accountKey = bcoin.hd.fromBase58(json.accountKey); for (i = 0; i < json.keys.length; i++) - this.keys.push(bcoin.hd.fromBase58(key)); + this.keys.push(bcoin.hd.fromBase58(json.keys[i])); return this; }; diff --git a/lib/bcoin/walletdb.js b/lib/bcoin/walletdb.js index 1c5b9fa4..0d126bb7 100644 --- a/lib/bcoin/walletdb.js +++ b/lib/bcoin/walletdb.js @@ -20,6 +20,7 @@ var bcoin = require('./env'); var EventEmitter = require('events').EventEmitter; var utils = require('./utils'); var assert = utils.assert; +var constants = bcoin.protocol.constants; var BufferReader = require('./reader'); var BufferWriter = require('./writer'); @@ -1046,8 +1047,6 @@ WalletDB.prototype.removeBlock = function removeBlock(block, callback) { */ WalletDB.prototype.fetchWallet = function fetchWallet(id, callback, handler) { - var self = this; - this.get(id, function(err, wallet) { if (err) return callback(err); @@ -1260,7 +1259,7 @@ Path.prototype.fromKey = function fromKey(key) { return this; }; -Path.fromKey = function fromKey(json) { +Path.fromKey = function fromKey(key) { return new Path().fromKey(key); };