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';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('addressesController', function($scope, $stateParams, $timeout, $ionicScrollDelegate, configService, popupService, gettextCatalog, ongoingProcess, lodash, profileService, walletService) {
|
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 config;
|
||||||
var unitName;
|
var unitName;
|
||||||
var unitToSatoshi;
|
var unitToSatoshi;
|
||||||
|
|
@ -16,28 +17,47 @@ angular.module('copayApp.controllers').controller('addressesController', functio
|
||||||
satToUnit = 1 / unitToSatoshi;
|
satToUnit = 1 / unitToSatoshi;
|
||||||
unitName = config.unitName;
|
unitName = config.unitName;
|
||||||
unitDecimals = config.unitDecimals;
|
unitDecimals = config.unitDecimals;
|
||||||
|
init();
|
||||||
|
});
|
||||||
|
|
||||||
// $scope.unusedAddresses = getUnusedAddreses(); No backend support TODO
|
function init() {
|
||||||
$scope.unusedAddresses = [{
|
|
||||||
createdOn: 1479138140,
|
|
||||||
address: "0m9sad00810m0m1d2192d9u12d9",
|
|
||||||
path: 'xpub/0/1'
|
|
||||||
}];
|
|
||||||
|
|
||||||
ongoingProcess.set('extractingWalletInfo', true);
|
ongoingProcess.set('extractingWalletInfo', true);
|
||||||
walletService.getBalance($scope.wallet, {}, function(err, resp) {
|
walletService.getMainAddresses($scope.wallet, {}, function(err, addresses) {
|
||||||
ongoingProcess.set('extractingWalletInfo', false);
|
|
||||||
if (err) {
|
if (err) {
|
||||||
|
ongoingProcess.set('extractingWalletInfo', false);
|
||||||
return popupService.showAlert(gettextCatalog.getString('Error'), err);
|
return popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.addresses = lodash.slice(resp.byAddress, 0, ADDRESS_LIMIT);
|
$scope.allAddresses = addresses;
|
||||||
lodash.each($scope.addresses, function(a) {
|
|
||||||
a.balanceStr = (a.amount * satToUnit).toFixed(unitDecimals) + ' ' + unitName;
|
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() {
|
$scope.showInformation = function() {
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
|
|
|
||||||
|
|
@ -773,10 +773,9 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
root.getMainAddresses = function(wallet, limit, cb) {
|
root.getMainAddresses = function(wallet, opts, cb) {
|
||||||
var opts = {};
|
opts = opts || {};
|
||||||
opts.reverse = true;
|
opts.reverse = true;
|
||||||
if (limit) opts.limit = limit;
|
|
||||||
|
|
||||||
wallet.getMainAddresses(opts, function(err, addresses) {
|
wallet.getMainAddresses(opts, function(err, addresses) {
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,11 @@
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
color: $mid-gray;
|
color: $mid-gray;
|
||||||
margin: 1rem 0;
|
margin: 1rem 0;
|
||||||
|
a {
|
||||||
|
font-weight: bold;
|
||||||
|
cursor: pointer;
|
||||||
|
cursor: hand;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
&-description-disabled {
|
&-description-disabled {
|
||||||
color: cadetblue;
|
color: cadetblue;
|
||||||
|
|
@ -35,32 +40,34 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
a {
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
.addr-list {
|
.addr-list {
|
||||||
.item {
|
.item {
|
||||||
color: $dark-gray;
|
color: $dark-gray;
|
||||||
padding-top: 1.3rem;
|
padding-top: 1.3rem;
|
||||||
padding-bottom: 1.3rem;
|
padding-bottom: 1.3rem;
|
||||||
|
|
||||||
&.has-addr-value {
|
&.has-addr-value {
|
||||||
padding-top: .65rem;
|
padding-top: .65rem;
|
||||||
padding-bottom: .65rem;
|
padding-bottom: .65rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.item-divider {
|
&.item-divider {
|
||||||
color: $mid-gray;
|
color: $mid-gray;
|
||||||
padding-bottom: .5rem;
|
padding-bottom: .5rem;
|
||||||
font-size: .9rem;
|
font-size: .9rem;
|
||||||
}
|
}
|
||||||
|
&.view-all {
|
||||||
.icon {
|
margin: 20px 0px 20px 0px;
|
||||||
color: $light-gray;
|
cursor: pointer;
|
||||||
|
cursor: hand;
|
||||||
|
i {
|
||||||
|
font-size: 35px;
|
||||||
|
margin-right: 5px;
|
||||||
|
color: #434CBE;
|
||||||
|
}
|
||||||
|
a {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.item-note {
|
.item-note {
|
||||||
color: $light-gray;
|
color: $light-gray;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,16 +29,16 @@
|
||||||
<i class="icon ion-ios-plus-empty"></i>
|
<i class="icon ion-ios-plus-empty"></i>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-if="unusedAddresses[0]">
|
<div ng-if="unused[0]">
|
||||||
<div class="item" ng-repeat="uAddress in unusedAddresses track by $index">
|
<div class="item" ng-repeat="u in unused track by $index">
|
||||||
{{uAddress.address}}
|
{{u.address}}
|
||||||
<div class="addr-path">
|
<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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-if="!unusedAddresses[0]">
|
<div ng-if="!unused[0]">
|
||||||
<span class="item" translate>Not unused addresses available</span>
|
<span class="item" translate>Not unused addresses available</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -46,9 +46,14 @@
|
||||||
Addresses With Balance
|
Addresses With Balance
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="item" ng-repeat="addr in addresses track by $index">
|
<div class="item" ng-repeat="w in withBalance track by $index">
|
||||||
{{addr.address}}
|
{{w.address}}
|
||||||
<div class="addr-balance">{{addr.balanceStr}}</div>
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue