Merge pull request #207 from gabrielbazan7/ref/fcWallet

delete focused wallet
This commit is contained in:
Matias Alejo Garcia 2016-08-19 13:18:08 -03:00 committed by GitHub
commit 7f960730b8
29 changed files with 186 additions and 205 deletions

View File

@ -1,18 +1,13 @@
<ion-view ng-controller="backupController" cache-view="false" ng-init="init(index.prevState)">
<ion-view>
<ion-nav-bar class="bar-stable">
<ion-nav-title>Backup Flow</ion-nav-title>
<ion-nav-buttons side="primary">
<button class="button no-border" ng-click="goToStep(1)" ng-show="(step != 1 && step != 4)">
<i class="icon ion-chevron-left"></i>
</button>
</ion-nav-buttons>
<ion-nav-buttons side="secondary">
  <span class="button no-border" ng-click="goBack()">
<i class="icon ion-close"></i>
</span>
 <button class="button" href ui-sref="wallet.preferences">
     <i class="ion-arrow-left-c"></i> Back
   </button>
  </ion-nav-buttons>
</ion-nav-bar>
<ion-content class="has-header">
<ion-content ng-controller="backupController" cache-view="false" ng-init="init()">
<div class="box-notification" ng-show="error">
<span class="text-warning">
{{error|translate}}
@ -23,27 +18,27 @@
## STEP 1
-->
<div class="content preferences text-center">
<div class="text-center">
<div ng-show="step == 1">
<div ng-show="mnemonicWords || (!credentialsEncrypted && !deleted)" class="row">
<h5 class="text-center" translate>Write your wallet recovery phrase</h5>
<div class="size-14 text-gray columns" ng-show="(index.n>1 && index.m != index.n )">
<div class="size-14 text-gray columns" ng-show="(wallet.n>1 && wallet.m != wallet.n )">
<span translate>
To restore this {{index.m}}-{{index.n}} <b>shared</b> wallet you will need
To restore this {{wallet.m}}-{{wallet.n}} <b>shared</b> wallet you will need
</span>:
<div class="m10t columns size-14 text-gray">
<span translate>Your wallet recovery phrase and access to the server that coordinated the initial wallet creation. You still need {{index.m}} keys to spend.</span>
<span translate>Your wallet recovery phrase and access to the server that coordinated the initial wallet creation. You still need {{wallet.m}} keys to spend.</span>
<span translate><b>OR</b> the wallet recovery phrase of <b>all</b> copayers in the wallet</span>
<span translate><b>OR</b> 1 wallet export file and the remaining quorum of wallet recovery phrases (e.g. in a 3-5 wallet: 1 wallet export file + 2 wallet recovery phrases of any of the other copayers).</span>
</div>
</span>
</div>
<div class="size-14 text-gray columns" ng-show="(index.n>1 && index.m == index.n )">
<div class="size-14 text-gray columns" ng-show="(wallet.n>1 && wallet.m == wallet.n )">
<span translate>
To restore this {{index.m}}-{{index.n}} <b>shared</b> wallet you will need
To restore this {{wallet.m}}-{{wallet.n}} <b>shared</b> wallet you will need
</span>:
<div class="m10t columns size-14 text-gray">
<span translate>Your wallet recovery phrase and access to the server that coordinated the initial wallet creation. You still need {{index.m}} keys to spend.</span>
<span translate>Your wallet recovery phrase and access to the server that coordinated the initial wallet creation. You still need {{wallet.m}} keys to spend.</span>
<span translate><b>OR</b> the wallet recovery phrases of <b>all</b> copayers in the wallet</span>
</div>
</span>
@ -57,14 +52,14 @@
</div>
<div ng-show="mnemonicWords || (!credentialsEncrypted && !deleted)">
<p class="text-center columns text-gray" ng-show="index.n==1 && step == 1">
<p class="text-center columns text-gray" ng-show="wallet.n==1 && step == 1">
<span translate>
You need the wallet recovery phrase to restore this personal wallet. Write it down and keep them somewhere safe.
</span>
</p>
<div class="row" ng-show="!credentialsEncrypted">
<div class="columns">
<div class="panel" ng-class="{'enable_text_select': index.network == 'testnet'}">
<div class="panel" ng-class="{'enable_text_select': wallet.network == 'testnet'}">
<span ng-repeat="word in mnemonicWords track by $index"><span style="white-space:nowrap">{{word}}</span><span ng-show="useIdeograms">&#x3000;</span> </span>
</div>
</div>

View File

@ -1,5 +1,5 @@
<ion-view ng-controller="exportController" cache-view="false" ng-init="init()">
<ion-view>
<ion-nav-bar class="bar-stable">
<ion-nav-title>Export Wallet</ion-nav-title>
<ion-nav-buttons side="primary">
@ -8,25 +8,22 @@
</button>
</ion-nav-buttons>
</ion-nav-bar>
<ion-content class="has-header">
<h4>{{wallet.name}}</h4>
<ion-content ng-controller="exportController" cache-view="false" ng-init="init()">
<div ng-show="!canSign"><h4></h4></div>
<div ng-show="canSign" class="create-tab small-only-text-center">
<div class="row">
<div class="tab-container small-6 columns"
<div class="row" ng-show="canSign">
<div class="col"
ng-class="{'selected':!exportQR}"
ng-style="{'border-color':!exportQR ? index.backgroundColor: 'inherit'}"
ng-style="{'border-color':!exportQR ? wallet.color: 'inherit'}"
ng-click="exportQR = false">
<a href ng-style="{'color':!exportQR ? index.backgroundColor: 'inherit'}" translate>File/Text</a>
<a class="button button-full button-clear" ng-style="{'color':!exportQR ? wallet.color: 'inherit'}" translate>File/Text</a>
</div>
<div class="tab-container small-6 columns"
<div class="col"
ng-class="{'selected':exportQR}"
ng-style="{'border-color':exportQR ? index.backgroundColor: 'inherit'}"
ng-style="{'border-color':exportQR ? wallet.color: 'inherit'}"
ng-click="exportQR = true">
<a href ng-style="{'color':exportQR ? index.backgroundColor: 'inherit'}" translate>QR Code</a>
<a class="button button-full button-clear" ng-style="{'color':exportQR ? wallet.color: 'inherit'}" translate>QR Code</a>
</div>
</div>
</div>
<div ng-show="!backupWalletPlainText">
@ -35,20 +32,15 @@
<span translate>Failed to export</span>
</div>
<form ng-show="!exportQR">
<div class="row">
<div class="columns">
<label for="password" translate>Set up a password </label>
<div class="input">
<input type="password" class="form-control" placeholder="{{'Your password'|translate}}" name="password" ng-model="password">
</div>
<label for="password" translate>Repeat the password</label>
<div class="input">
<input type="password" class="form-control" placeholder="{{'Repeat password'|translate}}" name="password" ng-model="repeatpassword">
</div>
</div>
</div>
<form name="exportForm" ng-show="!exportQR" novalidate>
<label class="item item-input item-stacked-label">
<span class="input-label" transalate>Set up a password</span>
<input type="password" placeholder="{{'Your password'|translate}}" name="password" ng-model="password">
</label>
<label class="item item-input item-stacked-label">
<span class="input-label" transalate>Repeat the password</span>
<input type="password" class="form-control" placeholder="{{'Repeat password'|translate}}" name="password" ng-model="repeatpassword">
</label>
</form>
<div class="m20t text-gray" ng-show="exportQR && supported">
@ -62,27 +54,18 @@
<div class="text-center size-12 m10" translate>Exporting via QR not supported for this wallet</div>
</div>
<div class="row" ng-show="!exportQR && canSign">
<div class="columns m15t">
<a class="button outline light-gray expand tiny p10i" ng-click="showAdvanced = !showAdvanced">
<i class="fi-widget m3r"></i>
<span translate ng-hide="showAdvanced">Show advanced options</span>
<span translate ng-hide="!showAdvanced">Hide advanced options</span>
<i ng-if="!showAdvanced" class="icon-arrow-down4"></i>
<i ng-if="showAdvanced" class="icon-arrow-up4"></i>
</a>
</div>
</div>
<ion-toggle ng-show="!exportQR && canSign" ng-model="showAdvanced" toggle-class="toggle-balanced">
<span translate ng-show="!showAdvanced">Show advanced options</span>
<span translate ng-show="showAdvanced">Hide advanced options</span>
</ion-toggle>
<div ng-show="showAdvanced && !exportQR">
<ion-toggle ng-model="noSignEnabled" toggle-class="toggle-balanced" class="r0" ng-change="noSignEnabledChange()">
<span class="toggle-label" translate>Do not include private key</span>
</ion-toggle>
</div>
<ion-toggle ng-model="noSignEnabled" ng-show="showAdvanced && !exportQR" toggle-class="toggle-balanced" class="r0" ng-change="noSignEnabledChange()">
<span class="toggle-label" translate>Do not include private key</span>
</ion-toggle>
<div class="box-notification p15l" ng-show="!canSign">
<span class="text-warning size-14">
<i class="fi-alert"></i>
<i class="ion-alert-circled"></i>
<span translate>
WARNING: The private key of this wallet is not available. The export allows to check the wallet balance, transaction history, and create spend proposals from the export. However, does not allow to approve (sign) proposals, so <b>funds will not be accessible from the export</b>.
</span>
@ -91,37 +74,44 @@
<div class="box-notification p15l" ng-show="noSignEnabled && !exportQR">
<span class="text-warning size-14">
<i class="fi-alert"></i>
<i class="ion-alert-circled"></i>
<span translate>
WARNING: Not including the private key allows to check the wallet balance, transaction history, and create spend proposals from the export. However, does not allow to approve (sign) proposals, so <b>funds will not be accessible from the export</b>.
</span>
</span>
</div>
<div class="row" ng-show="!exportQR">
<div class="columns">
<button class="black round expand m20t" ng-click="downloadWalletBackup()"
ng-disabled="(!password || password != repeatpassword)"
ng-style="{'background-color':wallet.color}"
ng-show="!isSafari && !isCordova"><i class="fi-download"></i>
<span translate>Download</span></button>
<button class="black round expand m20t" ng-click="viewWalletBackup()"
ng-disabled="(!password || password != repeatpassword)"
ng-style="{'background-color':wallet.color}"
ng-show="isSafari && !isCordova"><i class="fi-eye"></i>
<span translate>View</span></button>
<div ng-show="isCordova">
<h4 translate>Export options</h4>
<button class="black round expand" ng-disabled="(!password || password != repeatpassword)"
ng-style="{'background-color':index.backgroundColor}"
ng-click="copyWalletBackup()"><i class="fi-clipboard-pencil"></i>
<span translate>Copy to clipboard</span></button>
<button class="black round expand" ng-disabled="(!password || password != repeatpassword)"
ng-style="{'background-color':index.backgroundColor}"
ng-click="sendWalletBackup()"><i class="fi-mail"></i>
<span translate>Send by email</span></button>
</div>
</div>
<button ng-show="!exportQR"
ng-click="downloadWalletBackup()"
class="button button-block button-positive"
ng-disabled="(!password || password != repeatpassword)"
ng-style="{'background-color':wallet.color}"
ng-show="!isSafari && !isCordova">
<i class="fi-download"></i>
<span translate>Download</span>
</button>
<button ng-show="!exportQR"
ng-click="viewWalletBackup()"
class="button button-block button-positive"
ng-disabled="(!password || password != repeatpassword)"
ng-style="{'background-color':wallet.color}"
ng-show="isSafari && !isCordova">
<i class="fi-eye"></i>
<span translate>View</span>
</button>
<div ng-show="isCordova">
<h4 translate>Export options</h4>
<button class="button button-block button-positive"
ng-disabled="(!password || password != repeatpassword)"
ng-style="{'background-color':index.backgroundColor}"
ng-click="copyWalletBackup()">
<i class="fi-clipboard-pencil"></i>
<span translate>Copy to clipboard</span></button>
<button class="button button-block button-positive" ng-disabled="(!password || password != repeatpassword)"
ng-style="{'background-color':index.backgroundColor}"
ng-click="sendWalletBackup()"><i class="fi-mail"></i>
<span translate>Send by email</span></button>
</div>
</div>

View File

@ -7,7 +7,7 @@
</button>
</ion-nav-buttons>
</ion-nav-bar>
<ion-content class="has-header" ng-controller="preferencesController" cache-view="false" ng-init="init()">
<ion-content ng-controller="preferencesController" cache-view="false" ng-init="init()">
<div class="list">
<div class="item item-divider">
Preferences

View File

@ -7,7 +7,7 @@
</button>
</ion-nav-buttons>
</ion-nav-bar>
<ion-content class="has-header">
<ion-content>
<div class="list">
<div class="item item-divider">
</div>

View File

@ -7,7 +7,7 @@
</button>
</ion-nav-buttons>
</ion-nav-bar>
<ion-content class="has-header" ng-controller="preferencesAliasController" cache-view="false">
<ion-content ng-controller="preferencesAliasController" cache-view="false">
<form name="aliasForm" ng-submit="save(aliasForm)" novalidate>
<label class="item item-input item-stacked-label">
<span class="input-label" transalate>Alias for {{walletName}}</span>

View File

@ -7,7 +7,7 @@
</button>
</ion-nav-buttons>
</ion-nav-bar>
<ion-content class="has-header" ng-controller="preferencesBwsUrlController" cache-view="false">
<ion-content ng-controller="preferencesBwsUrlController" cache-view="false">
<form name="settingsBwsUrlForm" ng-submit="save(settingsBwsUrlForm)" novalidate>
<label class="item item-input item-stacked-label">
<span class="input-label" transalate>Wallet Service URL</span><a ng-click="resetDefaultUrl()" translate> Set default url</a>

