add updateIndex to model
This commit is contained in:
parent
45e44fba19
commit
0da641d1b8
4 changed files with 31 additions and 16 deletions
|
|
@ -36,10 +36,7 @@ angular.module('copayApp.controllers').controller('ImportController',
|
||||||
$scope.error = 'Could not read wallet. Please check your password';
|
$scope.error = 'Could not read wallet. Please check your password';
|
||||||
} else {
|
} else {
|
||||||
controllerUtils.installWalletHandlers($scope, wallet);
|
controllerUtils.installWalletHandlers($scope, wallet);
|
||||||
updateStatus('Importing wallet - Scanning for transactions...');
|
controllerUtils.setFocusedWallet(wallet);
|
||||||
wallet.updateIndexes(function(err) {
|
|
||||||
controllerUtils.setFocusedWallet(wallet);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ angular.module('copayApp.controllers').controller('ImportProfileController',
|
||||||
passphraseConfig: config.passphraseConfig,
|
passphraseConfig: config.passphraseConfig,
|
||||||
}, function(err, iden) {
|
}, function(err, iden) {
|
||||||
if (err && !iden) {
|
if (err && !iden) {
|
||||||
|
$scope.loading = false;
|
||||||
$scope.error = (err.toString() || '').match('BADSTR') ? 'Bad password or corrupt profile file' : 'Unknown error';
|
$scope.error = (err.toString() || '').match('BADSTR') ? 'Bad password or corrupt profile file' : 'Unknown error';
|
||||||
} else {
|
} else {
|
||||||
var firstWallet = iden.getLastFocusedWallet();
|
var firstWallet = iden.getLastFocusedWallet();
|
||||||
|
|
@ -54,14 +55,13 @@ angular.module('copayApp.controllers').controller('ImportProfileController',
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.import = function(form) {
|
$scope.import = function(form) {
|
||||||
|
$scope.loading = true;
|
||||||
|
|
||||||
if (form.$invalid) {
|
if (form.$invalid) {
|
||||||
$scope.loading = false;
|
$scope.loading = false;
|
||||||
$scope.error = 'Please enter the required fields';
|
$scope.error = 'Please enter the required fields';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$rootScope.starting = true;
|
|
||||||
|
|
||||||
var backupFile = $scope.file;
|
var backupFile = $scope.file;
|
||||||
var backupText = form.backupText.$modelValue;
|
var backupText = form.backupText.$modelValue;
|
||||||
var password = form.password.$modelValue;
|
var password = form.password.$modelValue;
|
||||||
|
|
|
||||||
|
|
@ -275,6 +275,9 @@ Identity.prototype.close = function(cb) {
|
||||||
}, cb);
|
}, cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: Add feedback 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);
|
||||||
|
|
@ -288,17 +291,21 @@ Identity.prototype.importWalletFromObj = function(obj, opts, cb) {
|
||||||
|
|
||||||
var w = importFunction(obj, readOpts);
|
var w = importFunction(obj, readOpts);
|
||||||
if (!w) return cb(new Error('Could not decrypt'));
|
if (!w) return cb(new Error('Could not decrypt'));
|
||||||
|
log.debug('Wallet decryped:' + w.getName());
|
||||||
|
|
||||||
self._checkVersion(w.version);
|
self._checkVersion(w.version);
|
||||||
self.addWallet(w);
|
log.debug('Updating Indexes for wallet:' + w.getName());
|
||||||
self.bindWallet(w);
|
w.updateIndexes(function(err) {
|
||||||
self.storeWallet(w, function(err) {
|
log.debug('Adding wallet to profile:' + w.getName());
|
||||||
if (err) return cb(err);
|
self.addWallet(w);
|
||||||
|
self.bindWallet(w);
|
||||||
self.store({
|
self.storeWallet(w, function(err) {
|
||||||
noWallets: true
|
if (err) return cb(err);
|
||||||
}, function(err) {
|
self.store({
|
||||||
return cb(err, w);
|
noWallets: true
|
||||||
|
}, function(err) {
|
||||||
|
return cb(err, w);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
@ -348,11 +355,16 @@ Identity.importFromFullJson = function(str, password, opts, cb) {
|
||||||
opts.email = email;
|
opts.email = email;
|
||||||
opts.password = password;
|
opts.password = password;
|
||||||
|
|
||||||
|
if (!email)
|
||||||
|
return cb('BADSTR');
|
||||||
|
|
||||||
var iden = new Identity(opts);
|
var iden = new Identity(opts);
|
||||||
|
|
||||||
json.wallets = json.wallets || {};
|
json.wallets = json.wallets || {};
|
||||||
|
|
||||||
async.map(json.wallets, function(walletData, callback) {
|
async.map(json.wallets, function(walletData, callback) {
|
||||||
|
if (!walletData)
|
||||||
|
return callback();
|
||||||
|
|
||||||
iden.importWalletFromObj(walletData, opts, function(err, w) {
|
iden.importWalletFromObj(walletData, opts, function(err, w) {
|
||||||
if (err) return callback(err);
|
if (err) return callback(err);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,11 @@
|
||||||
|
|
||||||
<div class="home" ng-controller="ImportProfileController">
|
<div class="home" ng-controller="ImportProfileController">
|
||||||
|
|
||||||
|
<div data-alert class="loading-screen" ng-show="loading">
|
||||||
|
<i class="size-60 fi-bitcoin-circle icon-rotate spinner"></i> {{ importStatus|translate }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div ng-show="!loading">
|
||||||
<div class="large-4 large-centered medium-6 medium-centered columns">
|
<div class="large-4 large-centered medium-6 medium-centered columns">
|
||||||
<div class="logo-setup">
|
<div class="logo-setup">
|
||||||
<img src="img/logo-negative-beta.svg" alt="Copay" width="146" height="59">
|
<img src="img/logo-negative-beta.svg" alt="Copay" width="146" height="59">
|
||||||
|
|
@ -19,7 +24,7 @@
|
||||||
|
|
||||||
<div ng-show="!is_iOS">
|
<div ng-show="!is_iOS">
|
||||||
<legend for="backupFile" class="m10b">
|
<legend for="backupFile" class="m10b">
|
||||||
<span translate>Choose backup file from your computer</span> <i class="fi-laptop"></i>
|
<span translate>Choose backup file</span>
|
||||||
</legend>
|
</legend>
|
||||||
<input type="file" class="form-control"
|
<input type="file" class="form-control"
|
||||||
placeholder="{{'Select a backup file'|translate}}" name="backupFile" ng-model="backupFile" ng-file-select>
|
placeholder="{{'Select a backup file'|translate}}" name="backupFile" ng-model="backupFile" ng-file-select>
|
||||||
|
|
@ -57,6 +62,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue