+
Shared Wallet
diff --git a/src/js/controllers/export.js b/src/js/controllers/export.js
index 395bdcd46..c60eaa3ef 100644
--- a/src/js/controllers/export.js
+++ b/src/js/controllers/export.js
@@ -10,6 +10,7 @@ angular.module('copayApp.controllers').controller('exportController',
$scope.isCordova = platformInfo.isCordova;
$scope.isSafari = platformInfo.isSafari;
$scope.error = null;
+ console.log(fc.credentials);
$scope.init = function(state) {
$scope.QROpts = false;
@@ -79,7 +80,8 @@ angular.module('copayApp.controllers').controller('exportController',
}
}
- return info.type + '|' + info.data;
+ var code = info.type + '|' + info.data + '|' + c.network.charAt(0).toLowerCase() + '|' + c.account + '|' + c.derivationStrategy + '|' + (c.mnemonicHasPassphrase);
+ return code;
};
$scope.downloadWalletBackup = function() {
diff --git a/src/js/controllers/import.js b/src/js/controllers/import.js
index 4f05bb486..2a34c7516 100644
--- a/src/js/controllers/import.js
+++ b/src/js/controllers/import.js
@@ -1,12 +1,10 @@
'use strict';
angular.module('copayApp.controllers').controller('importController',
- function($scope, $rootScope, $timeout, $log, profileService, configService, notification, go, sjcl, gettext, lodash, ledger, trezor, derivationPathHelper, platformInfo, bwsError, bwcService, ongoingProcess) {
+ function($scope, $rootScope, $timeout, $log, profileService, configService, notification, go, sjcl, gettext, ledger, trezor, derivationPathHelper, platformInfo, bwcService, ongoingProcess) {
var isChromeApp = platformInfo.isChromeApp;
var isDevel = platformInfo.isDevel;
-
- var self = this;
var reader = new FileReader();
var defaults = configService.getDefaults();
var errors = bwcService.getErrors();
@@ -14,52 +12,70 @@ angular.module('copayApp.controllers').controller('importController',
$scope.derivationPath = derivationPathHelper.default;
$scope.account = 1;
$scope.processingCode = null;
- self.importErr = false;
+ $scope.importErr = false;
var updateSeedSourceSelect = function() {
- self.seedOptions = [];
+ $scope.seedOptions = [];
if (isChromeApp) {
- self.seedOptions.push({
+ $scope.seedOptions.push({
id: 'ledger',
label: 'Ledger Hardware Wallet',
});
}
if (isChromeApp || isDevel) {
- self.seedOptions.push({
+ $scope.seedOptions.push({
id: 'trezor',
label: 'Trezor Hardware Wallet',
});
- $scope.seedSource = self.seedOptions[0];
+ $scope.seedSource = $scope.seedOptions[0];
}
};
$scope.processCode = function(code) {
+ $scope.importErr = false;
+ $scope.error = null;
ongoingProcess.set('processingCode', true);
- self.importErr = false;
var parsedCode = code.split('|');
- if (parsedCode.length != 2) {
+ if (parsedCode.length != 6) {
ongoingProcess.set('processingCode', false);
+ $log.debug('Missing parameters');
return;
}
var info = {
type: parsedCode[0],
data: parsedCode[1],
+ network: parsedCode[2] == 't' ? 'testnet' : 'livenet',
+ account: parseInt(parsedCode[3]),
+ derivationStrategy: parsedCode[4],
+ mnemonicHasPassphrase: parsedCode[5]
};
var client = bwcService.getClient(null, null);
if (info.type == 1) {
- client.seedFromMnemonic(info.data, {});
+ client.seedFromMnemonic(info.data, {
+ network: info.network,
+ account: info.account,
+ derivationStrategy: info.derivationStrategy
+ });
}
+
if (info.type == 2) {
- client.seedFromExtendedPrivateKey(info.data, {});
+ client.seedFromExtendedPrivateKey(info.data, {
+ account: info.account,
+ derivationStrategy: info.derivationStrategy
+ });
}
+
if (info.type == 3) {
- client.seedFromExtendedPublicKey(info.data, {});
+ client.seedFromExtendedPublicKey(info.data, {
+ account: info.account,
+ derivationStrategy: info.derivationStrategy
+ });
}
$scope.words = info.data;
@@ -76,9 +92,9 @@ angular.module('copayApp.controllers').controller('importController',
}, 1);
};
- this.setType = function(type) {
+ $scope.setType = function(type) {
$scope.type = type;
- this.error = null;
+ $scope.error = null;
$timeout(function() {
$rootScope.$apply();
}, 1);
@@ -87,14 +103,14 @@ angular.module('copayApp.controllers').controller('importController',
var _importBlob = function(str, opts) {
var str2, err;
try {
- str2 = sjcl.decrypt(self.password, str);
+ str2 = sjcl.decrypt($scope.password, str);
} catch (e) {
err = gettext('Could not decrypt file, check your password');
$log.warn(e);
};
if (err) {
- self.error = err;
+ $scope.error = err;
$timeout(function() {
$rootScope.$apply();
});
@@ -109,7 +125,7 @@ angular.module('copayApp.controllers').controller('importController',
profileService.importWallet(str2, opts, function(err, walletId) {
ongoingProcess.set('importingWallet', false);
if (err) {
- self.error = err;
+ $scope.error = err;
} else {
$rootScope.$emit('Local/WalletImported', walletId);
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
@@ -126,9 +142,9 @@ angular.module('copayApp.controllers').controller('importController',
ongoingProcess.set('importingWallet', false);
if (err) {
if (err instanceof errors.NOT_AUTHORIZED) {
- self.importErr = true;
+ $scope.importErr = true;
} else {
- self.error = err;
+ $scope.error = err;
}
return $timeout(function() {
$scope.$apply();
@@ -151,9 +167,9 @@ angular.module('copayApp.controllers').controller('importController',
if (err) {
if (err instanceof errors.NOT_AUTHORIZED) {
- self.importErr = true;
+ $scope.importErr = true;
} else {
- self.error = err;
+ $scope.error = err;
}
return $timeout(function() {
$scope.$apply();
@@ -185,9 +201,9 @@ angular.module('copayApp.controllers').controller('importController',
}
};
- this.importBlob = function(form) {
+ $scope.importBlob = function(form) {
if (form.$invalid) {
- this.error = gettext('There is an error in the form');
+ $scope.error = gettext('There is an error in the form');
$timeout(function() {
$scope.$apply();
});
@@ -199,7 +215,7 @@ angular.module('copayApp.controllers').controller('importController',
var password = form.password.$modelValue;
if (!backupFile && !backupText) {
- this.error = gettext('Please, select your backup file');
+ $scope.error = gettext('Please, select your backup file');
$timeout(function() {
$scope.$apply();
});
@@ -216,9 +232,9 @@ angular.module('copayApp.controllers').controller('importController',
}
};
- this.importMnemonic = function(form) {
+ $scope.importMnemonic = function(form) {
if (form.$invalid) {
- this.error = gettext('There is an error in the form');
+ $scope.error = gettext('There is an error in the form');
$timeout(function() {
$scope.$apply();
});
@@ -232,7 +248,7 @@ angular.module('copayApp.controllers').controller('importController',
var pathData = derivationPathHelper.parse($scope.derivationPath);
if (!pathData) {
- this.error = gettext('Invalid derivation path');
+ $scope.error = gettext('Invalid derivation path');
return;
}
opts.account = pathData.account;
@@ -240,21 +256,21 @@ angular.module('copayApp.controllers').controller('importController',
opts.derivationStrategy = pathData.derivationStrategy;
var words = form.words.$modelValue;
- this.error = null;
+ $scope.error = null;
if (!words) {
- this.error = gettext('Please enter the recovery phrase');
+ $scope.error = gettext('Please enter the recovery phrase');
} else if (words.indexOf('xprv') == 0 || words.indexOf('tprv') == 0) {
return _importExtendedPrivateKey(words, opts);
} else {
var wordList = words.split(/[\u3000\s]+/);
if ((wordList.length % 3) != 0) {
- this.error = gettext('Wrong number of recovery words:') + wordList.length;
+ $scope.error = gettext('Wrong number of recovery words:') + wordList.length;
}
}
- if (this.error) {
+ if ($scope.error) {
$timeout(function() {
$scope.$apply();
});
@@ -267,12 +283,12 @@ angular.module('copayApp.controllers').controller('importController',
_importMnemonic(words, opts);
};
- this.importTrezor = function(account, isMultisig) {
- var self = this;
+ $scope.importTrezor = function(account, isMultisig) {
+ var $scope = $scope;
trezor.getInfoForNewWallet(isMultisig, account, function(err, lopts) {
ongoingProcess.clear();
if (err) {
- self.error = err;
+ $scope.error = err;
$scope.$apply();
return;
}
@@ -285,7 +301,7 @@ angular.module('copayApp.controllers').controller('importController',
profileService.importExtendedPublicKey(lopts, function(err, walletId) {
ongoingProcess.set('importingWallet', false);
if (err) {
- self.error = err;
+ $scope.error = err;
return $timeout(function() {
$scope.$apply();
});
@@ -297,56 +313,56 @@ angular.module('copayApp.controllers').controller('importController',
}, 100);
};
- this.importHW = function(form) {
+ $scope.importHW = function(form) {
if (form.$invalid || $scope.account < 0) {
- this.error = gettext('There is an error in the form');
+ $scope.error = gettext('There is an error in the form');
$timeout(function() {
$scope.$apply();
});
return;
}
- this.error = '';
- this.importErr = false;
+ $scope.error = '';
+ $scope.importErr = false;
var account = +$scope.account;
- if (self.seedSourceId == 'trezor') {
+ if ($scope.seedSourceId == 'trezor') {
if (account < 1) {
- this.error = gettext('Invalid account number');
+ $scope.error = gettext('Invalid account number');
return;
}
account = account - 1;
}
- switch (self.seedSourceId) {
+ switch ($scope.seedSourceId) {
case ('ledger'):
ongoingProcess.set('connectingledger', true);
- self.importLedger(account);
+ $scope.importLedger(account);
break;
case ('trezor'):
ongoingProcess.set('connectingtrezor', true);
- self.importTrezor(account, $scope.isMultisig);
+ $scope.importTrezor(account, $scope.isMultisig);
break;
default:
throw ('Error: bad source id');
};
};
- this.setSeedSource = function() {
+ $scope.setSeedSource = function() {
if (!$scope.seedSource) return;
- self.seedSourceId = $scope.seedSource.id;
+ $scope.seedSourceId = $scope.seedSource.id;
$timeout(function() {
$rootScope.$apply();
});
};
- this.importLedger = function(account) {
- var self = this;
+ $scope.importLedger = function(account) {
+ var $scope = $scope;
ledger.getInfoForNewWallet(true, account, function(err, lopts) {
ongoingProcess.clear();
if (err) {
- self.error = err;
+ $scope.error = err;
$scope.$apply();
return;
}
@@ -359,7 +375,7 @@ angular.module('copayApp.controllers').controller('importController',
profileService.importExtendedPublicKey(lopts, function(err, walletId) {
ongoingProcess.set('importingWallet', false);
if (err) {
- self.error = err;
+ $scope.error = err;
return $timeout(function() {
$scope.$apply();
});
@@ -372,5 +388,5 @@ angular.module('copayApp.controllers').controller('importController',
};
updateSeedSourceSelect();
- self.setSeedSource('new');
+ $scope.setSeedSource('new');
});