From 5255d4ba31829d69f16aa93a6b44786c6e95871d Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Wed, 7 Jan 2015 19:59:35 -0300 Subject: [PATCH] add checksum on close --- js/models/Identity.js | 23 ++++++++++++++++++++--- js/services/identityService.js | 8 ++------ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/js/models/Identity.js b/js/models/Identity.js index 3cb8a4633..289f205bf 100644 --- a/js/models/Identity.js +++ b/js/models/Identity.js @@ -460,9 +460,26 @@ Identity.prototype._cleanUp = function() { /** * @desc Closes the wallet and disconnects all services */ -Identity.prototype.close = function() { - this._cleanUp(); - this.emitAndKeepAlive('closed'); +Identity.prototype.close = function(cb) { + var self = this; + + function doClose() { + self._cleanUp(); + self.emitAndKeepAlive('closed'); + if (cb) return cb(); + }; + + self.verifyChecksum(function(err, match) { + if (!err && match) { + self.store({ + noWallets: true, + }, function(err) { + return doClose(); + }); + } else { + return doClose(); + } + }); }; diff --git a/js/services/identityService.js b/js/services/identityService.js index 4cdb97d61..6f9e78324 100644 --- a/js/services/identityService.js +++ b/js/services/identityService.js @@ -322,12 +322,8 @@ angular.module('copayApp.services') root.signout = function() { $rootScope.signingOut = true; if ($rootScope.iden) { - $rootScope.iden.store({ - noWallets: true - }, function() { - $rootScope.signingOut = false; - $rootScope.iden.close(); // Will trigger 'closed' - }); + $rootScope.signingOut = false; + $rootScope.iden.close(); // Will trigger 'closed' } };