import from phrase and text done

This commit is contained in:
Javier 2016-09-06 15:11:02 -03:00
commit f2257f2519
8 changed files with 198 additions and 299 deletions

View file

@ -20,7 +20,7 @@
<i class="icon ion-ios-arrow-right nav-item-arrow-right"></i>
</a>
<a class="item item-remove-animate item-icon-right" type="item-text-wrap" ui-sref="tabs.import.phrase">
<a class="item item-remove-animate item-icon-right" type="item-text-wrap" ui-sref="tabs.import">
<h2 translate>Import wallet</h2>
<i class="icon ion-ios-arrow-right nav-item-arrow-right"></i>
</a>

View file

@ -1,33 +1,41 @@
<ion-view ng-controller="tabsController" ng-init="importInit()">
<ion-view>
<ion-nav-bar class="bar-royal">
<ion-nav-title>{{'Import Wallet' | translate}}</ion-nav-title>
<ion-nav-back-button>
<i class="icon ion-ios-arrow-thin-left"></i>
</ion-nav-back-button>
</ion-nav-bar>
<ion-content ng-controller="importController" ng-init="phrase = true; importInit()">
<div class="row text-center">
<div class="col" ng-click="phrase = true; file = hardware = false" ng-style="phrase && {'border-bottom': '2px solid'}">
<span translate>Recovery phrase</span>
</div>
<div class="col" ng-click="file = true; phrase = hardware = false" ng-style="file && {'border-bottom': '2px solid'}">
<span translate>File/Text</span>
</div>
<div class="col" ng-click="hardware = true; phrase = file = false" ng-style="hardware && {'border-bottom': '2px solid'}">
<span translate>Hardware wallet</span>
</div>
</div>
<div ng-include="'views/tab-import-phrase.html'" ng-if="phrase"></div>
<div ng-include="'views/tab-import-file.html'" ng-if="file"></div>
<div ng-include="'views/tab-import-hardware.html'" ng-if="hardware"></div>
</ion-content>
</ion-view>
<!-- <ion-view ng-controller="tabsController" ng-init="importInit()">
<ion-tabs class="tabs-striped tabs-color-positive tabs-color-active-positive tabs-top">
<div ng-if="!fromOnboarding">
<ion-tab title="Recovery Phrase" ui-sref="tabs.import.phrase">
<ion-nav-view name="tab-import-phrase"></ion-nav-view>
</ion-tab>
<ion-tab title="File/Text" ui-sref="tabs.import.file">
<ion-nav-view name="tab-import-file"></ion-nav-view>
</ion-tab>
<ion-tab title="Hardware Wallet" ui-sref="tabs.import.hardware">
<ion-nav-view name="tab-import-hardware"></ion-nav-view>
</ion-tab>
<div ng-include="'views/tab-import'"></div>
</div>
<div ng-if="fromOnboarding">
<ion-tab title="Recovery Phrase" ui-sref="onboarding.import.phrase">
<ion-nav-view name="tab-import-phrase"></ion-nav-view>
</ion-tab>
<ion-tab title="File/Text" ui-sref="onboarding.import.file">
<ion-nav-view name="tab-import-file"></ion-nav-view>
</ion-tab>
<ion-tab title="Hardware Wallet" ui-sref="onboarding.import.hardware">
<ion-nav-view name="tab-import-hardware"></ion-nav-view>
</ion-tab>
<div ng-include="'views/tab-import'"></div>
</div>
</ion-tabs>
</ion-view>
</ion-view> -->

View file

@ -1,61 +1,40 @@
<ion-view>
<ion-nav-bar class="bar-royal" ng-controller="backController">
<ion-nav-buttons side="primary">
<button class="button back-button" ng-click="importGoBack()">
<i class="icon ion-ios-arrow-thin-left"></i>
</button>
</ion-nav-buttons>
<ion-nav-title>{{'Import wallet' | translate}}</ion-nav-title>
</ion-nav-bar>
<ion-content ng-controller="importController" ng-init="type='file'">
<form name="importForm" ng-submit="importBlob(importForm)" novalidate>
<div class="list card">
<label class="item item-input item-stacked-label no-border" ng-show="!isSafari && !isCordova">
<div class="input-label" translate>Choose a backup file from your computer</div>
<div>
<input type="file"
placeholder="{{'Select a backup file'|translate}}"
name="backupFile"
ng-model="backupFile" ng-file-select>
</div>
</label>
<label class="item item-input item-stacked-label" ng-show="isSafari || isCordova">
<span class="input-label" translate>Paste the backup plain text code</span>
<textarea name="backupText" ng-model="backupText" rows="5"></textarea>
</label>
<label class="item item-input item-stacked-label">
<span class="input-label" translate>Password</span>
<input type="password"
placeholder="{{'Your password'|translate}}"
name="password"
ng-model="password">
</label>
<ion-toggle ng-model="showAdv" toggle-class="toggle-stable">
<span translate ng-show="!showAdv">Show advanced options</span>
<span translate ng-show="showAdv">Hide advanced options</span>
</ion-toggle>
<div ng-show="showAdv">
<label class="item item-input item-stacked-label">
<span class="input-label">Wallet Service URL</span>
<input type="text" id="bwsurl" name="bwsurl" ng-model="bwsurl">
</label>
</div>
<form name="importForm" ng-submit="importBlob(importForm)" novalidate>
<div class="list card">
<label class="item item-input item-stacked-label no-border" ng-show="!isSafari && !isCordova">
<div class="input-label" translate>Choose a backup file from your computer</div>
<div>
<input type="file"
placeholder="{{'Select a backup file'|translate}}"
ng-model="formData.backupFile" ng-file-select>
</div>
</label>
<button type="submit" class="button button-block button-positive" ng-disabled="importForm.$invalid || !password " translate>
Import backup
</button>
</form>
<label class="item item-input item-stacked-label" ng-show="isSafari || isCordova">
<span class="input-label" translate>Paste the backup plain text code</span>
<textarea ng-model="formData.backupText" rows="5"></textarea>
</label>
</ion-content>
</ion-view>
<label class="item item-input item-stacked-label">
<span class="input-label" translate>Password</span>
<input type="password"
placeholder="{{'Your password'|translate}}"
ng-model="formData.password">
</label>
<ion-toggle ng-model="showAdv" toggle-class="toggle-stable">
<span translate ng-show="!showAdv">Show advanced options</span>
<span translate ng-show="showAdv">Hide advanced options</span>
</ion-toggle>
<div ng-show="showAdv">
<label class="item item-input item-stacked-label">
<span class="input-label">Wallet Service URL</span>
<input type="text" ng-model="formData.bwsurl">
</label>
</div>
</div>
<button type="submit" class="button button-block button-positive" ng-disabled="importForm.$invalid || !formData.password" translate>
Import backup
</button>
</form>

View file

