diff --git a/lib/bcoin/mempool.js b/lib/bcoin/mempool.js index d473535d..ded29982 100644 --- a/lib/bcoin/mempool.js +++ b/lib/bcoin/mempool.js @@ -718,7 +718,7 @@ Mempool.prototype.removeUnchecked = function removeUnchecked(entry, limit) { // now exist on the blockchain). if (limit) { this._removeSpenders(entry); - this.logger.debug('Evicting %s from the mempool.', tx.rhash); + this.logger.debug('Evicting %s from the mempool.', entry.tx.rhash); } this.untrackEntry(entry); @@ -1485,7 +1485,7 @@ Mempool.prototype._removeSpenders = function _removeSpenders(entry) { Mempool.prototype.memUsage = function memUsage(tx) { var mem = 0; - var i, j, input, output; + var i, input, output; mem += 264; // tx mem += 80; // _hash diff --git a/lib/bcoin/spvnode.js b/lib/bcoin/spvnode.js index 5c5b465b..1e389d8b 100644 --- a/lib/bcoin/spvnode.js +++ b/lib/bcoin/spvnode.js @@ -198,7 +198,7 @@ SPVNode.prototype._open = function open(callback) { }, function(next) { var i; - self.walletdb.getAddresses(function(err, hashes) { + self.walletdb.getAddressHashes(function(err, hashes) { if (err) return next(err); diff --git a/lib/bcoin/txdb.js b/lib/bcoin/txdb.js index 527aefcf..f53ce6e9 100644 --- a/lib/bcoin/txdb.js +++ b/lib/bcoin/txdb.js @@ -1407,7 +1407,7 @@ TXDB.prototype.filterLocked = function filterLocked(coins) { TXDB.prototype.getLocked = function getLocked() { var keys = Object.keys(this.locked); var outpoints = []; - var i, key, hash, index; + var i, key, hash, index, outpoint; for (i = 0; i < keys.length; i++) { key = keys[i]; diff --git a/lib/bcoin/wallet.js b/lib/bcoin/wallet.js index ebe736ec..74bd9dbf 100644 --- a/lib/bcoin/wallet.js +++ b/lib/bcoin/wallet.js @@ -568,8 +568,8 @@ Wallet.prototype.getAccounts = function getAccounts(callback) { * @param {Function} callback - Returns [Error, Array]. */ -Wallet.prototype.getAddresses = function getAddresses(callback) { - this.db.getAddresses(this.wid, callback); +Wallet.prototype.getAddressHashes = function getAddressHashes(callback) { + this.db.getAddressHashes(this.wid, callback); }; /** @@ -724,23 +724,31 @@ Wallet.prototype.commit = function commit(callback) { /** * Test whether the wallet possesses an address. - * @param {Base58Address} address + * @param {Address|Hash} address * @param {Function} callback - Returns [Error, Boolean]. */ Wallet.prototype.hasAddress = function hasAddress(address, callback) { - return this.db.hasAddress(this.wid, address, callback); + var hash = bcoin.address.getHash(address, 'hex'); + if (!hash) + return callback(null, false); + return this.db.hasAddress(this.wid, hash, callback); }; /** * Get path by address hash. - * @param {Hash} address + * @param {Address|Hash} address * @param {Function} callback - Returns [Error, {@link Path}]. */ Wallet.prototype.getAddressPath = function getAddressPath(address, callback) { var self = this; - this.db.getAddressPath(this.wid, address, function(err, path) { + var hash = bcoin.address.getHash(address, 'hex'); + + if (!hash) + return callback(); + + this.db.getAddressPath(this.wid, hash, function(err, path) { if (err) return callback(err); @@ -755,7 +763,7 @@ Wallet.prototype.getAddressPath = function getAddressPath(address, callback) { /** * Get all wallet paths. - * @param {Number} account + * @param {(String|Number)?} account * @param {Function} callback - Returns [Error, {@link Path}]. */ @@ -1052,13 +1060,14 @@ Wallet.prototype.deriveInputs = function deriveInputs(tx, callback) { }; /** - * Retrieve a single keyring by address hash. - * @param {Hash} hash + * Retrieve a single keyring by address. + * @param {Address|Hash} hash * @param {Function} callback */ -Wallet.prototype.getKeyring = function getKeyring(hash, callback) { +Wallet.prototype.getKeyring = function getKeyring(address, callback) { var self = this; + var hash = bcoin.address.getHash(address, 'hex'); var address; if (!hash) diff --git a/lib/bcoin/walletdb.js b/lib/bcoin/walletdb.js index dc418436..2fdfc3c0 100644 --- a/lib/bcoin/walletdb.js +++ b/lib/bcoin/walletdb.js @@ -1017,7 +1017,7 @@ WalletDB.prototype.hasAddress = function hasAddress(wid, address, callback) { * @param {Function} callback */ -WalletDB.prototype.getAddresses = function getAddresses(wid, callback) { +WalletDB.prototype.getAddressHashes = function getAddressHashes(wid, callback) { if (!callback) { callback = wid; wid = null; @@ -1088,7 +1088,7 @@ WalletDB.prototype.getWallets = function getWallets(callback) { WalletDB.prototype.rescan = function rescan(chaindb, callback) { var self = this; - this.getAddresses(function(err, hashes) { + this.getAddressHashes(function(err, hashes) { if (err) return callback(err);