Merge pull request #1812 from matiu/feature/updateIndexes
Feature/update indexes
This commit is contained in:
commit
6e06deeba6
9 changed files with 132 additions and 156 deletions
|
|
@ -275,6 +275,9 @@ Identity.prototype.close = function(cb) {
|
|||
}, cb);
|
||||
};
|
||||
|
||||
|
||||
// TODO: Add feedback function
|
||||
//
|
||||
Identity.prototype.importWalletFromObj = function(obj, opts, cb) {
|
||||
var self = this;
|
||||
preconditions.checkArgument(cb);
|
||||
|
|
@ -288,17 +291,21 @@ Identity.prototype.importWalletFromObj = function(obj, opts, cb) {
|
|||
|
||||
var w = importFunction(obj, readOpts);
|
||||
if (!w) return cb(new Error('Could not decrypt'));
|
||||
log.debug('Wallet decryped:' + w.getName());
|
||||
|
||||
this._checkVersion(w.version);
|
||||
this.addWallet(w);
|
||||
self.bindWallet(w);
|
||||
self.storeWallet(w, function(err) {
|
||||
if (err) return cb(err);
|
||||
|
||||
self.store({
|
||||
noWallets: true
|
||||
}, function(err) {
|
||||
return cb(err, w);
|
||||
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.addWallet(w);
|
||||
self.bindWallet(w);
|
||||
self.storeWallet(w, function(err) {
|
||||
if (err) return cb(err);
|
||||
self.store({
|
||||
noWallets: true
|
||||
}, function(err) {
|
||||
return cb(err, w);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
@ -348,11 +355,16 @@ Identity.importFromFullJson = function(str, password, opts, cb) {
|
|||
opts.email = email;
|
||||
opts.password = password;
|
||||
|
||||
if (!email)
|
||||
return cb('BADSTR');
|
||||
|
||||
var iden = new Identity(opts);
|
||||
|
||||
json.wallets = json.wallets || {};
|
||||
|
||||
async.map(json.wallets, function(walletData, callback) {
|
||||
if (!walletData)
|
||||
return callback();
|
||||
|
||||
iden.importWalletFromObj(walletData, opts, function(err, w) {
|
||||
if (err) return callback(err);
|
||||
|
|
|
|||
|
|
@ -2487,7 +2487,8 @@ Wallet.prototype.createTxSync = function(toAddress, amountSatStr, comment, utxos
|
|||
};
|
||||
|
||||
/**
|
||||
* @desc Updates all the indexes for the current publicKeyRing
|
||||
* @desc Updates all the indexes for the current publicKeyRing. This scans
|
||||
* the blockchain looking for transactions on derived addresses.
|
||||
*
|
||||
* Triggers a wallet {@link Wallet#store} call
|
||||
* @param {Function} callback - called when all indexes have been updated. Receives an error, if any, as first argument
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue