Bug/select wallet incomplete / Refactor wallet Services (#4159)

* Addressbook: display error if select an incomplete wallet

* Check if wallet is complete/needs_backup for Glidera and Coinbase

* Ref/create a walletService

* Ref. walletService

* Fix Glidera and Coinbase

* Removes txService

* Fix glidera connection for mobile. Fix bitcode for xcode

* Fix duplicated entry

* Revert "Bump bwc version 2.3.1"

* adds karma-mocha

* Refactor

* Refactor lock function

* Refactor reject, remove and broadcast tx

* add walletService tests WIP

* add walletService tests WIP 2

* merge

* update tests to mocha

* fix tests. Angular 1.5?

* Fix test

* Generate angular-bwc before testing

* Rever gitignore

* Wording
This commit is contained in:
Gustavo Maximiliano Cortez 2016-05-09 15:56:44 -03:00
commit 98471e952a
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
27 changed files with 698 additions and 628 deletions

View file

@ -638,7 +638,7 @@ angular.module('copayApp.services')
$log.debug('Encrypting private key for', fc.credentials.walletName);
fc.setPrivateKeyEncryption(password);
root.lockFC();
fc.lock();
root.updateCredentialsFC(function() {
$log.debug('Wallet encrypted');
return cb();
@ -661,51 +661,6 @@ angular.module('copayApp.services')
});
};
root.lockFC = function() {
var fc = root.focusedClient;
try {
fc.lock();
} catch (e) {};
};
root.unlockFC = function(opts, cb) {
opts = opts || {};
var fc = opts.selectedClient || root.focusedClient;
if (!fc.isPrivKeyEncrypted())
return cb();
$log.debug('Wallet is encrypted');
$rootScope.$emit('Local/NeedsPassword', false, function(err2, password) {
if (err2)
return cb(err2);
if (!password)
return cb(gettext('Spending Password needed'));
try {
fc.unlock(password);
} catch (e) {
$log.warn('Error decrypting wallet:', e);
return cb(gettext('Wrong spending password'));
}
return cb();
});
};
root.isBackupNeeded = function(walletId, cb) {
var c = root.getClient(walletId);
if (c.isPrivKeyExternal()) return cb(false);
if (!c.credentials.mnemonic) return cb(false);
if (c.credentials.network == 'testnet') return cb(false);
storageService.getBackupFlag(walletId, function(err, val) {
if (err || val) return cb(false);
return cb(true);
});
};
root.getWallets = function(network) {
if (!root.profile) return [];