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
checkOK
cordova plugin add cordova-plugin-android-fingerprint-auth
checkOK
cordova plugin add cordova-plugin-screen-orientation
checkOK

View file

@ -96,7 +96,7 @@
</div>
<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>
</div>

View file

@ -24,83 +24,76 @@
<div class="row">
<div class="large-12 columns">
<div class="box-notification m20b" ng-show="import.importErr">
<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>
<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
</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>
</div>
<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>
<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
</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>
</div>
</div>
</div>
<div class="box-notification m20b" ng-show="import.error">
<div class="text-warning">
{{import.error|translate}}
</div>
<div class="text-warning">{{import.error|translate}}</div>
</div>
</div>
</div>
<div class="row">
<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 >
<label for="words">
<span translate>Type the Recovery Phrase (usually 12 words)</span>:
</label>
<textarea class="form-control" name="words" ng-model="import.words" rows="2" autocapitalize="off" spellcheck="false"></textarea>
</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 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="passphrase" class="oh"><span translate>Password</span> <small translate>The Wallet Recovery Phrase could require a password to be imported</small>
<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">
<input type="password" class="form-control" placeholder="{{'Password'|translate}}"
name="passphrase" ng-model="import.passphrase">
</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>
</div>
<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>
</div>
<label for="bws" class="oh">
<span>Wallet Service URL</span>
<input type="text" id="bwsurl" name="bwsurl" ng-model="bwsurl">
</label>
<label for="bws" class="oh">
<span>Wallet Service URL</span>
<input type="text" id="bwsurl" name="bwsurl" ng-model="bwsurl">
</label>
<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 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>
<button translate type="submit" class="button round expand black m10t"
ng-disabled="importForm12.$invalid ">
Import
</button>
</form>
<button translate type="submit" class="button round expand black m10t" ng-disabled="importForm12.$invalid">Import</button>
</form>
</div>
</div>
</div>
@ -175,58 +168,55 @@
</div>
<form name="importForm3" ng-submit="import.importHW(importForm3)" novalidate>
<div class="large-12 columns">
<div ng-show="!import.seedOptions[0]">
<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 ng-show="!import.seedOptions[0]">
<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 -->
</form>
</div>
</div>

View file

@ -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;
@ -64,7 +65,7 @@ angular.module('copayApp.controllers').controller('exportController',
if (c.mnemonic) {
info = {
type: encodingType.mnemonic,
data: c.mnemonic
data: c.mnemonic,
}
} else {
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;
};

View file

@ -13,6 +13,7 @@ angular.module('copayApp.controllers').controller('importController',
$scope.bwsurl = defaults.bws.url;
$scope.derivationPath = derivationPathHelper.default;
$scope.account = 1;
$scope.processingCode = null;
self.importErr = false;
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) {
$scope.type = type;
this.error = null;
$timeout(function() {
$rootScope.$apply();
});
}, 1);
};
var _importBlob = function(str, opts) {
@ -130,7 +165,7 @@ angular.module('copayApp.controllers').controller('importController',
$scope.derivationPath = derivationPathHelper.defaultTestnet;
else
$scope.derivationPath = derivationPathHelper.default;
}
};
$scope.getFile = function() {
// If we use onloadend, we need to check the readyState.