commit
7dae3c7034
10 changed files with 203 additions and 343 deletions
|
|
@ -20,7 +20,7 @@
|
|||
<i class="icon 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 nav-item-arrow-right"></i>
|
||||
</a>
|
||||
|
|
|
|||
|
|
@ -1,33 +1,26 @@
|
|||
<ion-view ng-controller="tabsController" ng-init="importInit()">
|
||||
<ion-tabs class="tabs-striped tabs-color-positive tabs-color-active-positive tabs-top">
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<ion-content ng-controller="importController" ng-init="phrase = true; init()">
|
||||
<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-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>
|
||||
|
||||
</ion-tabs>
|
||||
<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>
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
<button class="button button-block get-started col col-75" href ui-sref="onboarding.tour" translate>Get started</button>
|
||||
</div>
|
||||
<div class="row">
|
||||
<button class="button button-block restore col col-75" translate href ui-sref="onboarding.import.phrase({'fromOnboarding':true})">Restore</button>
|
||||
<button class="button button-block restore col col-75" translate href ui-sref="onboarding.import({'fromOnboarding':true})">Restore</button>
|
||||
</div>
|
||||
</ion-content>
|
||||
</ion-view>
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -1,69 +1,44 @@
|
|||
<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"></select>
|
||||
</label>
|
||||
|
||||
<label class="item item-input item-stacked-label" ng-show="seedSource.id == 'trezor' || seedSource.id == 'ledger'">
|
||||
<span class="input-label" translate>Account Number</span>
|
||||
<input type="number" ng-model="formData.account" ignore-mouse-wheel>
|
||||
</label>
|
||||
|
||||
<ion-toggle ng-show="seedSource.id == 'trezor'" ng-model="formData.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" ng-model="formData.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>
|
||||
|
|
|
|||
|
|
@ -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 > 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 > 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>
|
||||
|
|
|
|||
|
|
@ -1,21 +1,26 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('importController',
|
||||
function($scope, $rootScope, $timeout, $log, $state, $stateParams, $ionicHistory, profileService, configService, sjcl, gettext, ledger, trezor, derivationPathHelper, platformInfo, bwcService, ongoingProcess, walletService, popupService, gettextCatalog) {
|
||||
function($scope, $timeout, $log, $state, $stateParams, profileService, configService, sjcl, ledger, trezor, derivationPathHelper, platformInfo, bwcService, ongoingProcess, walletService, popupService, gettextCatalog) {
|
||||
|
||||
var isChromeApp = platformInfo.isChromeApp;
|
||||
var isDevel = platformInfo.isDevel;
|
||||
var reader = new FileReader();
|
||||
var defaults = configService.getDefaults();
|
||||
var errors = bwcService.getErrors();
|
||||
$scope.isSafari = platformInfo.isSafari;
|
||||
$scope.isCordova = platformInfo.isCordova;
|
||||
$scope.bwsurl = defaults.bws.url;
|
||||
$scope.derivationPath = derivationPathHelper.default;
|
||||
$scope.account = 1;
|
||||
$scope.importErr = false;
|
||||
|
||||
var updateSeedSourceSelect = function() {
|
||||
$scope.init = function() {
|
||||
$scope.isSafari = platformInfo.isSafari;
|
||||
$scope.isCordova = platformInfo.isCordova;
|
||||
$scope.formData = {};
|
||||
$scope.formData.bwsurl = defaults.bws.url;
|
||||
$scope.formData.derivationPath = derivationPathHelper.default;
|
||||
$scope.formData.account = 1;
|
||||
$scope.importErr = false;
|
||||
|
||||
if ($stateParams.code)
|
||||
$scope.processWalletInfo($stateParams.code);
|
||||
|
||||
$scope.seedOptions = [];
|
||||
|
||||
if (isChromeApp) {
|
||||
|
|
@ -36,6 +41,7 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
|
||||
$scope.processWalletInfo = function(code) {
|
||||
if (!code) return;
|
||||
|
||||
$scope.importErr = false;
|
||||
var parsedCode = code.split('|');
|
||||
|
||||
|
|
@ -56,26 +62,19 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
if (info.type == 1 && info.hasPassphrase)
|
||||
popupService.showAlert(gettextCatalog.getString('Password required. Make sure to enter your password in advanced options'));
|
||||
|
||||
$scope.derivationPath = info.derivationPath;
|
||||
$scope.testnetEnabled = info.network == 'testnet' ? true : false;
|
||||
$scope.formData.derivationPath = info.derivationPath;
|
||||
$scope.formData.testnetEnabled = info.network == 'testnet' ? true : false;
|
||||
|
||||
$timeout(function() {
|
||||
$scope.words = info.data;
|
||||
$rootScope.$apply();
|
||||
}, 1);
|
||||
};
|
||||
|
||||
$scope.setType = function(type) {
|
||||
$scope.type = type;
|
||||
$timeout(function() {
|
||||
$rootScope.$apply();
|
||||
$scope.formData.words = info.data;
|
||||
$scope.$apply();
|
||||
}, 1);
|
||||
};
|
||||
|
||||
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);
|
||||
|
|
@ -83,9 +82,6 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
|
||||
if (err) {
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
$timeout(function() {
|
||||
$rootScope.$apply();
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -147,7 +143,7 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
if (err) $log.error(err);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$state.go('tabs.home');
|
||||
});
|
||||
}, 100);
|
||||
|
|
@ -176,11 +172,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() {
|
||||
$scope.formData.derivationPath = $scope.formData.testnetEnabled ? derivationPathHelper.defaultTestnet : derivationPathHelper.default;
|
||||
};
|
||||
|
||||
$scope.getFile = function() {
|
||||
|
|
@ -188,7 +181,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 +193,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 +206,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 +218,22 @@ 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($scope.formData.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 +250,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);
|
||||
};
|
||||
|
||||
|
|
@ -269,7 +263,7 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
}
|
||||
|
||||
lopts.externalSource = 'trezor';
|
||||
lopts.bwsurl = $scope.bwsurl;
|
||||
lopts.bwsurl = $scope.formData.bwsurl;
|
||||
ongoingProcess.set('importingWallet', true);
|
||||
$log.debug('Import opts', lopts);
|
||||
|
||||
|
|
@ -285,45 +279,37 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
};
|
||||
|
||||
$scope.importHW = function(form) {
|
||||
if (form.$invalid || $scope.account < 0) {
|
||||
if (form.$invalid || $scope.formData.ccount < 0) {
|
||||
popupService.showAlert(gettextCatalog.getString('There is an error in the form'));
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.importErr = false;
|
||||
|
||||
var account = +$scope.account;
|
||||
var account = $scope.formData.ccount;
|
||||
|
||||
if ($scope.seedSourceId == 'trezor') {
|
||||
if ($scope.seedSource.id == 'trezor') {
|
||||
if (account < 1) {
|
||||
$scope.error = gettext('Invalid account number');
|
||||
popupService.showAlert(gettextCatalog.getString('Invalid account number'));
|
||||
return;
|
||||
}
|
||||
account = account - 1;
|
||||
}
|
||||
|
||||
switch ($scope.seedSourceId) {
|
||||
switch ($scope.seedSource.id) {
|
||||
case ('ledger'):
|
||||
ongoingProcess.set('connectingledger', true);
|
||||
$scope.importLedger(account);
|
||||
break;
|
||||
case ('trezor'):
|
||||
ongoingProcess.set('connectingtrezor', true);
|
||||
$scope.importTrezor(account, $scope.isMultisig);
|
||||
$scope.importTrezor(account, $scope.formData.isMultisig);
|
||||
break;
|
||||
default:
|
||||
throw ('Error: bad source id');
|
||||
};
|
||||
};
|
||||
|
||||
$scope.setSeedSource = function() {
|
||||
|
||||
if (!$scope.seedSource) return;
|
||||
$scope.seedSourceId = $scope.seedSource.id;
|
||||
$timeout(function() {
|
||||
$rootScope.$apply();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.importLedger = function(account) {
|
||||
ledger.getInfoForNewWallet(true, account, function(err, lopts) {
|
||||
ongoingProcess.clear();
|
||||
|
|
@ -333,7 +319,7 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
}
|
||||
|
||||
lopts.externalSource = 'ledger';
|
||||
lopts.bwsurl = $scope.bwsurl;
|
||||
lopts.bwsurl = $scope.formData.bwsurl;
|
||||
ongoingProcess.set('importingWallet', true);
|
||||
$log.debug('Import opts', lopts);
|
||||
|
||||
|
|
@ -349,7 +335,6 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
};
|
||||
|
||||
var finish = function(wallet) {
|
||||
|
||||
walletService.updateRemotePreferences(wallet, {}, function() {
|
||||
$log.debug('Remote preferences saved for:' + wallet.credentials.walletId)
|
||||
});
|
||||
|
|
@ -362,8 +347,4 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
}
|
||||
$state.go('tabs.home');
|
||||
};
|
||||
|
||||
updateSeedSourceSelect();
|
||||
$scope.setSeedSource();
|
||||
if ($stateParams.code) $scope.processWalletInfo($stateParams.code);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
angular.module('copayApp.controllers').controller('welcomeController', function($scope, $state, $timeout, $log, $ionicPopup, profileService) {
|
||||
|
||||
$scope.goImport = function(code) {
|
||||
$state.go('onboarding.import.phrase', {
|
||||
$state.go('onboarding.import', {
|
||||
fromOnboarding: true,
|
||||
code: code
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
/*
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue