one view/controller
This commit is contained in:
parent
945233363a
commit
3cd1498512
9 changed files with 295 additions and 379 deletions
|
|
@ -13,16 +13,6 @@
|
|||
</div>
|
||||
|
||||
<div ng-show="wordsC.mnemonicWords || (wordsC.credentialsEncrypted && !wordsC.deleted)">
|
||||
<div class="row" ng-show="index.n==1">
|
||||
<div class="m10t columns size-14 text-gray">
|
||||
<span translate>
|
||||
You need the wallet seed to restore this personal wallet.
|
||||
</span>
|
||||
<span translate class="text-bold">
|
||||
Write it down and keep them somewhere safe.
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" ng-show="(index.n>1 && index.m != index.n )">
|
||||
<div class="m10t columns size-14 text-gray">
|
||||
<span translate>
|
||||
|
|
@ -52,77 +42,159 @@
|
|||
|
||||
<div class="row m20t" ng-show="wordsC.deleted">
|
||||
<div class="columns size-14 text-gray text-center" translate>
|
||||
Wallet seed not available. You can still export it from Advanced > Export.
|
||||
Wallet seed not available. You can still export it from Advanced > Export.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-show="wordsC.mnemonicWords || (wordsC.credentialsEncrypted && !wordsC.deleted)">
|
||||
<!-- <div class="row">
|
||||
<div class="m10t columns">
|
||||
<a class="button outline light-gray expand tiny" ng-click="wordsC.toggle()">
|
||||
<i class="fi-widget m3r"></i>
|
||||
<span translate ng-hide="wordsC.show">Show Wallet Seed</span>
|
||||
<span translate ng-hide="!wordsC.show">Hide Wallet Seed</span>
|
||||
<i ng-if="!wordsC.show" class="icon-arrow-down4"></i>
|
||||
<i ng-if="wordsC.show" class="icon-arrow-up4"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
|
||||
<!-- <div class="row m10t m10b" ng-show="wordsC.show"> -->
|
||||
<div class="row m10t m10b" ng-show="!wordsC.credentialsEncrypted">
|
||||
<div class="small-centered text-gray columns size-14 text-center" translate>
|
||||
Your Wallet Seed
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <div class="row" ng-show="wordsC.show"> -->
|
||||
<div class="row" ng-show="!wordsC.credentialsEncrypted">
|
||||
<div class="columns">
|
||||
<div class="p10" style="background:white" ng-class="{'enable_text_select': index.network == 'testnet'}">
|
||||
<span ng-repeat="word in wordsC.mnemonicWords track by $index"><span style="white-space:nowrap">{{word}}</span><span ng-show="wordsC.useIdeograms"> </span> </span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <div class="row m10t m20b" ng-show="wordsC.show"> -->
|
||||
<div class="row m10t m20b" ng-show="!wordsC.credentialsEncrypted">
|
||||
<div class="columns" ng-show="wordsC.mnemonicHasPassphrase">
|
||||
<span class="size-12">
|
||||
<i class="fi-alert"></i>
|
||||
<span translate>
|
||||
WARNING: This seed was created with a passphrase. To recover this wallet both the mnemonic and passphrase are needed.
|
||||
</span>
|
||||
<div class="row" ng-show="index.n==1 && wordsC.step1">
|
||||
<div class="m10t columns size-14 text-gray">
|
||||
<span translate>
|
||||
You need the wallet seed to restore this personal wallet.
|
||||
</span>
|
||||
<span translate class="text-bold">
|
||||
Write it down and keep them somewhere safe.
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" ng-show="wordsC.credentialsEncrypted">
|
||||
<div class="m10t columns">
|
||||
<a class="button outline light-gray expand tiny" ng-click="wordsC.toggle()">
|
||||
<i class="fi-widget m3r"></i>
|
||||
<span translate ng-hide="wordsC.show">Show Wallet Seed</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <div class="row" ng-show="wordsC.show"> -->
|
||||
<!-- <div class="row">
|
||||
<div class="m10t text-center columns">
|
||||
<div class="size-12 text-gray">
|
||||
<div class="row m10t m10b" ng-show="!wordsC.credentialsEncrypted">
|
||||
<div class="small-centered text-gray columns size-14 text-center" translate>
|
||||
Your Wallet Seed
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--
|
||||
## STEP 1
|
||||
-->
|
||||
<div ng-show="wordsC.step1">
|
||||
<div class="row" ng-show="!wordsC.credentialsEncrypted">
|
||||
<div class="columns">
|
||||
<div class="p10" style="background:white" ng-class="{'enable_text_select': index.network == 'testnet'}">
|
||||
<span ng-repeat="word in wordsC.mnemonicWords track by $index"><span style="white-space:nowrap">{{word}}</span><span ng-show="wordsC.useIdeograms"> </span> </span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row m10t m20b" ng-show="!wordsC.credentialsEncrypted">
|
||||
<div class="columns" ng-show="wordsC.mnemonicHasPassphrase">
|
||||
<span class="size-12">
|
||||
<i class="fi-alert"></i>
|
||||
<span translate>
|
||||
Once you have copied your wallet seed down, it is recommended to delete it from this device.
|
||||
WARNING: This seed was created with a passphrase. To recover this wallet both the mnemonic and passphrase are needed.
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="columns text-center">
|
||||
<button
|
||||
ng-disabled="wordsC.credentialsEncrypted"
|
||||
class="black round small expand"
|
||||
ng-style="{'background-color':index.backgroundColor}"
|
||||
ng-click="wordsC.goToStep2();"
|
||||
translate>Continue
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--
|
||||
## STEP 2
|
||||
-->
|
||||
<div ng-show="wordsC.step2">
|
||||
<div class="row m10b">
|
||||
<div class="columns">
|
||||
<div class="p10 panel" ng-class="{'enable_text_select': index.network == 'testnet'}">
|
||||
<div id="addWord"></div>
|
||||
</div>
|
||||
<div class="p10" style="background:white" ng-class="{'enable_text_select': index.network == 'testnet'}">
|
||||
<span ng-repeat="word in wordsC.mnemonicWords track by $index">
|
||||
<button class="button radius tiny" ng-style="{'background-color':index.backgroundColor}" ng-click="wordsC.disableButton(word)" id="{{word}}">{{word}}</button>
|
||||
</span>
|
||||
</div>
|
||||
<button class="button outline m10t round dark-gray tiny" ng-click="wordsC.delete()">
|
||||
<i class="fi-trash"></i>
|
||||
<span translate>
|
||||
DELETE WORDS
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
|
||||
<div class="columns text-center">
|
||||
<button
|
||||
ng-disabled="wordsC.credentialsEncrypted"
|
||||
class="black round small expand"
|
||||
ng-style="{'background-color':index.backgroundColor}"
|
||||
ng-click="$root.go('backupWords');"
|
||||
translate>Continue
|
||||
</button>
|
||||
<div class="columns text-center">
|
||||
<button
|
||||
ng-disabled="!wordsC.selectComplete"
|
||||
class="black round small expand"
|
||||
ng-style="{'background-color':index.backgroundColor}"
|
||||
ng-click="wordsC.goToStep3();"
|
||||
translate>Continue
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--
|
||||
## STEP 3
|
||||
-->
|
||||
<div ng-show="wordsC.step3">
|
||||
<div class="row m10t m10b panel">
|
||||
<div class="small-centered text-gray columns size-14 text-center" translate>
|
||||
Passphrase needed
|
||||
</div>
|
||||
<div class="columns size-14 m20t">
|
||||
<input type="text" id="passphrase" ng-model="passphrase" autocapitalize="off" spellcheck="false" autofocus/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="columns text-center m20t">
|
||||
<button
|
||||
ng-disabled="!passphrase"
|
||||
ng-style="{'background-color':index.backgroundColor}"
|
||||
class="button black round expand"
|
||||
ng-click="wordsC.goToStep4();"
|
||||
translate>Continue
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--
|
||||
## STEP 4
|
||||
-->
|
||||
<div ng-show="wordsC.step4">
|
||||
<div class="box-notification" ng-show="wordsC.backupNoOk">
|
||||
<span class="text-warning" translate>
|
||||
Failed to verify backup. Please try again
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="onGoingProcess" ng-show="wordsC.checking">
|
||||
<div class="onGoingProcess-content" ng-style="{'background-color':index.backgroundColor}">
|
||||
<div class="spinner">
|
||||
<div class="rect1"></div>
|
||||
<div class="rect2"></div>
|
||||
<div class="rect3"></div>
|
||||
<div class="rect4"></div>
|
||||
<div class="rect5"></div>
|
||||
</div>
|
||||
<span translate>Verifying...</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row m10t m10b">
|
||||
<div class="small-centered text-gray columns size-14 text-center" translate>
|
||||
Congratulations
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="columns text-center m20t">
|
||||
<button
|
||||
ng-style="{'background-color':index.backgroundColor}"
|
||||
class="button black round expand"
|
||||
ng-click="wordsC.confirm();"
|
||||
translate>Finish
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- hide this in multisig just to show less text -->
|
||||
|
|
|
|||
|
|
@ -1,39 +0,0 @@
|
|||
<div
|
||||
class="topbar-container"
|
||||
ng-include="'views/includes/topbar.html'"
|
||||
ng-init="titleSection='Backup'; goBackToState = 'backupWords'">
|
||||
</div>
|
||||
|
||||
<div class="content preferences" ng-controller="backupConfirmController as backupConfirmC">
|
||||
<h4></h4>
|
||||
<div ng-show="backupConfirmC.mnemonicWords || (backupConfirmC.credentialsEncrypted && !backupConfirmC.deleted)">
|
||||
|
||||
<div class="row m10t m10b">
|
||||
<div class="small-centered text-gray columns size-14 text-center" translate>
|
||||
Congratulations
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="columns text-center m20t">
|
||||
<button
|
||||
ng-style="{'background-color':index.backgroundColor}"
|
||||
class="button black round expand"
|
||||
ng-click="backupConfirmC.confirm(); $root.go('walletHome');"
|
||||
translate>Finish
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="row m20t" ng-show="index.n==1">
|
||||
<div class="columns size-12 text-gray">
|
||||
<div class="p10t" style="border-top:1px solid #ccc">
|
||||
<span translate>You can safely install your wallet on another device and use it from multiple devices at the same time.</span>
|
||||
<a href="#" ng-click="$root.openExternalLink('https://github.com/bitpay/copay/blob/master/README.md#copay-backups-and-recovery')" translate>
|
||||
Learn more about Copay backups
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="extra-margin-bottom"></div>
|
||||
|
|
@ -1,70 +0,0 @@
|
|||
<div
|
||||
class="topbar-container"
|
||||
ng-include="'views/includes/topbar.html'"
|
||||
ng-init="titleSection='Backup'; goBackToState = 'backupWords'">
|
||||
</div>
|
||||
|
||||
<div class="content preferences" ng-controller="backupPassphraseController as backupPassphraseC">
|
||||
<h4></h4>
|
||||
<div class="box-notification" ng-show="backupPassphraseC.error">
|
||||
<span class="text-warning">
|
||||
{{backupPassphraseC.error|translate}}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="onGoingProcess" ng-show="backupPassphraseC.checkingPassphrase">
|
||||
<div class="onGoingProcess-content" ng-style="{'background-color':index.backgroundColor}">
|
||||
<div class="spinner">
|
||||
<div class="rect1"></div>
|
||||
<div class="rect2"></div>
|
||||
<div class="rect3"></div>
|
||||
<div class="rect4"></div>
|
||||
<div class="rect5"></div>
|
||||
</div>
|
||||
<span translate>Verifying passphrase...</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-show="backupPassphraseC.mnemonicWords || (backupPassphraseC.credentialsEncrypted && !backupPassphraseC.deleted)">
|
||||
<div class="row m10t m10b panel">
|
||||
<div class="small-centered text-gray columns size-14 text-center" translate>
|
||||
Passphrase needed
|
||||
</div>
|
||||
<div class="columns size-14 m20t">
|
||||
<input type="text" id="passphrase" ng-model="passphrase" autocapitalize="off" spellcheck="false" ng-keypress="backupPassphraseC.changePassphrase()" autofocus/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="columns text-center m20t">
|
||||
<button
|
||||
ng-show="!backupPassphraseC.passphraseSuccess"
|
||||
ng-disabled="!passphrase"
|
||||
ng-style="{'background-color':index.backgroundColor}"
|
||||
class="button black round expand"
|
||||
ng-click="backupPassphraseC.confirm()"
|
||||
translate>Confirm passphrase
|
||||
</button>
|
||||
<button
|
||||
ng-show="backupPassphraseC.passphraseSuccess"
|
||||
ng-disabled="!passphrase || backupPassphraseC.error"
|
||||
ng-style="{'background-color':index.backgroundColor}"
|
||||
class="button black round expand"
|
||||
ng-click="$root.go('backupConfirm');"
|
||||
translate>Continue
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="row m20t" ng-show="index.n==1">
|
||||
<div class="columns size-12 text-gray">
|
||||
<div class="p10t" style="border-top:1px solid #ccc">
|
||||
<span translate>You can safely install your wallet on another device and use it from multiple devices at the same time.</span>
|
||||
<a href="#" ng-click="$root.openExternalLink('https://github.com/bitpay/copay/blob/master/README.md#copay-backups-and-recovery')" translate>
|
||||
Learn more about Copay backups
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="extra-margin-bottom"></div>
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
<div
|
||||
class="topbar-container"
|
||||
ng-include="'views/includes/topbar.html'"
|
||||
ng-init="titleSection='Backup'; goBackToState = 'backup'">
|
||||
</div>
|
||||
|
||||
<div class="content preferences" ng-controller="backupWordsController as backupWordsC">
|
||||
<h4></h4>
|
||||
|
||||
<div ng-show="backupWordsC.mnemonicWords || (backupWordsC.credentialsEncrypted && !backupWordsC.deleted)">
|
||||
|
||||
<div class="row m10t m10b">
|
||||
<div class="small-centered text-gray columns size-14 text-center" translate>
|
||||
Your Wallet Seed
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row m10b">
|
||||
<div class="columns">
|
||||
<div class="p10 panel" ng-class="{'enable_text_select': index.network == 'testnet'}">
|
||||
<div id="addWord"></div>
|
||||
</div>
|
||||
<div class="p10" style="background:white" ng-class="{'enable_text_select': index.network == 'testnet'}">
|
||||
<span ng-repeat="word in backupWordsC.mnemonicWords track by $index">
|
||||
<button class="button radius tiny" ng-style="{'background-color':index.backgroundColor}" ng-click="backupWordsC.disableButton(word)" id="{{word}}">{{word}}</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="columns text-center m20t">
|
||||
<button
|
||||
ng-show="!backupWordsC.mnemonicHasPassphrase"
|
||||
ng-disabled="!backupWordsC.sorted"
|
||||
ng-style="{'background-color':index.backgroundColor}"
|
||||
class="button black round expand"
|
||||
ng-click="$root.go('backupConfirm');"
|
||||
translate>Continue
|
||||
</button>
|
||||
<button
|
||||
ng-show="backupWordsC.mnemonicHasPassphrase"
|
||||
ng-disabled="!backupWordsC.sorted"
|
||||
ng-style="{'background-color':index.backgroundColor}"
|
||||
class="button black round expand"
|
||||
ng-click="$root.go('backupPassphrase');"
|
||||
translate>Continue
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="row m20t" ng-show="index.n==1">
|
||||
<div class="columns size-12 text-gray">
|
||||
<div class="p10t" style="border-top:1px solid #ccc">
|
||||
<span translate>You can safely install your wallet on another device and use it from multiple devices at the same time.</span>
|
||||
<a href="#" ng-click="$root.openExternalLink('https://github.com/bitpay/copay/blob/master/README.md#copay-backups-and-recovery')" translate>
|
||||
Learn more about Copay backups
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="extra-margin-bottom"></div>
|
||||
|
|
@ -1,11 +1,21 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('backupController',
|
||||
function($rootScope, $scope, $timeout, $log, $compile, lodash, profileService, go, gettext, confirmDialog, notification, bwsError) {
|
||||
function($rootScope, $scope, $timeout, $log, $state, $compile, go, lodash, profileService, bwcService, bwsError) {
|
||||
|
||||
var self = this;
|
||||
var fc = profileService.focusedClient;
|
||||
var customWords = [];
|
||||
var mnemonic = null;
|
||||
self.xPrivKey = null;
|
||||
self.step1 = true;
|
||||
self.step2 = false;
|
||||
self.step3 = false;
|
||||
self.step4 = false;
|
||||
self.deleted = false;
|
||||
self.credentialsEncrypted = false;
|
||||
self.selectComplete = false;
|
||||
self.backupNoOk = false;
|
||||
|
||||
if (fc.credentials && !fc.credentials.mnemonicEncrypted && !fc.credentials.mnemonic)
|
||||
self.deleted = true;
|
||||
|
|
@ -14,7 +24,52 @@ angular.module('copayApp.controllers').controller('backupController',
|
|||
self.credentialsEncrypted = true;
|
||||
passwordRequest();
|
||||
} else
|
||||
setWords(fc.getMnemonic());
|
||||
setWords(getMnemonic());
|
||||
|
||||
function getMnemonic() {
|
||||
mnemonic = fc.getMnemonic();
|
||||
self.xPrivKey = fc.credentials.xPrivKey;
|
||||
profileService.lockFC();
|
||||
return mnemonic;
|
||||
}
|
||||
|
||||
self.goToStep2 = function() {
|
||||
self.step1 = false;
|
||||
self.step2 = true;
|
||||
self.step3 = false;
|
||||
self.step4 = false;
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 1);
|
||||
}
|
||||
|
||||
self.goToStep3 = function() {
|
||||
if (self.mnemonicHasPassphrase) {
|
||||
self.step1 = false;
|
||||
self.step2 = false;
|
||||
self.step3 = true;
|
||||
self.step4 = false;
|
||||
} else {
|
||||
self.step1 = false;
|
||||
self.step2 = false;
|
||||
self.step3 = false;
|
||||
self.step4 = true;
|
||||
}
|
||||
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 1);
|
||||
}
|
||||
|
||||
self.goToStep4 = function() {
|
||||
self.step1 = false;
|
||||
self.step2 = false;
|
||||
self.step3 = false;
|
||||
self.step4 = true;
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 1);
|
||||
}
|
||||
|
||||
function setWords(words) {
|
||||
if (words) {
|
||||
|
|
@ -24,9 +79,20 @@ angular.module('copayApp.controllers').controller('backupController',
|
|||
}
|
||||
};
|
||||
|
||||
self.toggle = function() {
|
||||
self.error = "";
|
||||
|
||||
if (self.credentialsEncrypted)
|
||||
passwordRequest();
|
||||
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 1);
|
||||
};
|
||||
|
||||
function passwordRequest() {
|
||||
try {
|
||||
setWords(fc.getMnemonic());
|
||||
setWords(getMnemonic());
|
||||
} catch (e) {
|
||||
if (e.message && e.message.match(/encrypted/) && fc.isPrivKeyEncrypted()) {
|
||||
|
||||
|
|
@ -42,9 +108,94 @@ angular.module('copayApp.controllers').controller('backupController',
|
|||
}
|
||||
|
||||
self.credentialsEncrypted = false;
|
||||
setWords(fc.getMnemonic());
|
||||
setWords(getMnemonic());
|
||||
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 1);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.enableButton = function(word) {
|
||||
document.getElementById(word).disabled = false;
|
||||
lodash.remove(customWords, function(v) {
|
||||
return v == word;
|
||||
});
|
||||
}
|
||||
|
||||
self.disableButton = function(word) {
|
||||
document.getElementById(word).disabled = true;
|
||||
customWords.push(word);
|
||||
self.addButton(word);
|
||||
}
|
||||
|
||||
self.addButton = function(word) {
|
||||
var btnhtml = '<button class="button radius tiny"' +
|
||||
'ng-style="{\'background-color\':index.backgroundColor}"' +
|
||||
'data-ng-click="wordsC.removeButton($event)" id="_' + word + '" > ' + word + ' </button>';
|
||||
var temp = $compile(btnhtml)($scope);
|
||||
angular.element(document.getElementById('addWord')).append(temp);
|
||||
self.shouldContinue();
|
||||
}
|
||||
|
||||
self.removeButton = function(event) {
|
||||
var id = (event.target.id);
|
||||
var element = document.getElementById(id);
|
||||
element.remove();
|
||||
self.enableButton(id.substring(1));
|
||||
self.shouldContinue();
|
||||
}
|
||||
|
||||
self.shouldContinue = function() {
|
||||
if (customWords.length == 12)
|
||||
self.selectComplete = true;
|
||||
else
|
||||
self.selectComplete = false;
|
||||
}
|
||||
|
||||
self.confirm = function() {
|
||||
self.backupNoOk = false;
|
||||
|
||||
var walletClient = bwcService.getClient();
|
||||
|
||||
try {
|
||||
var formatedCustomWords = '';
|
||||
|
||||
lodash.each(customWords, function(d) {
|
||||
return formatedCustomWords += ' ' + d;
|
||||
});
|
||||
|
||||
var passphrase = $scope.passphrase || '';
|
||||
|
||||
walletClient.seedFromMnemonic(formatedCustomWords.trim(), {
|
||||
network: fc.credentials.network,
|
||||
passphrase: passphrase,
|
||||
account: fc.credentials.account
|
||||
})
|
||||
|
||||
if (walletClient.credentials.xPrivKey != self.xPrivKey)
|
||||
throw 'Private key mismatch';
|
||||
|
||||
} catch (err) {
|
||||
$log.debug('Failed to verify backup: ', err);
|
||||
self.backupNoOk = true;
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('OK');
|
||||
|
||||
var words = lodash.map(mnemonic.split(' '), function(d) {
|
||||
return d;
|
||||
});
|
||||
|
||||
if (lodash.isEqual(words, customWords)) {
|
||||
$rootScope.$emit('Local/BackupDone');
|
||||
go.walletHome();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,22 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('backupConfirmController',
|
||||
function($rootScope, $scope, $timeout, $log, $compile, lodash, profileService, go, gettext, confirmDialog, notification, bwsError) {
|
||||
|
||||
var self = this;
|
||||
var fc = profileService.focusedClient;
|
||||
|
||||
setWords(fc.getMnemonic());
|
||||
|
||||
function setWords(words) {
|
||||
if (words) {
|
||||
self.mnemonicWords = words.split(/[\u3000\s]+/);
|
||||
self.mnemonicHasPassphrase = fc.mnemonicHasPassphrase();
|
||||
self.useIdeograms = words.indexOf("\u3000") >= 0;
|
||||
}
|
||||
};
|
||||
|
||||
self.confirm = function() {
|
||||
$rootScope.$emit('Local/BackupDone');
|
||||
}
|
||||
});
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('backupPassphraseController',
|
||||
function($rootScope, $scope, $timeout, $log, $compile, bwcService, lodash, profileService, go, gettext, confirmDialog, notification, bwsError) {
|
||||
|
||||
var self = this;
|
||||
var fc = profileService.focusedClient;
|
||||
self.passphraseSuccess = false;
|
||||
self.checkingPassphrase = false;
|
||||
self.error = "";
|
||||
|
||||
setWords(fc.getMnemonic());
|
||||
var words = fc.getMnemonic();
|
||||
|
||||
self.changePassphrase = function() {
|
||||
self.passphraseSuccess = false;
|
||||
$timeout(function() {
|
||||
$rootScope.$apply();
|
||||
}, 1);
|
||||
}
|
||||
|
||||
function setWords(words) {
|
||||
if (words) {
|
||||
self.mnemonicWords = words.split(/[\u3000\s]+/);
|
||||
self.mnemonicHasPassphrase = fc.mnemonicHasPassphrase();
|
||||
self.useIdeograms = words.indexOf("\u3000") >= 0;
|
||||
}
|
||||
};
|
||||
|
||||
self.confirm = function() {
|
||||
self.checkingPassphrase = true;
|
||||
self.error = "";
|
||||
|
||||
var walletClient = bwcService.getClient();
|
||||
|
||||
walletClient.importFromMnemonic(words, {
|
||||
network: 'livenet',
|
||||
passphrase: $scope.passphrase,
|
||||
account: 0,
|
||||
}, function(err) {
|
||||
self.checkingPassphrase = false;
|
||||
if (err) {
|
||||
self.error = err.message;
|
||||
$timeout(function() {
|
||||
$rootScope.$apply();
|
||||
}, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
self.passphraseSuccess = true;
|
||||
$timeout(function() {
|
||||
$rootScope.$apply();
|
||||
}, 1);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('backupWordsController',
|
||||
function($rootScope, $scope, $timeout, $log, $compile, lodash, profileService, go, gettext, confirmDialog, notification, bwsError) {
|
||||
|
||||
var self = this;
|
||||
var fc = profileService.focusedClient;
|
||||
var customSortWords = [];
|
||||
self.sorted = false;
|
||||
|
||||
setWords(fc.getMnemonic());
|
||||
|
||||
function setWords(words) {
|
||||
if (words) {
|
||||
self.mnemonicWords = words.split(/[\u3000\s]+/);
|
||||
self.mnemonicHasPassphrase = fc.mnemonicHasPassphrase();
|
||||
self.useIdeograms = words.indexOf("\u3000") >= 0;
|
||||
}
|
||||
};
|
||||
|
||||
self.enableButton = function(word) {
|
||||
document.getElementById(word).disabled = false;
|
||||
lodash.remove(customSortWords, function(v) {
|
||||
return v == word;
|
||||
});
|
||||
}
|
||||
|
||||
self.disableButton = function(word) {
|
||||
document.getElementById(word).disabled = true;
|
||||
customSortWords.push(word);
|
||||
self.addButton(word);
|
||||
}
|
||||
|
||||
self.addButton = function(word) {
|
||||
var btnhtml = '<button class="button radius tiny"' +
|
||||
'ng-style="{\'background-color\':index.backgroundColor}"' +
|
||||
'data-ng-click="backupWordsC.removeButton($event)" id="_' + word + '" > ' + word + ' </button>';
|
||||
var temp = $compile(btnhtml)($scope);
|
||||
angular.element(document.getElementById('addWord')).append(temp);
|
||||
self.shouldContinue(customSortWords);
|
||||
}
|
||||
|
||||
self.removeButton = function(event) {
|
||||
var id = (event.target.id);
|
||||
var element = document.getElementById(id);
|
||||
element.remove();
|
||||
self.enableButton(id.substring(1));
|
||||
self.shouldContinue(customSortWords);
|
||||
}
|
||||
|
||||
self.shouldContinue = function(customSortWords) {
|
||||
if (lodash.isEqual(self.mnemonicWords, customSortWords))
|
||||
self.sorted = true;
|
||||
else
|
||||
self.sorted = false;
|
||||
}
|
||||
});
|
||||
|
|
@ -445,17 +445,6 @@ angular
|
|||
},
|
||||
}
|
||||
})
|
||||
.state('backupConfirm', {
|
||||
url: '/backupConfirm',
|
||||
templateUrl: 'views/backupConfirm.html',
|
||||
walletShouldBeComplete: true,
|
||||
needProfile: true,
|
||||
views: {
|
||||
'main': {
|
||||
templateUrl: 'views/backupConfirm.html'
|
||||
},
|
||||
}
|
||||
})
|
||||
.state('backupPassphrase', {
|
||||
url: '/backupPassphrase',
|
||||
templateUrl: 'views/backupPassphrase.html',
|
||||
|
|
@ -467,6 +456,17 @@ angular
|
|||
},
|
||||
}
|
||||
})
|
||||
.state('backupConfirm', {
|
||||
url: '/backupConfirm',
|
||||
templateUrl: 'views/backupConfirm.html',
|
||||
walletShouldBeComplete: true,
|
||||
needProfile: true,
|
||||
views: {
|
||||
'main': {
|
||||
templateUrl: 'views/backupConfirm.html'
|
||||
},
|
||||
}
|
||||
})
|
||||
.state('preferencesGlobal', {
|
||||
url: '/preferencesGlobal',
|
||||
needProfile: true,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue