used/unused addresses list
This commit is contained in:
parent
fc73d4ff36
commit
e3746bfaec
4 changed files with 67 additions and 36 deletions
|
|
@ -1,7 +1,8 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('addressesController', function($scope, $stateParams, $timeout, $ionicScrollDelegate, configService, popupService, gettextCatalog, ongoingProcess, lodash, profileService, walletService) {
|
||||
var ADDRESS_LIMIT = 5;
|
||||
var UNUSED_ADDRESS_LIMIT = 5;
|
||||
var BALANCE_ADDRESS_LIMIT = 5;
|
||||
var config;
|
||||
var unitName;
|
||||
var unitToSatoshi;
|
||||
|
|
@ -16,28 +17,47 @@ angular.module('copayApp.controllers').controller('addressesController', functio
|
|||
satToUnit = 1 / unitToSatoshi;
|
||||
unitName = config.unitName;
|
||||
unitDecimals = config.unitDecimals;
|
||||
init();
|
||||
});
|
||||
|
||||
// $scope.unusedAddresses = getUnusedAddreses(); No backend support TODO
|
||||
$scope.unusedAddresses = [{
|
||||
createdOn: 1479138140,
|
||||
address: "0m9sad00810m0m1d2192d9u12d9",
|
||||
path: 'xpub/0/1'
|
||||
}];
|
||||
|
||||
function init() {
|
||||
ongoingProcess.set('extractingWalletInfo', true);
|
||||
walletService.getBalance($scope.wallet, {}, function(err, resp) {
|
||||
ongoingProcess.set('extractingWalletInfo', false);
|
||||
walletService.getMainAddresses($scope.wallet, {}, function(err, addresses) {
|
||||
if (err) {
|
||||
ongoingProcess.set('extractingWalletInfo', false);
|
||||
return popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
}
|
||||
|
||||
$scope.addresses = lodash.slice(resp.byAddress, 0, ADDRESS_LIMIT);
|
||||
lodash.each($scope.addresses, function(a) {
|
||||
a.balanceStr = (a.amount * satToUnit).toFixed(unitDecimals) + ' ' + unitName;
|
||||
$scope.allAddresses = addresses;
|
||||
|
||||
walletService.getBalance($scope.wallet, {}, function(err, resp) {
|
||||
ongoingProcess.set('extractingWalletInfo', false);
|
||||
if (err) {
|
||||
return popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
}
|
||||
|
||||
var withBalance = resp.byAddress;
|
||||
var idx = lodash.indexBy(withBalance, 'address');
|
||||
var noBalance = lodash.reject($scope.allAddresses, function(x) {
|
||||
return idx[x.address];
|
||||
});
|
||||
lodash.each(noBalance, function(n) {
|
||||
n.path = n.path.replace(/^m/g, 'xpub');
|
||||
});
|
||||
$scope.unused = lodash.slice(noBalance, 0, UNUSED_ADDRESS_LIMIT);
|
||||
$scope.withBalance = lodash.slice(withBalance, 0, BALANCE_ADDRESS_LIMIT);
|
||||
|
||||
lodash.each($scope.withBalance, function(a) {
|
||||
a.balanceStr = (a.amount * satToUnit).toFixed(unitDecimals) + ' ' + unitName;
|
||||
});
|
||||
|
||||
$scope.viewAll = {
|
||||
value: noBalance.length > UNUSED_ADDRESS_LIMIT || withBalance.length > BALANCE_ADDRESS_LIMIT
|
||||
};
|
||||
$scope.$digest();
|
||||
});
|
||||
$scope.$digest();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.showInformation = function() {
|
||||
$timeout(function() {
|
||||
|
|
|
|||
|
|
@ -773,10 +773,9 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
});
|
||||
};
|
||||
|
||||
root.getMainAddresses = function(wallet, limit, cb) {
|
||||
var opts = {};
|
||||
root.getMainAddresses = function(wallet, opts, cb) {
|
||||
opts = opts || {};
|
||||
opts.reverse = true;
|
||||
if (limit) opts.limit = limit;
|
||||
|
||||
wallet.getMainAddresses(opts, function(err, addresses) {
|
||||
if (err) return cb(err);
|
||||
|
|
|
|||
|
|
@ -14,6 +14,11 @@
|
|||
font-size: 15px;
|
||||
color: $mid-gray;
|
||||
margin: 1rem 0;
|
||||
a {
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
cursor: hand;
|
||||
}
|
||||
}
|
||||
&-description-disabled {
|
||||
color: cadetblue;
|
||||
|
|
@ -35,32 +40,34 @@
|
|||
}
|
||||
}
|
||||
|
||||
a {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.addr-list {
|
||||
.item {
|
||||
color: $dark-gray;
|
||||
padding-top: 1.3rem;
|
||||
padding-bottom: 1.3rem;
|
||||
|
||||
&.has-addr-value {
|
||||
padding-top: .65rem;
|
||||
padding-bottom: .65rem;
|
||||
}
|
||||
|
||||
&.item-divider {
|
||||
color: $mid-gray;
|
||||
padding-bottom: .5rem;
|
||||
font-size: .9rem;
|
||||
}
|
||||
|
||||
.icon {
|
||||
color: $light-gray;
|
||||
&.view-all {
|
||||
margin: 20px 0px 20px 0px;
|
||||
cursor: pointer;
|
||||
cursor: hand;
|
||||
i {
|
||||
font-size: 35px;
|
||||
margin-right: 5px;
|
||||
color: #434CBE;
|
||||
}
|
||||
a {
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.item-note {
|
||||
color: $light-gray;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,16 +29,16 @@
|
|||
<i class="icon ion-ios-plus-empty"></i>
|
||||
</div>
|
||||
|
||||
<div ng-if="unusedAddresses[0]">
|
||||
<div class="item" ng-repeat="uAddress in unusedAddresses track by $index">
|
||||
{{uAddress.address}}
|
||||
<div ng-if="unused[0]">
|
||||
<div class="item" ng-repeat="u in unused track by $index">
|
||||
{{u.address}}
|
||||
<div class="addr-path">
|
||||
{{uAddress.path}} {{uAddress.createdOn * 1000 | amDateFormat:'MMMM Do YYYY, hh:mm a'}}
|
||||
{{u.path}} {{u.createdOn * 1000 | amDateFormat:'MMMM Do YYYY, hh:mm a'}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-if="!unusedAddresses[0]">
|
||||
<div ng-if="!unused[0]">
|
||||
<span class="item" translate>Not unused addresses available</span>
|
||||
</div>
|
||||
|
||||
|
|
@ -46,9 +46,14 @@
|
|||
Addresses With Balance
|
||||
</div>
|
||||
|
||||
<div class="item" ng-repeat="addr in addresses track by $index">
|
||||
{{addr.address}}
|
||||
<div class="addr-balance">{{addr.balanceStr}}</div>
|
||||
<div class="item" ng-repeat="w in withBalance track by $index">
|
||||
{{w.address}}
|
||||
<div class="addr-balance">{{w.balanceStr}}</div>
|
||||
</div>
|
||||
|
||||
<div class="item item-icon-right view-all" ng-show="viewAll.value">
|
||||
<a ui-sref="#" translate>View All Addresses</a>
|
||||
<i class="icon ion-ios-arrow-thin-right"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue