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

View File

@ -5,15 +5,16 @@
</div>
<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="tab-container small-6 medium-3 large-2"
<div class="tab-container small-6 columns"
ng-class="{'selected':!exportQR}"
ng-style="{'border-color':!exportQR ? index.backgroundColor: 'inherit'}"
ng-click="exportQR = false">
<a href ng-style="{'color':!exportQR ? index.backgroundColor: 'inherit'}" translate>File/Text</a>
</div>
<div class="tab-container small-6 medium-3 large-2"
<div class="tab-container small-6 columns"
ng-class="{'selected':exportQR}"
ng-style="{'border-color':exportQR ? index.backgroundColor: 'inherit'}"
ng-click="exportQR = true">
@ -45,18 +46,13 @@
</form>
<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>
</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 class="text-center size-12 m10" translate>From the destination device, go to Add wallet > Import wallet and scan this QR code</div>
</div>
<div class="row">
<div class="row" ng-show="!exportQR && index.canSign">
<div class="columns m15t">
<a class="button outline light-gray expand tiny p10i" ng-click="showAdvanced = !showAdvanced">
<i class="fi-widget m3r"></i>
@ -74,16 +70,16 @@
</ion-toggle>
</div>
<div class="box-notification" ng-show="!index.canSign">
<div class="box-notification p15l" ng-show="!index.canSign">
<span class="text-warning size-14">
<i class="fi-alert"></i>
<span translate>
WARNING: The private key of this wallet is not available. The export allows to check the wallet balance, transaction history, and create spend proposals from the export. However, does not allow to approve (sign) proposals, so <b>funds will not be accessible from the export</b>.
WARNING: The private key of this wallet is not available. The export allows to check the wallet balance, transaction history, and create spend proposals from the export. However, does not allow to approve (sign) proposals, so <b>funds will not be accessible from the export</b>.
</span>
</span>
</div>
<div class="box-notification" ng-show="noSign">
<div class="box-notification p15l" ng-show="noSignEnabled">
<span class="text-warning size-14">
<i class="fi-alert"></i>
<span translate>

View File

@ -29,7 +29,7 @@
<ul class="size-12">
<li translate>The password of the recovery phrase (if set)</li>
<li translate>The derivation path</li>
<li translate>The wallet service URL
<li translate>The wallet service URL</li>
</ul>
<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>
@ -51,7 +51,7 @@
</label>
<div class="qr-scanner-input">
<qr-scanner on-scan="processCode(data)"></qr-scanner>
<qr-scanner on-scan="processWalletInfo(data)"></qr-scanner>
</div>
<div class="lock-fromQR" ng-show="fromQR">

View File

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

View File

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

View File

@ -12,7 +12,6 @@ angular.module('copayApp.controllers').controller('importController',
$scope.bwsurl = defaults.bws.url;
$scope.derivationPath = derivationPathHelper.default;
$scope.account = 1;
$scope.processingCode = null;
$scope.importErr = false;
$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.importErr = false;
$scope.error = null;
ongoingProcess.set('processingCode', true);
var parsedCode = code.split('|');
if (parsedCode.length != 6) {
ongoingProcess.set('processingCode', false);
if (parsedCode.length != 5) {
$scope.error = gettext('Cannot read the code properly. Missing parameters');
return;
}
@ -51,48 +48,18 @@ angular.module('copayApp.controllers').controller('importController',
var info = {
type: parsedCode[0],
data: parsedCode[1],
network: parsedCode[2] == 't' ? 'testnet' : 'livenet',
account: parseInt(parsedCode[3]),
derivationStrategy: parsedCode[4],
hasPassphrase: parsedCode[5] == 'true' ? true : false
network: parsedCode[2],
derivationPath: parsedCode[3],
hasPassphrase: parsedCode[4] == 'true' ? true : false
};
if (info.type == 1 && info.hasPassphrase)
$scope.error = gettext('Password required. Make sure to enter your password in advanced options');
var client = bwcService.getClient(null, null);
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;
$scope.derivationPath = info.derivationPath;
$scope.testnetEnabled = info.network == 'testnet' ? true : false;
$timeout(function() {
ongoingProcess.set('processingCode', false);
$scope.fromQR = true;
$scope.words = null;
dataFromQR = info.data;
@ -166,6 +133,28 @@ angular.module('copayApp.controllers').controller('importController',
}, 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) {
ongoingProcess.set('importingWallet', true);
@ -269,6 +258,8 @@ angular.module('copayApp.controllers').controller('importController',
$scope.error = gettext('Please enter the recovery phrase');
} else if (words.indexOf('xprv') == 0 || words.indexOf('tprv') == 0) {
return _importExtendedPrivateKey(words, opts);
} else if (words.indexOf('xpub') == 0 || words.indexOf('tpuv') == 0) {
return _importExtendedPublicKey(words, opts);
} else {
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...'),
'sweepingWallet': gettext('Sweeping Wallet...'),
'deletingWallet': gettext('Deleting Wallet...'),
'processingCode': gettext('Processing code...'),
'extractingWalletInfo': gettext('Extracting Wallet Information...'),
};
root.clear = function() {

View File

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