Merge branch 'master' into bugs/ui-07

This commit is contained in:
bechi 2014-10-30 16:56:26 -03:00
commit 11ab17ec94
13 changed files with 67 additions and 81 deletions

View file

@ -20,6 +20,7 @@ Compatibility._getWalletIds = function(cb) {
preconditions.checkArgument(cb);
var walletIds = [];
var uniq = {};
var key;
for (key in localStorage) {
var split = key.split('::');
if (split.length == 2) {
@ -111,7 +112,9 @@ Compatibility.getWallets_Old = function(cb) {
Compatibility.getWallets2 = function(cb) {
var self = this;
var re = /wallet::([^_]+)(_?(.*))/;
var va = /^{+/;
var key;
var keys = [];
for (key in localStorage) {
keys.push(key);
@ -120,11 +123,15 @@ Compatibility.getWallets2 = function(cb) {
if (key.indexOf('wallet::') !== 0)
return null;
var match = key.match(re);
var matchValue = localStorage[key].match(va);
if (match.length != 4)
return null;
if (matchValue)
return null;
return {
id: match[1],
name: match[3] ? match[3] : undefined,
value: localStorage[key]
};
}));
@ -186,7 +193,7 @@ Compatibility.readWalletPre8 = function(walletId, password, cb) {
};
Compatibility.importEncryptedWallet = function(identity, cypherText, password, opts, cb) {
var crypto = opts.cryptoUtil || cryptoUtils;
var crypto = (opts && opts.cryptoUtil) || cryptoUtils;
var key = crypto.kdf(password);
var obj = crypto.decrypt(key, cypherText);
if (!obj) {
@ -227,5 +234,10 @@ Compatibility.kdf = function(password) {
return sbase64;
};
Compatibility.deleteOldWallet = function(walletObj) {
localStorage.removeItem('wallet::'+walletObj.id+'_'+walletObj.name);
log.info('Old wallet ' + walletObj.name + ' deleted: ' + walletObj.id);
};
module.exports = Compatibility;

View file

@ -490,20 +490,6 @@ Identity.prototype.addWallet = function(wallet, cb) {
this.storage.setItem(wallet.getStorageKey(), wallet.toObj(), cb);
};
/**
* check if any profile exists on storage
* @param opts.storageOpts
* @param cb
*/
Identity.checkIfExistsAny = function(opts, cb) {
var storage = opts.storage || opts.pluginManager.get('DB');
storage.getFirst(Identity.getStoragePrefix(), {
onlyKey: true
}, function(err, v, k) {
return cb(k ? true : false);
});
};
/**
* @desc Checks if a version is compatible with the current version
* @param {string} inVersion - a version, with major, minor, and revision, period-separated (x.y.z)

View file

@ -178,20 +178,6 @@ Wallet.prototype.getStorageKey = function() {
return Wallet.getStorageKey(this.getId());
};
/**
* check if any wallet exists on storage
* @param opts.storageOpts
* @param cb
*/
Wallet.checkIfExistsAny = function(opts, cb) {
var storage = opts.storage || opts.pluginManager.get('DB');
storage.getFirst(Wallet.getStoragePrefix(), {
onlyKey: true
}, function(err, v, k) {
return cb(k ? true : false);
});
};
/* for stubbing */
Wallet._newInsight = function(opts) {
return new Insight(opts);