add checksum on close

This commit is contained in:
Ivan Socolsky 2015-01-07 19:59:35 -03:00
commit 5255d4ba31
2 changed files with 22 additions and 9 deletions

View file

@ -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();
}
});
};