save profile on wallet import
This commit is contained in:
parent
e57422231b
commit
b1e686ee68
1 changed files with 34 additions and 18 deletions
|
|
@ -468,26 +468,42 @@ Identity.prototype.close = function() {
|
||||||
Identity.prototype.importWalletFromObj = function(obj, opts, cb) {
|
Identity.prototype.importWalletFromObj = function(obj, opts, cb) {
|
||||||
var self = this;
|
var self = this;
|
||||||
preconditions.checkArgument(cb);
|
preconditions.checkArgument(cb);
|
||||||
var importFunction = opts.importWallet || Wallet.fromUntrustedObj;
|
|
||||||
|
|
||||||
var readOpts = {
|
self.verifyChecksum(function(err, match) {
|
||||||
networkOpts: this.networkOpts,
|
if (err) return cb(err);
|
||||||
blockchainOpts: this.blockchainOpts,
|
if (!match) return cb('The profile is out of sync. Please re-login to get the latest changes.');
|
||||||
skipFields: opts.skipFields,
|
|
||||||
};
|
|
||||||
|
|
||||||
var w = importFunction(obj, readOpts);
|
var importFunction = opts.importWallet || Wallet.fromUntrustedObj;
|
||||||
if (!w) return cb(new Error('Could not decrypt'));
|
|
||||||
log.debug('Wallet decrypted:' + w.getName());
|
|
||||||
|
|
||||||
self._checkVersion(w.version);
|
var readOpts = {
|
||||||
log.debug('Updating Indexes for wallet:' + w.getName());
|
networkOpts: self.networkOpts,
|
||||||
w.updateIndexes(function(err) {
|
blockchainOpts: self.blockchainOpts,
|
||||||
log.debug('Adding wallet to profile:' + w.getName());
|
skipFields: opts.skipFields,
|
||||||
self.addWallet(w);
|
};
|
||||||
self.updateFocusedTimestamp(w.getId());
|
|
||||||
self.bindWallet(w);
|
var w = importFunction(obj, readOpts);
|
||||||
self.storeWallet(w, cb);
|
if (!w) return cb(new Error('Could not decrypt'));
|
||||||
|
log.debug('Wallet decrypted:' + w.getName());
|
||||||
|
|
||||||
|
self._checkVersion(w.version);
|
||||||
|
log.debug('Updating Indexes for wallet:' + w.getName());
|
||||||
|
w.updateIndexes(function(err) {
|
||||||
|
log.debug('Adding wallet to profile:' + w.getName());
|
||||||
|
self.storeWallet(w, function (err) {
|
||||||
|
if (err) return cb(err);
|
||||||
|
|
||||||
|
self.addWallet(w);
|
||||||
|
self.updateFocusedTimestamp(w.getId());
|
||||||
|
self.bindWallet(w);
|
||||||
|
|
||||||
|
self.backupNeeded = true;
|
||||||
|
self.store({
|
||||||
|
noWallets: true,
|
||||||
|
}, function(err) {
|
||||||
|
return cb(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue