process code - parse information to import wallet

This commit is contained in:
Javier 2016-06-28 15:34:10 -03:00
commit 6aa075326e
5 changed files with 131 additions and 107 deletions

View file

@ -155,9 +155,6 @@ if [ ! -d $PROJECT ]; then
cordova plugin add cordova-plugin-disable-bitcode cordova plugin add cordova-plugin-disable-bitcode
checkOK checkOK
cordova plugin add cordova-plugin-android-fingerprint-auth
checkOK
cordova plugin add cordova-plugin-screen-orientation cordova plugin add cordova-plugin-screen-orientation
checkOK checkOK

View file

@ -96,7 +96,7 @@
</div> </div>
<div class="containter text-center p50t" ng-show="exportQR"> <div class="containter text-center p50t" ng-show="exportQR">
<qrcode size="220" version="7" error-correction-level="M" data="{{exportWalletInfo}}"></qrcode> <qrcode size="220" version="10" error-correction-level="M" data="{{exportWalletInfo}}"></qrcode>
<span translate></span> <span translate></span>
</div> </div>

View file

@ -24,83 +24,76 @@
<div class="row"> <div class="row">
<div class="large-12 columns"> <div class="large-12 columns">
<div class="box-notification m20b" ng-show="import.importErr"> <div class="box-notification m20b" ng-show="import.importErr">
<div ng-show="import.importErr" class="text-warning"> <div ng-show="import.importErr" class="text-warning">
<div class="m10 text-bold" translate>Could not access the wallet at the server. Please check:</div> <div class="m10 text-bold" translate>Could not access the wallet at the server. Please check:</div>
<ul class="size-12"> <ul class="size-12">
<li translate>The password of the recovery phrase (if set) <li translate>The password of the recovery phrase (if set)</li>
</li> <li translate>The derivation path</li>
<li translate>The derivation path <li translate>The wallet service URL
</li> </ul>
<li translate>The wallet service URL <div class="m15l">
</ul> <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>
<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>
</div>
</div> </div>
</div>
</div> </div>
<div class="box-notification m20b" ng-show="import.error"> <div class="box-notification m20b" ng-show="import.error">
<div class="text-warning"> <div class="text-warning">{{import.error|translate}}</div>
{{import.error|translate}}
</div>
</div> </div>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="large-12 columns"> <div class="large-12 columns">
<form name="importForm12" ng-submit="import.importMnemonic(importForm12)" novalidate> <form name="importForm12" ng-submit="import.importMnemonic(importForm12)" novalidate>
<label for="words">
<span translate>Type the Recovery Phrase (usually 12 words)</span>:
</label>
<div class="qr-scanner-input">
<qr-scanner on-scan="processCode(data)"></qr-scanner>
</div>
<textarea class="form-control" name="words" ng-model="words" rows="2" autocapitalize="off" spellcheck="false"></textarea>
<div > <div class="m10t oh" ng-init="hideAdv=true">
<label for="words"> <a class="button outline light-gray expand tiny p10i" ng-click="hideAdv=!hideAdv">
<span translate>Type the Recovery Phrase (usually 12 words)</span>: <i class="fi-widget m3r"></i>
</label> <span translate ng-hide="!hideAdv">Show advanced options</span>
<textarea class="form-control" name="words" ng-model="import.words" rows="2" autocapitalize="off" spellcheck="false"></textarea> <span translate ng-hide="hideAdv">Hide advanced options</span>
</div> <i ng-if="hideAdv" class="icon-arrow-down4"></i>
<i ng-if="!hideAdv" class="icon-arrow-up4"></i>
</a>
</div>
<div class="m10t oh" ng-init="hideAdv=true"> <div ng-hide="hideAdv" class="row">
<a class="button outline light-gray expand tiny p10i" ng-click="hideAdv=!hideAdv"> <div class="large-12 columns">
<i class="fi-widget m3r"></i> <label for="passphrase" class="oh"><span translate>Password</span> <small translate>The Wallet Recovery Phrase could require a password to be imported</small>
<span translate ng-hide="!hideAdv">Show advanced options</span>
<span translate ng-hide="hideAdv">Hide advanced options</span>
<i ng-if="hideAdv" class="icon-arrow-down4"></i>
<i ng-if="!hideAdv" class="icon-arrow-up4"></i>
</a>
</div>
<div ng-hide="hideAdv" class="row">
<div class="large-12 columns">
<label for="passphrase" class="oh"><span translate>Password</span> <small translate>The Wallet Recovery Phrase could require a password to be imported</small>
<div class="input"> <div class="input">
<input type="password" class="form-control" placeholder="{{'Password'|translate}}" <input type="password" class="form-control" placeholder="{{'Password'|translate}}"
name="passphrase" ng-model="import.passphrase"> name="passphrase" ng-model="import.passphrase">
</div> </div>
</label>
<div>
<label class="oh"><span translate>Derivation Path</span> <small translate>BIP32 path for address derivation</small>
<input type="text" class="form-control" name="derivationPath" ng-model="derivationPath">
</label> </label>
</div>
<div> <label for="bws" class="oh">
<label class="oh"><span translate>Derivation Path</span> <small translate>BIP32 path for address derivation</small> <span>Wallet Service URL</span>
<input type="text" class="form-control" name="derivationPath" ng-model="derivationPath"> <input type="text" id="bwsurl" name="bwsurl" ng-model="bwsurl">
</label> </label>
</div>
<label for="bws" class="oh"> <div class="oh">
<span>Wallet Service URL</span> <ion-toggle ng-model="testnetEnabled" ng-change="setDerivationPath()" toggle-class="toggle-balanced" class="bct">
<input type="text" id="bwsurl" name="bwsurl" ng-model="bwsurl"> <span class="toggle-label">Testnet</span>
</label> </ion-toggle>
<div class="oh">
<ion-toggle ng-model="testnetEnabled" ng-change="setDerivationPath()" toggle-class="toggle-balanced" class="bct">
<span class="toggle-label">Testnet</span>
</ion-toggle>
</div>
</div> </div>
</div> </div>
</div>
<button translate type="submit" class="button round expand black m10t" <button translate type="submit" class="button round expand black m10t" ng-disabled="importForm12.$invalid">Import</button>
ng-disabled="importForm12.$invalid "> </form>
Import
</button>
</form>
</div> </div>
</div> </div>
</div> </div>
@ -175,58 +168,55 @@
</div> </div>
<form name="importForm3" ng-submit="import.importHW(importForm3)" novalidate> <form name="importForm3" ng-submit="import.importHW(importForm3)" novalidate>
<div class="large-12 columns"> <div ng-show="!import.seedOptions[0]">
<div ng-show="!import.seedOptions[0]"> <span translate>No hardware wallets supported on this device</span>
<span translate>No hardware wallets supported on this device</span>
</div>
<div ng-show="import.seedOptions[0]">
<div>
<label><span translate>Wallet Recovery Phrase</span>
<select class="m10t" ng-model="seedSource"
ng-options="seed as seed.label for seed in import.seedOptions"
ng-change="import.setSeedSource()">
</select>
</label>
</div>
<div ng-show="import.seedSourceId == 'trezor' || import.seedSourceId == 'ledger'">
<label class="oh"><span translate>Account Number</span>
<input type="number" id="account" ng-model="account">
</label>
</div>
<div class="oh" ng-show="import.seedSourceId == 'trezor'">
<ion-toggle ng-model="isMultisig" toggle-class="toggle-balanced" class="bct">
<span class="toggle-label" translate>Shared Wallet</span>
</ion-toggle>
</div>
<div class="m10t oh" ng-init="hideAdv=true">
<a class="button outline light-gray expand tiny p10i" ng-click="hideAdv=!hideAdv">
<i class="fi-widget m3r"></i>
<span translate ng-hide="!hideAdv">Show advanced options</span>
<span translate ng-hide="hideAdv">Hide advanced options</span>
<i ng-if="hideAdv" class="icon-arrow-down4"></i>
<i ng-if="!hideAdv" class="icon-arrow-up4"></i>
</a>
</div>
<div ng-hide="hideAdv" class="row">
<div class="large-12 columns">
<label for="bws" class="oh">
<span>Wallet Service URL</span>
<input type="text" id="bwsurl" name="bwsurl" ng-model="bwsurl">
</label>
</div>
</div>
<button translate type="submit" class="button round expand black">
Import
</button>
</div> <!-- seedoptions show -->
</div> </div>
<div ng-show="import.seedOptions[0]">
<div>
<label><span translate>Wallet Recovery Phrase</span>
<select class="m10t" ng-model="seedSource"
ng-options="seed as seed.label for seed in import.seedOptions"
ng-change="import.setSeedSource()">
</select>
</label>
</div>
<div ng-show="import.seedSourceId == 'trezor' || import.seedSourceId == 'ledger'">
<label class="oh"><span translate>Account Number</span>
<input type="number" id="account" ng-model="account">
</label>
</div>
<div class="oh" ng-show="import.seedSourceId == 'trezor'">
<ion-toggle ng-model="isMultisig" toggle-class="toggle-balanced" class="bct">
<span class="toggle-label" translate>Shared Wallet</span>
</ion-toggle>
</div>
<div class="m10t oh" ng-init="hideAdv=true">
<a class="button outline light-gray expand tiny p10i" ng-click="hideAdv=!hideAdv">
<i class="fi-widget m3r"></i>
<span translate ng-hide="!hideAdv">Show advanced options</span>
<span translate ng-hide="hideAdv">Hide advanced options</span>
<i ng-if="hideAdv" class="icon-arrow-down4"></i>
<i ng-if="!hideAdv" class="icon-arrow-up4"></i>
</a>
</div>
<div ng-hide="hideAdv" class="row">
<div class="large-12 columns">
<label for="bws" class="oh">
<span>Wallet Service URL</span>
<input type="text" id="bwsurl" name="bwsurl" ng-model="bwsurl">
</label>
</div>
</div>
<button translate type="submit" class="button round expand black">
Import
</button>
</div> <!-- seedoptions show -->
</form> </form>
</div> </div>
</div> </div>