@ -1,69 +1,50 @@
<ion-view>
<ion-nav-bar class="bar-royal" ng-controller="backController">
<ion-nav-buttons side="primary">
<button class="button back-button" ng-click="importGoBack()">
<i class="icon ion-ios-arrow-thin-left"></i>
</button>
</ion-nav-buttons>
<ion-nav-title>{{'Import wallet' | translate}}</ion-nav-title>
</ion-nav-bar>
<form name="importForm3" ng-submit="importHW(importForm3)" novalidate>
<div class="card" ng-show="!seedOptions[0]">
<div class="item item-text-wrap" translate>
No hardware wallets supported on this device
</div>
</div>
<ion-content ng-controller="importController" ng-init="type='hwWallet'">
<form name="importForm3" ng-submit="importHW(importForm3)" novalidate>
<div class="card" ng-show="!seedOptions[0]">
<div class="item item-text-wrap" translate>
No hardware wallets supported on this device
<div ng-show="seedOptions[0]">
<div class="card list">
<label class="item item-input item-select">
<div class="input-label" translate>
Wallet Type
</div>
<select ng-model="seedSource"
ng-options="seed as seed.label for seed in seedOptions"
ng-change="setSeedSource()">
</select>
</label>
<label class="item item-input item-stacked-label"
ng-show="seedSourceId == 'trezor' || seedSourceId == 'ledger'">
<span class="input-label" translate>Account Number</span>
<input type="number" id="account" ng-model="account" ignore-mouse-wheel>
</label>
<ion-toggle ng-show="seedSourceId == 'trezor'"
ng-model="isMultisig"
toggle-class="toggle-positive">
<span translate>Shared Wallet</span>
</ion-toggle>
<ion-toggle ng-model="showAdv" toggle-class="toggle-stable">
<span translate ng-show="!showAdv">Show advanced options</span>
<span translate ng-show="showAdv">Hide advanced options</span>
</ion-toggle>
<div ng-show="showAdv">
<label class="item item-input item-stacked-label">
<span class="input-label">Wallet Service URL</span>
<input type="text" id="bwsurl" name="bwsurl" ng-model="bwsurl">
</label>
</div>
</div>
<div ng-show="seedOptions[0]">
<div class="card list">
<label class="item item-input item-select">
<div class="input-label" translate>
Wallet Type
</div>
<select ng-model="seedSource"
ng-options="seed as seed.label for seed in seedOptions"
ng-change="setSeedSource()">
</select>
</label>
<label class="item item-input item-stacked-label"
ng-show="seedSourceId == 'trezor' || seedSourceId == 'ledger'">
<span class="input-label" translate>Account Number</span>
<input type="number" id="account" ng-model="account" ignore-mouse-wheel>
</label>
<ion-toggle ng-show="seedSourceId == 'trezor'"
ng-model="isMultisig"
toggle-class="toggle-positive">
<span translate>Shared Wallet</span>
</ion-toggle>
<ion-toggle ng-model="showAdv" toggle-class="toggle-stable">
<span translate ng-show="!showAdv">Show advanced options</span>
<span translate ng-show="showAdv">Hide advanced options</span>
</ion-toggle>
<div ng-show="showAdv">
<label class="item item-input item-stacked-label">
<span class="input-label">Wallet Service URL</span>
<input type="text" id="bwsurl" name="bwsurl" ng-model="bwsurl">
</label>
</div>
</div>
<button translate type="submit" class="button button-block button-positive">
Import
</button>
</div> <!-- seedoptions show -->
</form>
</ion-content>
</ion-view>
<button translate type="submit" class="button button-block button-positive">
Import
</button>
</div> <!-- seedoptions show -->
</form>

View file

