mirror of https://github.com/BTCPrivate/copay.git
Merge pull request #755 from yemel/feature/importing-feedback
Add feedback while importing wallet
This commit is contained in:
commit
dff3c9c479
|
@ -291,7 +291,7 @@
|
||||||
<div ng-controller="ImportController">
|
<div ng-controller="ImportController">
|
||||||
<div data-alert class="alert-box info radius" ng-show="loading">
|
<div data-alert class="alert-box info radius" ng-show="loading">
|
||||||
<i class="size-21 fi-bitcoin-circle icon-rotate spinner"></i>
|
<i class="size-21 fi-bitcoin-circle icon-rotate spinner"></i>
|
||||||
Importing wallet...
|
{{ importStatus }}
|
||||||
</div>
|
</div>
|
||||||
<div ng-init="choosefile=0; pastetext=0" ng-show="!loading">
|
<div ng-init="choosefile=0; pastetext=0" ng-show="!loading">
|
||||||
<h3>{{title}}</h3>
|
<h3>{{title}}</h3>
|
||||||
|
|
|
@ -3,10 +3,19 @@
|
||||||
angular.module('copayApp.controllers').controller('ImportController',
|
angular.module('copayApp.controllers').controller('ImportController',
|
||||||
function($scope, $rootScope, walletFactory, controllerUtils, Passphrase) {
|
function($scope, $rootScope, walletFactory, controllerUtils, Passphrase) {
|
||||||
$scope.title = 'Import a backup';
|
$scope.title = 'Import a backup';
|
||||||
|
$scope.importStatus = 'Importing wallet - Reading backup...';
|
||||||
|
|
||||||
var reader = new FileReader();
|
var reader = new FileReader();
|
||||||
|
|
||||||
|
var updateStatus = function(status) {
|
||||||
|
$scope.importStatus = status;
|
||||||
|
$scope.$digest();
|
||||||
|
}
|
||||||
|
|
||||||
var _importBackup = function(encryptedObj) {
|
var _importBackup = function(encryptedObj) {
|
||||||
Passphrase.getBase64Async($scope.password, function(passphrase) {
|
Passphrase.getBase64Async($scope.password, function(passphrase) {
|
||||||
walletFactory.import(encryptedObj, passphrase, function(err, w) {
|
updateStatus('Importing wallet - Setting things up...');
|
||||||
|
var w = walletFactory.import(encryptedObj, passphrase, function(err, w) {
|
||||||
if (err) {
|
if (err) {
|
||||||
$scope.loading = false;
|
$scope.loading = false;
|
||||||
$rootScope.$flashMessage = {
|
$rootScope.$flashMessage = {
|
||||||
|
@ -19,6 +28,10 @@ angular.module('copayApp.controllers').controller('ImportController',
|
||||||
$rootScope.wallet = w;
|
$rootScope.wallet = w;
|
||||||
controllerUtils.startNetwork($rootScope.wallet, $scope);
|
controllerUtils.startNetwork($rootScope.wallet, $scope);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
w.on('updatingIndexes', function(){
|
||||||
|
updateStatus('Importing wallet - We are almost there...');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -759,6 +759,7 @@ Wallet.prototype.updateIndexes = function(callback) {
|
||||||
if (changeIndex != -1)
|
if (changeIndex != -1)
|
||||||
self.publicKeyRing.indexes.changeIndex = changeIndex + 1;
|
self.publicKeyRing.indexes.changeIndex = changeIndex + 1;
|
||||||
|
|
||||||
|
self.emit('updatingIndexes');
|
||||||
start = self.publicKeyRing.indexes.receiveIndex;
|
start = self.publicKeyRing.indexes.receiveIndex;
|
||||||
self.indexDiscovery(start, false, 20, function(err, receiveIndex) {
|
self.indexDiscovery(start, false, 20, function(err, receiveIndex) {
|
||||||
if (err) return callback(err);
|
if (err) return callback(err);
|
||||||
|
|
|
@ -84,6 +84,7 @@ WalletFactory.prototype.import = function(base64, password, cb) {
|
||||||
self.log('Indexes updated');
|
self.log('Indexes updated');
|
||||||
cb(null, w);
|
cb(null, w);
|
||||||
});
|
});
|
||||||
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
WalletFactory.prototype.read = function(walletId) {
|
WalletFactory.prototype.read = function(walletId) {
|
||||||
|
|
|
@ -331,7 +331,6 @@ describe('Wallet model', function() {
|
||||||
var w = cachedCreateW2();
|
var w = cachedCreateW2();
|
||||||
var spy = sinon.spy(w, 'scheduleConnect');
|
var spy = sinon.spy(w, 'scheduleConnect');
|
||||||
var callCount = 3;
|
var callCount = 3;
|
||||||
w.reconnectDelay = 25;
|
|
||||||
w.netStart();
|
w.netStart();
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
sinon.assert.callCount(spy, callCount);
|
sinon.assert.callCount(spy, callCount);
|
||||||
|
@ -743,7 +742,7 @@ describe('Wallet model', function() {
|
||||||
var spyEmit = sinon.spy(w, 'emit');
|
var spyEmit = sinon.spy(w, 'emit');
|
||||||
w.updateIndexes(function(err) {
|
w.updateIndexes(function(err) {
|
||||||
sinon.assert.callCount(spyStore, 1);
|
sinon.assert.callCount(spyStore, 1);
|
||||||
sinon.assert.callCount(spyEmit, 1);
|
sinon.assert.callCount(spyEmit, 2);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -94,6 +94,29 @@ describe('WalletFactory model', function() {
|
||||||
JSON.stringify(w.toObj()).should.equal(o);
|
JSON.stringify(w.toObj()).should.equal(o);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should create wallet from encrypted object', function() {
|
||||||
|
var wf = new WalletFactory(config, '0.0.1');
|
||||||
|
wf.storage._setPassphrase = sinon.spy();
|
||||||
|
wf.storage.import = sinon.spy();
|
||||||
|
|
||||||
|
var w = wf.fromEncryptedObj("encrypted object", "password");
|
||||||
|
should.exist(w);
|
||||||
|
wf.storage._setPassphrase.called.should.be.true;
|
||||||
|
wf.storage.import.called.should.be.true;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should import and update indexes', function() {
|
||||||
|
var wf = new WalletFactory(config, '0.0.1');
|
||||||
|
var wallet = {id: "fake wallet", updateIndexes: function(cb) { cb(); }};
|
||||||
|
wf.fromEncryptedObj = sinon.stub().returns(wallet);
|
||||||
|
var callback = sinon.spy();
|
||||||
|
|
||||||
|
var w = wf.import("encrypted", "password", callback);
|
||||||
|
|
||||||
|
should.exist(w);
|
||||||
|
wallet.should.equal(w);
|
||||||
|
sinon.assert.callCount(callback, 1);
|
||||||
|
});
|
||||||
|
|
||||||
it('BIP32 length problem', function() {
|
it('BIP32 length problem', function() {
|
||||||
var sconfig = {
|
var sconfig = {
|
||||||
|
|
Loading…
Reference in New Issue