mirror of https://github.com/BTCPrivate/copay.git
fix import wallets and profile form 0.7.2
This commit is contained in:
parent
e614b375e7
commit
b15679c08c
|
@ -198,13 +198,23 @@ Compatibility.importEncryptedWallet = function(identity, cypherText, password, o
|
|||
var crypto = (opts && opts.cryptoUtil) || cryptoUtils;
|
||||
|
||||
var obj = crypto.decrypt(password, cypherText);
|
||||
if (!obj) {
|
||||
// 0.7.3 broken KDF
|
||||
log.debug('Trying legacy encryption 0.7.2...');
|
||||
var passphrase = crypto.kdf(password, 'mjuBtGybi/4=', 100);
|
||||
obj = crypto.decrypt(passphrase, cypherText);
|
||||
}
|
||||
|
||||
if (!obj) {
|
||||
log.info("Could not decrypt, trying legacy..");
|
||||
obj = Compatibility.importLegacy(cypherText, password);
|
||||
if (!obj) {
|
||||
return cb('Could not decrypt', null);
|
||||
}
|
||||
};
|
||||
|
||||
if (!obj) {
|
||||
return cb('Could not decrypt', null);
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
obj = JSON.parse(obj);
|
||||
} catch (e) {
|
||||
|
|
|
@ -285,29 +285,35 @@ Identity.prototype.close = function(cb) {
|
|||
* @param {string[]} opts.importFunction - for stubbing
|
||||
* @return {Wallet}
|
||||
*/
|
||||
Identity.prototype.importEncryptedWallet = function(cypherText, password, opts, cb) {
|
||||
var crypto = opts.cryptoUtil || cryptoUtil;
|
||||
var obj = crypto.decrypt(password, cypherText);
|
||||
console.log('[Identity.js.290:obj:]',obj); //TODO
|
||||
|
||||
if (!obj) {
|
||||
// 0.7.3 broken KDF
|
||||
log.debug('Trying legacy encryption...');
|
||||
var passphrase = crypto.kdf(password, 'mjuBtGybi/4=', 100);
|
||||
obj = crypto.decrypt(passphrase, ejson);
|
||||
}
|
||||
console.log('[Identity.js.300:obj:]',obj); //TOD
|
||||
|
||||
if (!obj)
|
||||
return cb(new Error('Could not decrypt'));
|
||||
try {
|
||||
obj = JSON.parse(obj);
|
||||
} catch (e) {
|
||||
return cb(new Error('Could not decrypt'));
|
||||
}
|
||||
return this.importWalletFromObj(obj, opts, cb)
|
||||
};
|
||||
// This is not used in favor of Compatibility. importEncryptedWallet
|
||||
|
||||
// Identity.prototype.importEncryptedWallet = function(cypherText, password, opts, cb) {
|
||||
// var crypto = opts.cryptoUtil || cryptoUtil;
|
||||
// var obj = crypto.decrypt(password, cypherText);
|
||||
// console.log('[Identity.js.290:obj:]',obj); //TODO
|
||||
//
|
||||
// if (!obj) {
|
||||
// // 0.7.3 broken KDF
|
||||
// log.debug('Trying legacy encryption...');
|
||||
// console.log('[Identity.js.296:password:]',password); //TODO
|
||||
// var passphrase = crypto.kdf(password, 'mjuBtGybi/4=', 100);
|
||||
// console.log('[Identity.js.296:passphrase:]',passphrase); //TODO
|
||||
// obj = crypto.decrypt(passphrase, ejson);
|
||||
// console.log('[Identity.js.297:obj:]',obj); //TODO
|
||||
// }
|
||||
// console.log('[Identity.js.300:obj:]',obj); //TOD
|
||||
//
|
||||
// if (!obj)
|
||||
// return cb(new Error('Could not decrypt'));
|
||||
// try {
|
||||
// obj = JSON.parse(obj);
|
||||
// } catch (e) {
|
||||
// return cb(new Error('Could not decrypt'));
|
||||
// }
|
||||
// return this.importWalletFromObj(obj, opts, cb)
|
||||
// };
|
||||
//
|
||||
Identity.prototype.importWalletFromObj = function(obj, opts, cb) {
|
||||
var self = this;
|
||||
preconditions.checkArgument(cb);
|
||||
|
|
|
@ -238,7 +238,8 @@ describe('Identity model', function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe('#importWallet', function() {
|
||||
// This is implemented in Compatibility
|
||||
describe.skip('#importWallet', function() {
|
||||
it('should import a wallet, call the right encryption functions', function(done) {
|
||||
var args = createIdentity();
|
||||
args.storage.getItem.onFirstCall().callsArgWith(1, null, '{"wallet": "fakeData"}');
|
||||
|
|
|
@ -10,11 +10,11 @@
|
|||
<div class="large-12 columns">
|
||||
<div class="panel">
|
||||
<form name="importForm" ng-submit="import(importForm)" novalidate>
|
||||
<p class="text-warning size-12"
|
||||
<div class="text-warning size-12 m20b"
|
||||
ng-show="error">
|
||||
<i class="fi-x"></i>
|
||||
{{error|translate}}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-show="!is_iOS && !backupOldWallet">
|
||||
|
|
Loading…
Reference in New Issue