This commit is contained in:
Javier 2016-06-29 17:04:40 -03:00
commit 84b92044a2
7 changed files with 62 additions and 58 deletions

View file

@ -5,15 +5,16 @@
</div> </div>
<div class="content preferences" ng-controller="exportController" ng-init="init(index.prevState)"> <div class="content preferences" ng-controller="exportController" ng-init="init(index.prevState)">
<div class="create-tab small-only-text-center"> <div ng-show="!index.canSign"><h4></h4></div>
<div ng-show="index.canSign" class="create-tab small-only-text-center">
<div class="row"> <div class="row">
<div class="tab-container small-6 medium-3 large-2" <div class="tab-container small-6 columns"
ng-class="{'selected':!exportQR}" ng-class="{'selected':!exportQR}"
ng-style="{'border-color':!exportQR ? index.backgroundColor: 'inherit'}" ng-style="{'border-color':!exportQR ? index.backgroundColor: 'inherit'}"
ng-click="exportQR = false"> ng-click="exportQR = false">
<a href ng-style="{'color':!exportQR ? index.backgroundColor: 'inherit'}" translate>File/Text</a> <a href ng-style="{'color':!exportQR ? index.backgroundColor: 'inherit'}" translate>File/Text</a>
</div> </div>
<div class="tab-container small-6 medium-3 large-2" <div class="tab-container small-6 columns"
ng-class="{'selected':exportQR}" ng-class="{'selected':exportQR}"
ng-style="{'border-color':exportQR ? index.backgroundColor: 'inherit'}" ng-style="{'border-color':exportQR ? index.backgroundColor: 'inherit'}"
ng-click="exportQR = true"> ng-click="exportQR = true">
@ -45,18 +46,13 @@
</form> </form>
<div class="m20t text-gray" ng-show="exportQR"> <div class="m20t text-gray" ng-show="exportQR">
<div class="text-center"> <div class="text-center m20b">
<qrcode size="220" version="8" error-correction-level="M" data="{{exportWalletInfo}}"></qrcode> <qrcode size="220" version="8" error-correction-level="M" data="{{exportWalletInfo}}"></qrcode>
</div> </div>
<div class="text-center size-12 m10" translate>From the destination device, go to Add wallet > Import wallet and scan this QR code</div>
<div class="text-center size-18 m10t" ng-style="{color: index.backgroundColor}">
<span translate>Exporting Walelt: </span>
<span>{{index.walletName}}</span>
</div>
<div class="text-center size-12 m10" translate>From/In the destination device, go to Add wallet > Import wallet and scan this QR code</div>
</div> </div>
<div class="row"> <div class="row" ng-show="!exportQR && index.canSign">
<div class="columns m15t"> <div class="columns m15t">
<a class="button outline light-gray expand tiny p10i" ng-click="showAdvanced = !showAdvanced"> <a class="button outline light-gray expand tiny p10i" ng-click="showAdvanced = !showAdvanced">
<i class="fi-widget m3r"></i> <i class="fi-widget m3r"></i>
@ -74,7 +70,7 @@
</ion-toggle> </ion-toggle>
</div> </div>
<div class="box-notification" ng-show="!index.canSign"> <div class="box-notification p15l" ng-show="!index.canSign">
<span class="text-warning size-14"> <span class="text-warning size-14">
<i class="fi-alert"></i> <i class="fi-alert"></i>
<span translate> <span translate>
@ -83,7 +79,7 @@
</span> </span>
</div> </div>
<div class="box-notification" ng-show="noSign"> <div class="box-notification p15l" ng-show="noSignEnabled">
<span class="text-warning size-14"> <span class="text-warning size-14">
<i class="fi-alert"></i> <i class="fi-alert"></i>
<span translate> <span translate>

View file

@ -29,7 +29,7 @@
<ul class="size-12"> <ul class="size-12">
<li translate>The password of the recovery phrase (if set)</li> <li translate>The password of the recovery phrase (if set)</li>
<li translate>The derivation path</li> <li translate>The derivation path</li>
<li translate>The wallet service URL <li translate>The wallet service URL</li>
</ul> </ul>
<div class="m15l"> <div class="m15l">
<span translate>NOTE: To import a wallet from a 3rd party software, please go to Add Wallet &gt; Create Wallet, and specify the Recovery Phrase there.</span><br> <span translate>NOTE: To import a wallet from a 3rd party software, please go to Add Wallet &gt; Create Wallet, and specify the Recovery Phrase there.</span><br>
@ -51,7 +51,7 @@
</label> </label>
<div class="qr-scanner-input"> <div class="qr-scanner-input">
<qr-scanner on-scan="processCode(data)"></qr-scanner> <qr-scanner on-scan="processWalletInfo(data)"></qr-scanner>
</div> </div>
<div class="lock-fromQR" ng-show="fromQR"> <div class="lock-fromQR" ng-show="fromQR">

View file

@ -23,6 +23,7 @@ angular.module('copayApp.controllers').controller('backupController',
handleEncryptedWallet(fc, function(err) { handleEncryptedWallet(fc, function(err) {
if (err) { if (err) {
$log.warn('Error decrypting credentials:', $scope.error);
go.path(prevState); go.path(prevState);
return; return;
} }

View file

@ -12,6 +12,7 @@ angular.module('copayApp.controllers').controller('exportController',
$scope.error = null; $scope.error = null;
$scope.init = function(state) { $scope.init = function(state) {
$scope.exportQR = false;
$scope.noSignEnabled = false; $scope.noSignEnabled = false;
$scope.showAdvanced = false; $scope.showAdvanced = false;
prevState = state || 'walletHome'; prevState = state || 'walletHome';
@ -36,12 +37,16 @@ angular.module('copayApp.controllers').controller('exportController',
}); });
}; };
/*
EXPORT WITHOUT PRIVATE KEY - PENDING
$scope.noSignEnabledChange = function() { $scope.noSignEnabledChange = function() {
$scope.exportWalletInfo = encodeWalletInfo(); $scope.exportWalletInfo = encodeWalletInfo();
$timeout(function() { $timeout(function() {
$scope.$apply(); $scope.$apply();
}, 1); }, 1);
}; };
*/
$scope.$on('$destroy', function() { $scope.$on('$destroy', function() {
walletService.lock(fc); walletService.lock(fc);
@ -61,6 +66,7 @@ angular.module('copayApp.controllers').controller('exportController',
function encodeWalletInfo() { function encodeWalletInfo() {
var c = fc.credentials; var c = fc.credentials;
var derivationPath = fc.credentials.getBaseAddressDerivationPath();
var encodingType = { var encodingType = {
mnemonic: 1, mnemonic: 1,
xpriv: 2, xpriv: 2,
@ -81,13 +87,19 @@ angular.module('copayApp.controllers').controller('exportController',
} }
} }
} else { } else {
/*
EXPORT WITHOUT PRIVATE KEY - PENDING
info = { info = {
type: encodingType.xpub, type: encodingType.xpub,
data: c.xPubKey data: c.xPubKey
} }
*/
return null;
} }
var code = info.type + '|' + info.data + '|' + c.network.charAt(0).toLowerCase() + '|' + c.account + '|' + c.derivationStrategy + '|' + (c.mnemonicHasPassphrase); var code = info.type + '|' + info.data + '|' + c.network.toLowerCase() + '|' + derivationPath + '|' + (c.mnemonicHasPassphrase);
return code; return code;
}; };

View file

@ -12,7 +12,6 @@ angular.module('copayApp.controllers').controller('importController',
$scope.bwsurl = defaults.bws.url; $scope.bwsurl = defaults.bws.url;
$scope.derivationPath = derivationPathHelper.default; $scope.derivationPath = derivationPathHelper.default;
$scope.account = 1; $scope.account = 1;
$scope.processingCode = null;
$scope.importErr = false; $scope.importErr = false;
$scope.fromQR = null; $scope.fromQR = null;
@ -35,15 +34,13 @@ angular.module('copayApp.controllers').controller('importController',
} }
}; };
$scope.processCode = function(code) { $scope.processWalletInfo = function(code) {
$scope.fromQR = null; $scope.fromQR = null;
$scope.importErr = false; $scope.importErr = false;
$scope.error = null; $scope.error = null;
ongoingProcess.set('processingCode', true);
var parsedCode = code.split('|'); var parsedCode = code.split('|');
if (parsedCode.length != 6) { if (parsedCode.length != 5) {
ongoingProcess.set('processingCode', false);
$scope.error = gettext('Cannot read the code properly. Missing parameters'); $scope.error = gettext('Cannot read the code properly. Missing parameters');
return; return;
} }
@ -51,48 +48,18 @@ angular.module('copayApp.controllers').controller('importController',
var info = { var info = {
type: parsedCode[0], type: parsedCode[0],
data: parsedCode[1], data: parsedCode[1],
network: parsedCode[2] == 't' ? 'testnet' : 'livenet', network: parsedCode[2],
account: parseInt(parsedCode[3]), derivationPath: parsedCode[3],
derivationStrategy: parsedCode[4], hasPassphrase: parsedCode[4] == 'true' ? true : false
hasPassphrase: parsedCode[5] == 'true' ? true : false
}; };
if (info.type == 1 && info.hasPassphrase) if (info.type == 1 && info.hasPassphrase)
$scope.error = gettext('Password required. Make sure to enter your password in advanced options'); $scope.error = gettext('Password required. Make sure to enter your password in advanced options');
var client = bwcService.getClient(null, null); $scope.derivationPath = info.derivationPath;
$scope.testnetEnabled = info.network == 'testnet' ? true : false;
if (info.type == 1) {
client.seedFromMnemonic(info.data, {
network: info.network,
account: info.account,
derivationStrategy: info.derivationStrategy
});
}
if (info.type == 2) {
client.seedFromExtendedPrivateKey(info.data, {
account: info.account,
derivationStrategy: info.derivationStrategy
});
}
if (info.type == 3) {
client.seedFromExtendedPublicKey(info.data, {
account: info.account,
derivationStrategy: info.derivationStrategy
});
}
$scope.derivationPath = client.credentials.getBaseAddressDerivationPath();
if (client.credentials.network == 'testnet')
$scope.testnetEnabled = true;
else
$scope.testnetEnabled = false;
$timeout(function() { $timeout(function() {
ongoingProcess.set('processingCode', false);
$scope.fromQR = true; $scope.fromQR = true;
$scope.words = null; $scope.words = null;
dataFromQR = info.data; dataFromQR = info.data;
@ -166,6 +133,28 @@ angular.module('copayApp.controllers').controller('importController',
}, 100); }, 100);
}; };
/*
IMPORT FROM PUBLIC KEY - PENDING
var _importExtendedPublicKey = function(xPubKey, opts) {
ongoingProcess.set('importingWallet', true);
$timeout(function() {
profileService.importExtendedPublicKey(opts, function(err, walletId) {
ongoingProcess.set('importingWallet', false);
if (err) {
$scope.error = err;
return $timeout(function() {
$scope.$apply();
});
}
$rootScope.$emit('Local/WalletImported', walletId);
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
go.walletHome();
});
}, 100);
};
*/
var _importMnemonic = function(words, opts) { var _importMnemonic = function(words, opts) {
ongoingProcess.set('importingWallet', true); ongoingProcess.set('importingWallet', true);
@ -269,6 +258,8 @@ angular.module('copayApp.controllers').controller('importController',
$scope.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) { } else if (words.indexOf('xprv') == 0 || words.indexOf('tprv') == 0) {
return _importExtendedPrivateKey(words, opts); return _importExtendedPrivateKey(words, opts);
} else if (words.indexOf('xpub') == 0 || words.indexOf('tpuv') == 0) {
return _importExtendedPublicKey(words, opts);
} else { } else {
var wordList = words.split(/[\u3000\s]+/); var wordList = words.split(/[\u3000\s]+/);

View file

@ -28,7 +28,7 @@ angular.module('copayApp.services').factory('ongoingProcess', function($log, $ti
'importingWallet': gettext('Importing Wallet...'), 'importingWallet': gettext('Importing Wallet...'),
'sweepingWallet': gettext('Sweeping Wallet...'), 'sweepingWallet': gettext('Sweeping Wallet...'),
'deletingWallet': gettext('Deleting Wallet...'), 'deletingWallet': gettext('Deleting Wallet...'),
'processingCode': gettext('Processing code...'), 'extractingWalletInfo': gettext('Extracting Wallet Information...'),
}; };
root.clear = function() { root.clear = function() {

View file

@ -699,6 +699,10 @@ ul.manage li {
padding-left: 25px; padding-left: 25px;
} }
.p15l {
padding-left: 15px;
}
.p15 { .p15 {
padding: 15px; padding: 15px;
} }