Merge branch 'ref/design' of https://github.com/bitpay/bitpay-wallet into feature/onboarding_backup_phrase

# Conflicts:
#	public/views/includes/confirmBackupPopup.html
#	src/js/controllers/backup.js
This commit is contained in:
Jamal Jackson 2016-09-13 14:26:25 -04:00
commit d39f69531d
49 changed files with 1108 additions and 636 deletions

View file

@ -42,7 +42,7 @@
"url": "https://github.com/bitpay/copay/issues"
},
"dependencies": {
"bitcore-wallet-client": "4.2.0",
"bitcore-wallet-client": "4.2.1",
"coveralls": "^2.11.9",
"express": "^4.11.2",
"fs": "0.0.2",

View file

@ -45,7 +45,7 @@
"url": "https://github.com/bitpay/copay/issues"
},
"dependencies": {
"bitcore-wallet-client": "4.2.0",
"bitcore-wallet-client": "4.2.1",
"coveralls": "^2.11.9",
"express": "^4.11.2",
"fs": "0.0.2",

View file

@ -0,0 +1,63 @@
<ion-view>
<ion-nav-bar class="bar-royal">
<ion-nav-buttons side="primary">
<button class="button button-clear" ui-sref="tabs.addressbook">
<i class="icon ion-ios-arrow-thin-left"></i>
</button>
</ion-nav-buttons>
<ion-nav-title>
<span translate>Add entry</span>
</ion-nav-title>
</ion-nav-bar>
<ion-content>
<form name="addressbookForm" no-validate>
<div class="card list">
<label class="item item-input item-stacked-label">
<span class="input-label" translate>Name</span>
<input type="text"
id="name"
name="name"
ng-model="addressbookEntry.name"
required>
</label>
<label class="item item-input item-stacked-label">
<span class="input-label" translate>Email</span>
<input type="text"
id="email"
name="email"
ng-model="addressbookEntry.email">
</label>
<label class="item item-input item-stacked-label">
<span class="input-label" translate>Address</span>
<div class="input-notification">
<i class="icon ion-checkmark-circled balanced"
ng-show="!addressbookForm.address.$invalid"></i>
<i class="icon ion-close-circled assertive"
ng-show="addressbookForm.address.$invalid && addressbookEntry.address"></i>
</div>
<div class="qr-scan-icon">
<qr-scanner on-scan="onQrCodeScanned(data, addressbookForm)"></qr-scanner>
<input type="text"
id="address"
name="address"
ng-model="addressbookEntry.address"
valid-address required>
</div>
</label>
</div>
<div class="padding">
<button type="submit"
class="button button-block button-positive"
ng-click="add(addressbookEntry)"
ng-disabled="!addressbookForm.$valid" translate>
Save
</button>
</div>
</form>
</ion-content>
</ion-view>

View file

@ -0,0 +1,52 @@
<ion-view>
<ion-nav-bar class="bar-royal">
<ion-nav-buttons side="primary">
<button class="button button-clear" ui-sref="tabs.settings">
<i class="icon ion-ios-arrow-thin-left"></i>
</button>
</ion-nav-buttons>
<ion-nav-title>
<span translate>Addressbook</span>
</ion-nav-title>
<ion-nav-buttons side="secondary">
<button class="button button-clear" ui-sref="tabs.addressbook.add">
<i class="icon ion-ios-plus-empty"></i>
</button>
</ion-nav-buttons>
</ion-nav-bar>
<ion-content ng-init="initAddressbook()">
<div class="bar bar-header item-input-inset" ng-show="!isEmptyList">
<label class="item-input-wrapper">
<i class="icon ion-ios-search placeholder-icon"></i>
<input type="search"
placeholder="Search"
ng-model="addrSearch"
ng-change="findAddressbook(addrSearch)" ng-model-onblur>
</label>
</div>
<ion-list>
<ion-item ng-repeat="addrEntry in addressbook"
class="item-icon-left item-icon-right"
ui-sref="tabs.addressbook.view({address:addrEntry.address})">
<i class="icon ion-ios-person-outline"></i>
{{addrEntry.name}}
<i class="icon nav-item-arrow-right"></i>
<ion-option-button class="button-assertive" ng-click="remove(addrEntry.address)">
<i class="icon ion-minus-circled"></i>
</ion-option-button>
</ion-item>
</ion-list>
<div class="list" ng-show="isEmptyList">
<a class="item item-icon-left" ui-sref="tabs.addressbook.add">
<i class="icon ion-person-add"></i>
<span translate>Add a new entry</span>
</a>
</div>
</ion-content>
</ion-view>

View file

@ -0,0 +1,36 @@
<ion-view>
<ion-nav-bar class="bar-royal">
<ion-nav-buttons side="primary">
<button class="button button-clear" ui-sref="tabs.addressbook">
<i class="icon ion-ios-arrow-thin-left"></i>
</button>
</ion-nav-buttons>
<ion-nav-title>
<span translate>Addressbook</span>
</ion-nav-title>
</ion-nav-bar>
<ion-content>
<div class="card">
<div class="item item-text-wrap">
<h3 translate>Name</h3>
<strong>{{addressbookEntry.name}}</strong>
</div>
<div class="item item-text-wrap">
<h3 translate>Email</h3>
<strong>{{addressbookEntry.email}}</strong>
</div>
<div class="item item-text-wrap">
<h3 translate>Address</h3>
<strong>{{addressbookEntry.address}}</strong>
</div>
</div>
<button class="button button-block button-positive"
ng-click="sendTo()" translate>
Send Money
</button>
</ion-content>
</ion-view>

View file

@ -1,96 +0,0 @@
<ion-modal-view ng-controller="addressbookModalController" ng-init="initAddressbook()">
<ion-header-bar align-title="center" class="bar-royal">
<button class="button button-clear" ng-click="closeAddressbookModal()">
Close
</button>
<div class="h1 title">
<span ng-show="!addAddressbookEntry" translate>Addressbook</span>
<span ng-show="addAddressbookEntry" translate>Add entry</span>
</div>
<button class="button button-clear"
ng-click="toggleAddAddressbookEntry()">
<i ng-show="!addAddressbookEntry" class="icon ion-ios-plus-empty"></i>
<span ng-show="addAddressbookEntry" translate>Cancel</span>
</button>
</ion-header-bar>
<ion-content>
<div class="bar bar-header item-input-inset" ng-show="!addAddressbookEntry && !isEmptyList">
<label class="item-input-wrapper">
<i class="icon ion-ios-search placeholder-icon"></i>
<input type="search"
placeholder="Search"
ng-model="addrSearch"
ng-change="findAddressbook(addrSearch)" ng-model-onblur>
</label>
</div>
<div ng-show="!addAddressbookEntry">
<ion-list>
<ion-item ng-repeat="addrEntry in addressbook"
class="item-icon-left"
ng-show="!addrEntry.isWallet"
ng-click="sendTo(addrEntry)">
<i class="icon ion-ios-person-outline"></i>
<h2>{{addrEntry.label}}</h2>
<p>{{addrEntry.address}}</p>
<ion-option-button class="button-assertive" ng-click="remove(addrEntry.address)">
<i class="icon ion-minus-circled"></i>
</ion-option-button>
</ion-item>
<ion-list>
<div class="list" ng-show="isEmptyList">
<a class="item item-icon-left" ng-click="toggleAddAddressbookEntry()">
<i class="icon ion-person-add"></i>
<span translate>Add a new entry</span>
</a>
</div>
</div>
<form name="addressbookForm" ng-show="addAddressbookEntry" no-validate>
<div class="list">
<label class="item item-input item-stacked-label">
<span class="input-label" translate>Address</span>
<div class="input-notification">
<i class="icon ion-checkmark-circled balanced"
ng-show="!addressbookForm.address.$invalid"></i>
<i class="icon ion-close-circled assertive"
ng-show="addressbookForm.address.$invalid && addressbookEntry.address"></i>
</div>
<div class="qr-scan-icon">
<qr-scanner on-scan="onQrCodeScanned(data, addressbookForm)"></qr-scanner>
<input type="text"
id="address"
name="address"
ng-model="addressbookEntry.address"
valid-address required>
</div>
</label>
<label class="item item-input item-stacked-label">
<span class="input-label" translate>Label</span>
<input type="text"
id="label"
name="label"
ng-model="addressbookEntry.label"
required>
</label>
</div>
<div class="padding">
<button type="submit"
class="button button-block button-positive"
ng-click="add(addressbookEntry)"
ng-disabled="!addressbookForm.$valid" translate>
Save
</button>
</div>
</form>
</ion-content>
</ion-modal-view>

View file

@ -0,0 +1,15 @@
<ion-modal-view ng-style="{opacity: '0.9'}" ng-controller="receiveTipsController">
<ion-nav-bar class="bar-ligt">
<ion-nav-buttons side="secondary">
<button class="button" ng-click="close()">
X
</button>
</ion-nav-buttons>
</ion-nav-bar>
<ion-content class="has-header">
<div class="text-center">
<h2>Receive bitcoin by sharing your address</h2>
<h3>Other bitcoin users can scan this code to send you money</h3>
</div>
</ion-content>
</ion-modal-view>

View file

@ -0,0 +1,15 @@
<ion-modal-view ng-style="{opacity: '0.9'}" ng-controller="scanTipsController">
<ion-nav-bar class="bar-ligt">
<ion-nav-buttons side="secondary">
<button class="button" ng-click="close()">
X
</button>
</ion-nav-buttons>
</ion-nav-bar>
<ion-content class="has-header">
<div class="text-center">
<h2>Scan the code to pay with bitcoin</h2>
<h3>QR codes could also contain a bitcoin wallet invitation, or an URL</h3>
</div>
</ion-content>
</ion-modal-view>

View file

@ -16,12 +16,14 @@
<div class="row text-center">
<i class="ion-ios-arrow-thin-down light-blue col col-60" id="arrow-down"></i>
</div>
<div class="row">
<button class="button button-block button-positive col-75 col" href
ui-sref="onboarding.backupWarning({walletId: walletId})" translate>Backup wallet</button>
</div>
<div class="row">
<button class="button button-block button-transparent col-75 col" ng-click="openPopup()" translate>I'll backup my wallet later</button>
<div class="cta-buttons">
<div class="row">
<button class="button button-block button-positive col-75 col" href
ui-sref="onboarding.backupWarning({walletId: walletId})" translate>Backup wallet</button>
</div>
<div class="row">
<button class="button button-block button-transparent col-75 col" ng-click="openPopup()" translate>I'll backup my wallet later</button>
</div>
</div>
</ion-content>
</ion-view>

View file

@ -8,7 +8,7 @@
</ion-nav-bar>
<ion-content>
<div class="row text-center">
<h3 translate class="col col-75">
<h3 translate class="col col-80">
Are you being watched?
</h3>
</div>
@ -18,14 +18,14 @@
</p>
</div>
<div class="row">
<img src="img/onboarding-backup-warning.svg" class="col col-60">
<img src="img/onboarding-backup-warning.svg" class="col col-60 warning-image">
</div>
<div class="row text-center">
<p class="col col-60">
Anyone with your backup phrase can access or spend your bitcoin.
</p>
</div>
<div class="row">
<div class="cta-buttons">
<button class="button button-block button-primary col col-75" ng-click="openPopup()" translate>All clear, let's do this</button>
</div>
</ion-content>

View file

@ -1,11 +1,4 @@
<ion-view ng-controller="collectEmailController" id="onboarding-collect-email" class="onboarding">
<ion-nav-bar class="bar-overlay">
<ion-nav-buttons side="right">
<button class="button button-block button-positive button-clear" ng-click="onboardingMailSkip()">
{{'Skip' | translate}}
</button>
</ion-nav-buttons>
</ion-nav-bar>
<ion-content>
<div class="row">
<img src="img/onboarding-success.svg" class="col col-75" id="success-image" />
@ -14,16 +7,42 @@
<h3 translate class="col">Wallet Created</h3>
</div>
<div id="collect-email">
<div class="row text-center">
<p translate class="col col-75 center-block">Where would you like to receive email notifications about payments? </p>
<div ng-if="!confirmation">
<div class="row text-center">
<p translate class="col col-75">Where would you like to receive email notifications about payments?</p>
</div>
<form name="emailForm" ng-submit="confirm(emailForm)" novalidate>
<label class="item item-input col col-75">
<i class="icon ion-arrow-right-c"></i>
<input type="email" id="email" name="email" ng-model="email" laceholder="satoshi@example.com" required></input>
</label>
</form>
</div>
<div ng-if="confirmation">
<div class="row text-center">
<p translate class="col col-75">Is this email address correct?</p>
</div>
<div class="row text-center">
<p class="col col-75">{{email}}</p>
</div>
<div class="row">
<div class="col col-50">
<button class="button button-block button-stable" ng-click="cancel()">
{{'No' | translate}}
</button>
</div>
<div class="col col-50">
<button class="button button-block button-stable" ng-click="save()">
{{'Yes' | translate}}
</button>
</div>
</div>
</div>
</div>
<div class="overlay collect-overlay">
<button class="button button-stable button-clear" ng-click="onboardingMailSkip()">
{{'Skip' | translate}}
</button>
</div>
<form name="emailForm" ng-submit="save(emailForm)" novalidate>
<label class="item item-input col col-75 center-block">
<i class="icon ion-arrow-right-c"></i>
<input type="email" id="email" name="email" ng-model="email" placeholder="satoshi@example.com" required></input>
</label>
</form>
</div>
<div class="overlay collect-overlay"></div>
</ion-content>
</ion-view>

View file

@ -30,7 +30,7 @@
Just scan the code to pay
</p>
</div>
<div class="row">
<div class="row cta-button">
<button class="button button-positive col col-75 next-slide" ng-click="slideNext()">
Got it <i class="icon ion-ios-arrow-thin-right"></i>
</button>
@ -54,9 +54,9 @@
The exchange rate changes with the market
</p>
</div>
<div class="row">
<div class="row cta-button">
<button class="button button-positive col col-75 next-slide" ng-click="slideNext()">
Makes sense <i class="icon ion-arrow-right-c"></i>
Makes sense <i class="icon ion-ios-arrow-thin-right"></i>
</button>
</div>
</ion-content>
@ -78,7 +78,7 @@
Not even BitPay can access it
</p>
</div>
<div class="row">
<div class="row cta-button">
<button class="button button-positive col col-75 get-started" ng-click="createDefaultWallet()">
Create bitcoin wallet
</button>

View file

@ -1,84 +1,100 @@
<div
class="topbar-container"
ng-include="'views/includes/topbar.html'"
ng-init="titleSection='Sweep paper wallet'; goBackToState = 'preferencesAdvanced';">
</div>
<ion-view>
<ion-nav-bar class="bar-royal">
<ion-nav-title>{{'Sweep paper wallet' | translate}}</ion-nav-title>
<ion-nav-back-button>
<i class="icon ion-ios-arrow-thin-left"></i>
</ion-nav-back-button>
</ion-nav-bar>
<div class="content preferences" ng-controller="paperWalletController">
<div class="row" ng-show="index.needsBackup">
<div class="columns">
<h4></h4>
<div class="size-14 text-warning m20b">
<i class="fi-alert size-12"></i>
<span class="text-warning" translate>Backup Needed</span>.
<span translate>
Before receiving funds, you must backup your wallet. If this device is lost, it is impossible to access your funds without a backup.
</span>
<ion-content ng-controller="paperWalletController" ng-init="init()">
<div class="row" ng-show="needsBackup">
<div class="columns">
<h4></h4>
<div class="size-14 text-warning m20b">
<i class="fi-alert size-12"></i>
<span class="text-warning" translate>Backup Needed</span>.
<span translate>
Before receiving funds, you must backup your wallet. If this device is lost, it is impossible to access your funds without a backup.
</span>
</div>
<div class="text-center m20t">
<a class="button outline round dark-gray" href ui-sref="tabs.preferences.preferencesAdvanced">
<span translate>Preferences</span>
</a>
</div>
</div>
<div class="text-center m20t">
<a class="button outline round dark-gray" href ui-sref="preferences" >
<span translate>Preferences</span>
</a>
</div>
</div>
</div>
<div ng-show="!index.needsBackup">
<h4 ng-show="!error"></h4>
<div class="box-notification m20b" ng-show="error">
<span class="text-warning">{{error|translate}}</span>
</div>
<form ng-show="!balance" class="oh">
<div class="row">
<div class="large-12 medium-12 columns">
<div class="input">
<label for="inputData" translate>Paper Wallet Private Key</label>
<input type="text" placeholder="{{'Paste your paper wallet private key here'|translate}}" ng-model="inputData" id="inputData" ng-change="onData(inputData)">
<div class="qr-scanner-input">
<qr-scanner on-scan="onQrCodeScanned(data)"></qr-scanner>
</div>
<div ng-show="isPkEncrypted">
<label for="passphrase">
<span translate>Password</span>
<div ng-show="!needsBackup">
<h4 ng-show="!error"></h4>
<div class="box-notification m20b" ng-show="error">
<span class="text-warning">{{error|translate}}</span>
</div>
<form ng-show="!balance" ng-submit="scanFunds()" novalidate>
<div class="list card">
<div class="row">
<div class="col col-90">
<label class="item item-input item-stacked-label">
<span class="input-label" translate>Paper Wallet Private Key</span>
<input type="text" placeholder="{{'Paste your paper wallet private key here'|translate}}" ng-model="formData.inputData" id="inputData" ng-change="onData(formData.inputData)">
</label>
<input id="passphrase" type="password" name="passphrase" placeholder="{{'Passphrase'|translate}}" ng-model="passphrase">
<p ng-show="index.isCordova" translate class="size-12 text-gray">
</div>
<div class="col text-center">
<qr-scanner class="qr-icon size-24" on-scan="onQrCodeScanned(data)"></qr-scanner>
</div>
</div>
<div class="row" ng-show="isPkEncrypted">
<div class="col">
<label class="item item-input item-stacked-label">
<span class="input-label" translate>Password</span>
<input type="text" name="passphrase" placeholder="{{'Passphrase'|translate}}" ng-model="passphrase">
</label>
<p ng-show="isCordova" class="card size-12 text-gray" translate>
Decrypting a paper wallet could take around 5 minutes on this device. please be patient and keep the app open.
</p>
</div>
<button
ng-disabled="scanning || !scannedKey"
ng-style="{'background-color':index.backgroundColor}"
class="button black round expand"
ng-click="scanFunds()"
translate>Scan Wallet Funds
</button>
</div>
</div>
</div>
</form>
<div ng-show="balance" class="row">
<div class="large-12 medium-12 columns">
<div class="text-center m20b">
<h4 class="text-bold" translate>Funds found</h4>
<div class="size-24">
{{balance}}
</div>
</div>
<button
ng-disabled="sending || balanceSat <= 0"
ng-style="{'background-color':index.backgroundColor}"
class="button black round expand"
ng-click="sweepWallet()"
translate>Sweep Wallet
<button type="submit"
ng-disabled="scanning || !scannedKey"
class="button button-block button-positive"
ng-style="{'background-color': wallet.color}"
translate>Scan Wallet Funds
</button>
</form>
<div class="row">
<div class="col text-center">
<div ng-show="scanned">
<h4 class="text-bold" translate>Funds found</h4>
<div class="size-24">{{balance}}</div>
</div>
<button
ng-show="balanceSat > 0"
ng-disabled="sending"
class="button button-block button-positive"
ng-style="{'background-color': wallet.color}"
ng-click="sweepWallet()"
translate>Sweep Wallet
</button>
<button
ng-show="balanceSat <= 0 && scanned"
class="button button-block button-positive"
ng-style="{'background-color': wallet.color}"
ng-click="init()"
translate>Scan Again
</button>
</div>
</div>
<div class="text-center size-12 text-gray">
<span translate>Funds will be transferred to</span>:
<b>{{walletAlias || walletName}}</b>
</div>
</div>
<div class="text-center size-12 text-gray">
<span translate>Funds will be transferred to</span>:
<b>{{index.alias || index.walletName}}</b>
</div>
</div>
</div>
<div class="extra-margin-bottom"></div>
</ion-content>
</ion-view>

View file

@ -5,7 +5,7 @@
<i class="icon ion-ios-arrow-thin-left"></i>
</ion-nav-back-button>
</ion-nav-bar>
<ion-content>
<ion-content ng-controller="preferencesAdvancedController">
<div class="list">
<div class="item item-divider">
</div>
@ -13,7 +13,7 @@
<span translate>Wallet Information</span>
<i class="icon nav-item-arrow-right"></i>
</a>
<a class="item item-icon-right" ng-show="index.network == 'livenet'" ui-sref="tabs.preferences.paperWallet">
<a class="item item-icon-right" ng-show="network == 'livenet'" ui-sref="tabs.preferences.paperWallet">
<span translate>Sweep paper wallet</span>
<i class="icon nav-item-arrow-right"></i>
</a>

View file

@ -4,12 +4,12 @@
<i class="icon ion-ios-arrow-thin-left"></i>
</ion-nav-back-button>
</ion-nav-bar>
<ion-content ng-controller="preferencesHistory" ng-init="index.updatingTxHistory ? null : csvHistory()">
<ion-content ng-controller="preferencesHistory" ng-init="csvHistory()">
<div class="item item-divider"></div>
<div class="item" ng-show="csvReady && !index.isCordova" ng-csv="csvContent" csv-header="csvHeader" filename="Copay-{{wallet.name}}.csv">
<div class="item" ng-show="csvReady && !isCordova" ng-csv="csvContent" csv-header="csvHeader" filename="Copay-{{wallet.name}}.csv">
<span translate>Export to file</span>
</div>
<div class="item" ng-show="!csvReady && !index.isCordova">
<div class="item" ng-show="!csvReady && !isCordova">
<span translate>Export to file</span>
<span class="item-note" translate>
preparing...

View file

@ -17,15 +17,15 @@
</div>
<div class="card" ng-if="list[0]">
<div class="item item-heading item-icon-right">
<div class="item item-heading item-icon-right" ui-sref="tabs.addressbook">
<span translate>Contacts & Wallets</span>
<i class="icon ion-person-add" ng-click="openAddressbookModal()"></i>
<i class="icon nav-item-arrow-right"></i>
</div>
<div class="item text-center" ng-show="!list[0]" translate>No Wallet - Contact</div>
<a class="item item-icon-left" ng-repeat="item in list" ng-click="goToAmount(item)">
<i ng-show="item.isWallet" class="icon ion-briefcase size-21" ng-style="{'color':item.color}"></i>
<i ng-show="!item.isWallet" class="icon ion-ios-person-outline"></i>
{{item.label}}
{{item.name}}
</a>
</div>
</ion-content>

View file

@ -6,9 +6,10 @@
<ion-content ng-controller="tabSettingsController" ng-init="init()">
<div class="list">
<div class="item item-divider"></div>
<a class="item item-icon-left" ng-click="openAddressbookModal()">
<a class="item item-icon-left item-icon-right" ui-sref="tabs.addressbook">
<i class="icon ion-ios-book-outline"></i>
<span translate>Address Book</span>
<i class="icon nav-item-arrow-right"></i>
</a>
<div class="item item-divider" translate>Preferences</div>

View file

@ -0,0 +1,56 @@
'use strict';
angular.module('copayApp.controllers').controller('addressbookListController', function($scope, $log, $timeout, addressbookService, lodash, popupService) {
var contacts;
$scope.initAddressbook = function() {
addressbookService.list(function(err, ab) {
if (err) $log.error(err);
$scope.isEmptyList = lodash.isEmpty(ab);
contacts = [];
lodash.each(ab, function(v, k) {
contacts.push({
name: lodash.isObject(v) ? v.name : v,
address: k,
email: lodash.isObject(v) ? v.email : null
});
});
$scope.addressbook = lodash.clone(contacts);
});
};
$scope.findAddressbook = function(search) {
if (!search || search.length < 2) {
$scope.addressbook = contacts;
$timeout(function() {
$scope.$apply();
}, 10);
return;
}
var result = lodash.filter(contacts, function(item) {
var val = item.name;
return lodash.includes(val.toLowerCase(), search.toLowerCase());
});
$scope.addressbook = result;
};
$scope.remove = function(addr) {
$timeout(function() {
addressbookService.remove(addr, function(err, ab) {
if (err) {
popupService.showAlert(err);
return;
}
$scope.initAddressbook();
$scope.$digest();
});
}, 100);
};
});

View file

@ -0,0 +1,36 @@
'use strict';
angular.module('copayApp.controllers').controller('addressbookAddController', function($scope, $state, $timeout, addressbookService, popupService) {
$scope.addressbookEntry = {
'address': '',
'name': '',
'email': ''
};
$scope.onQrCodeScanned = function(data, addressbookForm) {
$timeout(function() {
var form = addressbookForm;
if (data && form) {
data = data.replace('bitcoin:', '');
form.address.$setViewValue(data);
form.address.$isValid = true;
form.address.$render();
}
$scope.$digest();
}, 100);
};
$scope.add = function(addressbook) {
$timeout(function() {
addressbookService.add(addressbook, function(err, ab) {
if (err) {
popupService.showAlert(err);
return;
}
$state.go('tabs.addressbook');
});
}, 100);
};
});

View file

@ -0,0 +1,37 @@
'use strict';
angular.module('copayApp.controllers').controller('addressbookViewController', function($scope, $state, $timeout, $stateParams, lodash, addressbookService, popupService) {
var address = $stateParams.address;
if (!address) {
$state.go('tabs.addressbook');
return;
}
addressbookService.get(address, function(err, obj) {
if (err) {
popupService.showAlert(err);
return;
}
if (!lodash.isObject(obj)) {
var name = obj;
obj = {
'name': name,
'address': address,
'email': ''
};
}
$scope.addressbookEntry = obj;
});
$scope.sendTo = function() {
$timeout(function() {
$state.transitionTo('send.amount', {
toAddress: $scope.addressbookEntry.address,
toName: $scope.addressbookEntry.name
});
}, 100);
};
});

View file

@ -1,209 +1,219 @@
'use strict';
angular.module('copayApp.controllers').controller('backupController',
function($rootScope, $scope, $timeout, $log, $state, $stateParams, $ionicPopup, $ionicModal, $ionicNavBarDelegate, uxLanguage, lodash, fingerprintService, platformInfo, configService, profileService, bwcService, walletService, ongoingProcess, storageService) {
var wallet = profileService.getWallet($stateParams.walletId);
$ionicNavBarDelegate.title(wallet.credentials.walletName);
$scope.n = wallet.n;
var keys;
function($rootScope, $scope, $timeout, $log, $state, $stateParams, $ionicPopup, $ionicNavBarDelegate, uxLanguage, lodash, fingerprintService, platformInfo, configService, profileService, bwcService, walletService, ongoingProcess, storageService, popupService, gettextCatalog, $ionicModal) {
var wallet = profileService.getWallet($stateParams.walletId);
$ionicNavBarDelegate.title(wallet.credentials.walletName);
$scope.n = wallet.n;
var keys;
$scope.credentialsEncrypted = wallet.isPrivKeyEncrypted();
$scope.credentialsEncrypted = wallet.isPrivKeyEncrypted();
var isDeletedSeed = function() {
if (!wallet.credentials.mnemonic && !wallet.credentials.mnemonicEncrypted)
return true;
var isDeletedSeed = function() {
if (!wallet.credentials.mnemonic && !wallet.credentials.mnemonicEncrypted)
return true;
return false;
};
return false;
};
$scope.init = function() {
$scope.deleted = isDeletedSeed();
if ($scope.deleted) {
$log.debug('no mnemonics');
return;
}
walletService.getKeys(wallet, function(err, k) {
if (err || !k) {
$state.go('wallet.preferences');
$scope.init = function() {
$scope.deleted = isDeletedSeed();
if ($scope.deleted) {
$log.debug('no mnemonics');
return;
}
$scope.credentialsEncrypted = false;
keys = k;
$scope.initFlow();
});
};
var shuffledWords = function(words) {
var sort = lodash.sortBy(words);
return lodash.map(sort, function(w) {
return {
word: w,
selected: false
};
});
};
$scope.initFlow = function() {
if (!keys) return;
$scope.viewTitle = "Backup Phrase";
var words = keys.mnemonic;
$scope.mnemonicWords = words.split(/[\u3000\s]+/);
$scope.shuffledMnemonicWords = shuffledWords($scope.mnemonicWords);
$scope.mnemonicHasPassphrase = wallet.mnemonicHasPassphrase();
$scope.useIdeograms = words.indexOf("\u3000") >= 0;
$scope.passphrase = '';
$scope.customWords = [];
$scope.step = 1;
$scope.selectComplete = false;
$scope.backupError = false;
words = lodash.repeat('x', 300);
$timeout(function() {
$scope.$apply();
}, 10);
};
$scope.goBack = function() {
if ($scope.step == 1) {
if ($stateParams.fromOnboarding) $state.go('onboarding.backupRequest');
else $state.go('wallet.preferences');
} else {
$scope.goToStep($scope.step - 1);
}
};
var backupError = function(err) {
ongoingProcess.set('validatingWords', false);
$log.debug('Failed to verify backup: ', err);
$scope.backupError = true;
$timeout(function() {
$scope.$apply();
}, 1);
};
$scope.closePopup = function(val) {
if (val) {
$scope.closeModal();
if ($stateParams.fromOnboarding) $state.go('onboarding.disclaimer');
else $state.go('tabs.home')
} else {
confirmBackupPopup.close();
$scope.goToStep(1);
}
};
$ionicModal.fromTemplateUrl('views/includes/confirmBackupPopup.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.modal = modal;
});
$scope.openModal = function() {
$scope.modal.show();
};
$scope.closeModal = function() {
$scope.modal.hide();
};
// Cleanup the modal when we're done with it!
$scope.$on('$destroy', function() {
$scope.modal.remove();
});
var confirm = function(cb) {
$scope.backupError = false;
var customWordList = lodash.pluck($scope.customWords, 'word');
if (!lodash.isEqual($scope.mnemonicWords, customWordList)) {
return cb('Mnemonic string mismatch');
}
$timeout(function() {
if ($scope.mnemonicHasPassphrase) {
var walletClient = bwcService.getClient();
var separator = $scope.useIdeograms ? '\u3000' : ' ';
var customSentence = customWordList.join(separator);
var passphrase = $scope.passphrase || '';
try {
walletClient.seedFromMnemonic(customSentence, {
network: wallet.credentials.network,
passphrase: passphrase,
account: wallet.credentials.account
});
} catch (err) {
walletClient.credentials.xPrivKey = lodash.repeat('x', 64);
return cb(err);
walletService.getKeys(wallet, function(err, k) {
if (err || !k) {
$log.error('Could not get keys: ', err);
$state.go('wallet.preferences');
return;
}
if (walletClient.credentials.xPrivKey.substr(walletClient.credentials.xPrivKey) != keys.xPrivKey) {
delete walletClient.credentials;
return cb('Private key mismatch');
}
}
profileService.setBackupFlag(wallet.credentials.walletId);
return cb();
}, 1);
};
var finalStep = function() {
ongoingProcess.set('validatingWords', true);
confirm(function(err) {
ongoingProcess.set('validatingWords', false);
if (err) {
backupError(err);
}
$timeout(function() {
$scope.openModal();
return;
}, 1);
});
};
$scope.goToStep = function(n) {
if (n == 1)
$scope.initFlow();
if (n == 2) {
$scope.step = 2;
$scope.viewTitle = "Let's verify your backup phrase";
}
if (n == 3) {
if (!$scope.mnemonicHasPassphrase)
finalStep();
else
$scope.step = 3;
}
if (n == 4)
finalStep();
};
$scope.addButton = function(index, item) {
var newWord = {
word: item.word,
prevIndex: index
$scope.credentialsEncrypted = false;
keys = k;
$scope.initFlow();
});
};
$scope.customWords.push(newWord);
$scope.shuffledMnemonicWords[index].selected = true;
$scope.shouldContinue();
};
$scope.removeButton = function(index, item) {
if ($scope.loading) return;
$scope.customWords.splice(index, 1);
$scope.shuffledMnemonicWords[item.prevIndex].selected = false;
$scope.shouldContinue();
};
var shuffledWords = function(words) {
var sort = lodash.sortBy(words);
$scope.shouldContinue = function() {
if ($scope.customWords.length == $scope.shuffledMnemonicWords.length)
$scope.selectComplete = true;
else
return lodash.map(sort, function(w) {
return {
word: w,
selected: false
};
});
};
$scope.initFlow = function() {
if (!keys) return;
var words = keys.mnemonic;
$scope.mnemonicWords = words.split(/[\u3000\s]+/);
$scope.shuffledMnemonicWords = shuffledWords($scope.mnemonicWords);
$scope.mnemonicHasPassphrase = wallet.mnemonicHasPassphrase();
$scope.useIdeograms = words.indexOf("\u3000") >= 0;
$scope.passphrase = '';
$scope.customWords = [];
$scope.step = 1;
$scope.selectComplete = false;
};
$scope.backupError = false;
});
words = lodash.repeat('x', 300);
$timeout(function() {
$scope.$apply();
}, 10);
};
$scope.goBack = function() {
if ($scope.step == 1) {
if ($stateParams.fromOnboarding) $state.go('onboarding.backupRequest');
else $state.go('wallet.preferences');
} else {
$scope.goToStep($scope.step - 1);
}
};
var backupError = function(err) {
ongoingProcess.set('validatingWords', false);
$log.debug('Failed to verify backup: ', err);
$scope.backupError = true;
$timeout(function() {
$scope.$apply();
}, 1);
};
$ionicModal.fromTemplateUrl('views/includes/confirmBackupPopup.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.modal = modal;
});
$scope.openModal = function() {
$scope.modal.show();
};
$scope.closeModal = function() {
$scope.modal.hide();
};
// Cleanup the modal when we're done with it!
$scope.$on('$destroy', function() {
$scope.modal.remove();
});
var openPopup = function() {
if ($scope.backupError) {
var title = gettextCatalog.getString('uh oh...');
var message = gettextCatalog.getString("It's importante that you write your backup phrase down correctly. If something happens to your wallet, you'll need this backup to recover your money Please review your backup and try again");
popupService.showAlert(title, message, function() {
$scope.goToStep(1);
})
}
else {
$scope.openModal();
$scope.closePopup = function() {
$scope.closeModal();
if ($stateParams.fromOnboarding) $state.go('onboarding.disclaimer');
else {
$ionicHistory.clearHistory();
$state.go('tabs.home')
}
};
}
}
var confirm = function(cb) {
$scope.backupError = false;
var customWordList = lodash.pluck($scope.customWords, 'word');
if (!lodash.isEqual($scope.mnemonicWords, customWordList)) {
return cb('Mnemonic string mismatch');
}
$timeout(function() {
if ($scope.mnemonicHasPassphrase) {
var walletClient = bwcService.getClient();
var separator = $scope.useIdeograms ? '\u3000' : ' ';
var customSentence = customWordList.join(separator);
var passphrase = $scope.passphrase || '';
try {
walletClient.seedFromMnemonic(customSentence, {
network: wallet.credentials.network,
passphrase: passphrase,
account: wallet.credentials.account
});
} catch (err) {
walletClient.credentials.xPrivKey = lodash.repeat('x', 64);
return cb(err);
}
if (walletClient.credentials.xPrivKey.substr(walletClient.credentials.xPrivKey) != keys.xPrivKey) {
delete walletClient.credentials;
return cb('Private key mismatch');
}
}
profileService.setBackupFlag(wallet.credentials.walletId);
return cb();
}, 1);
};
var finalStep = function() {
ongoingProcess.set('validatingWords', true);
confirm(function(err) {
ongoingProcess.set('validatingWords', false);
if (err) {
backupError(err);
}
$timeout(function() {
openPopup();
return;
}, 1);
});
};
$scope.goToStep = function(n) {
if (n == 1)
$scope.initFlow();
if (n == 2)
$scope.step = 2;
if (n == 3) {
if (!$scope.mnemonicHasPassphrase)
finalStep();
else
$scope.step = 3;
}
if (n == 4)
finalStep();
};
$scope.addButton = function(index, item) {
var newWord = {
word: item.word,
prevIndex: index
};
$scope.customWords.push(newWord);
$scope.shuffledMnemonicWords[index].selected = true;
$scope.shouldContinue();
};
$scope.removeButton = function(index, item) {
if ($scope.loading) return;
$scope.customWords.splice(index, 1);
$scope.shuffledMnemonicWords[item.prevIndex].selected = false;
$scope.shouldContinue();
};
$scope.shouldContinue = function() {
if ($scope.customWords.length == $scope.shuffledMnemonicWords.length)
$scope.selectComplete = true;
else
$scope.selectComplete = false;
};
});

View file

@ -21,7 +21,7 @@ angular.module('copayApp.controllers').controller('copayersController',
$scope.isCordova = platformInfo.isCordova;
$scope.showDeletePopup = function() {
popupService.showConfirm(gettextCatalog.getString('Confirm'), gettextCatalog.getString('Are you sure you want to delete this wallet?'), function(res) {
popupService.showConfirm(gettextCatalog.getString('Confirm'), gettextCatalog.getString('Are you sure you want to delete this wallet?'), null, null, function(res) {
if (res) deleteWallet();
});
};

View file

@ -1,111 +0,0 @@
'use strict';
angular.module('copayApp.controllers').controller('addressbookModalController', function($scope, $log, $state, $timeout, $ionicPopup, addressbookService, lodash, popupService) {
var contacts;
$scope.initAddressbook = function() {
addressbookService.list(function(err, ab) {
if (err) $log.error(err);
$scope.isEmptyList = lodash.isEmpty(ab);
contacts = [];
lodash.each(ab, function(v, k) {
contacts.push({
label: v,
address: k
});
});
$scope.addressbook = lodash.clone(contacts);
});
};
$scope.findAddressbook = function(search) {
if (!search || search.length < 2) {
$scope.addressbook = contacts;
$timeout(function() {
$scope.$apply();
}, 10);
return;
}
var result = lodash.filter(contacts, function(item) {
var val = item.label;
return lodash.includes(val.toLowerCase(), search.toLowerCase());
});
$scope.addressbook = result;
};
$scope.sendTo = function(item) {
$scope.closeAddressbookModal();
$timeout(function() {
$state.transitionTo('send.amount', { toAddress: item.address, toName: item.label})
}, 100);
};
$scope.closeAddressbookModal = function() {
$scope.cleanAddressbookEntry();
$scope.addAddressbookEntry = false;
$scope.addressbookModal.hide();
};
$scope.onQrCodeScanned = function(data, addressbookForm) {
$timeout(function() {
var form = addressbookForm;
if (data && form) {
data = data.replace('bitcoin:', '');
form.address.$setViewValue(data);
form.address.$isValid = true;
form.address.$render();
}
$scope.$digest();
}, 100);
};
$scope.cleanAddressbookEntry = function() {
$scope.addressbookEntry = {
'address': '',
'label': ''
};
};
$scope.toggleAddAddressbookEntry = function() {
$scope.cleanAddressbookEntry();
$scope.addAddressbookEntry = !$scope.addAddressbookEntry;
};
$scope.add = function(addressbook) {
$timeout(function() {
addressbookService.add(addressbook, function(err, ab) {
if (err) {
popupService.showAlert(err);
return;
}
$scope.initAddressbook();
$scope.toggleAddAddressbookEntry();
$scope.$digest();
});
}, 100);
};
$scope.remove = function(addr) {
$timeout(function() {
addressbookService.remove(addr, function(err, ab) {
if (err) {
popupService.showAlert(err);
return;
}
$scope.initAddressbook();
$scope.$digest();
});
}, 100);
};
$scope.$on('$destroy', function() {
$scope.addressbookModal.remove();
});
});

View file

@ -0,0 +1,10 @@
'use strict';
angular.module('copayApp.controllers').controller('receiveTipsController', function($scope, $log, storageService) {
$scope.close = function() {
$log.debug('Receive tips accepted');
storageService.setReceiveTipsAccepted(true, function(err) {
$scope.receiveTipsModal.hide();
});
}
});

View file

@ -0,0 +1,11 @@
'use strict';
angular.module('copayApp.controllers').controller('scanTipsController', function($scope, $log, storageService) {
$scope.close = function() {
$log.debug('Scan tips accepted');
storageService.setScanTipsAccepted(true, function(err) {
$scope.$emit('TipsModalClosed', function() {});
$scope.scanTipsModal.hide();
});
}
});

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('scannerController', function($scope, $timeout) {
angular.module('copayApp.controllers').controller('scannerController', function($scope, $timeout, storageService, $ionicModal, platformInfo) {
// QR code Scanner
var video;
@ -73,6 +73,35 @@ angular.module('copayApp.controllers').controller('scannerController', function(
};
$scope.init = function() {
if (platformInfo.isCordova) scannerInit();
else checkTips();
};
function checkTips() {
//TODO addapt tips to the new QR plugin (mobile)
storageService.getScanTipsAccepted(function(err, accepted) {
if (err) $log.warn(err);
if (accepted) {
scannerInit();
return;
}
$timeout(function() {
$ionicModal.fromTemplateUrl('views/modals/scan-tips.html', {
scope: $scope
}).then(function(modal) {
$scope.scanTipsModal = modal;
$scope.scanTipsModal.show();
});
}, 1000);
});
};
$scope.$on('TipsModalClosed', function(event) {
scannerInit();
});
function scannerInit() {
setScanner();
$timeout(function() {
if ($scope.beforeScan) {

View file

@ -1,22 +1,28 @@
'use strict';
angular.module('copayApp.controllers').controller('backupRequestController', function($scope, $state, $stateParams, $ionicPopup) {
angular.module('copayApp.controllers').controller('backupRequestController', function($scope, $state, $stateParams, $ionicPopup, popupService, gettextCatalog) {
$scope.walletId = $stateParams.walletId;
$scope.openPopup = function() {
var backupLaterPopup = $ionicPopup.show({
templateUrl: "views/includes/backupLaterPopup.html",
scope: $scope,
var title = gettextCatalog.getString('Without a backup, you could lose money');
var message = gettextCatalog.getString('If something happens to this device, this app is deleted, or your password forgotten, neither you nor Bitpay can recover your funds');
var okText = gettextCatalog.getString('I understand');
var cancelText = gettextCatalog.getString('Go back');
popupService.showConfirm(title, message, okText, cancelText, function(val) {
if (val) {
var title = gettextCatalog.getString('Are you sure you want to skip the backup?');
var message = gettextCatalog.getString('You can create a backup later from your wallet settings');
var okText = gettextCatalog.getString('Yes, skip backup');
var cancelText = gettextCatalog.getString('Go back');
popupService.showConfirm(title, message, okText, cancelText, function(val) {
if (val) {
$state.go('onboarding.disclaimer');
}
});
}
});
$scope.goBack = function() {
backupLaterPopup.close();
};
$scope.continue = function() {
backupLaterPopup.close();
$state.go('onboarding.disclaimer');
};
}
});

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('collectEmailController', function($scope, $state, $stateParams, profileService, configService, walletService, platformInfo) {
angular.module('copayApp.controllers').controller('collectEmailController', function($scope, $state, $timeout, $stateParams, profileService, configService, walletService, platformInfo) {
var isCordova = platformInfo.isCordova;
var isWP = platformInfo.isWP;
@ -9,11 +9,7 @@ angular.module('copayApp.controllers').controller('collectEmailController', func
var wallet = profileService.getWallet($stateParams.walletId);
var walletId = wallet.credentials.walletId;
var config = configService.getSync();
config.emailFor = config.emailFor || {};
$scope.email = config.emailFor && config.emailFor[walletId];
$scope.save = function(form) {
$scope.save = function() {
var opts = {
emailFor: {}
};
@ -25,13 +21,32 @@ angular.module('copayApp.controllers').controller('collectEmailController', func
if (err) $log.warn(err);
configService.set(opts, function(err) {
if (err) $log.warn(err);
if (!usePushNotifications) $state.go('onboarding.backupRequest', {walletId: walletId});
else $state.go('onboarding.notifications', {walletId: walletId});
if (!usePushNotifications) $state.go('onboarding.backupRequest', {
walletId: walletId
});
else $state.go('onboarding.notifications', {
walletId: walletId
});
});
});
};
$scope.confirm = function(emailForm) {
if (emailForm.$invalid) return;
$scope.confirmation = true;
$scope.email = emailForm.email.$modelValue;
};
$scope.cancel = function() {
$scope.confirmation = false;
$timeout(function() {
$scope.$digest();
}, 1);
};
$scope.onboardingMailSkip = function() {
$state.go('onboarding.backupRequest', {walletId: walletId});
$state.go('onboarding.backupRequest', {
walletId: walletId
});
};
});

View file

@ -1,16 +1,31 @@
angular.module('copayApp.controllers').controller('paperWalletController',
function($scope, $timeout, $log, $ionicModal, $ionicHistory, configService, profileService, $state, addressService, bitcore, ongoingProcess, txFormatService, $stateParams, walletService) {
function($scope, $timeout, $log, $ionicModal, $ionicHistory, popupService, gettextCatalog, platformInfo, configService, profileService, $state, bitcore, ongoingProcess, txFormatService, $stateParams, walletService) {
var wallet = profileService.getWallet($stateParams.walletId);
var rawTx;
$scope.init = function() {
$scope.wallet = wallet;
$scope.isCordova = platformInfo.isCordova;
$scope.needsBackup = wallet.needsBackup;
$scope.walletAlias = wallet.name;
$scope.walletName = wallet.credentials.walletName;
$scope.formData = {};
$scope.formData.inputData = null;
$scope.scannedKey = null;
$scope.balance = null;
$scope.balanceSat = null;
$scope.scanned = false;
$timeout(function() {
$scope.$apply();
}, 10);
};
$scope.onQrCodeScanned = function(data) {
$scope.inputData = data;
$scope.formData.inputData = data;
$scope.onData(data);
};
$scope.onData = function(data) {
$scope.error = null;
$scope.scannedKey = data;
$scope.isPkEncrypted = (data.substring(0, 2) == '6P');
};
@ -48,7 +63,6 @@ angular.module('copayApp.controllers').controller('paperWalletController',
$scope.scanFunds = function() {
$scope.privateKey = '';
$scope.balanceSat = 0;
$scope.error = null;
ongoingProcess.set('scanning', true);
$timeout(function() {
@ -56,12 +70,13 @@ angular.module('copayApp.controllers').controller('paperWalletController',
ongoingProcess.set('scanning', false);
if (err) {
$log.error(err);
$scope.error = err.message || err.toString();
popupService.showAlert(gettextCatalog.getString('Error scanning funds:'), err || err.toString());
} else {
$scope.privateKey = privateKey;
$scope.balanceSat = balance;
var config = configService.getSync().wallet.settings;
$scope.balance = txFormatService.formatAmount(balance) + ' ' + config.unitName;
$scope.scanned = true;
}
$scope.$apply();
@ -70,7 +85,7 @@ angular.module('copayApp.controllers').controller('paperWalletController',
};
function _sweepWallet(cb) {
addressService.getAddress(wallet.credentials.walletId, true, function(err, destinationAddress) {
walletService.getAddress(wallet, true, function(err, destinationAddress) {
if (err) return cb(err);
wallet.buildTxFromPrivateKey($scope.privateKey, destinationAddress, null, function(err, tx) {
@ -90,18 +105,16 @@ angular.module('copayApp.controllers').controller('paperWalletController',
$scope.sweepWallet = function() {
ongoingProcess.set('sweepingWallet', true);
$scope.sending = true;
$scope.error = null;
$timeout(function() {
_sweepWallet(function(err, destinationAddress, txid) {
ongoingProcess.set('sweepingWallet', false);
$scope.sending = false;
if (err) {
$scope.error = err.message || err.toString();
$log.error(err);
popupService.showAlert(gettextCatalog.getString('Error sweeping wallet:'), err || err.toString());
} else {
var type = walletService.getViewStatus(wallet, txp);
$scope.openStatusModal(type, txp, function() {
$scope.openStatusModal('broadcasted', function() {
$ionicHistory.clearHistory();
$state.go('tabs.home');
});
@ -111,19 +124,18 @@ angular.module('copayApp.controllers').controller('paperWalletController',
}, 100);
};
$scope.openStatusModal = function(type, txp, cb) {
$scope.openStatusModal = function(type, cb) {
$scope.tx = {};
$scope.tx.amountStr = $scope.balance;
$scope.type = type;
$scope.tx = txFormatService.processTx(txp);
$scope.color = wallet.backgroundColor;
$scope.cb = cb;
$ionicModal.fromTemplateUrl('views/modals/tx-status.html', {
scope: $scope,
animation: 'slide-in-up'
scope: $scope
}).then(function(modal) {
$scope.txStatusModal = modal;
$scope.txStatusModal.show();
});
};
});

View file

@ -0,0 +1,10 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesAdvancedController', function($scope, $timeout, $stateParams, profileService) {
var wallet = profileService.getWallet($stateParams.walletId);
$scope.network = wallet.network;
$timeout(function() {
$scope.$apply();
}, 1);
});

View file

@ -5,7 +5,7 @@ angular.module('copayApp.controllers').controller('preferencesBitpayCardControll
$scope.logout = function() {
var title = 'Are you sure you would like to log out of your Bitpay Card account?';
popupService.showConfirm(title, null, function(res) {
popupService.showConfirm(title, null, null, null, function(res) {
if (res) logout();
});
};

View file

@ -10,7 +10,7 @@ angular.module('copayApp.controllers').controller('preferencesDeleteWalletContro
$scope.showDeletePopup = function() {
var title = gettextCatalog.getString('Warning!');
var message = gettextCatalog.getString('Are you sure you want to delete this wallet?');
popupService.showConfirm(title, message, function(res) {
popupService.showConfirm(title, message, null, null, function(res) {
if (res) deleteWallet();
});
};

View file

@ -23,7 +23,9 @@ angular.module('copayApp.controllers').controller('preferencesGlideraController'
}
$scope.token = glidera.token;
$scope.permissions = glidera.permissions;
$scope.update({fullUpdate: true});
$scope.update({
fullUpdate: true
});
});
};
@ -62,7 +64,7 @@ angular.module('copayApp.controllers').controller('preferencesGlideraController'
};
$scope.revokeToken = function() {
popupService.showConfirm('Glidera', 'Are you sure you would like to log out of your Glidera account?', function(res) {
popupService.showConfirm('Glidera', 'Are you sure you would like to log out of your Glidera account?', null, null, function(res) {
if (res) {
glideraService.removeToken(function() {
$timeout(function() {

View file

@ -1,10 +1,11 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesHistory',
function($scope, $log, $stateParams, $timeout, $ionicNavBarDelegate, gettextCatalog, storageService, $state, $ionicHistory, profileService, lodash) {
function($scope, $log, $stateParams, $timeout, $state, $ionicHistory, $ionicNavBarDelegate, gettextCatalog, storageService, platformInfo, profileService, lodash) {
$ionicNavBarDelegate.title(gettextCatalog.getString('Transaction History'));
$scope.wallet = profileService.getWallet($stateParams.walletId);
$scope.csvReady = false;
$scope.isCordova = platformInfo.isCordova;
$scope.csvHistory = function(cb) {
var allTxs = [];

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('tabReceiveController', function($scope, $timeout, $log, platformInfo, walletService, profileService, configService, lodash, gettextCatalog, popupService) {
angular.module('copayApp.controllers').controller('tabReceiveController', function($scope, $timeout, $log, $ionicModal, storageService, platformInfo, walletService, profileService, configService, lodash, gettextCatalog, popupService) {
$scope.isCordova = platformInfo.isCordova;
@ -8,10 +8,27 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
$scope.wallets = profileService.getWallets({
onlyComplete: true
});
$scope.isCordova = platformInfo.isCordova;
$scope.isNW = platformInfo.isNW;
$scope.isCordova = platformInfo.isCordova;
if (!$scope.isCordova) $scope.checkTips();
}
$scope.checkTips = function() {
storageService.getReceiveTipsAccepted(function(err, accepted) {
if (err) $log.warn(err);
if (accepted) return;
$timeout(function() {
$ionicModal.fromTemplateUrl('views/modals/receive-tips.html', {
scope: $scope
}).then(function(modal) {
$scope.receiveTipsModal = modal;
$scope.receiveTipsModal.show();
});
}, 1000);
});
};
$scope.$on('Wallet/Changed', function(event, wallet) {
if (!wallet) {
$log.debug('No wallet provided');

View file

@ -1,18 +1,20 @@
'use strict';
angular.module('copayApp.controllers').controller('tabSendController', function($scope, $ionicModal, $log, $timeout, addressbookService, profileService, lodash, $state, walletService, incomingData ) {
angular.module('copayApp.controllers').controller('tabSendController', function($scope, $log, $timeout, addressbookService, profileService, lodash, $state, walletService, incomingData ) {
var originalList;
$scope.init = function() {
originalList = [];
var wallets = profileService.getWallets({onlyComplete: true});
var wallets = profileService.getWallets({
onlyComplete: true
});
lodash.each(wallets, function(v) {
originalList.push({
color: v.color,
label: v.name,
name: v.name,
isWallet: true,
getAddress: function(cb) {
walletService.getAddress(v, false, cb);
@ -26,16 +28,20 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
var contacts = [];
lodash.each(ab, function(v, k) {
contacts.push({
label: v,
name: lodash.isObject(v) ? v.name : v,
address: k,
getAddress: function(cb) {
return cb(null,k);
return cb(null, k);
},
});
});
originalList = originalList.concat(contacts);
$scope.list = lodash.clone(originalList);
$timeout(function() {
$scope.$apply();
}, 1);
});
};
@ -54,7 +60,7 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
}
var result = lodash.filter(originalList, function(item) {
var val = item.label || item.alias || item.name;
var val = item.name;
return lodash.includes(val.toLowerCase(), search.toLowerCase());
});
@ -62,22 +68,16 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
};
$scope.goToAmount = function(item) {
item.getAddress(function(err,addr){
if (err|| !addr) {
item.getAddress(function(err, addr) {
if (err || !addr) {
$log.error(err);
return;
}
$log.debug('Got toAddress:' + addr + ' | ' + item.label)
return $state.transitionTo('send.amount', { toAddress: addr, toName: item.label})
});
};
$scope.openAddressbookModal = function() {
$ionicModal.fromTemplateUrl('views/modals/addressbook.html', {
scope: $scope
}).then(function(modal) {
$scope.addressbookModal = modal;
$scope.addressbookModal.show();
$log.debug('Got toAddress:' + addr + ' | ' + item.name);
return $state.transitionTo('send.amount', {
toAddress: addr,
toName: item.name
})
});
};

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('tabSettingsController', function($scope, $rootScope, $log, $ionicModal, $window, lodash, configService, uxLanguage, platformInfo, pushNotificationsService, profileService, feeService) {
angular.module('copayApp.controllers').controller('tabSettingsController', function($scope, $rootScope, $log, $window, lodash, configService, uxLanguage, platformInfo, pushNotificationsService, profileService, feeService) {
$scope.init = function() {
@ -38,17 +38,6 @@ angular.module('copayApp.controllers').controller('tabSettingsController', funct
$scope.wallets = profileService.getWallets();
};
$scope.openAddressbookModal = function() {
$ionicModal.fromTemplateUrl('views/modals/addressbook.html', {
scope: $scope
}).then(function(modal) {
$scope.addressbookModal = modal;
$scope.addressbookModal.show();
});
};
$scope.openSettings = function() {
cordova.plugins.diagnostic.switchToSettings(function() {
$log.debug('switched to settings');

View file

@ -490,6 +490,41 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
}
})
/*
*
* Addressbook
*
*/
.state('tabs.addressbook', {
url: '/addressbook',
views: {
'tab-settings': {
templateUrl: 'views/addressbook.html',
controller: 'addressbookListController'
}
}
})
.state('tabs.addressbook.add', {
url: '/add',
views: {
'tab-settings@tabs': {
templateUrl: 'views/addressbook.add.html',
controller: 'addressbookAddController'
}
}
})
.state('tabs.addressbook.view', {
url: '/view/:address',
views: {
'tab-settings@tabs': {
templateUrl: 'views/addressbook.view.html',
controller: 'addressbookViewController'
}
}
})
/*
*
*TO DO
@ -726,7 +761,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
}
});
})
.run(function($rootScope, $state, $location, $log, $timeout, $ionicHistory, $ionicPlatform, lodash, platformInfo, profileService, uxLanguage, gettextCatalog, openURLService) {
.run(function($rootScope, $state, $location, $log, $timeout, $ionicHistory, $ionicPlatform, lodash, platformInfo, profileService, uxLanguage, gettextCatalog, openURLService, storageService) {
uxLanguage.init();
openURLService.init();
@ -739,21 +774,35 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
cordova.plugins.Keyboard.disableScroll(true);
}
window.addEventListener('native.keyboardshow', function() {
document.querySelector('div.tabs').style.display = 'none';
angular.element(document.querySelector('ion-content.has-tabs')).css('bottom', 0);
});
window.addEventListener('native.keyboardhide', function() {
var tabs = document.querySelectorAll('div.tabs');
angular.element(tabs[0]).css('display', '');
});
$ionicPlatform.registerBackButtonAction(function(e) {
var fromDisclaimer = $ionicHistory.currentStateName().match(/disclaimer/) ? 'true' : '';
var fromTabs = $ionicHistory.currentStateName().match(/tabs/) ? 'true' : '';
var fromWelcome = $ionicHistory.currentStateName().match(/welcome/) ? true : false;
var matchHome = $ionicHistory.currentStateName().match(/home/) ? true : false;
var matchReceive = $ionicHistory.currentStateName().match(/receive/) ? true : false;
var matchSend = $ionicHistory.currentStateName().match(/send/) ? true : false;
var matchSettings = $ionicHistory.currentStateName().match(/settings/) ? true : false;
var fromTabs = matchHome | matchReceive | matchSend | matchSettings;
if ($rootScope.backButtonPressedOnceToExit || fromDisclaimer) {
ionic.Platform.exitApp();
} else if ($ionicHistory.backView() && !fromTabs) {
if ($ionicHistory.backView() && !fromTabs) {
$ionicHistory.goBack();
} else if ($rootScope.backButtonPressedOnceToExit || fromWelcome) {
ionic.Platform.exitApp();
} else {
$rootScope.backButtonPressedOnceToExit = true;
window.plugins.toast.showShortBottom(gettextCatalog.getString('Press again to exit'));
setInterval(function() {
$timeout(function() {
$rootScope.backButtonPressedOnceToExit = false;
}, 5000);
}, 3000);
}
e.preventDefault();
}, 101);
@ -782,10 +831,19 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
if (err) {
if (err.message && err.message.match('NOPROFILE')) {
$log.debug('No profile... redirecting');
$state.transitionTo('onboarding.welcome');
$state.go('onboarding.welcome');
} else if (err.message && err.message.match('NONAGREEDDISCLAIMER')) {
$log.debug('Display disclaimer... redirecting');
$state.transitionTo('onboarding.disclaimer');
storageService.getLastState(function(err, state) {
if (err && !state) {
$log.error(err);
$state.go('onboarding.disclaimer');
}
else {
var state = JSON.parse(state);
$state.go(state.name, state.toParams);
}
})
} else {
throw new Error(err); // TODO
}
@ -793,7 +851,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
profileService.storeProfileIfDirty();
$log.debug('Profile loaded ... Starting UX.');
$state.transitionTo('tabs.home');
$state.go('tabs.home');
}
});
});
@ -816,6 +874,9 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
$log.debug('Route change from:', fromState.name || '-', ' to:', toState.name);
$log.debug(' toParams:' + JSON.stringify(toParams || {}));
$log.debug(' fromParams:' + JSON.stringify(fromParams || {}));
var state = {};
state.name = toState.name;
state.toParams = toParams;
storageService.setLastState(JSON.stringify(state), function() {});
});
});

View file

@ -3,12 +3,16 @@
angular.module('copayApp.services').factory('addressbookService', function(bitcore, storageService, lodash) {
var root = {};
root.getLabel = function(addr, cb) {
root.get = function(addr, cb) {
storageService.getAddressbook('testnet', function(err, ab) {
if (ab && ab[addr]) return cb(ab[addr]);
if (err) return cb(err);
if (ab) ab = JSON.parse(ab);
if (ab && ab[addr]) return cb(null, ab[addr]);
storageService.getAddressbook('livnet', function(err, ab) {
if (ab && ab[addr]) return cb(ab[addr]);
storageService.getAddressbook('livenet', function(err, ab) {
if (err) return cb(err);
if (ab) ab = JSON.parse(ab);
if (ab && ab[addr]) return cb(null, ab[addr]);
return cb();
});
});
@ -38,7 +42,7 @@ angular.module('copayApp.services').factory('addressbookService', function(bitco
ab = ab || {};
if (lodash.isArray(ab)) ab = {}; // No array
if (ab[entry.address]) return cb('Entry already exist');
ab[entry.address] = entry.label;
ab[entry.address] = entry;
storageService.setAddressbook(network, JSON.stringify(ab), function(err, ab) {
if (err) return cb('Error adding new entry');
root.list(function(err, ab) {

View file

@ -10,14 +10,19 @@ angular.module('copayApp.services').service('popupService', function($log, $ioni
if (!cb) cb = function() {};
$ionicPopup.alert({
title: title,
template: message
template: message,
okType: 'button-clear button-positive'
}).then(cb);
};
var _ionicConfirm = function(title, message, cb) {
var _ionicConfirm = function(title, message, okText, cancelText, cb) {
$ionicPopup.confirm({
title: title,
template: message
template: message,
cancelText: cancelText,
cancelType: 'button-clear button-positive',
okText: okText,
okType: 'button-clear button-positive'
}).then(function(res) {
return cb(res);
});
@ -42,16 +47,16 @@ angular.module('copayApp.services').service('popupService', function($log, $ioni
navigator.notification.alert(message, cb, title);
};
var _cordovaConfirm = function(title, message, cb) {
var onConfirm = function (buttonIndex) {
var _cordovaConfirm = function(title, message, okText, cancelText, cb) {
var onConfirm = function(buttonIndex) {
if (buttonIndex == 1) return cb(true);
else return cb(false);
}
navigator.notification.confirm(message, onConfirm, title);
navigator.notification.confirm(message, onConfirm, title, [okText, cancelText]);
};
var _cordovaPrompt = function(title, message, cb) {
var onPrompt = function (results) {
var onPrompt = function(results) {
if (results.buttonIndex == 1) return cb(results.input1);
else return cb();
}
@ -81,17 +86,19 @@ angular.module('copayApp.services').service('popupService', function($log, $ioni
*
* @param {String} Title
* @param {String} Message
* @param {String} okText
* @param {String} cancelText
* @param {Callback} Function
* @returns {Callback} OK: true, Cancel: false
*/
this.showConfirm = function(title, message, cb) {
this.showConfirm = function(title, message, okText, cancelText, cb) {
$log.warn(title + ": " + message);
if (isCordova)
_cordovaConfirm(title, message, cb);
_cordovaConfirm(title, message, okText, cancelText, cb);
else
_ionicConfirm(title, message, cb);
_ionicConfirm(title, message, okText, cancelText, cb);
};
/**

View file

@ -276,6 +276,13 @@ angular.module('copayApp.services')
storage.remove('nextStep-' + service, cb);
};
root.setLastState = function(state, toParams, cb) {
storage.set('lastState', state, toParams, cb);
};
root.getLastState = function(cb) {
storage.get('lastState', cb);
};
root.checkQuota = function() {
var block = '';
@ -342,6 +349,22 @@ angular.module('copayApp.services')
});
};
root.setScanTipsAccepted = function(val, cb) {
storage.set('scanTips', val, cb);
};
root.getScanTipsAccepted = function(cb) {
storage.get('scanTips', cb);
};
root.setReceiveTipsAccepted = function(val, cb) {
storage.set('receiveTips', val, cb);
};
root.getReceiveTipsAccepted = function(cb) {
storage.get('receiveTips', cb);
};
root.setAmazonGiftCards = function(network, gcs, cb) {
storage.set('amazonGiftCards-' + network, gcs, cb);
};

View file

@ -1023,7 +1023,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
try {
keys = wallet.getKeys(password);
} catch (e) {
return cb(err);
return cb(e);
}
return cb(null, keys);

View file

@ -8,4 +8,50 @@
#arrow-down{
font-size: 4.2rem;
}
.cta-buttons{
width:100%;
float:none;
position: absolute;
bottom: 0;
}
}
@media (max-width: 400px){
#onboarding-backup-request{
.warning{
margin: 2rem auto 1rem;
height: 8rem;
}
h3{
font-size:1.3rem;
}
p{
font-size:.9rem;
max-width: 80%;
flex: 0 0 80%;
}
.cta-buttons{
float:none;
bottom:0;
position: absolute;
button{
max-width: 400px;
}
}
}
}
@media (max-height: 540px){
#onboarding-backup-request{
.cta-buttons{
float:left;
position: relative;
}
}
}
@media (min-height: 980px){
#onboarding-backup-request{
#arrow-down{
margin-top: 15rem;
}
}
}

View file

@ -8,4 +8,46 @@
#arrow-down{
font-size: 4.2rem;
}
.cta-buttons{
float:none;
bottom:46px;
position: absolute;
width:100%;
button{
max-width: 400px;
}
}
}
@media (max-width: 400px){
#onboarding-backup-warning{
.warning{
margin: 2rem auto 1rem;
height: 8rem;
}
h3{
font-size:1.3rem;
}
p{
font-size:.9rem;
max-width: 80%;
flex: 0 0 80%;
}
.warning-image{
height: 11rem;
}
.cta-buttons{
float:none;
bottom:46px;
position: absolute;
}
}
}
@media (max-height: 540px){
#onboarding-backup-warning{
.cta-buttons{
float:left;
position: relative;
}
}
}

View file

@ -14,25 +14,22 @@
margin-top: 1rem;
margin-bottom: 1rem;
}
.collect-overlay, .bar-overlay {
animation-name: opacity;
animation-iteration-count: 1;
animation-timing-function: ease-in;
animation-duration: .2s;
animation-delay: .8s;
animation-fill-mode: forwards;
opacity: 0;
}
.collect-overlay{
top:-1px;
}
.bar-overlay{
background: rgba(0, 0, 0, 0.23);
.button-clear{
color:#fff;
min-width: 100%;
}
}
.collect-overlay {
animation-name: opacity;
animation-iteration-count: 1;
animation-timing-function: ease-in;
animation-duration: .2s;
animation-delay: .8s;
animation-fill-mode: forwards;
opacity: 0;
button {
position: absolute;
right: 11px;
}
}
.collect-overlay{
top:-1px;
}
#collect-email {
opacity: 1;
background: #fff;
@ -52,10 +49,7 @@
label {
background: rgba(200, 200, 200, 0.20);
height: 3rem;
margin-top: 0;
input {
position: absolute;
}
margin-top:0;
i {
position: absolute;
right: 3%;
@ -64,6 +58,19 @@
}
}
}
@media (min-width: 1000px){
#onboarding-collect-email{
#collect-email{
p, form{
max-width: 600px;
@include center-block();
}
form{
margin-top:.5rem;
}
}
}
}
@keyframes topBottom {
0% {

View file

@ -23,6 +23,10 @@
background-position: top;
}
}
.cta-button{
position: absolute;
bottom: 85px;
}
}
@media (max-width: 400px){
@ -34,3 +38,22 @@
}
}
}
@media (min-width: 1000px){
#onboard-tour{
p, h2, h3{
max-width: 600px;
}
button{
max-width: 400px;
}
#cta{
margin: 2rem 0 0;
}
&-control{
#cta{
margin-bottom: 2rem;
}
}
}
}

View file

@ -81,6 +81,12 @@
h2{
font-size: 1.2rem;
}
p,h2,h3{
max-width: 600px !important;
}
button{
max-width: 400px !important;
}
}
}
}