@ -1,84 +1,66 @@
<ion-view>
<ion-nav-bar class="bar-royal" ng-controller="backController">
<ion-nav-buttons side="primary">
<button class="button back-button" ng-click="importGoBack()">
<i class="icon ion-ios-arrow-thin-left"></i>
</button>
</ion-nav-buttons>
<ion-nav-title>Import wallet</ion-nav-title>
</ion-nav-bar>
<div ng-show="importErr" class="padding assertive" ng-click="importErr = null">
<div translate>Could not access the wallet at the server. Please check:</div>
<ul>
<li translate>The password of the recovery phrase (if set)</li>
<li translate>The derivation path</li>
<li translate>The wallet service URL</li>
</ul>
<div 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.
</div>
</div>
<ion-content ng-controller="importController" ng-init="type='12'">
<div ng-show="importErr" class="padding assertive" ng-click="importErr = null">
<div translate>Could not access the wallet at the server. Please check:</div>
<ul>
<li translate>The password of the recovery phrase (if set)</li>
<li translate>The derivation path</li>
<li translate>The wallet service URL</li>
</ul>
<div 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.
<form name="importForm12" ng-submit="importMnemonic(importForm12)" novalidate>
<div class="list card">
<div class="row">
<div class="col col-90">
<label class="item item-input item-stacked-label no-border">
<span class="input-label" translate>Type the Recovery Phrase (usually 12 words)</span>
<textarea ng-model="formData.words"
rows="3"
autocapitalize="off"
spellcheck="false"></textarea>
</label>
</div>
<div class="col text-center">
<qr-scanner class="qr-icon size-24" on-scan="processWalletInfo(data)"></qr-scanner>
</div>
</div>
<form name="importForm12" ng-submit="importMnemonic(importForm12)" novalidate>
<div class="list card">
<ion-toggle ng-model="showAdv" toggle-class="toggle-stable">
<span translate ng-show="!showAdv">Show advanced options</span>
<span translate ng-show="showAdv">Hide advanced options</span>
</ion-toggle>
<div class="row">
<div class="col col-90">
<label class="item item-input item-stacked-label no-border">
<span class="input-label" translate>Type the Recovery Phrase (usually 12 words)</span>
<textarea name="words"
ng-model="words"
rows="3"
autocapitalize="off"
spellcheck="false"></textarea>
</label>
</div>
<div class="col text-center">
<qr-scanner class="qr-icon size-24" on-scan="processWalletInfo(data)"></qr-scanner>
</div>
</div>
<div ng-show="showAdv">
<label class="item item-input item-stacked-label">
<span class="input-label" translate>Password</span>
<input type="text"
placeholder="{{'The recovery phrase could require a password to be imported'|translate}}"
autocapitalize="off"
ng-model="formData.passphrase">
</label>
<ion-toggle ng-model="showAdv" toggle-class="toggle-stable">
<span translate ng-show="!showAdv">Show advanced options</span>
<span translate ng-show="showAdv">Hide advanced options</span>
</ion-toggle>
<label class="item item-input item-stacked-label">
<span class="input-label" translate>Derivation Path</span>
<input type="text"
placeholder="{{'BIP32 path for address derivation'|translate}}"
ng-model="formData.derivationPath">
</label>
<div ng-show="showAdv">
<label class="item item-input item-stacked-label">
<span class="input-label">Wallet Service URL</span>
<input type="text" ng-model="formData.bwsurl">
</label>
<label class="item item-input item-stacked-label">
<span class="input-label">Wallet Service URL</span>
<input type="text" id="bwsurl" name="bwsurl" ng-model="bwsurl">
</label>
<ion-toggle ng-model="formData.testnetEnabled" ng-change="setDerivationPath()" toggle-class="toggle-positive">
Testnet
</ion-toggle>
</div>
</div>
<label class="item item-input item-stacked-label">
<span class="input-label" translate>Password</span>
<input type="text"
placeholder="{{'The recovery phrase could require a password to be imported'|translate}}"
autocapitalize="off"
name="passphrase"
ng-model="passphrase">
</label>
<label class="item item-input item-stacked-label">
<span class="input-label" translate>Derivation Path</span>
<input type="text"
placeholder="{{'BIP32 path for address derivation'|translate}}"
name="derivationPath"
ng-model="derivationPath">
</label>
<ion-toggle ng-model="testnetEnabled" ng-change="setDerivationPath(testnetEnabled)" toggle-class="toggle-positive">
Testnet
</ion-toggle>
</div>
</div>
<button type="submit"
class="button button-block button-positive"
ng-disabled="importForm12.$invalid" translate>Import</button>
</form>
</ion-content>
</ion-view>
<button type="submit"
class="button button-block button-positive"
ng-disabled="importForm12.$invalid" translate>Import
</button>
</form>

View file