View File

@ -7,7 +7,7 @@
</button>
</ion-nav-buttons>
</ion-nav-bar>
<ion-content class="has-header" ng-controller="preferencesColorController" cache-view="false">
<ion-content ng-controller="preferencesColorController" cache-view="false">
<ion-radio ng-repeat="c in colorList" ng-value="c" ng-model="currentColor" ng-click="save(c)">
<span ng-style="{'color': c}">&block;</span>
</ion-radio>

View File

@ -7,7 +7,7 @@
</button>
</ion-nav-buttons>
</ion-nav-bar>
<ion-content class="has-header" ng-controller="preferencesDeleteWordsController" cache-view="false">
<ion-content ng-controller="preferencesDeleteWordsController" cache-view="false">
<div ng-show="!deleted">
<div ng-show="error">
{{error|translate}}

View File

@ -7,7 +7,7 @@
</button>
</ion-nav-buttons>
</ion-nav-bar>
<ion-content class="has-header" ng-controller="preferencesEmailController" cache-view="false">
<ion-content ng-controller="preferencesEmailController" cache-view="false">
<form name="emailForm" ng-submit="save(emailForm)" novalidate>
<label class="item item-input item-stacked-label">
<span class="input-label" transalate>Email for wallet notifications</span>

View File

@ -5,7 +5,7 @@
<div class="content preferences" ng-controller="preferencesGlobalController" ng-init="init()">
<h4></h4>
<ul class="no-bullet m0">
<ul>
<li href ui-sref="preferencesLanguage">
<div class="right text-gray">
{{currentLanguageName|translate}}

View File

@ -7,7 +7,7 @@
</button>
</ion-nav-buttons>
</ion-nav-bar>
<ion-content class="has-header" ng-controller="preferencesHistory" cache-view="false" ng-init="index.updatingTxHistory ? null : csvHistory()">
<ion-content ng-controller="preferencesHistory" cache-view="false" ng-init="index.updatingTxHistory ? null : csvHistory()">
<div class="item item-divider"></div>
<div class="item" ng-show="csvReady && !index.isCordova" ng-csv="csvContent" csv-header="csvHeader" filename="Copay-{{index.alias || index.walletName}}.csv">
<span translate>Export to file</span>

View File

@ -7,7 +7,7 @@
</button>
</ion-nav-buttons>
</ion-nav-bar>
<ion-content class="has-header" ng-controller="preferencesInformation" cache-view="false" ng-init="init()">
<ion-content ng-controller="preferencesInformation" cache-view="false" ng-init="init()">
<div class="list">
<div class="item item-divider">
Wallet Information

View File

@ -2,7 +2,7 @@
<ion-nav-bar class="bar-stable">
<ion-nav-title>Global Settings</ion-nav-title>
</ion-nav-bar>
<ion-content class="has-header" ng-controller="tabSettingsController" cache-view="false" ng-init="init()">
<ion-content ng-controller="tabSettingsController" cache-view="false" ng-init="init()">
<div class="item item-divider">
</div>
<div class="list">

View File

@ -13,7 +13,7 @@
</ion-nav-buttons>
</ion-nav-bar>
<ion-content ng-controller="walletDetailsController" ng-init="init()" cache-view="false" class="has-header" delegate-handle="my-handle" overflow-scroll="true">
<ion-content ng-controller="walletDetailsController" ng-init="init()" cache-view="false" delegate-handle="my-handle" overflow-scroll="true">
<div ng-show="!wallet">
No Wallet
<a href ui-sref="tabs.home" class="button">

View File

@ -1,30 +1,28 @@
'use strict';
angular.module('copayApp.controllers').controller('backupController',
function($rootScope, $scope, $timeout, $log, $state, lodash, fingerprintService, platformInfo, configService, profileService, gettext, bwcService, walletService, ongoingProcess) {
function($rootScope, $scope, $timeout, $log, $state, $stateParams, lodash, fingerprintService, platformInfo, configService, profileService, gettext, bwcService, walletService, ongoingProcess) {
var fc = profileService.focusedClient;
var prevState;
var wallet = profileService.getWallet($stateParams.walletId);
$scope.customWords = [];
$scope.walletName = fc.credentials.walletName;
$scope.credentialsEncrypted = fc.isPrivKeyEncrypted;
$scope.walletName = wallet.credentials.walletName;
$scope.credentialsEncrypted = wallet.isPrivKeyEncrypted;
$scope.init = function(state) {
prevState = state || 'walletHome';
$scope.init = function() {
$scope.step = 1;
$scope.deleted = isDeletedSeed();
if ($scope.deleted) return;
fingerprintService.check(fc, function(err) {
fingerprintService.check(wallet, function(err) {
if (err) {
go.path(prevState);
$state.transitionTo('preferences');
return;
}
handleEncryptedWallet(fc, function(err) {
handleEncryptedWallet(wallet, function(err) {
if (err) {
$log.warn('Error decrypting credentials:', $scope.error);
go.path(prevState);
$state.transitionTo('preferences');
return;
}
$scope.credentialsEncrypted = false;
@ -45,11 +43,11 @@ angular.module('copayApp.controllers').controller('backupController',
};
$scope.initFlow = function() {
var words = fc.getMnemonic();
$scope.xPrivKey = fc.credentials.xPrivKey;
var words = wallet.getMnemonic();
$scope.xPrivKey = wallet.credentials.xPrivKey;
$scope.mnemonicWords = words.split(/[\u3000\s]+/);
$scope.shuffledMnemonicWords = shuffledWords($scope.mnemonicWords);
$scope.mnemonicHasPassphrase = fc.mnemonicHasPassphrase();
$scope.mnemonicHasPassphrase = wallet.mnemonicHasPassphrase();
$scope.useIdeograms = words.indexOf("\u3000") >= 0;
$scope.passphrase = '';
$scope.customWords = [];
@ -63,17 +61,13 @@ angular.module('copayApp.controllers').controller('backupController',
};
function isDeletedSeed() {
if (lodash.isEmpty(fc.credentials.mnemonic) && lodash.isEmpty(fc.credentials.mnemonicEncrypted))
if (lodash.isEmpty(wallet.credentials.mnemonic) && lodash.isEmpty(wallet.credentials.mnemonicEncrypted))
return true;
return false;
};
$scope.goBack = function() {
$state.go('wallet.preferences');
};
$scope.$on('$destroy', function() {
walletService.lock(fc);
walletService.lock(wallet);
});
$scope.goToStep = function(n) {
@ -147,9 +141,9 @@ angular.module('copayApp.controllers').controller('backupController',
try {
walletClient.seedFromMnemonic(customSentence, {
network: fc.credentials.network,
network: wallet.credentials.network,
passphrase: passphrase,
account: fc.credentials.account
account: wallet.credentials.account
});
} catch (err) {
return cb(err);

View File

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('copayersController',
function($scope, $rootScope, $timeout, $log, $ionicModal, profileService, go, notification, platformInfo, gettext, gettextCatalog, $stateParams, $state) {
function($scope, $rootScope, $timeout, $log, $ionicModal, $stateParams, profileService, go, notification, platformInfo, gettext, gettextCatalog, $state) {
var self = this;
$scope.isCordova = platformInfo.isCordova;
var isWP = platformInfo.isWP;
@ -30,9 +30,9 @@ angular.module('copayApp.controllers').controller('copayersController',
};
var doDeleteWallet = function() {
var fc = profileService.focusedClient;
var walletName = fc.credentials.walletName;
profileService.deleteWalletClient(fc, function(err) {
var wallet = profileService.getWallet($stateParams.walletId);
var walletName = wallet.credentials.walletName;
profileService.deleteWalletClient(wallet, function(err) {
if (err) {
self.error = err.message || err;
$timeout(function() {
@ -53,7 +53,7 @@ angular.module('copayApp.controllers').controller('copayersController',
};
$scope.deleteWallet = function() {
var fc = profileService.focusedClient;
var wallet = profileService.focusedClient;
if ($scope.isCordova) {
navigator.notification.confirm(
delete_msg,
@ -86,18 +86,18 @@ angular.module('copayApp.controllers').controller('copayersController',
};
if (!$stateParams.walletId) {
$log.debug('No wallet provided...back to home');
return $state.transitionTo('tabs.home')
}
if (!$stateParams.walletId) {
$log.debug('No wallet provided...back to home');
return $state.transitionTo('tabs.home')
}
var wallet = profileService.getWallet($stateParams.walletId);
var secret;
try {
secret = wallet.status.wallet.secret;
} catch (e) {};
var wallet = profileService.getWallet($stateParams.walletId);
var secret;
try {
secret = wallet.status.wallet.secret;
} catch (e) {};
$scope.wallet = wallet;
$scope.secret = secret;
});
$scope.wallet = wallet;
$scope.secret = secret;
});

View File

@ -75,7 +75,7 @@ angular.module('copayApp.controllers').controller('exportController',
};
$scope.getAddressbook = function(cb) {
storageService.getAddressbook(fc.credentials.network, function(err, addressBook) {
storageService.getAddressbook(wallet.credentials.network, function(err, addressBook) {
if (err) return cb(err);
var localAddressBook = [];

View File

@ -1,17 +1,17 @@
'use strict';
angular.module('copayApp.controllers').controller('txDetailsController', function($rootScope, $log, $scope, $filter, $ionicPopup, gettextCatalog, profileService, configService, lodash, txFormatService) {
angular.module('copayApp.controllers').controller('txDetailsController', function($rootScope, $log, $scope, $filter, $stateParams, $ionicPopup, gettextCatalog, profileService, configService, lodash, txFormatService) {
var self = $scope.self;
var fc = profileService.focusedClient;
var wallet = profileService.getWallet($stateParams.walletId);
var config = configService.getSync();
var configWallet = config.wallet;
var walletSettings = configWallet.settings;
$scope.alternativeIsoCode = walletSettings.alternativeIsoCode;
$scope.color = fc.backgroundColor;
$scope.copayerId = fc.credentials.copayerId;
$scope.isShared = fc.credentials.n > 1;
$scope.color = wallet.color;
$scope.copayerId = wallet.credentials.copayerId;
$scope.isShared = wallet.credentials.n > 1;
$scope.btx.amountStr = txFormatService.formatAmount($scope.btx.amount, true) + ' ' + walletSettings.unitName;
$scope.btx.feeStr = txFormatService.formatAmount($scope.btx.fees, true) + ' ' + walletSettings.unitName;
@ -40,7 +40,7 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
args.body = $scope.data.comment;
};
fc.editTxNote(args, function(err) {
wallet.editTxNote(args, function(err) {
if (err) {
$log.debug('Could not save tx comment');
return;
@ -50,7 +50,7 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
if (args.body) {
$scope.btx.note = {};
$scope.btx.note.body = $scope.data.comment;
$scope.btx.note.editedByName = fc.credentials.copayerName;
$scope.btx.note.editedByName = wallet.credentials.copayerName;
$scope.btx.note.editedOn = Math.floor(Date.now() / 1000);
}
$scope.btx.searcheableString = null;
@ -62,7 +62,7 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
$scope.getAlternativeAmount = function() {
var satToBtc = 1 / 100000000;
fc.getFiatRate({
wallet.getFiatRate({
code: $scope.alternativeIsoCode,
ts: $scope.btx.time * 1000
}, function(err, res) {
@ -81,7 +81,7 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
};
$scope.getShortNetworkName = function() {
var n = fc.credentials.network;
var n = wallet.credentials.network;
return n.substring(0, 4);
};

View File

@ -1,7 +1,7 @@
angular.module('copayApp.controllers').controller('paperWalletController',
function($scope, $timeout, $log, $ionicModal, configService, profileService, go, addressService, txStatus, bitcore, ongoingProcess, txFormatService) {
function($scope, $timeout, $log, $ionicModal, $stateParams, configService, profileService, go, addressService, txStatus, bitcore, ongoingProcess, txFormatService) {
var fc = profileService.focusedClient;
var wallet = profileService.getWallet($stateParams.walletId);
var rawTx;
$scope.onQrCodeScanned = function(data) {
@ -18,11 +18,11 @@ angular.module('copayApp.controllers').controller('paperWalletController',
function _scanFunds(cb) {
function getPrivateKey(scannedKey, isPkEncrypted, passphrase, cb) {
if (!isPkEncrypted) return cb(null, scannedKey);
fc.decryptBIP38PrivateKey(scannedKey, passphrase, null, cb);
wallet.decryptBIP38PrivateKey(scannedKey, passphrase, null, cb);
};
function getBalance(privateKey, cb) {
fc.getBalanceFromPrivateKey(privateKey, cb);
wallet.getBalanceFromPrivateKey(privateKey, cb);
};
function checkPrivateKey(privateKey) {
@ -70,13 +70,13 @@ angular.module('copayApp.controllers').controller('paperWalletController',
};
function _sweepWallet(cb) {
addressService.getAddress(fc.credentials.walletId, true, function(err, destinationAddress) {
addressService.getAddress(wallet.credentials.walletId, true, function(err, destinationAddress) {
if (err) return cb(err);
fc.buildTxFromPrivateKey($scope.privateKey, destinationAddress, null, function(err, tx) {
wallet.buildTxFromPrivateKey($scope.privateKey, destinationAddress, null, function(err, tx) {
if (err) return cb(err);
fc.broadcastRawTx({
wallet.broadcastRawTx({
rawTx: tx.serialize(),
network: 'livenet'
}, function(err, txid) {
@ -113,7 +113,7 @@ angular.module('copayApp.controllers').controller('paperWalletController',
$scope.openStatusModal = function(type, txp, cb) {
$scope.type = type;
$scope.tx = txFormatService.processTx(txp);
$scope.color = fc.backgroundColor;
$scope.color = wallet.backgroundColor;
$scope.cb = cb;
$ionicModal.fromTemplateUrl('views/modals/tx-status.html', {

View File

@ -11,7 +11,6 @@ angular.module('copayApp.controllers').controller('preferencesController',
$scope.externalSource = null;
if (wallet) {
walletService.getStatus(wallet, {}, function(err, status) {});
var config = configService.getSync();
config.aliasFor = config.aliasFor || {};
$scope.alias = config.aliasFor[walletId] || wallet.credentials.walletName;

View File

@ -1,12 +1,12 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesBwsUrlController',
function($scope, $log, configService, applicationService, profileService, storageService) {
function($scope, $log, $stateParams, configService, applicationService, profileService, storageService) {
$scope.error = null;
$scope.success = null;
var fc = profileService.focusedClient;
var walletId = fc.credentials.walletId;
var wallet = profileService.getWallet($stateParams.walletId);
var walletId = wallet.credentials.walletId;
var defaults = configService.getDefaults();
var config = configService.getSync();

View File

@ -1,9 +1,10 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesHistory',
function($scope, $log, $timeout, storageService, go, profileService, lodash) {
var fc = profileService.focusedClient;
var c = fc.credentials;
function($scope, $log, $stateParams, $timeout, storageService, go, profileService, lodash) {
var wallet = profileService.getWallet($stateParams.walletId);
var c = wallet.credentials;
$scope.csvReady = false;
$scope.csvHistory = function(cb) {
@ -125,7 +126,7 @@ angular.module('copayApp.controllers').controller('preferencesHistory',
$scope.$emit('Local/ClearHistory');
$timeout(function() {
go.walletHome();
go.WalletHome();
}, 100);
});
};

View File

@ -13,8 +13,8 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
$scope.openSearchModal = function() {
var fc = profileService.focusedClient;
$scope.color = fc.backgroundColor;
var wallet = profileService.getWallet($stateParams.walletId);
$scope.color = wallet.color;
$scope.self = self;
$ionicModal.fromTemplateUrl('views/modals/search.html', {

View File

@ -190,17 +190,17 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
templateUrl: 'views/copayers.html'
})
// OLD
// .state('walletHome', {
// url: '/old',
// needProfile: true,
// views: {
// 'main': {
// templateUrl: 'views/walletHome.html',
// },
// }
// })
.state('tabs', {
// OLD
// .state('walletHome', {
// url: '/old',
// needProfile: true,
// views: {
// 'main': {
// templateUrl: 'views/walletHome.html',
// },
// }
// })
.state('tabs', {
url: '/tabs',
cache: false,
needProfile: true,
@ -280,7 +280,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
},
})
.state('unsupported', {
.state('unsupported', {
url: '/unsupported',
needProfile: false,
views: {
@ -697,7 +697,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
} else {
profileService.storeProfileIfDirty();
$log.debug('Profile loaded ... Starting UX.');
$state.transitionTo('tabs.home');
// $state.transitionTo('tabs.home');
}
});

View File

@ -1,11 +1,11 @@
'use strict';
angular.module('copayApp.services').factory('addressbookService', function(storageService, profileService, lodash) {
angular.module('copayApp.services').factory('addressbookService', function($stateParams, storageService, profileService, lodash) {
var root = {};
root.getLabel = function(addr, cb) {
var fc = profileService.focusedClient;
storageService.getAddressbook(fc.credentials.network, function(err, ab) {
var wallet = profileService.getWallet($stateParams.walletId);
storageService.getAddressbook(wallet.credentials.network, function(err, ab) {
if (!ab) return cb();
if (ab[addr]) return cb(ab[addr]);
else return cb();
@ -23,19 +23,19 @@ angular.module('copayApp.services').factory('addressbookService', function(stora
if (ab2) ab2 = JSON.parse(ab2);
ab2 = ab2 || {};
return cb(err, lodash.defaults(ab2,ab));
return cb(err, lodash.defaults(ab2, ab));
});
});
};
root.add = function(entry, cb) {
var fc = profileService.focusedClient;
var wallet = profileService.getWallet($stateParams.walletId);
root.list(function(err, ab) {
if (err) return cb(err);
if (!ab) ab = {};
if (ab[entry.address]) return cb('Entry already exist');
ab[entry.address] = entry.label;
storageService.setAddressbook(fc.credentials.network, JSON.stringify(ab), function(err, ab) {
storageService.setAddressbook(wallet.credentials.network, JSON.stringify(ab), function(err, ab) {
if (err) return cb('Error adding new entry');
root.list(function(err, ab) {
return cb(err, ab);
@ -43,26 +43,26 @@ angular.module('copayApp.services').factory('addressbookService', function(stora
});
});
};
root.remove = function(addr, cb) {
var fc = profileService.focusedClient;
var wallet = profileService.getWallet($stateParams.walletId);
root.list(function(err, ab) {
if (err) return cb(err);
if (!ab) return;
if (!ab[addr]) return cb('Entry does not exist');
delete ab[addr];
storageService.setAddressbook(fc.credentials.network, JSON.stringify(ab), function(err) {
storageService.setAddressbook(wallet.credentials.network, JSON.stringify(ab), function(err) {
if (err) return cb('Error deleting entry');
root.list(function(err, ab) {
return cb(err, ab);
});
});
});
});
};
root.removeAll = function() {
var fc = profileService.focusedClient;
storageService.removeAddressbook(fc.credentials.network, function(err) {
var wallet = profileService.getWallet($stateParams.walletId);
storageService.removeAddressbook(wallet.credentials.network, function(err) {
if (err) return cb('Error deleting addressbook');
return cb();
});

View File

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.services')
.factory('backupService', function backupServiceFactory($log, $timeout, profileService, sjcl) {
.factory('backupService', function backupServiceFactory($log, $timeout, $stateParams, profileService, sjcl) {
var root = {};
@ -57,10 +57,10 @@ angular.module('copayApp.services')
if (!password) {
return null;
}
var fc = profileService.focusedClient;
var wallet = profileService.getWallet($stateParams.walletId);
try {
opts = opts || {};
var b = fc.export(opts);
var b = wallet.export(opts);
if (opts.addressBook) b = root.addMetadata(b, opts);
var e = sjcl.encrypt(password, b, {
@ -74,11 +74,11 @@ angular.module('copayApp.services')
};
root.walletDownload = function(password, opts, cb) {
var fc = profileService.focusedClient;
var wallet = profileService.getWallet($stateParams.walletId);
var ew = root.walletExport(password, opts);
if (!ew) return cb('Could not create backup');
var walletName = (fc.alias || '') + (fc.alias ? '-' : '') + fc.credentials.walletName;
var walletName = (wallet.alias || '') + (wallet.alias ? '-' : '') + wallet.credentials.walletName;
if (opts.noSign) walletName = walletName + '-noSign'
var filename = walletName + '-Copaybackup.aes.json';
_download(ew, filename, cb)

View File

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.services').factory('feeService', function($log, bwcService, walletService, configService, gettext, lodash, txFormatService) {
angular.module('copayApp.services').factory('feeService', function($log, $stateParams, bwcService, walletService, configService, gettext, lodash, txFormatService) {
var root = {};
// Constant fee options to translate
@ -16,12 +16,12 @@ angular.module('copayApp.services').factory('feeService', function($log, bwcServ
};
root.getCurrentFeeValue = function(cb) {
console.log('[feeService.js.18:getCurrentFeeValue:] TODO TODO TODO'); //TODO
console.log('[feeService.js.18:getCurrentFeeValue:] TODO TODO TODO'); //TODO
// TODO TODO TODO
var fc = walletService.focusedClient;
var wallet = profileService.getWallet($stateParams.walletId);
var feeLevel = root.getCurrentFeeLevel();
fc.getFeeLevels(fc.credentials.network, function(err, levels) {
wallet.getFeeLevels(wallet.credentials.network, function(err, levels) {
if (err)
return cb({
message: 'Could not get dynamic fee'

View File

@ -30,10 +30,12 @@ angular.module('copayApp.services').factory('go', function($window, $ionicSideMe
};
root.walletHome = function() {
var fc = profileService.focusedClient;
if (fc && !fc.isComplete()) {
var wallet = profileService.getWallet($stateParams.walletId);
if (wallet && !wallet.isComplete()) {
$log.debug("Wallet not complete at startup... redirecting");
$state.transitionTo('wallet.details', {walletId: fc.credentials.walletId})
$state.transitionTo('wallet.details', {
walletId: wallet.credentials.walletId
})
} else {
root.path('tabs.home');
}

View File

@ -5,7 +5,7 @@ angular.module('copayApp.services').factory('txStatus', function(lodash, profile
var isCordova = platformInfo.isCordova;
root.notify = function(txp) {
var fc = profileService.focusedClient;
var wallet = profileService.getWallet($stateParams.walletId);
var status = txp.status;
var type;
var INMEDIATE_SECS = 10;
@ -16,7 +16,7 @@ angular.module('copayApp.services').factory('txStatus', function(lodash, profile
var n = txp.actions.length;
var action = lodash.find(txp.actions, {
copayerId: fc.credentials.copayerId
copayerId: wallet.credentials.copayerId
});
if (!action) {