fix copayers

This commit is contained in:
Matias Alejo Garcia 2016-08-15 16:07:30 -03:00
commit 9e70821c4c
No known key found for this signature in database
GPG key ID: 02470DB551277AB3
11 changed files with 392 additions and 315 deletions

View file

@ -1,31 +1,38 @@
<div
class="topbar-container"
ng-include="'views/includes/topbar.html'"
ng-init="">
</div>
<div class="copayers content p20v" ng-controller="copayersController as copayers" ng-init="copayers.init()"> <ion-view ng-controller="copayersController">
<div ng-show="!index.notAuthorized">
<ion-nav-title>{{wallet.name}}</ion-nav-title>
<ion-nav-buttons side="primary">
<button class="button" href ui-sref="tabs.home">
<i class="ion-arrow-left-c"></i> Back
</button>
</ion-nav-buttons>
<ion-content delegate-handle="my-handle" overflow-scroll="true">
<div ng-show="!wallet.notAuthorized">
<h1 class="text-center" translate>Share this invitation with your copayers</h1> <h1 class="text-center" translate>Share this invitation with your copayers</h1>
<div ng-click="copayers.copySecret(index.walletSecret)" ng-class="{'enable_text_select': !index.isCordova}"> <div ng-click="copySecret()" ng-class="{'enable_text_select': !isCordova}">
<div class="text-center"> <div class="text-center">
<qrcode size="220" error-correction-level="L" data="{{index.walletSecret}}"></qrcode> <qrcode size="220" error-correction-level="L" data="{{secret}}"></qrcode>
<div ng-show="!index.walletSecret" style="position:relative; top:-226px; height:0px"> <div ng-show="!secret" style="position:relative; top:-226px; height:0px">
<div style="height:220px; width:220px; margin:auto; background: white"> <div style="height:220px; width:220px; margin:auto; background: white">
<ion-spinner class="spinner-stable" icon="lines"></ion-spinner> <ion-spinner class="spinner-stable" icon="lines"></ion-spinner>
</div> </div>
</div> </div>
<div class="secret" ng-show="!index.isCordova"> <div class="secret" ng-show="!isCordova">
{{index.walletSecret || ('Loading...'|translate)}} {{secret || ('Loading...'|translate)}}
</div> </div>
</div> </div>
</div> </div>
<div ng-show="index.walletSecret"> <div ng-show="secret">
<div class="text-center m10t" ng-if="index.isCordova"> <div class="text-center m10t" ng-if="isCordova">
<span class="button outline round dark-gray tiny m0" <span class="button outline round dark-gray tiny m0"
ng-click="copayers.shareSecret(index.walletSecret)"> ng-click="shareSecret()">
<i class="fi-share"></i> <i class="fi-share"></i>
<span translate>Share invitation</span> <span translate>Share invitation</span>
</span> </span>
@ -35,28 +42,34 @@
<h4 class="size-14 p10h m10t"> <h4 class="size-14 p10h m10t">
<span translate>Waiting for copayers</span> <span translate>Waiting for copayers</span>
<span class="text-gray right"> <span class="text-gray right">
[ <span translate>{{index.m}}-of-{{index.n}}</span> ] [ <span translate>{{wallet.m}}-of-{{wallet.n}}</span> ]
</span> </span>
</h4> </h4>
<div class="white line-b p10" ng-include="'views/includes/copayers.html'"></div> <div class="white line-b p10" ng-include="'views/includes/copayers.html'"></div>
<div ng-if="!index.isComplete" class="line-b p10 white size-12"> <div ng-if="!wallet.isComplete()" class="line-b p10 white size-12">
<i class="fi-loop m5r p10l"></i> <i class="fi-loop m5r p10l"></i>
<span translate>Waiting...</span> <span translate>Waiting...</span>
</div> </div>
<div ng-if="wallet.isComplete()" class="line-b p10 white size-12" href>
<button class="button" href ui-sref="tabs.home">
<span translate>WALLET COMPLETE!</span>
</button>
</div>
</div> </div>
<div class="m20b text-center" ng-show="index.notAuthorized"> <div class="m20b text-center" ng-show="wallet.notAuthorized">
<h1 translate>Wallet incomplete and broken</h1> <h1 translate>Wallet incomplete and broken</h1>
<h4 translate>Delete it and create a new one</h4> <h4 translate>Delete it and create a new one</h4>
</div> </div>
<div class="text-center"> <div class="text-center">
<button class="tiny round outline dark-gray warning" ng-click="copayers.deleteWallet()"> <button class="tiny round outline dark-gray warning" ng-click="deleteWallet()">
<i class="fi-trash"></i> <span translate>Cancel and delete the wallet</span> <i class="fi-trash"></i> <span translate>Cancel and delete the wallet</span>
</button> </button>
</div> </div>
</div> </div>
</div> </div>
</ion-content>
<div class="extra-margin-bottom"></div> </ion-view>
</div>

View file

@ -15,7 +15,6 @@
{{item.m}}-of-{{item.n}} {{item.m}}-of-{{item.n}}
</span> </span>
<span class="badge badge-assertive" ng-show="!item.isComplete()" translate> <span class="badge badge-assertive" ng-show="!item.isComplete()" translate>
Incomplete Incomplete
</span> </span>

View file

@ -1,230 +1,234 @@
<div ng-controller="walletDetailsController">
<div class="onGoingProcess" ng-show="wallet.updating"> <ion-view ng-controller="walletDetailsController">
<div class="onGoingProcess-content" ng-style="{'background-color':wallet.color}">
<div class="spinner"> <ion-nav-title>{{wallet.name}}</ion-nav-title>
<div class="rect1"></div>
<div class="rect2"></div> <ion-nav-buttons side="primary">
<div class="rect3"></div> <button class="button" href ui-sref="tabs.home">
<div class="rect4"></div> <i class="ion-arrow-left-c"></i> Back
<div class="rect5"></div> </button>
</ion-nav-buttons>
<ion-content delegate-handle="my-handle" overflow-scroll="true">
<div ng-show="!wallet">
No Wallet
<a href ui-sref="tabs.home" class="button">
Go home
</a>
</div>
<div ng-show="!wallet.isComplete()">
Wallet Incomplete.
<a href ui-sref="copayers({'walletId': wallet.id})" class="button">
Wait for Copayers
</a>
</div>
<div class="oh pr" ng-show="wallet && wallet.isComplete()">
<div ng-style="{'background-color':wallet.color}" class="amount">
<div ng-if="!wallet.notAuthorized && !wallet.updating">
<div class="m20t" ng-show="wallet.updateError" ng-click='update()'>
<span class="size-12 db m10b">{{wallet.updateError|translate}}</span>
<button class="outline white tiny round" translate>Tap to retry</button>
</div>
<div ng-show="wallet.walletScanStatus == 'error'" ng-click='wallet.retryScan()'>
<span translate>Scan status finished with error</span>
<br><span translate>Tap to retry</span>
</div>
<div ng-click='wallet.updateAll({triggerTxUpdate: true})' ng-show="!wallet.updateError && wallet.walletScanStatus != 'error' && !wallet.hideBalance" on-hold="hideToggle()">
<strong class="size-36">{{wallet.totalBalanceStr}}</strong>
<div class="size-14" ng-if="wallet.totalBalanceAlternative">{{wallet.totalBalanceAlternative}} {{wallet.alternativeIsoCode}}</div>
<div class="size-14" ng-if="wallet.pendingAmount">
<span translate>Pending Confirmation</span>: {{wallet.pendingAmountStr}}
</div>
</div>
<div ng-show="!wallet.updateError && wallet.walletScanStatus != 'error' && wallet.shouldHideBalance" on-hold="wallet.hideToggle()">
<strong class="size-24" translate>[Balance Hidden]</strong>
<div class="size-14" translate>
Tap and hold to show
</div>
</div>
</div>
<div ng-if="wallet.updating">
<div class="size-36">
<strong>...</strong>
</div>
</div>
</div> <!-- amount -->
<div class="wallet-info">
<span ng-include="'views/includes/walletInfo.html'"></span>
</div> </div>
<span translate>Updating Wallet...</span> </div> <!-- oh -->
</div>
</div>
<div class="oh"> <div class="p60b" ng-show="wallet && wallet.isComplete()">
<div class="oh pr m20t" ng-show="wallet.incorrectDerivation">
<div class="text-center text-warning">
<i class="fi-alert"></i>
<span translate>
WARNING: Key derivation is not working on this device/wallet. Actions cannot be performed on this wallet.
</span>
</div>
</div>
<div class="oh pr m20t" ng-show="wallet.notAuthorized && !wallet.updating">
<div class="text-center text-warning">
<i class="fi-alert"></i>
<span translate>
WARNING: Wallet not registered
</span>
</div>
<div class="text-center text-gray m15r m15l" translate>
This wallet is not registered at the given Bitcore Wallet Service (BWS). You can recreate it from the local information.
</div>
<div class="text-center m10t ">
<span class="button outline round dark-gray tiny"
ng-click="wallet.recreate()">
<span translate>Recreate</span>
</span>
</div>
</div>
<div id="walletHome" class="walletHome"> <div class="release size-12" ng-show="newRelease" ng-click="$root.openExternalLink('https://github.com/bitpay/copay/releases/latest')">
<ion-content delegate-handle="my-handle" overflow-scroll="true"> <span>{{newRelease}}</span><i class="icon-arrow-right3 right size-18"></i>
<div class="oh pr"> </div>
<div ng-style="{'background-color':wallet.color}" class="amount">
<div ng-if="!wallet.notAuthorized && !wallet.updating">
<div class="size-14 m10b" ng-if="wallet.totalBalanceAlternative">{{wallet.name}}</div> <div ng-if="wallet.txps[0]">
<h4 ng-show="wallet.requiresMultipleSignatures" class="title m0" translate>Payment Proposals</h4>
<h4 ng-show="!wallet.requiresMultipleSignatures" class="title m0" translate>Unsent transactions</h4>
<div ng-repeat="tx in wallet.txps">
<div ng-include="wallet.txTemplateUrl"></div>
</div>
<div class="m15t" ng-show="wallet.updateError" ng-click='update()'> <div class="text-gray text-center size-12 p10t"
<span class="size-12 db m10b">{{wallet.updateError|translate}}</span> ng-show="wallet.lockedBalanceSat">
<button class="outline white tiny round" translate>Tap to retry</button> <span translate>Total Locked Balance</span>:
</div> <b>{{wallet.lockedBalanceStr}} </b>
<span> {{wallet.lockedBalanceAlternative}}
{{wallet.alternativeIsoCode}} </span>
</div>
</div>
<div ng-show="wallet.walletScanStatus == 'error'" ng-click='wallet.retryScan()'> <!-- Activity -->
<span translate>Scan status finished with error</span>
<br><span translate>Tap to retry</span>
</div>
<h4 class="title" ng-click="wallet.startSearch(); openSearchModal()" ng-show="!wallet.notAuthorized">
<span translate>Activity</span>
<i class="dib m5l size-16 pointer fi-magnifying-glass"></i>
</h4>
<div ng-click='wallet.updateAll({triggerTxUpdate: true})' ng-show="!wallet.updateError && wallet.walletScanStatus != 'error' && !wallet.hideBalance" on-hold="hideToggle()"> <div class="oh pr m20t text-gray size-12 text-center"
<strong class="size-36">{{wallet.totalBalanceStr}}</strong> ng-show="!wallet.loadingWallet && !wallet.txHistory[0] && !wallet.updatingTxHistory && !wallet.txHistoryError && !wallet.updateError && !wallet.notAuthorized"
<div class="size-14" ng-if="wallet.totalBalanceAlternative">{{wallet.totalBalanceAlternative}} {{wallet.alternativeIsoCode}}</div> translate>No transactions yet ZZZZ {{wallet.totalBalanceStr}}
<div class="size-14" ng-if="wallet.pendingAmount"> </div>
<span translate>Pending Confirmation</span>: {{wallet.pendingAmountStr}}
</div>
</div>
<div ng-show="!wallet.updateError && wallet.walletScanStatus != 'error' && wallet.shouldHideBalance" on-hold="wallet.hideToggle()"> <div class="oh pr" ng-show="(wallet.txHistory[0] || wallet.txProgress > 5) && !wallet.notAuthorized">
<strong class="size-24" translate>[Balance Hidden]</strong>
<div class="size-14" translate> <div ng-show="wallet.updatingTxHistory && wallet.txProgress > 5">
Tap and hold to show <div class="row p20 text-center">
</div> <div class="columns large-12 medium-12 small-12 m10b">
</div> <ion-spinner class="spinner-dark" icon="lines"></ion-spinner>
</div> </div>
<div ng-if="wallet.updating"> <div class="size-12 text-gray m20t">
<div class="size-36"> <div translate>{{wallet.txProgress}} transactions downloaded</div>
<strong>...</strong> <div translate>Updating transaction history. Please stand by.</div>
</div>
</div>
</div> <!-- amount -->
<div class="wallet-info">
<span ng-include="'views/includes/walletInfo.html'"></span>
</div>
</div> <!-- oh -->
<div class="p60b">
<div class="oh pr m20t" ng-show="wallet.incorrectDerivation">
<div class="text-center text-warning">
<i class="fi-alert"></i>
<span translate>
WARNING: Key derivation is not working on this device/wallet. Actions cannot be performed on this wallet.
</span>
</div> </div>
</div> </div>
<div class="oh pr m20t" ng-show="wallet.notAuthorized && !wallet.updating">
<div class="text-center text-warning">
<i class="fi-alert"></i>
<span translate>
WARNING: Wallet not registered
</span>
</div>
<div class="text-center text-gray m15r m15l" translate>
This wallet is not registered at the given Bitcore Wallet Service (BWS). You can recreate it from the local information.
</div>
<div class="text-center m10t ">
<span class="button outline round dark-gray tiny"
ng-click="wallet.recreate()">
<span translate>Recreate</span>
</span>
</div>
</div>
<div class="release size-12" ng-show="newRelease" ng-click="$root.openExternalLink('https://github.com/bitpay/copay/releases/latest')">
<span>{{newRelease}}</span><i class="icon-arrow-right3 right size-18"></i>
</div>
<div ng-if="wallet.txps[0]">
<h4 ng-show="wallet.requiresMultipleSignatures" class="title m0" translate>Payment Proposals</h4>
<h4 ng-show="!wallet.requiresMultipleSignatures" class="title m0" translate>Unsent transactions</h4>
<div ng-repeat="tx in wallet.txps">
<div ng-include="wallet.txTemplateUrl"></div>
</div>
<div class="text-gray text-center size-12 p10t"
ng-show="wallet.lockedBalanceSat">
<span translate>Total Locked Balance</span>:
<b>{{wallet.lockedBalanceStr}} </b>
<span> {{wallet.lockedBalanceAlternative}}
{{wallet.alternativeIsoCode}} </span>
</div>
</div>
<!-- Activity -->
<h4 class="title" ng-click="wallet.startSearch(); openSearchModal()" ng-show="!wallet.notAuthorized">
<span translate>Activity</span>
<i class="dib m5l size-16 pointer fi-magnifying-glass"></i>
</h4>
<div class="oh pr m20t text-gray size-12 text-center"
ng-show="!wallet.loadingWallet && !wallet.txHistory[0] && !wallet.updatingTxHistory && !wallet.txHistoryError && !wallet.updateError && !wallet.notAuthorized"
translate>No transactions yet ZZZZ {{wallet.totalBalanceStr}}
</div>
<div class="oh pr" ng-show="(wallet.txHistory[0] || wallet.txProgress > 5) && !wallet.notAuthorized">
<div ng-show="wallet.updatingTxHistory && wallet.txProgress > 5">
<div class="row p20 text-center">
<div class="columns large-12 medium-12 small-12 m10b">
<ion-spinner class="spinner-dark" icon="lines"></ion-spinner>
</div>
<div class="size-12 text-gray m20t">
<div translate>{{wallet.txProgress}} transactions downloaded</div>
<div translate>Updating transaction history. Please stand by.</div>
</div>
</div>
</div>
<div ng-if="wallet.txHistory[0] && wallet.updatingTxHistory && wallet.newTx" class="row collapse last-transactions-content animated fadeInDown">
<div class="large-6 medium-6 small-6 columns size-14">
<div class="m10r left">
<img src="img/icon-new.svg" width="40">
</div>
<div class="m10t" style="background:#eee; width: 8em; margin-left: 52px; line-height:0.6em">
<span>&nbsp;</span>
</div>
<div style="margin-top:5px; background:#eee; width: 6em; margin-left: 52px; line-height:0.6em">
<span>&nbsp;</span>
</div>
</div>
</div>
<div ng-repeat="btx in wallet.txHistory track by btx.txid"
ng-click="openTxModal(btx)"
class="row collapse last-transactions-content">
<div class="large-6 medium-6 small-6 columns size-14">
<div class="m10r left">
<img src="img/icon-receive-history.svg" alt="sync" width="40" ng-show="btx.action == 'received'">
<img src="img/icon-sent-history.svg" alt="sync" width="40" ng-show="btx.action == 'sent'">
<img src="img/icon-moved.svg" alt="sync" width="40" ng-show="btx.action == 'moved'">
</div>
<div class="m10t">
<span ng-show="btx.action == 'received'">
<span class="ellipsis">
<span ng-if="btx.note.body">{{btx.note.body}}</span>
<span ng-if="!btx.note.body" translate> Received</span>
</span>
</span>
<span ng-show="btx.action == 'sent'">
<span class="ellipsis">
<span ng-if="btx.message">{{btx.message}}</span>
<span ng-if="!btx.message && btx.note.body">{{btx.note.body}}</span>
<span ng-if="!btx.message && !btx.note.body && wallet.addressbook[btx.addressTo]">{{wallet.addressbook[btx.addressTo]}}</span>
<span ng-if="!btx.message && !btx.note.body && !wallet.addressbook[btx.addressTo]" translate> Sent</span>
</span>
</span>
<span ng-show="btx.action == 'moved'">
<span class="ellipsis">
<span ng-if="btx.note.body">{{btx.note.body}}</span>
<span ng-if="!btx.note.body" translate>Moved</span>
</span>
</span>
<span class="label tu warning radius" ng-show="btx.action == 'invalid'" translate>Invalid</span>
</div>
</div>
<div class="large-5 medium-5 small-5 columns text-right" >
<span class="size-16" ng-class="{'text-bold': btx.recent}">
<span ng-if="btx.action == 'received'">+</span>
<span ng-if="btx.action == 'sent'">-</span>
<span class="size-12" ng-if="btx.action == 'invalid'" translate>
(possible double spend)
</span>
<span ng-if="btx.action != 'invalid'">
{{btx.amountStr}}
</span>
</span>
<div class="size-12 text-gray">
<time ng-if="btx.time">{{btx.time * 1000 | amTimeAgo}}</time>
<span translate class="text-warning"
ng-show="!btx.time && (!btx.confirmations || btx.confirmations == 0)">
Unconfirmed
</span>
</div>
</div>
<div class="large-1 medium-1 small-1 columns text-right m10t">
<i class="icon-arrow-right3 size-18"></i>
</div>
</div>
<div class="row m20t text-center" ng-show="wallet.historyRendering && !wallet.ching">
<div class="columns large-12 medium-12 small-12">
<ion-spinner class="spinner-stable" icon="lines"></ion-spinner>
</div>
</div>
<ion-infinite-scroll
ng-if="historyShowMore"
on-infinite="showMore()"
distance="1%">
</ion-infinite-scroll>
</div>
</div> </div>
</ion-content> <div ng-if="wallet.txHistory[0] && wallet.updatingTxHistory && wallet.newTx" class="row collapse last-transactions-content animated fadeInDown">
<div class="extra-margin-bottom"></div> <div class="large-6 medium-6 small-6 columns size-14">
</div> <!-- END WalletHome --> <div class="m10r left">
</div> <img src="img/icon-new.svg" width="40">
</div> </div>
<div class="m10t" style="background:#eee; width: 8em; margin-left: 52px; line-height:0.6em">
<span>&nbsp;</span>
</div>
<div style="margin-top:5px; background:#eee; width: 6em; margin-left: 52px; line-height:0.6em">
<span>&nbsp;</span>
</div>
</div>
</div>
<div ng-repeat="btx in wallet.txHistory track by btx.txid"
ng-click="openTxModal(btx)"
class="row collapse last-transactions-content">
<div class="large-6 medium-6 small-6 columns size-14">
<div class="m10r left">
<img src="img/icon-receive-history.svg" alt="sync" width="40" ng-show="btx.action == 'received'">
<img src="img/icon-sent-history.svg" alt="sync" width="40" ng-show="btx.action == 'sent'">
<img src="img/icon-moved.svg" alt="sync" width="40" ng-show="btx.action == 'moved'">
</div>
<div class="m10t">
<span ng-show="btx.action == 'received'">
<span class="ellipsis">
<span ng-if="btx.note.body">{{btx.note.body}}</span>
<span ng-if="!btx.note.body" translate> Received</span>
</span>
</span>
<span ng-show="btx.action == 'sent'">
<span class="ellipsis">
<span ng-if="btx.message">{{btx.message}}</span>
<span ng-if="!btx.message && btx.note.body">{{btx.note.body}}</span>
<span ng-if="!btx.message && !btx.note.body && wallet.addressbook[btx.addressTo]">{{wallet.addressbook[btx.addressTo]}}</span>
<span ng-if="!btx.message && !btx.note.body && !wallet.addressbook[btx.addressTo]" translate> Sent</span>
</span>
</span>
<span ng-show="btx.action == 'moved'">
<span class="ellipsis">
<span ng-if="btx.note.body">{{btx.note.body}}</span>
<span ng-if="!btx.note.body" translate>Moved</span>
</span>
</span>
<span class="label tu warning radius" ng-show="btx.action == 'invalid'" translate>Invalid</span>
</div>
</div>
<div class="large-5 medium-5 small-5 columns text-right" >
<span class="size-16" ng-class="{'text-bold': btx.recent}">
<span ng-if="btx.action == 'received'">+</span>
<span ng-if="btx.action == 'sent'">-</span>
<span class="size-12" ng-if="btx.action == 'invalid'" translate>
(possible double spend)
</span>
<span ng-if="btx.action != 'invalid'">
{{btx.amountStr}}
</span>
</span>
<div class="size-12 text-gray">
<time ng-if="btx.time">{{btx.time * 1000 | amTimeAgo}}</time>
<span translate class="text-warning"
ng-show="!btx.time && (!btx.confirmations || btx.confirmations == 0)">
Unconfirmed
</span>
</div>
</div>
<div class="large-1 medium-1 small-1 columns text-right m10t">
<i class="icon-arrow-right3 size-18"></i>
</div>
</div>
<div class="row m20t text-center" ng-show="wallet.historyRendering && !wallet.ching">
<div class="columns large-12 medium-12 small-12">
<ion-spinner class="spinner-stable" icon="lines"></ion-spinner>
</div>
</div>
<ion-infinite-scroll
ng-if="historyShowMore"
on-infinite="showMore()"
distance="1%">
</ion-infinite-scroll>
</div>
</div>
</ion-content>
</ion-view>

View file

@ -1,9 +1,9 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('copayersController', angular.module('copayApp.controllers').controller('copayersController',
function($scope, $rootScope, $timeout, $log, $ionicModal, profileService, go, notification, platformInfo, gettext, gettextCatalog) { function($scope, $rootScope, $timeout, $log, $ionicModal, profileService, go, notification, platformInfo, gettext, gettextCatalog, $stateParams, $state) {
var self = this; var self = this;
var isCordova = platformInfo.isCordova; $scope.isCordova = platformInfo.isCordova;
var isWP = platformInfo.isWP; var isWP = platformInfo.isWP;
var isAndroid = platformInfo.isAndroid; var isAndroid = platformInfo.isAndroid;
@ -12,20 +12,6 @@ angular.module('copayApp.controllers').controller('copayersController',
var cancel_msg = gettextCatalog.getString('Cancel'); var cancel_msg = gettextCatalog.getString('Cancel');
var confirm_msg = gettextCatalog.getString('Confirm'); var confirm_msg = gettextCatalog.getString('Confirm');
// Note that this is ONLY triggered when the page is opened
// IF a wallet is incomplete and copay is at /#copayers
// and the user switch to an other complete wallet
// THIS IS NOT TRIGGERED.
//
self.init = function() {
var fc = profileService.focusedClient;
if (fc.isComplete()) {
$log.debug('Wallet Complete...redirecting')
go.walletHome();
return;
}
};
var _modalDeleteWallet = function() { var _modalDeleteWallet = function() {
$scope.title = delete_msg; $scope.title = delete_msg;
$scope.accept_msg = accept_msg; $scope.accept_msg = accept_msg;
@ -66,9 +52,9 @@ angular.module('copayApp.controllers').controller('copayersController',
}); });
}; };
self.deleteWallet = function() { $scope.deleteWallet = function() {
var fc = profileService.focusedClient; var fc = profileService.focusedClient;
if (isCordova) { if ($scope.isCordova) {
navigator.notification.confirm( navigator.notification.confirm(
delete_msg, delete_msg,
function(buttonIndex) { function(buttonIndex) {
@ -83,15 +69,15 @@ angular.module('copayApp.controllers').controller('copayersController',
} }
}; };
self.copySecret = function(secret) { $scope.copySecret = function() {
if (isCordova) { if ($scope.isCordova) {
window.cordova.plugins.clipboard.copy(secret); window.cordova.plugins.clipboard.copy(secret);
window.plugins.toast.showShortCenter(gettextCatalog.getString('Copied to clipboard')); window.plugins.toast.showShortCenter(gettextCatalog.getString('Copied to clipboard'));
} }
}; };
self.shareSecret = function(secret) { $scope.shareSecret = function() {
if (isCordova) { if ($scope.isCordova) {
var message = gettextCatalog.getString('Join my Copay wallet. Here is the invitation code: {{secret}} You can download Copay for your phone or desktop at https://copay.io', { var message = gettextCatalog.getString('Join my Copay wallet. Here is the invitation code: {{secret}} You can download Copay for your phone or desktop at https://copay.io', {
secret: secret secret: secret
}); });
@ -99,4 +85,19 @@ angular.module('copayApp.controllers').controller('copayersController',
} }
}; };
});
if (!$stateParams.walletId) {
$log.debug('No wallet provided...back to home');
return $state.transitionTo('tabs.home')
}
var wallet = profileService.getWallet($stateParams.walletId);
var secret = wallet.status.wallet.secret;
try {
secret = wallet.status.wallet.secret;
} catch (e) {};
$scope.wallet = wallet;
$scope.secret = secret;
});

View file

@ -1,7 +1,7 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('createController', angular.module('copayApp.controllers').controller('createController',
function($scope, $rootScope, $timeout, $log, lodash, go, profileService, configService, gettext, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess) { function($scope, $rootScope, $timeout, $log, lodash, go, profileService, configService, gettext, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService) {
var isChromeApp = platformInfo.isChromeApp; var isChromeApp = platformInfo.isChromeApp;
var isCordova = platformInfo.isCordova; var isCordova = platformInfo.isCordova;
@ -166,7 +166,7 @@ angular.module('copayApp.controllers').controller('createController',
ongoingProcess.set('creatingWallet', true); ongoingProcess.set('creatingWallet', true);
$timeout(function() { $timeout(function() {
profileService.createWallet(opts, function(err) { profileService.createWallet(opts, function(err, wallet) {
ongoingProcess.set('creatingWallet', false); ongoingProcess.set('creatingWallet', false);
if (err) { if (err) {
$log.warn(err); $log.warn(err);
@ -176,13 +176,19 @@ angular.module('copayApp.controllers').controller('createController',
}); });
return; return;
} }
walletService.updateRemotePreferences(wallet, {}, function() {
$log.debug('Remote preferences saved for:' + wallet.walletId)
});
if (self.seedSourceId == 'set') { if (self.seedSourceId == 'set') {
$timeout(function() { $timeout(function() {
$rootScope.$emit('Local/BackupDone'); $rootScope.$emit('Local/BackupDone');
}, 1); }, 1);
} }
go.walletHome();
go.walletHome();
}); });
}, 100); }, 100);
} }

View file

@ -95,15 +95,21 @@ angular.module('copayApp.controllers').controller('importController',
opts.password = null; opts.password = null;
$timeout(function() { $timeout(function() {
profileService.importWallet(str2, opts, function(err, walletId) { profileService.importWallet(str2, opts, function(err, wallet) {
ongoingProcess.set('importingWallet', false); ongoingProcess.set('importingWallet', false);
if (err) { if (err) {
$scope.error = err; $scope.error = err;
} else { return;
$rootScope.$emit('Local/WalletImported', walletId);
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
go.walletHome();
} }
walletService.updateRemotePreferences(wallet, {}, function() {
$log.debug('Remote preferences saved for:' + wallet.walletId)
});
$rootScope.$emit('Local/WalletImported', wallet.walletId);
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
go.walletHome();
}); });
}, 100); }, 100);
}; };
@ -111,7 +117,7 @@ angular.module('copayApp.controllers').controller('importController',
var _importExtendedPrivateKey = function(xPrivKey, opts) { var _importExtendedPrivateKey = function(xPrivKey, opts) {
ongoingProcess.set('importingWallet', true); ongoingProcess.set('importingWallet', true);
$timeout(function() { $timeout(function() {
profileService.importExtendedPrivateKey(xPrivKey, opts, function(err, walletId) { profileService.importExtendedPrivateKey(xPrivKey, opts, function(err, wallet) {
ongoingProcess.set('importingWallet', false); ongoingProcess.set('importingWallet', false);
if (err) { if (err) {
if (err instanceof errors.NOT_AUTHORIZED) { if (err instanceof errors.NOT_AUTHORIZED) {
@ -124,7 +130,12 @@ angular.module('copayApp.controllers').controller('importController',
}); });
} }
$rootScope.$emit('Local/WalletImported', walletId);
walletService.updateRemotePreferences(wallet, {}, function() {
$log.debug('Remote preferences saved for:' + wallet.walletId)
});
$rootScope.$emit('Local/WalletImported', wallet.walletId);
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
go.walletHome(); go.walletHome();
}); });
@ -157,7 +168,7 @@ angular.module('copayApp.controllers').controller('importController',
ongoingProcess.set('importingWallet', true); ongoingProcess.set('importingWallet', true);
$timeout(function() { $timeout(function() {
profileService.importMnemonic(words, opts, function(err, walletId) { profileService.importMnemonic(words, opts, function(err, wallet) {
ongoingProcess.set('importingWallet', false); ongoingProcess.set('importingWallet', false);
if (err) { if (err) {
@ -171,7 +182,11 @@ angular.module('copayApp.controllers').controller('importController',
}); });
} }
$rootScope.$emit('Local/WalletImported', walletId); walletService.updateRemotePreferences(wallet, {}, function() {
$log.debug('Remote preferences saved for:' + wallet.walletId)
});
$rootScope.$emit('Local/WalletImported', wallet.walletId);
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
go.walletHome(); go.walletHome();
}); });
@ -293,7 +308,7 @@ angular.module('copayApp.controllers').controller('importController',
ongoingProcess.set('importingWallet', true); ongoingProcess.set('importingWallet', true);
$log.debug('Import opts', lopts); $log.debug('Import opts', lopts);
profileService.importExtendedPublicKey(lopts, function(err, walletId) { profileService.importExtendedPublicKey(lopts, function(err, wallet) {
ongoingProcess.set('importingWallet', false); ongoingProcess.set('importingWallet', false);
if (err) { if (err) {
$scope.error = err; $scope.error = err;
@ -301,7 +316,12 @@ angular.module('copayApp.controllers').controller('importController',
$scope.$apply(); $scope.$apply();
}); });
} }
$rootScope.$emit('Local/WalletImported', walletId);
walletService.updateRemotePreferences(wallet, {}, function() {
$log.debug('Remote preferences saved for:' + wallet.walletId)
});
$rootScope.$emit('Local/WalletImported', wallet.walletId);
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
go.walletHome(); go.walletHome();
}); });
@ -366,7 +386,7 @@ angular.module('copayApp.controllers').controller('importController',
ongoingProcess.set('importingWallet', true); ongoingProcess.set('importingWallet', true);
$log.debug('Import opts', lopts); $log.debug('Import opts', lopts);
profileService.importExtendedPublicKey(lopts, function(err, walletId) { profileService.importExtendedPublicKey(lopts, function(err, wallet) {
ongoingProcess.set('importingWallet', false); ongoingProcess.set('importingWallet', false);
if (err) { if (err) {
$scope.error = err; $scope.error = err;
@ -374,7 +394,12 @@ angular.module('copayApp.controllers').controller('importController',
$scope.$apply(); $scope.$apply();
}); });
} }
$rootScope.$emit('Local/WalletImported', walletId);
walletService.updateRemotePreferences(wallet, {}, function() {
$log.debug('Remote preferences saved for:' + wallet.walletId)
});
$rootScope.$emit('Local/WalletImported', wallet.walletId);
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
go.walletHome(); go.walletHome();
}); });

View file

@ -128,13 +128,18 @@ angular.module('copayApp.controllers').controller('joinController',
this._join = function(opts) { this._join = function(opts) {
ongoingProcess.set('joiningWallet', true); ongoingProcess.set('joiningWallet', true);
$timeout(function() { $timeout(function() {
profileService.joinWallet(opts, function(err) { profileService.joinWallet(opts, function(err, wallet) {
ongoingProcess.set('joiningWallet', false); ongoingProcess.set('joiningWallet', false);
if (err) { if (err) {
self.error = err; self.error = err;
$rootScope.$apply(); $rootScope.$apply();
return; return;
} }
walletService.updateRemotePreferences(wallet, {}, function() {
$log.debug('Remote preferences saved for:' + wallet.walletId)
});
go.walletHome(); go.walletHome();
}); });
}, 100); }, 100);

View file

@ -1,9 +1,8 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('walletDetailsController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $stateParams, profileService, lodash, configService, gettext, gettextCatalog, platformInfo, go, walletService ) { angular.module('copayApp.controllers').controller('walletDetailsController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $state, $stateParams, profileService, lodash, configService, gettext, gettextCatalog, platformInfo, go, walletService) {
console.log('[walletDetails.js.5]', $stateParams); //TODO
var isCordova = platformInfo.isCordova; var isCordova = platformInfo.isCordova;
var isWP = platformInfo.isWP; var isWP = platformInfo.isWP;
var isAndroid = platformInfo.isAndroid; var isAndroid = platformInfo.isAndroid;
@ -63,14 +62,32 @@ console.log('[walletDetails.js.5]', $stateParams); //TODO
}; };
$scope.update = function() { $scope.update = function() {
console.log('[walletDetails.js.65:update:] TODO'); //TODO walletService.updateStatus(wallet, {
// {triggerTxUpdate: true} force: true
}, function(err, status) {
if (err) {} // TODO
});
}; };
$scope.hideToggle = function() { $scope.hideToggle = function() {
console.log('[walletDetails.js.70:hideToogle:] TODO'); //TODO console.log('[walletDetails.js.70:hideToogle:] TODO'); //TODO
}; };
$scope.wallet = profileService.getWallet($stateParams.walletId);
console.log('[walletDetails.js.66]',$scope.wallet); //TODO if (!$stateParams.walletId) {
$log.debug('No wallet provided... using the first one');
$stateParams.walletId = profileService.getWallets({
onlyComplete: true
})[0].id;
}
var wallet = profileService.getWallet($stateParams.walletId);
$scope.wallet = wallet;
if (wallet) {
walletService.updateStatus(wallet, {}, function(err, status) {
if (err) {} // TODO
});
}
}); });

View file

@ -223,11 +223,15 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
.state('copayers', { .state('copayers', {
url: '/copayers', url: '/copayers',
needProfile: true, needProfile: true,
cache: false,
views: { views: {
'main': { 'main': {
templateUrl: 'views/copayers.html' templateUrl: 'views/copayers.html'
}, },
} },
params: {
walletId: null,
},
}) })
.state('preferences', { .state('preferences', {
url: '/preferences', url: '/preferences',

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
angular.module('copayApp.services') angular.module('copayApp.services')
.factory('profileService', function profileServiceFactory($rootScope, $timeout, $filter, $log, sjcl, lodash, storageService, bwcService, configService, notificationService, pushNotificationsService, gettext, gettextCatalog, bwcError, uxLanguage, bitcore, platformInfo, walletService) { .factory('profileService', function profileServiceFactory($rootScope, $timeout, $filter, $log, sjcl, lodash, storageService, bwcService, configService, notificationService, pushNotificationsService, gettext, gettextCatalog, bwcError, uxLanguage, bitcore, platformInfo, $ionicHistory) {
var isChromeApp = platformInfo.isChromeApp; var isChromeApp = platformInfo.isChromeApp;
@ -95,6 +95,9 @@ angular.module('copayApp.services')
client.on('notification', function(n) { client.on('notification', function(n) {
$log.debug('BWC Notification:', n); $log.debug('BWC Notification:', n);
$ionicHistory.clearCache();
notificationService.newBWCNotification(n, notificationService.newBWCNotification(n,
walletId, client.credentials.walletName); walletId, client.credentials.walletName);
@ -401,7 +404,7 @@ angular.module('copayApp.services')
doCreateWallet(opts, function(err, walletClient, secret) { doCreateWallet(opts, function(err, walletClient, secret) {
if (err) return cb(err); if (err) return cb(err);
root.addAndBindWalletClient(walletClient, { addAndBindWalletClient(walletClient, {
bwsurl: opts.bwsurl bwsurl: opts.bwsurl
}, cb); }, cb);
}); });
@ -433,7 +436,7 @@ angular.module('copayApp.services')
walletClient.joinWallet(opts.secret, opts.myName || 'me', {}, function(err) { walletClient.joinWallet(opts.secret, opts.myName || 'me', {}, function(err) {
if (err) return bwcError.cb(err, gettext('Could not join wallet'), cb); if (err) return bwcError.cb(err, gettext('Could not join wallet'), cb);
root.addAndBindWalletClient(walletClient, { addAndBindWalletClient(walletClient, {
bwsurl: opts.bwsurl bwsurl: opts.bwsurl
}, cb); }, cb);
}); });
@ -496,7 +499,7 @@ angular.module('copayApp.services')
} }
// Adds and bind a new client to the profile // Adds and bind a new client to the profile
root.addAndBindWalletClient = function(client, opts, cb) { var addAndBindWalletClient = function(client, opts, cb) {
if (!client || !client.credentials) if (!client || !client.credentials)
return cb(gettext('Could not access wallet')); return cb(gettext('Could not access wallet'));
@ -530,19 +533,14 @@ angular.module('copayApp.services')
}); });
}; };
walletService.updateRemotePreferences(client, {}, function() {
$log.debug('Remote preferences saved for:' + walletId)
});
saveBwsUrl(function() { saveBwsUrl(function() {
root.setAndStoreFocus(walletId, function() { root.setAndStoreFocus(walletId, function() {
storageService.storeProfile(root.profile, function(err) { storageService.storeProfile(root.profile, function(err) {
var config = configService.getSync(); var config = configService.getSync();
if (config.pushNotifications.enabled) if (config.pushNotifications.enabled)
pushNotificationsService.enableNotifications(root.wallet); pushNotificationsService.enableNotifications(root.wallet);
return cb(err, walletId); return cb(err, walletClient);
}); });
}); });
}); });
}; };
@ -584,13 +582,13 @@ angular.module('copayApp.services')
var addressBook = str.addressBook || {}; var addressBook = str.addressBook || {};
root.addAndBindWalletClient(walletClient, { addAndBindWalletClient(walletClient, {
bwsurl: opts.bwsurl bwsurl: opts.bwsurl
}, function(err, walletId) { }, function(err, walletId) {
if (err) return cb(err); if (err) return cb(err);
root.setMetaData(walletClient, addressBook, function(error) { root.setMetaData(walletClient, addressBook, function(error) {
if (error) $log.warn(error); if (error) $log.warn(error);
return cb(err, walletId); return cb(err, walletClient);
}); });
}); });
}; };
@ -607,7 +605,7 @@ angular.module('copayApp.services')
return bwcError.cb(err, gettext('Could not import'), cb); return bwcError.cb(err, gettext('Could not import'), cb);
} }
root.addAndBindWalletClient(walletClient, { addAndBindWalletClient(walletClient, {
bwsurl: opts.bwsurl bwsurl: opts.bwsurl
}, cb); }, cb);
}); });
@ -638,7 +636,7 @@ angular.module('copayApp.services')
return bwcError.cb(err, gettext('Could not import'), cb); return bwcError.cb(err, gettext('Could not import'), cb);
} }
root.addAndBindWalletClient(walletClient, { addAndBindWalletClient(walletClient, {
bwsurl: opts.bwsurl bwsurl: opts.bwsurl
}, cb); }, cb);
}); });
@ -661,7 +659,7 @@ angular.module('copayApp.services')
return bwcError.cb(err, gettext('Could not import'), cb); return bwcError.cb(err, gettext('Could not import'), cb);
} }
root.addAndBindWalletClient(walletClient, { addAndBindWalletClient(walletClient, {
bwsurl: opts.bwsurl bwsurl: opts.bwsurl
}, cb); }, cb);
}); });
@ -745,28 +743,5 @@ angular.module('copayApp.services')
return lodash.sortBy(ret, 'name'); return lodash.sortBy(ret, 'name');
}; };
root.needsBackup = function(client, cb) {
if (!walletService.needsBackup(client))
return cb(false);
storageService.getBackupFlag(client.credentials.walletId, function(err, val) {
if (err) $log.error(err);
if (val) return cb(false);
return cb(true);
});
};
root.isReady = function(client, cb) {
if (!client.isComplete())
return cb('WALLET_NOT_COMPLETE');
root.needsBackup(client, function(needsBackup) {
if (needsBackup)
return cb('WALLET_NEEDS_BACKUP');
return cb();
});
};
return root; return root;
}); });

View file

@ -61,7 +61,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
}); });
}; };
root.needsBackup = function(wallet) { root.requiresBackup = function(wallet) {
if (wallet.isPrivKeyExternal()) return false; if (wallet.isPrivKeyExternal()) return false;
if (!wallet.credentials.mnemonic) return false; if (!wallet.credentials.mnemonic) return false;
if (wallet.credentials.network == 'testnet') return false; if (wallet.credentials.network == 'testnet') return false;
@ -69,6 +69,18 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
return true; return true;
}; };
root.needsBackup = function(wallet, cb) {
if (!walletService.requiresBackup(wallet))
return cb(false);
storageService.getBackupFlag(wallet.credentials.walletId, function(err, val) {
if (err) $log.error(err);
if (val) return cb(false);
return cb(true);
});
};
var _walletStatusHash = function(walletStatus) { var _walletStatusHash = function(walletStatus) {
var bal; var bal;
if (walletStatus) { if (walletStatus) {
@ -90,6 +102,9 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
$log.warn('TODO'); $log.warn('TODO');
return; // TODO!!! return; // TODO!!!
if (err instanceof errors.NOT_AUTHORIZED) { if (err instanceof errors.NOT_AUTHORIZED) {
console.log('[walletService.js.93] TODO NOT AUTH'); //TODO
// TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO
self.notAuthorized = true; self.notAuthorized = true;
go.walletHome(); go.walletHome();
} else if (err instanceof errors.NOT_FOUND) { } else if (err instanceof errors.NOT_FOUND) {
@ -815,5 +830,18 @@ console.log('[walletService.js.786:wallet:]',wallet, forceNew); //TODO
}; };
root.isReady = function(wallet, cb) {
if (!wallet.isComplete())
return cb('WALLET_NOT_COMPLETE');
root.needsBackup(wallet, function(needsBackup) {
if (needsBackup)
return cb('WALLET_NEEDS_BACKUP');
return cb();
});
};
return root; return root;
}); });