mirror of https://github.com/BTCPrivate/copay.git
fix tx details
This commit is contained in:
commit
8fff3da3c7
12
old/index.js
12
old/index.js
|
@ -535,14 +535,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
self.removeAndMarkSoftConfirmedTx = function(txs) {
|
|
||||||
return lodash.filter(txs, function(tx) {
|
|
||||||
if (tx.confirmations >= SOFT_CONFIRMATION_LIMIT)
|
|
||||||
return tx;
|
|
||||||
tx.recent = true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
self.showMore = function() {
|
self.showMore = function() {
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
|
@ -1188,9 +1180,9 @@ console.log('[index.js:1063] walletImported'); //TODO
|
||||||
});
|
});
|
||||||
|
|
||||||
$rootScope.$on('Local/NewFocusedWallet', function() {
|
$rootScope.$on('Local/NewFocusedWallet', function() {
|
||||||
console.log('[index.js.1200:NewFocusedWallet:] TODO'); //TODO
|
console.log('[index.js.1200:NewFocusedWallet:] TODO'); //TODO
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
uxLanguage.update();
|
uxLanguage.update();
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
"//":"PLEASE! Do not edit this file directly",
|
"//":"PLEASE! Do not edit this file directly",
|
||||||
"//":" Modify it at app-template/",
|
"//":" Modify it at app-template/",
|
||||||
|
|
||||||
"name": "copay",
|
"name": "bitpay",
|
||||||
"description": "A Secure Bitcoin Wallet",
|
"description": "The BitPay Bitcoin Wallet",
|
||||||
"author": "BitPay",
|
"author": "BitPay",
|
||||||
"version": "2.5.0",
|
"version": "0.1.1",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"wallet",
|
"wallet",
|
||||||
"copay",
|
"copay",
|
||||||
|
|
|
@ -149,11 +149,11 @@
|
||||||
|
|
||||||
<div ng-show="btx.txid" class="tx-details-blockchain">
|
<div ng-show="btx.txid" class="tx-details-blockchain">
|
||||||
<div class="text-center m20t">
|
<div class="text-center m20t">
|
||||||
<button class="button outline round dark-gray tiny" ng-click="$root.openExternalLink('https://' +
|
<button class="button button-positive" ng-click="$root.openExternalLink('https://' +
|
||||||
(getShortNetworkName() == 'test' ? 'test-' : '') + 'insight.bitpay.com/tx/' + btx.txid)">
|
(getShortNetworkName() == 'test' ? 'test-' : '') + 'insight.bitpay.com/tx/' + btx.txid)">
|
||||||
<span class="text-gray" translate>See it on the blockchain</span>
|
<span class="text-gray" translate>See it on the blockchain</span>
|
||||||
</button>
|
</button>
|
||||||
<button class="button outline round dark-gray tiny" ng-click="showCommentPopup()">
|
<button class="button button-positive" ng-click="showCommentPopup()">
|
||||||
<span class="text-gray" translate ng-show="!btx.note">Add comment</i></span>
|
<span class="text-gray" translate ng-show="!btx.note">Add comment</i></span>
|
||||||
<span class="text-gray" translate ng-show="btx.note">Edit comment</span>
|
<span class="text-gray" translate ng-show="btx.note">Edit comment</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
<ion-nav-bar class="bar-stable">
|
<ion-nav-bar class="bar-stable">
|
||||||
<ion-nav-title>Home</ion-nav-title>
|
<ion-nav-title>Home</ion-nav-title>
|
||||||
</ion-nav-bar>
|
</ion-nav-bar>
|
||||||
<ion-content class="padding home" ng-controller="tabHomeController">
|
<ion-content class="padding home" ng-controller="tabHomeController" cache-view="false">
|
||||||
|
|
||||||
<h2 class="title m0" translate>Payment Proposals</h2>
|
<h2 class="title m0" ng-if="txps[0]" translate>Payment Proposals</h2>
|
||||||
<div class="list card" ng-if="txps[0]">
|
<div class="list card" ng-if="txps[0]">
|
||||||
<ul>
|
<ul>
|
||||||
<li ng-repeat="tx in txps" class="item item-icon-left"
|
<li ng-repeat="tx in txps" class="item item-icon-left"
|
||||||
|
@ -46,8 +46,9 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h2>Wallets
|
||||||
<a href="#/add"><i class="ion-ios-plus-outline right"></i></a>
|
<a href="#/add"><i class="ion-ios-plus-outline right"></i></a>
|
||||||
<h2>Wallets </h2>
|
</h2>
|
||||||
<div class="list card">
|
<div class="list card">
|
||||||
<ul class="pr">
|
<ul class="pr">
|
||||||
|
|
||||||
|
@ -64,7 +65,7 @@
|
||||||
Incomplete
|
Incomplete
|
||||||
</span>
|
</span>
|
||||||
<span class="item-note" ng-show="item.isComplete()">
|
<span class="item-note" ng-show="item.isComplete()">
|
||||||
{{item.availableBalanceStr}}
|
{{item.status.availableBalanceStr}}
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
|
|
||||||
<ion-view ng-controller="walletDetailsController">
|
<ion-view>
|
||||||
<ion-nav-bar class="bar-stable">
|
<ion-nav-bar class="bar-stable">
|
||||||
<ion-nav-title>{{wallet.name}}</ion-nav-title>
|
<ion-nav-title>{{wallet.name}}</ion-nav-title>
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
</ion-nav-buttons>
|
</ion-nav-buttons>
|
||||||
</ion-nav-bar>
|
</ion-nav-bar>
|
||||||
|
|
||||||
<ion-content class="has-header" delegate-handle="my-handle" overflow-scroll="true">
|
<ion-content ng-controller="walletDetailsController" ng-init="init()" cache-view="false" class="has-header" delegate-handle="my-handle" overflow-scroll="true">
|
||||||
<div ng-show="!wallet">
|
<div ng-show="!wallet">
|
||||||
No Wallet
|
No Wallet
|
||||||
<a href ui-sref="tabs.home" class="button">
|
<a href ui-sref="tabs.home" class="button">
|
||||||
|
@ -33,35 +33,35 @@
|
||||||
|
|
||||||
<div class="oh pr" ng-show="wallet && wallet.isComplete()">
|
<div class="oh pr" ng-show="wallet && wallet.isComplete()">
|
||||||
<div ng-style="{'background-color':wallet.color}" class="amount">
|
<div ng-style="{'background-color':wallet.color}" class="amount">
|
||||||
<div ng-if="!wallet.notAuthorized && !wallet.updating">
|
<div ng-if="!notAuthorized && !updatingStatus">
|
||||||
|
|
||||||
<div class="m20t" ng-show="wallet.updateError" ng-click='update()'>
|
<div class="m20t" ng-show="updateStatusError" ng-click='update()'>
|
||||||
<span class="size-12 db m10b">{{wallet.updateError|translate}}</span>
|
<span class="size-12 db m10b">{{updateStatusError|translate}}</span>
|
||||||
<button class="outline white tiny round" translate>Tap to retry</button>
|
<button class="outline white tiny round" translate>Tap to retry</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-show="wallet.walletScanStatus == 'error'" ng-click='wallet.retryScan()'>
|
<div ng-show="wallet.walletScanStatus == 'error'" ng-click='retryScan()'>
|
||||||
<span translate>Scan status finished with error</span>
|
<span translate>Scan status finished with error</span>
|
||||||
<br><span translate>Tap to retry</span>
|
<br><span translate>Tap to retry</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div ng-click='wallet.updateAll({triggerTxUpdate: true})' ng-show="!wallet.updateError && wallet.walletScanStatus != 'error' && !wallet.hideBalance" on-hold="hideToggle()">
|
<div ng-click='updateAll()' ng-show="!updateStatusError && wallet.walletScanStatus != 'error' && !hideBalance" on-hold="hideToggle()">
|
||||||
<strong class="size-36">{{wallet.totalBalanceStr}}</strong>
|
<strong class="size-36">{{status.totalBalanceStr}}</strong>
|
||||||
<div class="size-14" ng-if="wallet.totalBalanceAlternative">{{wallet.totalBalanceAlternative}} {{wallet.alternativeIsoCode}}</div>
|
<div class="size-14" ng-if="status.totalBalanceAlternative">{{status.totalBalanceAlternative}} {{status.alternativeIsoCode}}</div>
|
||||||
<div class="size-14" ng-if="wallet.pendingAmount">
|
<div class="size-14" ng-if="status.pendingAmount">
|
||||||
<span translate>Pending Confirmation</span>: {{wallet.pendingAmountStr}}
|
<span translate>Pending Confirmation</span>: {{status.pendingAmountStr}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-show="!wallet.updateError && wallet.walletScanStatus != 'error' && wallet.shouldHideBalance" on-hold="wallet.hideToggle()">
|
<div ng-show="!updateStatusError && wallet.walletScanStatus != 'error' && shouldHideBalance" on-hold="hideToggle()">
|
||||||
<strong class="size-24" translate>[Balance Hidden]</strong>
|
<strong class="size-24" translate>[Balance Hidden]</strong>
|
||||||
<div class="size-14" translate>
|
<div class="size-14" translate>
|
||||||
Tap and hold to show
|
Tap and hold to show
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div ng-if="wallet.updating">
|
<div ng-if="updatingStatus">
|
||||||
<div class="size-36">
|
<div class="size-36">
|
||||||
<strong>...</strong>
|
<strong>...</strong>
|
||||||
</div>
|
</div>
|
||||||
|
@ -82,7 +82,7 @@
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="oh pr m20t" ng-show="wallet.notAuthorized && !wallet.updating">
|
<div class="oh pr m20t" ng-show="notAuthorized && !updatingStatus">
|
||||||
<div class="text-center text-warning">
|
<div class="text-center text-warning">
|
||||||
<i class="fi-alert"></i>
|
<i class="fi-alert"></i>
|
||||||
<span translate>
|
<span translate>
|
||||||
|
@ -94,7 +94,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="text-center m10t ">
|
<div class="text-center m10t ">
|
||||||
<span class="button outline round dark-gray tiny"
|
<span class="button outline round dark-gray tiny"
|
||||||
ng-click="wallet.recreate()">
|
ng-click="recreate()">
|
||||||
<span translate>Recreate</span>
|
<span translate>Recreate</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -105,48 +105,45 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-if="wallet.txps[0]">
|
<div ng-if="wallet.txps[0]">
|
||||||
<h4 ng-show="wallet.requiresMultipleSignatures" class="title m0" translate>Payment Proposals</h4>
|
<h4 ng-show="requiresMultipleSignatures" class="title m0" translate>Payment Proposals</h4>
|
||||||
<h4 ng-show="!wallet.requiresMultipleSignatures" class="title m0" translate>Unsent transactions</h4>
|
<h4 ng-show="!requiresMultipleSignatures" class="title m0" translate>Unsent transactions</h4>
|
||||||
<div ng-repeat="tx in wallet.txps">
|
<div ng-repeat="tx in wallet.txps">
|
||||||
<div ng-include="wallet.txTemplateUrl"></div>
|
<div ng-include="wallet.txTemplateUrl"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="text-gray text-center size-12 p10t"
|
<div class="text-gray text-center size-12 p10t"
|
||||||
ng-show="wallet.lockedBalanceSat">
|
ng-show="status.lockedBalanceSat">
|
||||||
<span translate>Total Locked Balance</span>:
|
<span translate>Total Locked Balance</span>:
|
||||||
<b>{{wallet.lockedBalanceStr}} </b>
|
<b>{{status.lockedBalanceStr}} </b>
|
||||||
<span> {{wallet.lockedBalanceAlternative}}
|
<span> {{status.lockedBalanceAlternative}}
|
||||||
{{wallet.alternativeIsoCode}} </span>
|
{{status.alternativeIsoCode}} </span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Activity -->
|
<!-- Transactions -->
|
||||||
|
<h4 class="title" ng-click="startSearch(); openSearchModal()" ng-show="!notAuthorized">
|
||||||
<h4 class="title" ng-click="wallet.startSearch(); openSearchModal()" ng-show="!wallet.notAuthorized">
|
|
||||||
<span translate>Activity</span>
|
<span translate>Activity</span>
|
||||||
<i class="dib m5l size-16 pointer fi-magnifying-glass"></i>
|
<i class="dib m5l size-16 pointer fi-magnifying-glass"></i>
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
<div class="oh pr m20t text-gray size-12 text-center"
|
<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"
|
ng-show="!txHistory[0] && !updatingTxHistory && !txHistoryError && !updateStatusError && !notAuthorized"
|
||||||
translate>No transactions yet ZZZZ {{wallet.totalBalanceStr}}
|
translate>No transactions yet {{status.totalBalanceStr}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="oh pr" ng-show="(wallet.txHistory[0] || wallet.txProgress > 5) && !wallet.notAuthorized">
|
<div ng-show="updatingTxHistory">
|
||||||
|
|
||||||
<div ng-show="wallet.updatingTxHistory && wallet.txProgress > 5">
|
|
||||||
<div class="row p20 text-center">
|
<div class="row p20 text-center">
|
||||||
<div class="columns large-12 medium-12 small-12 m10b">
|
<div class="columns large-12 medium-12 small-12 m10b">
|
||||||
<ion-spinner class="spinner-dark" icon="lines"></ion-spinner>
|
<ion-spinner class="spinner-dark" icon="lines"></ion-spinner>
|
||||||
</div>
|
</div>
|
||||||
<div class="size-12 text-gray m20t">
|
<div class="size-12 text-gray m20t">
|
||||||
<div translate>{{wallet.txProgress}} transactions downloaded</div>
|
<div translate>{{updatingTxHistoryProgress}} transactions downloaded</div>
|
||||||
<div translate>Updating transaction history. Please stand by.</div>
|
<div translate>Updating transaction history. Please stand by.</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-if="wallet.txHistory[0] && wallet.updatingTxHistory && wallet.newTx" class="row collapse last-transactions-content animated fadeInDown">
|
<div ng-if="txHistory[0] && updatingTxHistory && newTx" class="row collapse last-transactions-content animated fadeInDown">
|
||||||
<div class="large-6 medium-6 small-6 columns size-14">
|
<div class="large-6 medium-6 small-6 columns size-14">
|
||||||
<div class="m10r left">
|
<div class="m10r left">
|
||||||
<img src="img/icon-new.svg" width="40">
|
<img src="img/icon-new.svg" width="40">
|
||||||
|
@ -160,10 +157,13 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-repeat="btx in wallet.txHistory track by btx.txid"
|
<div class="list card">
|
||||||
ng-click="openTxModal(btx)"
|
<ul>
|
||||||
class="row collapse last-transactions-content">
|
<li ng-repeat="btx in txHistory track by btx.txid" class="item"
|
||||||
<div class="large-6 medium-6 small-6 columns size-14">
|
ng-click="openTxModal(btx)">
|
||||||
|
<div class="row">
|
||||||
|
|
||||||
|
<div class="col col-50">
|
||||||
<div class="m10r left">
|
<div class="m10r left">
|
||||||
<img src="img/icon-receive-history.svg" alt="sync" width="40" ng-show="btx.action == 'received'">
|
<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-sent-history.svg" alt="sync" width="40" ng-show="btx.action == 'sent'">
|
||||||
|
@ -195,7 +195,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="large-5 medium-5 small-5 columns text-right" >
|
<div class="col" >
|
||||||
<span class="size-16" ng-class="{'text-bold': btx.recent}">
|
<span class="size-16" ng-class="{'text-bold': btx.recent}">
|
||||||
<span ng-if="btx.action == 'received'">+</span>
|
<span ng-if="btx.action == 'received'">+</span>
|
||||||
<span ng-if="btx.action == 'sent'">-</span>
|
<span ng-if="btx.action == 'sent'">-</span>
|
||||||
|
@ -206,31 +206,29 @@
|
||||||
{{btx.amountStr}}
|
{{btx.amountStr}}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
<div class="size-12 text-gray">
|
<p>
|
||||||
<time ng-if="btx.time">{{btx.time * 1000 | amTimeAgo}}</time>
|
<time ng-if="btx.time">{{btx.time * 1000 | amTimeAgo}}</time>
|
||||||
<span translate class="text-warning"
|
<span translate class="text-warning"
|
||||||
ng-show="!btx.time && (!btx.confirmations || btx.confirmations == 0)">
|
ng-show="!btx.time && (!btx.confirmations || btx.confirmations == 0)">
|
||||||
Unconfirmed
|
Unconfirmed
|
||||||
</span>
|
</span>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<i class="icon ion-chevron-right"></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="large-1 medium-1 small-1 columns text-right m10t">
|
</li>
|
||||||
<i class="icon-arrow-right3 size-18"></i>
|
<li class="item" ng-show="updatingTxHistory && !isSearching">
|
||||||
</div>
|
Updating...
|
||||||
</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>
|
<ion-spinner class="spinner-stable" icon="lines"></ion-spinner>
|
||||||
</div>
|
</li>
|
||||||
</div>
|
|
||||||
|
|
||||||
<ion-infinite-scroll
|
<ion-infinite-scroll
|
||||||
ng-if="historyShowMore"
|
ng-if="txHistoryShowMore"
|
||||||
on-infinite="showMore()"
|
on-infinite="showMore()"
|
||||||
distance="1%">
|
distance="1%">
|
||||||
</ion-infinite-scroll>
|
</ion-infinite-scroll>
|
||||||
</div>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</ion-content>
|
</ion-content>
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -11,7 +11,7 @@ angular.module('copayApp.controllers').controller('preferencesController',
|
||||||
$scope.externalSource = null;
|
$scope.externalSource = null;
|
||||||
|
|
||||||
if (wallet) {
|
if (wallet) {
|
||||||
walletService.updateStatus(wallet, {}, function(err, status) {});
|
walletService.getStatus(wallet, {}, function(err, status) {});
|
||||||
var config = configService.getSync();
|
var config = configService.getSync();
|
||||||
config.aliasFor = config.aliasFor || {};
|
config.aliasFor = config.aliasFor || {};
|
||||||
$scope.alias = config.aliasFor[walletId] || wallet.credentials.walletName;
|
$scope.alias = config.aliasFor[walletId] || wallet.credentials.walletName;
|
||||||
|
|
|
@ -7,22 +7,19 @@ angular.module('copayApp.controllers').controller('preferencesUnitController', f
|
||||||
$scope.currentUnit = config.wallet.settings.unitCode;
|
$scope.currentUnit = config.wallet.settings.unitCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.unitList = [
|
$scope.unitList = [{
|
||||||
{
|
|
||||||
name: 'bits (1,000,000 bits = 1BTC)',
|
name: 'bits (1,000,000 bits = 1BTC)',
|
||||||
shortName: 'bits',
|
shortName: 'bits',
|
||||||
value: 100,
|
value: 100,
|
||||||
decimals: 2,
|
decimals: 2,
|
||||||
code: 'bit',
|
code: 'bit',
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
name: 'BTC',
|
name: 'BTC',
|
||||||
shortName: 'BTC',
|
shortName: 'BTC',
|
||||||
value: 100000000,
|
value: 100000000,
|
||||||
decimals: 8,
|
decimals: 8,
|
||||||
code: 'btc',
|
code: 'btc',
|
||||||
}
|
}];
|
||||||
];
|
|
||||||
|
|
||||||
$scope.save = function(newUnit) {
|
$scope.save = function(newUnit) {
|
||||||
var opts = {
|
var opts = {
|
||||||
|
|
|
@ -88,23 +88,21 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
||||||
|
|
||||||
self.updateAllClients = function() {
|
self.updateAllClients = function() {
|
||||||
var txps = [];
|
var txps = [];
|
||||||
var wallets = profileService.getWallets();
|
var i = $scope.wallets.length;
|
||||||
var l = wallets.length,
|
|
||||||
i = 0;
|
|
||||||
|
|
||||||
lodash.each(wallets, function(wallet) {
|
lodash.each($scope.wallets, function(wallet) {
|
||||||
walletService.updateStatus(wallet, {}, function(err) {
|
walletService.getStatus(wallet, {}, function(err, status) {
|
||||||
var status = wallet.status;
|
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log('[tab-home.js.35:err:]',$log.error(err)); //TODO
|
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
||||||
return;
|
return;
|
||||||
} // TODO
|
} // TODO
|
||||||
if (status.pendingTxps && status.pendingTxps[0]) {
|
if (status.pendingTxps && status.pendingTxps[0]) {
|
||||||
txps = txps.concat(status.pendingTxps);
|
txps = txps.concat(status.pendingTxps);
|
||||||
}
|
}
|
||||||
if (++i == l) {
|
if (--i == 0) {
|
||||||
setPendingTxps(txps);
|
setPendingTxps(txps);
|
||||||
}
|
}
|
||||||
|
wallet.status = status;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,36 +1,16 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
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) {
|
angular.module('copayApp.controllers').controller('walletDetailsController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $state, $stateParams, bwcError, profileService, lodash, configService, gettext, gettextCatalog, platformInfo, go, walletService) {
|
||||||
|
|
||||||
|
|
||||||
var isCordova = platformInfo.isCordova;
|
var isCordova = platformInfo.isCordova;
|
||||||
var isWP = platformInfo.isWP;
|
var isWP = platformInfo.isWP;
|
||||||
var isAndroid = platformInfo.isAndroid;
|
var isAndroid = platformInfo.isAndroid;
|
||||||
var isChromeApp = platformInfo.isChromeApp;
|
var isChromeApp = platformInfo.isChromeApp;
|
||||||
|
|
||||||
var self = this;
|
var errorPopup;
|
||||||
$rootScope.shouldHideMenuBar = false;
|
|
||||||
$rootScope.wpInputFocused = false;
|
var HISTORY_SHOW_LIMIT = 10;
|
||||||
var config = configService.getSync();
|
|
||||||
var configWallet = config.wallet;
|
|
||||||
var walletSettings = configWallet.settings;
|
|
||||||
var ret = {};
|
|
||||||
|
|
||||||
// INIT. Global value
|
|
||||||
ret.unitToSatoshi = walletSettings.unitToSatoshi;
|
|
||||||
ret.satToUnit = 1 / ret.unitToSatoshi;
|
|
||||||
ret.unitName = walletSettings.unitName;
|
|
||||||
ret.alternativeIsoCode = walletSettings.alternativeIsoCode;
|
|
||||||
ret.alternativeName = walletSettings.alternativeName;
|
|
||||||
ret.alternativeAmount = 0;
|
|
||||||
ret.unitDecimals = walletSettings.unitDecimals;
|
|
||||||
ret.isCordova = isCordova;
|
|
||||||
ret.addresses = [];
|
|
||||||
ret.isMobile = platformInfo.isMobile;
|
|
||||||
ret.isWindowsPhoneApp = platformInfo.isWP;
|
|
||||||
ret.countDown = null;
|
|
||||||
ret.sendMaxInfo = {};
|
|
||||||
ret.showAlternative = false;
|
|
||||||
|
|
||||||
$scope.openSearchModal = function() {
|
$scope.openSearchModal = function() {
|
||||||
var fc = profileService.focusedClient;
|
var fc = profileService.focusedClient;
|
||||||
|
@ -46,7 +26,7 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.openTxModal = function(btx) {
|
$scope.openTxModal = function(btx) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
$scope.btx = lodash.cloneDeep(btx);
|
$scope.btx = lodash.cloneDeep(btx);
|
||||||
|
@ -61,32 +41,100 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.update = function() {
|
$scope.recreate = function() {
|
||||||
walletService.updateStatus(wallet, {
|
walletService.recreate();
|
||||||
force: true
|
};
|
||||||
|
|
||||||
|
$scope.updateStatus = function(force) {
|
||||||
|
$scope.updatingStatus = true;
|
||||||
|
$scope.updateStatusError = false;
|
||||||
|
$timeout(function() {
|
||||||
|
walletService.getStatus(wallet, {
|
||||||
|
force: !!force,
|
||||||
}, function(err, status) {
|
}, function(err, status) {
|
||||||
if (err) {} // TODO
|
$scope.updatingStatus = false;
|
||||||
|
if (err) {
|
||||||
|
$scope.status = null;
|
||||||
|
$scope.updateStatusError = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$scope.status = status;
|
||||||
|
});
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.updateTxHistory = function() {
|
||||||
|
|
||||||
|
if ($scope.updatingTxHistory) return;
|
||||||
|
|
||||||
|
$scope.updatingTxHistory = true;
|
||||||
|
$scope.updateTxHistoryError = false;
|
||||||
|
$scope.updatingTxHistoryProgress = null;
|
||||||
|
|
||||||
|
var progressFn = function(txs) {
|
||||||
|
$scope.updatingTxHistoryProgress = txs ? txs.length : 0;
|
||||||
|
completeTxHistory = txs;
|
||||||
|
$scope.showHistory();
|
||||||
|
$scope.$digest();
|
||||||
|
};
|
||||||
|
|
||||||
|
$timeout(function() {
|
||||||
|
walletService.getTxHistory(wallet, {
|
||||||
|
progressFn: progressFn,
|
||||||
|
}, function(err, txHistory) {
|
||||||
|
$scope.updatingTxHistory = false;
|
||||||
|
if (err) {
|
||||||
|
$scope.txHistory = null;
|
||||||
|
$scope.updateTxHistoryError = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
completeTxHistory = txHistory;
|
||||||
|
|
||||||
|
$scope.showHistory();
|
||||||
|
$scope.$apply();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.showHistory = function() {
|
||||||
|
if ($scope.isSearching) {
|
||||||
|
$scope.txHistorySearchResults = filteredTxHistory ? filteredTxHistory.slice(0, (currentTxHistoryPage + 1) * HISTORY_SHOW_LIMIT) : [];
|
||||||
|
$scope.txHistoryShowMore = filteredTxHistory.length > $scope.txHistorySearchResults.length;
|
||||||
|
} else {
|
||||||
|
$scope.txHistory = completeTxHistory ? completeTxHistory.slice(0, (currentTxHistoryPage + 1) * HISTORY_SHOW_LIMIT) : [];
|
||||||
|
$scope.txHistoryShowMore = completeTxHistory.length > $scope.txHistory.length;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.showMore = function() {
|
||||||
|
currentTxHistoryPage++;
|
||||||
|
$scope.showHistory();
|
||||||
|
$scope.$broadcast('scroll.infiniteScrollComplete');
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.updateAll = function() {
|
||||||
|
$scope.updateStatus(false);
|
||||||
|
$scope.updateTxHistory();
|
||||||
|
}
|
||||||
|
|
||||||
$scope.hideToggle = function() {
|
$scope.hideToggle = function() {
|
||||||
console.log('[walletDetails.js.70:hideToogle:] TODO'); //TODO
|
console.log('[walletDetails.js.70:hideToogle:] TODO'); //TODO
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!$stateParams.walletId) {
|
var currentTxHistoryPage;
|
||||||
$log.debug('No wallet provided... using the first one');
|
var completeTxHistory;
|
||||||
$stateParams.walletId = profileService.getWallets({
|
var wallet;
|
||||||
onlyComplete: true
|
|
||||||
})[0].id;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
$scope.init = function() {
|
||||||
|
currentTxHistoryPage = 0;
|
||||||
|
completeTxHistory = [];
|
||||||
|
|
||||||
var wallet = profileService.getWallet($stateParams.walletId);
|
wallet = profileService.getWallet($stateParams.walletId);
|
||||||
$scope.wallet = wallet;
|
$scope.wallet = wallet;
|
||||||
|
$scope.requiresMultipleSignatures = wallet.credentials.m > 1;
|
||||||
|
$scope.newTx = false;
|
||||||
|
|
||||||
|
$scope.updateAll();
|
||||||
|
};
|
||||||
|
|
||||||
if (wallet) {
|
|
||||||
walletService.updateStatus(wallet, {}, function(err, status) {
|
|
||||||
if (err) {} // TODO
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,17 +3,6 @@
|
||||||
angular.module('copayApp.services').factory('txFormatService', function(bwcService, rateService, configService, lodash) {
|
angular.module('copayApp.services').factory('txFormatService', function(bwcService, rateService, configService, lodash) {
|
||||||
var root = {};
|
var root = {};
|
||||||
|
|
||||||
|
|
||||||
// // RECEIVE
|
|
||||||
// // Check address
|
|
||||||
// root.isUsed(wallet.walletId, balance.byAddress, function(err, used) {
|
|
||||||
// if (used) {
|
|
||||||
// $log.debug('Address used. Creating new');
|
|
||||||
// $rootScope.$emit('Local/AddressIsUsed');
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
|
|
||||||
root.Utils = bwcService.getUtils();
|
root.Utils = bwcService.getUtils();
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// DO NOT INCLUDE STORAGE HERE \/ \/
|
// DO NOT INCLUDE STORAGE HERE \/ \/
|
||||||
angular.module('copayApp.services').factory('walletService', function($log, $timeout, lodash, trezor, ledger, storageService, configService, rateService, uxLanguage, bwcService, $filter, gettextCatalog, bwcError, $ionicPopup, fingerprintService, ongoingProcess, gettext, $rootScope, txStatus, txFormatService, $ionicModal) {
|
angular.module('copayApp.services').factory('walletService', function($log, $timeout, lodash, trezor, ledger, storageService, configService, rateService, uxLanguage, $filter, gettextCatalog, bwcError, $ionicPopup, fingerprintService, ongoingProcess, gettext, $rootScope, txStatus, txFormatService, $ionicModal) {
|
||||||
// DO NOT INCLUDE STORAGE HERE ^^
|
// DO NOT INCLUDE STORAGE HERE ^^
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -9,6 +9,10 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
|
|
||||||
var root = {};
|
var root = {};
|
||||||
|
|
||||||
|
root.WALLET_STATUS_MAX_TRIES = 7;
|
||||||
|
root.WALLET_STATUS_DELAY_BETWEEN_TRIES = 1.4 * 1000;
|
||||||
|
root.SOFT_CONFIRMATION_LIMIT = 12;
|
||||||
|
root.SAFE_CONFIRMATIONS = 6;
|
||||||
|
|
||||||
// UI Related
|
// UI Related
|
||||||
root.openStatusModal = function(type, txp, cb) {
|
root.openStatusModal = function(type, txp, cb) {
|
||||||
|
@ -27,8 +31,15 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// // RECEIVE
|
||||||
|
// // Check address
|
||||||
|
// root.isUsed(wallet.walletId, balance.byAddress, function(err, used) {
|
||||||
|
// if (used) {
|
||||||
|
// $log.debug('Address used. Creating new');
|
||||||
|
// $rootScope.$emit('Local/AddressIsUsed');
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
|
||||||
var _signWithLedger = function(wallet, txp, cb) {
|
var _signWithLedger = function(wallet, txp, cb) {
|
||||||
$log.info('Requesting Ledger Chrome app to sign the transaction');
|
$log.info('Requesting Ledger Chrome app to sign the transaction');
|
||||||
|
@ -78,16 +89,6 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var _walletStatusHash = function(walletStatus) {
|
|
||||||
var bal;
|
|
||||||
if (walletStatus) {
|
|
||||||
bal = walletStatus.balance.totalAmount;
|
|
||||||
} else {
|
|
||||||
bal = self.totalBalanceSat;
|
|
||||||
}
|
|
||||||
return bal;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
// This handles errors from BWS/index which normally
|
// This handles errors from BWS/index which normally
|
||||||
|
@ -102,7 +103,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
|
|
||||||
console.log('[walletService.js.93] TODO NOT AUTH'); //TODO
|
console.log('[walletService.js.93] TODO NOT AUTH'); //TODO
|
||||||
// TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO
|
// TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO
|
||||||
self.notAuthorized = true;
|
wallet.notAuthorized = true;
|
||||||
go.walletHome();
|
go.walletHome();
|
||||||
} else if (err instanceof errors.NOT_FOUND) {
|
} else if (err instanceof errors.NOT_FOUND) {
|
||||||
root.showErrorPopup(gettext('Could not access Wallet Service: Not found'));
|
root.showErrorPopup(gettext('Could not access Wallet Service: Not found'));
|
||||||
|
@ -115,170 +116,127 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
};
|
};
|
||||||
root.handleError = lodash.debounce(_handleError, 1000);
|
root.handleError = lodash.debounce(_handleError, 1000);
|
||||||
|
|
||||||
|
root.getStatus = function(wallet, opts, cb) {
|
||||||
|
opts = opts || {};
|
||||||
|
|
||||||
root.setBalance = function(wallet, balance) {
|
function get(cb) {
|
||||||
|
wallet.getStatus({
|
||||||
|
twoStep: true
|
||||||
|
}, function(err, ret) {
|
||||||
|
if (err) {
|
||||||
|
return cb(bwcError.msg(err, gettext('Could not update Wallet')));
|
||||||
|
}
|
||||||
|
return cb(null, ret);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
function cacheBalance(wallet, balance) {
|
||||||
if (!balance) return;
|
if (!balance) return;
|
||||||
|
|
||||||
var config = configService.getSync().wallet.settings;
|
var config = configService.getSync().wallet.settings;
|
||||||
var COIN = 1e8;
|
|
||||||
|
var cache = wallet.cachedStatus;
|
||||||
|
|
||||||
// Address with Balance
|
// Address with Balance
|
||||||
wallet.balanceByAddress = balance.byAddress;
|
cache.balanceByAddress = balance.byAddress;
|
||||||
|
|
||||||
// Spend unconfirmed funds
|
// Spend unconfirmed funds
|
||||||
if (wallet.spendUnconfirmed) {
|
if (cache.spendUnconfirmed) {
|
||||||
wallet.totalBalanceSat = balance.totalAmount;
|
cache.totalBalanceSat = balance.totalAmount;
|
||||||
wallet.lockedBalanceSat = balance.lockedAmount;
|
cache.lockedBalanceSat = balance.lockedAmount;
|
||||||
wallet.availableBalanceSat = balance.availableAmount;
|
cache.availableBalanceSat = balance.availableAmount;
|
||||||
wallet.totalBytesToSendMax = balance.totalBytesToSendMax;
|
cache.totalBytesToSendMax = balance.totalBytesToSendMax;
|
||||||
wallet.pendingAmount = null;
|
cache.pendingAmount = null;
|
||||||
} else {
|
} else {
|
||||||
wallet.totalBalanceSat = balance.totalConfirmedAmount;
|
cache.totalBalanceSat = balance.totalConfirmedAmount;
|
||||||
wallet.lockedBalanceSat = balance.lockedConfirmedAmount;
|
cache.lockedBalanceSat = balance.lockedConfirmedAmount;
|
||||||
wallet.availableBalanceSat = balance.availableConfirmedAmount;
|
cache.availableBalanceSat = balance.availableConfirmedAmount;
|
||||||
wallet.totalBytesToSendMax = balance.totalBytesToSendConfirmedMax;
|
cache.totalBytesToSendMax = balance.totalBytesToSendConfirmedMax;
|
||||||
wallet.pendingAmount = balance.totalAmount - balance.totalConfirmedAmount;
|
cache.pendingAmount = balance.totalAmount - balance.totalConfirmedAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Selected unit
|
// Selected unit
|
||||||
wallet.unitToSatoshi = config.unitToSatoshi;
|
cache.unitToSatoshi = config.unitToSatoshi;
|
||||||
wallet.satToUnit = 1 / wallet.unitToSatoshi;
|
cache.satToUnit = 1 / cache.unitToSatoshi;
|
||||||
wallet.unitName = config.unitName;
|
cache.unitName = config.unitName;
|
||||||
|
|
||||||
//STR
|
//STR
|
||||||
wallet.totalBalanceStr = txFormatService.formatAmount(wallet.totalBalanceSat) + ' ' + wallet.unitName;
|
cache.totalBalanceStr = txFormatService.formatAmount(cache.totalBalanceSat) + ' ' + cache.unitName;
|
||||||
wallet.lockedBalanceStr = txFormatService.formatAmount(wallet.lockedBalanceSat) + ' ' + wallet.unitName;
|
cache.lockedBalanceStr = txFormatService.formatAmount(cache.lockedBalanceSat) + ' ' + cache.unitName;
|
||||||
wallet.availableBalanceStr = txFormatService.formatAmount(wallet.availableBalanceSat) + ' ' + wallet.unitName;
|
cache.availableBalanceStr = txFormatService.formatAmount(cache.availableBalanceSat) + ' ' + cache.unitName;
|
||||||
|
|
||||||
if (wallet.pendingAmount) {
|
if (cache.pendingAmount) {
|
||||||
wallet.pendingAmountStr = txFormatService.formatAmount(wallet.pendingAmount) + ' ' + wallet.unitName;
|
cache.pendingAmountStr = txFormatService.formatAmount(cache.pendingAmount) + ' ' + cache.unitName;
|
||||||
} else {
|
} else {
|
||||||
wallet.pendingAmountStr = null;
|
cache.pendingAmountStr = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
wallet.alternativeName = config.alternativeName;
|
cache.alternativeName = config.alternativeName;
|
||||||
wallet.alternativeIsoCode = config.alternativeIsoCode;
|
cache.alternativeIsoCode = config.alternativeIsoCode;
|
||||||
|
|
||||||
rateService.whenAvailable(function() {
|
rateService.whenAvailable(function() {
|
||||||
|
|
||||||
var totalBalanceAlternative = rateService.toFiat(wallet.totalBalanceSat, wallet.alternativeIsoCode);
|
var totalBalanceAlternative = rateService.toFiat(cache.totalBalanceSat, cache.alternativeIsoCode);
|
||||||
var lockedBalanceAlternative = rateService.toFiat(wallet.lockedBalanceSat, wallet.alternativeIsoCode);
|
var lockedBalanceAlternative = rateService.toFiat(cache.lockedBalanceSat, cache.alternativeIsoCode);
|
||||||
var alternativeConversionRate = rateService.toFiat(100000000, wallet.alternativeIsoCode);
|
var alternativeConversionRate = rateService.toFiat(100000000, cache.alternativeIsoCode);
|
||||||
|
|
||||||
wallet.totalBalanceAlternative = $filter('formatFiatAmount')(totalBalanceAlternative);
|
cache.totalBalanceAlternative = $filter('formatFiatAmount')(totalBalanceAlternative);
|
||||||
wallet.lockedBalanceAlternative = $filter('formatFiatAmount')(lockedBalanceAlternative);
|
cache.lockedBalanceAlternative = $filter('formatFiatAmount')(lockedBalanceAlternative);
|
||||||
wallet.alternativeConversionRate = $filter('formatFiatAmount')(alternativeConversionRate);
|
cache.alternativeConversionRate = $filter('formatFiatAmount')(alternativeConversionRate);
|
||||||
|
|
||||||
wallet.alternativeBalanceAvailable = true;
|
cache.alternativeBalanceAvailable = true;
|
||||||
wallet.isRateAvailable = true;
|
cache.isRateAvailable = true;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
root.setStatus = function(wallet, status) {
|
function isStatusCached() {
|
||||||
wallet.status = status;
|
return wallet.cachedStatus && wallet.cachedStatus.isValid;
|
||||||
wallet.statusUpdatedOn = Date.now();
|
|
||||||
wallet.isValid = true;
|
|
||||||
root.setBalance(wallet, status.balance);
|
|
||||||
wallet.email = status.preferences.email;
|
|
||||||
wallet.copayers = status.wallet.copayers;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
root.updateStatus = function(wallet, opts, cb, initStatusHash, tries) {
|
function cacheStatus(status) {
|
||||||
|
wallet.cachedStatus = status || {};
|
||||||
|
var cache = wallet.cachedStatus;
|
||||||
|
cache.statusUpdatedOn = Date.now();
|
||||||
|
cache.isValid = true;
|
||||||
|
cache.email = status.preferences ? status.preferences.email : null;
|
||||||
|
cacheBalance(wallet, status.balance);
|
||||||
|
};
|
||||||
|
|
||||||
|
function walletStatusHash(status) {
|
||||||
|
return status ? status.balance.totalAmount : wallet.totalBalanceSat;
|
||||||
|
};
|
||||||
|
|
||||||
|
function _getStatus(initStatusHash, tries, cb) {
|
||||||
|
if (isStatusCached() && !opts.force) return cb(null, wallet.cachedStatus);
|
||||||
|
|
||||||
tries = tries || 0;
|
tries = tries || 0;
|
||||||
opts = opts || {};
|
|
||||||
|
|
||||||
if (wallet.isValid && !opts.force)
|
|
||||||
return;
|
|
||||||
|
|
||||||
|
|
||||||
var walletId = wallet.id;
|
|
||||||
|
|
||||||
if (opts.untilItChanges && lodash.isUndefined(initStatusHash)) {
|
|
||||||
initStatusHash = _walletStatusHash();
|
|
||||||
$log.debug('Updating status until it changes. initStatusHash:' + initStatusHash)
|
|
||||||
}
|
|
||||||
|
|
||||||
var get = function(cb) {
|
|
||||||
if (opts.walletStatus)
|
|
||||||
return cb(null, opts.walletStatus);
|
|
||||||
else {
|
|
||||||
return wallet.getStatus({
|
|
||||||
twoStep: true
|
|
||||||
}, function(err, ret) {
|
|
||||||
if (err)
|
|
||||||
return cb(bwcError.msg(err, gettext('Could not update Wallet')));
|
|
||||||
// TODO??
|
|
||||||
// self.isSingleAddress = !!ret.wallet.singleAddress;
|
|
||||||
// self.updating = ret.wallet.scanStatus == 'running';
|
|
||||||
return cb(null, ret);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// If not untilItChanges...trigger history update now
|
|
||||||
if (opts.triggerTxUpdate && !opts.untilItChanges) {
|
|
||||||
$timeout(function() {
|
|
||||||
root.debounceUpdateHistory();
|
|
||||||
}, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
$timeout(function() {
|
|
||||||
|
|
||||||
// if (!opts.quiet)
|
|
||||||
// self.updating = true;
|
|
||||||
|
|
||||||
$log.debug('Updating Status:', wallet.credentials.walletName, tries);
|
$log.debug('Updating Status:', wallet.credentials.walletName, tries);
|
||||||
get(function(err, walletStatus) {
|
get(function(err, status) {
|
||||||
var currentStatusHash = _walletStatusHash(walletStatus);
|
if (err) return cb(err);
|
||||||
|
|
||||||
|
var currentStatusHash = walletStatusHash(status);
|
||||||
$log.debug('Status update. hash:' + currentStatusHash + ' Try:' + tries);
|
$log.debug('Status update. hash:' + currentStatusHash + ' Try:' + tries);
|
||||||
if (!err && opts.untilItChanges && initStatusHash == currentStatusHash && tries < 7 && walletId == profileService.focusedClient.credentials.walletId) {
|
if (opts.untilItChanges &&
|
||||||
|
initStatusHash == currentStatusHash &&
|
||||||
|
tries < root.WALLET_STATUS_MAX_TRIES &&
|
||||||
|
walletId == wallet.credentials.walletId) {
|
||||||
return $timeout(function() {
|
return $timeout(function() {
|
||||||
$log.debug('Retrying update... ' + walletId + ' Try:' + tries)
|
$log.debug('Retrying update... ' + walletId + ' Try:' + tries)
|
||||||
return root.updateStatus(wallet, {
|
return _getStatus(initStatusHash, ++tries, cb);
|
||||||
walletStatus: null,
|
}, root.WALLET_STATUS_DELAY_BETWEEN_TRIES * tries);
|
||||||
untilItChanges: true,
|
|
||||||
triggerTxUpdate: opts.triggerTxUpdate,
|
|
||||||
}, cb, initStatusHash, ++tries);
|
|
||||||
}, 1400 * tries);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err) {
|
|
||||||
root.handleError(err);
|
|
||||||
return cb(err);
|
|
||||||
}
|
|
||||||
$log.debug('Got Wallet Status for:' + wallet.credentials.walletName);
|
$log.debug('Got Wallet Status for:' + wallet.credentials.walletName);
|
||||||
|
|
||||||
root.setStatus(wallet, walletStatus);
|
cacheStatus(status);
|
||||||
|
|
||||||
// self.setPendingTxps(walletStatus.pendingTxps);
|
// wallet.setPendingTxps(status.pendingTxps);
|
||||||
//
|
return cb(null, status);
|
||||||
// // Status Shortcuts
|
});
|
||||||
// self.lastUpdate = Date.now();
|
};
|
||||||
// self.walletName = walletStatus.wallet.name;
|
|
||||||
// self.walletSecret = walletStatus.wallet.secret;
|
|
||||||
// self.walletStatus = walletStatus.wallet.status;
|
|
||||||
// self.walletScanStatus = walletStatus.wallet.scanStatus;
|
|
||||||
// self.copayers = walletStatus.wallet.copayers;
|
|
||||||
// self.preferences = walletStatus.preferences;
|
|
||||||
// self.setBalance(walletStatus.balance);
|
|
||||||
// self.otherWallets = lodash.filter(profileService.getWallets(self.network), function(w) {
|
|
||||||
// return w.id != self.walletId;
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// Notify external addons or plugins
|
|
||||||
|
|
||||||
// TODO
|
_getStatus(walletStatusHash(), 0, cb);
|
||||||
if (opts.triggerTxUpdate && opts.untilItChanges) {
|
|
||||||
$timeout(function() {
|
|
||||||
root.debounceUpdateHistory();
|
|
||||||
}, 1);
|
|
||||||
}
|
|
||||||
return cb();
|
|
||||||
// } else {
|
|
||||||
// self.loadingWallet = false;
|
|
||||||
// }
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var getSavedTxs = function(walletId, cb) {
|
var getSavedTxs = function(walletId, cb) {
|
||||||
|
@ -321,14 +279,60 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var removeAndMarkSoftConfirmedTx = function(txs) {
|
||||||
|
return lodash.filter(txs, function(tx) {
|
||||||
|
if (tx.confirmations >= root.SOFT_CONFIRMATION_LIMIT)
|
||||||
|
return tx;
|
||||||
|
tx.recent = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var updateLocalTxHistory = function(wallet, cb) {
|
var processNewTxs = function(wallet, txs) {
|
||||||
|
var config = configService.getSync().wallet.settings;
|
||||||
|
var now = Math.floor(Date.now() / 1000);
|
||||||
|
var txHistoryUnique = {};
|
||||||
|
var ret = [];
|
||||||
|
wallet.hasUnsafeConfirmed = false;
|
||||||
|
|
||||||
|
lodash.each(txs, function(tx) {
|
||||||
|
tx = txFormatService.processTx(tx);
|
||||||
|
|
||||||
|
// no future transactions...
|
||||||
|
if (tx.time > now)
|
||||||
|
tx.time = now;
|
||||||
|
|
||||||
|
if (tx.confirmations >= root.SAFE_CONFIRMATIONS) {
|
||||||
|
tx.safeConfirmed = root.SAFE_CONFIRMATIONS + '+';
|
||||||
|
} else {
|
||||||
|
tx.safeConfirmed = false;
|
||||||
|
wallet.hasUnsafeConfirmed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tx.note) {
|
||||||
|
delete tx.note.encryptedEditedByName;
|
||||||
|
delete tx.note.encryptedBody;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!txHistoryUnique[tx.txid]) {
|
||||||
|
ret.push(tx);
|
||||||
|
txHistoryUnique[tx.txid] = true;
|
||||||
|
} else {
|
||||||
|
$log.debug('Ignoring duplicate TX in history: ' + tx.txid)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
|
||||||
|
var updateLocalTxHistory = function(wallet, progressFn, cb) {
|
||||||
var FIRST_LIMIT = 5;
|
var FIRST_LIMIT = 5;
|
||||||
var LIMIT = 50;
|
var LIMIT = 50;
|
||||||
var requestLimit = FIRST_LIMIT;
|
var requestLimit = FIRST_LIMIT;
|
||||||
var walletId = wallet.credentials.walletId;
|
var walletId = wallet.credentials.walletId;
|
||||||
var config = configService.getSync().wallet.settings;
|
var config = configService.getSync().wallet.settings;
|
||||||
|
|
||||||
|
progressFn = progressFn || function() {};
|
||||||
|
|
||||||
var fixTxsUnit = function(txs) {
|
var fixTxsUnit = function(txs) {
|
||||||
if (!txs || !txs[0] || !txs[0].amountStr) return;
|
if (!txs || !txs[0] || !txs[0].amountStr) return;
|
||||||
|
|
||||||
|
@ -352,54 +356,33 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
|
|
||||||
fixTxsUnit(txsFromLocal);
|
fixTxsUnit(txsFromLocal);
|
||||||
|
|
||||||
var confirmedTxs = self.removeAndMarkSoftConfirmedTx(txsFromLocal);
|
var confirmedTxs = removeAndMarkSoftConfirmedTx(txsFromLocal);
|
||||||
var endingTxid = confirmedTxs[0] ? confirmedTxs[0].txid : null;
|
var endingTxid = confirmedTxs[0] ? confirmedTxs[0].txid : null;
|
||||||
var endingTs = confirmedTxs[0] ? confirmedTxs[0].time : null;
|
var endingTs = confirmedTxs[0] ? confirmedTxs[0].time : null;
|
||||||
|
|
||||||
|
|
||||||
// First update
|
// First update
|
||||||
if (walletId == profileService.focusedClient.credentials.walletId) {
|
wallet.completeHistory = txsFromLocal;
|
||||||
self.completeHistory = txsFromLocal;
|
|
||||||
setCompactTxHistory();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (historyUpdateInProgress[walletId])
|
function getNewTxs(newTxs, skip, cb) {
|
||||||
return;
|
|
||||||
|
|
||||||
historyUpdateInProgress[walletId] = true;
|
|
||||||
|
|
||||||
function getNewTxs(newTxs, skip, i_cb) {
|
|
||||||
getTxsFromServer(wallet, skip, endingTxid, requestLimit, function(err, res, shouldContinue) {
|
getTxsFromServer(wallet, skip, endingTxid, requestLimit, function(err, res, shouldContinue) {
|
||||||
if (err) return i_cb(err);
|
if (err) return cb(err);
|
||||||
|
|
||||||
|
newTxs = newTxs.concat(processNewTxs(wallet, lodash.compact(res)));
|
||||||
|
|
||||||
|
progressFn(newTxs);
|
||||||
|
|
||||||
newTxs = newTxs.concat(lodash.compact(res));
|
|
||||||
skip = skip + requestLimit;
|
skip = skip + requestLimit;
|
||||||
|
|
||||||
$log.debug('Syncing TXs. Got:' + newTxs.length + ' Skip:' + skip, ' EndingTxid:', endingTxid, ' Continue:', shouldContinue);
|
$log.debug('Syncing TXs. Got:' + newTxs.length + ' Skip:' + skip, ' EndingTxid:', endingTxid, ' Continue:', shouldContinue);
|
||||||
|
|
||||||
if (!shouldContinue) {
|
if (!shouldContinue) {
|
||||||
newTxs = self.processNewTxs(newTxs);
|
|
||||||
$log.debug('Finished Sync: New / soft confirmed Txs: ' + newTxs.length);
|
$log.debug('Finished Sync: New / soft confirmed Txs: ' + newTxs.length);
|
||||||
return i_cb(null, newTxs);
|
return cb(null, newTxs);
|
||||||
}
|
}
|
||||||
|
|
||||||
requestLimit = LIMIT;
|
requestLimit = LIMIT;
|
||||||
getNewTxs(newTxs, skip, i_cb);
|
getNewTxs(newTxs, skip, cb);
|
||||||
|
|
||||||
// Progress update
|
|
||||||
if (walletId == profileService.focusedClient.credentials.walletId) {
|
|
||||||
self.txProgress = newTxs.length;
|
|
||||||
if (self.completeHistory < FIRST_LIMIT && txsFromLocal.length == 0) {
|
|
||||||
$log.debug('Showing partial history');
|
|
||||||
var newHistory = self.processNewTxs(newTxs);
|
|
||||||
newHistory = lodash.compact(newHistory.concat(confirmedTxs));
|
|
||||||
self.completeHistory = newHistory;
|
|
||||||
setCompactTxHistory();
|
|
||||||
}
|
|
||||||
$timeout(function() {
|
|
||||||
$rootScope.$apply();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -445,9 +428,8 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
$log.debug('Tx History synced. Total Txs: ' + newHistory.length);
|
$log.debug('Tx History synced. Total Txs: ' + newHistory.length);
|
||||||
|
|
||||||
// Final update
|
// Final update
|
||||||
if (walletId == profileService.focusedClient.credentials.walletId) {
|
if (walletId == wallet.credentials.walletId) {
|
||||||
self.completeHistory = newHistory;
|
wallet.completeHistory = newHistory;
|
||||||
setCompactTxHistory();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return storageService.setTxHistory(historyToSave, walletId, function() {
|
return storageService.setTxHistory(historyToSave, walletId, function() {
|
||||||
|
@ -461,30 +443,18 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
root.updateHistory = function(wallet) {
|
root.getTxHistory = function(wallet, opts, cb) {
|
||||||
|
opts = opts || {};
|
||||||
|
|
||||||
var walletId = wallet.credentials.walletId;
|
var walletId = wallet.credentials.walletId;
|
||||||
|
|
||||||
if (!wallet.isComplete()) return;
|
if (!wallet.isComplete()) return cb();
|
||||||
|
|
||||||
|
|
||||||
$log.debug('Updating Transaction History');
|
$log.debug('Updating Transaction History');
|
||||||
self.txHistoryError = false;
|
|
||||||
self.updatingTxHistory = true;
|
|
||||||
|
|
||||||
$timeout(function() {
|
updateLocalTxHistory(wallet, opts.progressFn, function(err) {
|
||||||
updateLocalTxHistory(wallet, function(err) {
|
if (err) return cb(err);
|
||||||
historyUpdateInProgress[walletId] = self.updatingTxHistory = false;
|
return cb(err, wallet.completeHistory);
|
||||||
self.loadingWallet = false;
|
|
||||||
self.txProgress = 0;
|
|
||||||
if (err)
|
|
||||||
self.txHistoryError = true;
|
|
||||||
|
|
||||||
$timeout(function() {
|
|
||||||
self.newTx = false
|
|
||||||
}, 1000);
|
|
||||||
|
|
||||||
$rootScope.$apply();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -673,20 +643,11 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var setCompactTxHistory = function() {
|
|
||||||
|
|
||||||
// TODO
|
|
||||||
self.isSearching = false;
|
|
||||||
self.nextTxHistory = self.historyShowMoreLimit;
|
|
||||||
self.txHistory = self.completeHistory ? self.completeHistory.slice(0, self.historyShowLimit) : null;
|
|
||||||
self.historyShowMore = self.completeHistory ? self.completeHistory.length > self.historyShowLimit : null;
|
|
||||||
};
|
|
||||||
|
|
||||||
root.debounceUpdateHistory = lodash.debounce(function() {
|
root.debounceUpdateHistory = lodash.debounce(function() {
|
||||||
root.updateHistory();
|
root.updateHistory();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
self.throttledUpdateHistory = lodash.throttle(function() {
|
root.throttledUpdateHistory = lodash.throttle(function() {
|
||||||
root.updateHistory();
|
root.updateHistory();
|
||||||
}, 5000);
|
}, 5000);
|
||||||
|
|
||||||
|
@ -707,19 +668,18 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
root.recreate = function(wallet, cb) {
|
root.recreate = function(wallet, cb) {
|
||||||
ongoingProcess.set('recreating', true);
|
ongoingProcess.set('recreating', true);
|
||||||
wallet.recreateWallet(function(err) {
|
wallet.recreateWallet(function(err) {
|
||||||
self.notAuthorized = false;
|
wallet.notAuthorized = false;
|
||||||
ongoingProcess.set('recreating', false);
|
ongoingProcess.set('recreating', false);
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
self.handleError(err);
|
wallet.handleError(err);
|
||||||
$rootScope.$apply();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
profileService.bindWalletClient(wallet, {
|
profileService.bindWalletClient(wallet, {
|
||||||
force: true
|
force: true
|
||||||
});
|
});
|
||||||
self.startScan(wallet);
|
wallet.startScan(wallet);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -727,16 +687,16 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
$log.debug('Scanning wallet ' + wallet.credentials.walletId);
|
$log.debug('Scanning wallet ' + wallet.credentials.walletId);
|
||||||
if (!wallet.isComplete()) return;
|
if (!wallet.isComplete()) return;
|
||||||
|
|
||||||
// self.updating = true;
|
// wallet.updating = true;
|
||||||
|
|
||||||
wallet.startScan({
|
wallet.startScan({
|
||||||
includeCopayerBranches: true,
|
includeCopayerBranches: true,
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
// if (err && self.walletId == walletId) {
|
// if (err && wallet.walletId == walletId) {
|
||||||
// self.updating = false;
|
// wallet.updating = false;
|
||||||
// self.handleError(err);
|
// wallet.handleError(err);
|
||||||
// $rootScope.$apply();
|
// $rootScope.$apply();
|
||||||
// }
|
// }
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue