From 02ccde4f8a6729b1d8d12f4f75e48ba0160751b2 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Wed, 5 Oct 2016 07:59:12 -0700 Subject: [PATCH] wallet: handle account init errors. --- lib/wallet/wallet.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/wallet/wallet.js b/lib/wallet/wallet.js index 67d21088..f7214e21 100644 --- a/lib/wallet/wallet.js +++ b/lib/wallet/wallet.js @@ -729,15 +729,13 @@ Wallet.prototype._createAccount = co(function* createAccount(options) { try { account = Account.fromOptions(this.db, options); + account.wallet = this; + yield account.init(); } catch (e) { this.drop(); throw e; } - account.wallet = this; - - yield account.init(); - this.logger.info('Created account %s/%s/%d.', account.id, account.name, @@ -761,10 +759,10 @@ Wallet.prototype.ensureAccount = co(function* ensureAccount(options) { var name = options.name; var account = yield this.getAccount(name); - if (!account) - return yield this.createAccount(options); + if (account) + return account; - return account; + return yield this.createAccount(options); }); /**