fix export wallet

This commit is contained in:
Javier 2016-10-12 18:11:02 -03:00
commit 696c5bbd18
3 changed files with 97 additions and 54 deletions

View file

@ -869,10 +869,9 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
if (!root.isEncrypted(wallet)) return cb();
askPassword(wallet.name, gettext('Enter Spending Password'), function(password) {
if (!password) return cb('no password');
if (!wallet.checkPassword(password)) return cb('wrong password');
if (!password) return cb('No password');
if (!wallet.checkPassword(password)) return cb('Wrong password');
wallet.credentials.decryptPrivateKey(password);
return cb(null, password);
});
};
@ -990,8 +989,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
});
};
root.getEncodedWalletInfo = function(wallet, cb) {
root.getEncodedWalletInfo = function(wallet, password, cb) {
var derivationPath = wallet.credentials.getBaseAddressDerivationPath();
var encodingType = {
mnemonic: 1,
@ -1004,23 +1002,21 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
if (wallet.credentials.derivationStrategy != 'BIP44' || !wallet.canSign())
return null;
root.getKeys(wallet, function(err, keys) {
if (err || !keys) return cb(err);
var keys = root.getKeysWithPassword(wallet, password);
if (keys.mnemonic) {
info = {
type: encodingType.mnemonic,
data: keys.mnemonic,
}
} else {
info = {
type: encodingType.xpriv,
data: keys.xPrivKey
}
if (keys.mnemonic) {
info = {
type: encodingType.mnemonic,
data: keys.mnemonic,
}
return cb(null, info.type + '|' + info.data + '|' + wallet.credentials.network.toLowerCase() + '|' + derivationPath + '|' + (wallet.credentials.mnemonicHasPassphrase));
} else {
info = {
type: encodingType.xpriv,
data: keys.xPrivKey
}
}
});
return cb(null, info.type + '|' + info.data + '|' + wallet.credentials.network.toLowerCase() + '|' + derivationPath + '|' + (wallet.credentials.mnemonicHasPassphrase));
};
root.setTouchId = function(wallet, enabled, cb) {
@ -1055,6 +1051,12 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
});
};
root.getKeysWithPassword = function(wallet, password) {
try {
return wallet.getKeys(password);
} catch (e) {}
}
root.getViewStatus = function(wallet, txp) {
var status = txp.status;
var type;