View file

@ -10,6 +10,7 @@ angular.module('copayApp.controllers').controller('exportController',
$scope.isCordova = platformInfo.isCordova; $scope.isCordova = platformInfo.isCordova;
$scope.isSafari = platformInfo.isSafari; $scope.isSafari = platformInfo.isSafari;
$scope.error = null; $scope.error = null;
console.log(fc.credentials);
$scope.init = function(state) { $scope.init = function(state) {
$scope.QROpts = false; $scope.QROpts = false;
@ -64,7 +65,7 @@ angular.module('copayApp.controllers').controller('exportController',
if (c.mnemonic) { if (c.mnemonic) {
info = { info = {
type: encodingType.mnemonic, type: encodingType.mnemonic,
data: c.mnemonic data: c.mnemonic,
} }
} else { } else {
info = { info = {
@ -79,7 +80,8 @@ angular.module('copayApp.controllers').controller('exportController',
} }
} }
var code = info.type + c.network.charAt(0).toLowerCase() + info.data; var code = info.type + '|' + c.network.charAt(0).toLowerCase() + '|' + info.data + '|' + c.account + '|' + c.derivationStrategy +
'|' + (c.mnemonicHasPassphrase || null);
return code; return code;
}; };

View file

@ -13,6 +13,7 @@ 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;
self.importErr = false; self.importErr = false;
var updateSeedSourceSelect = function() { var updateSeedSourceSelect = function() {
@ -34,12 +35,46 @@ angular.module('copayApp.controllers').controller('importController',
} }
}; };
$scope.processCode = function(code) {
var parsedCode = code.split('|');
var derivationStrategy = "44'";
var networkVal;
var info = {
type: parsedCode[0],
network: parsedCode[1],
data: parsedCode[2],
account: parsedCode[3],
derivationStrategy: parsedCode[4],
hasPassphrase: parsedCode[5]
};
$scope.words = info.data;
if (info.network == 't') {
networkVal = "1'";
$scope.testnetEnabled = true;
} else {
networkVal = "0'";
$scope.testnetEnabled = false;
}
if (info.derivationStrategy == 'BIP45' || info.derivationStrategy == 'BIP48')
derivationStrategy = info.derivationStrategy.substring(3, 5) + "'";
$scope.derivationPath = "m/" + derivationStrategy + '/' + networkVal + '/' + info.account + "'";
$timeout(function() {
$rootScope.$apply();
}, 1);
};
this.setType = function(type) { this.setType = function(type) {
$scope.type = type; $scope.type = type;
this.error = null; this.error = null;
$timeout(function() { $timeout(function() {
$rootScope.$apply(); $rootScope.$apply();
}); }, 1);
}; };
var _importBlob = function(str, opts) { var _importBlob = function(str, opts) {
@ -130,7 +165,7 @@ angular.module('copayApp.controllers').controller('importController',
$scope.derivationPath = derivationPathHelper.defaultTestnet; $scope.derivationPath = derivationPathHelper.defaultTestnet;
else else
$scope.derivationPath = derivationPathHelper.default; $scope.derivationPath = derivationPathHelper.default;
} };
$scope.getFile = function() { $scope.getFile = function() {
// If we use onloadend, we need to check the readyState. // If we use onloadend, we need to check the readyState.