diff --git a/lib/wallet/txdb.js b/lib/wallet/txdb.js index 8644db04..f8cdf4e0 100644 --- a/lib/wallet/txdb.js +++ b/lib/wallet/txdb.js @@ -1484,7 +1484,7 @@ TXDB.prototype.getLast = function getLast(account, limit) { start: 0, end: 0xffffffff, reverse: true, - limit: limit + limit: limit || 10 }); }; @@ -1529,7 +1529,7 @@ TXDB.prototype.getAccountHistory = co(function* getAccountHistory(account) { txs.push(tx); } - return sortTX(txs); + return txs; }); /** @@ -1554,7 +1554,7 @@ TXDB.prototype.getUnconfirmed = co(function* getUnconfirmed(account) { txs.push(tx); } - return sortTX(txs); + return txs; }); /** @@ -2038,20 +2038,6 @@ Balance.prototype.toString = function toString() { * Helpers */ -function sortTX(txs) { - return txs.sort(function(a, b) { - return a.ps - b.ps; - }); -} - -function sortCoins(coins) { - return coins.sort(function(a, b) { - a = a.height === -1 ? 0x7fffffff : a.height; - b = b.height === -1 ? 0x7fffffff : b.height; - return a - b; - }); -} - function Conflict(tx, info) { this.tx = tx; this.info = info; diff --git a/lib/wallet/wallet.js b/lib/wallet/wallet.js index 674e5a95..e0d3d481 100644 --- a/lib/wallet/wallet.js +++ b/lib/wallet/wallet.js @@ -753,17 +753,17 @@ Wallet.prototype._createAccount = co(function* createAccount(options) { Wallet.prototype.ensureAccount = co(function* ensureAccount(options) { var name = options.account; - var exists; + var account; if (typeof options.name === 'string') name = options.name; - exists = yield this.hasAccount(name); + account = yield this.getAccount(name); - if (exists) - return yield this.getAccount(name); + if (!account) + return yield this.createAccount(options); - return this.createAccount(options); + return account; }); /**