@ -8,11 +8,13 @@ angular.module('copayApp.controllers').controller('importController',
var reader = new FileReader();
var defaults = configService.getDefaults();
var errors = bwcService.getErrors();
var derivationPath = 'livenet';
$scope.isSafari = platformInfo.isSafari;
$scope.isCordova = platformInfo.isCordova;
$scope.bwsurl = defaults.bws.url;
$scope.derivationPath = derivationPathHelper.default;
$scope.account = 1;
$scope.formData = {};
$scope.formData.bwsurl = defaults.bws.url;
$scope.formData.derivationPath = derivationPathHelper.default;
$scope.formData.account = 1;
$scope.importErr = false;
var updateSeedSourceSelect = function() {
@ -75,7 +77,7 @@ angular.module('copayApp.controllers').controller('importController',
var _importBlob = function(str, opts) {
var str2, err;
try {
str2 = sjcl.decrypt($scope.password, str);
str2 = sjcl.decrypt($scope.formData.password, str);
} catch (e) {
err = gettextCatalog.getString('Could not decrypt file, check your password');
$log.warn(e);
@ -147,7 +149,7 @@ angular.module('copayApp.controllers').controller('importController',
if (err) $log.error(err);
});
}
$state.go('tabs.home');
});
}, 100);
@ -176,11 +178,8 @@ angular.module('copayApp.controllers').controller('importController',
}, 100);
};
$scope.setDerivationPath = function(testnetEnabled) {
if (testnetEnabled)
$scope.derivationPath = derivationPathHelper.defaultTestnet;
else
$scope.derivationPath = derivationPathHelper.default;
$scope.setDerivationPath = function() {
derivationPath = $scope.formData.testnetEnabled ? derivationPathHelper.defaultTestnet : derivationPathHelper.default;
};
$scope.getFile = function() {
@ -188,7 +187,7 @@ angular.module('copayApp.controllers').controller('importController',
reader.onloadend = function(evt) {
if (evt.target.readyState == FileReader.DONE) { // DONE == 2
var opts = {};
opts.bwsurl = $scope.bwsurl;
opts.bwsurl = $scope.formData.bwsurl;
_importBlob(evt.target.result, opts);
}
}
@ -200,9 +199,9 @@ angular.module('copayApp.controllers').controller('importController',
return;
}
var backupFile = $scope.file;
var backupText = form.backupText.$modelValue;
var password = form.password.$modelValue;
var backupFile = $scope.formData.file;
var backupText = $scope.formData.backupText;
var password = $scope.formData.password;
if (!backupFile && !backupText) {
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Please, select your backup file'));
@ -213,7 +212,7 @@ angular.module('copayApp.controllers').controller('importController',
reader.readAsBinaryString(backupFile);
} else {
var opts = {};
opts.bwsurl = $scope.bwsurl;
opts.bwsurl = $scope.formData.bwsurl;
_importBlob(backupText, opts);
}
};
@ -225,19 +224,21 @@ angular.module('copayApp.controllers').controller('importController',
}
var opts = {};
if ($scope.bwsurl)
opts.bwsurl = $scope.bwsurl;
var pathData = derivationPathHelper.parse($scope.derivationPath);
if ($scope.formData.bwsurl)
opts.bwsurl = $scope.formData.bwsurl;
var pathData = derivationPathHelper.parse(derivationPath);
if (!pathData) {
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Invalid derivation path'));
return;
}
opts.account = pathData.account;
opts.networkName = pathData.networkName;
opts.derivationStrategy = pathData.derivationStrategy;
var words = form.words.$modelValue || null;
var words = $scope.formData.words || null;
if (!words) {
popupService.showAlert(gettextCatalog.getString('Please enter the recovery phrase'));
@ -254,9 +255,7 @@ angular.module('copayApp.controllers').controller('importController',
}
}
var passphrase = form.passphrase.$modelValue;
opts.passphrase = form.passphrase.$modelValue || null;
opts.passphrase = $scope.formData.passphrase || null;
_importMnemonic(words, opts);
};

View file

@ -107,7 +107,7 @@ angular.module('copayApp.directives')
return {
link: function($scope, el) {
el.bind('change', function(e) {
$scope.file = (e.srcElement || e.target).files[0];
$scope.formData.file = (e.srcElement || e.target).files[0];
$scope.getFile();
});
}

View file

@ -276,37 +276,12 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
})
.state('tabs.import', {
url: '/import',
// abstract: true,
views: {
'tab-home': {
templateUrl: 'views/import.html'
},
},
})
.state('tabs.import.phrase', {
url: '/tab-import-phrase',
views: {
'tab-import-phrase': {
templateUrl: 'views/tab-import-phrase.html',
},
}
})
.state('tabs.import.file', {
url: '/tab-import-file',
views: {
'tab-import-file': {
templateUrl: 'views/tab-import-file.html',
},
}
})
.state('tabs.import.hardware', {
url: '/tab-import-hardware',
views: {
'tab-import-hardware': {
templateUrl: 'views/tab-import-hardware.html',
},
}
})
.state('tabs.create', {
url: '/create',
views: {
@ -626,7 +601,6 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
})
.state('onboarding.import', {
url: '/import',
abstract: true,
views: {
'onboarding': {
templateUrl: 'views/import.html'
@ -637,30 +611,6 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
fromOnboarding: null
},
})
.state('onboarding.import.phrase', {
url: '/tab-import-phrase',
views: {
'tab-import-phrase': {
templateUrl: 'views/tab-import-phrase.html',
},
}
})
.state('onboarding.import.file', {
url: '/tab-import-file',
views: {
'tab-import-file': {
templateUrl: 'views/tab-import-file.html',
},
}
})
.state('onboarding.import.hardware', {
url: '/tab-import-hardware',
views: {
'tab-import-hardware': {
templateUrl: 'views/tab-import-hardware.html',
},
}
})
/*
*