Merge pull request #66 from colkito/feature/addresses-balance
added balance for each address
This commit is contained in:
commit
1c2b8ee7ec
2 changed files with 19 additions and 7 deletions
|
|
@ -177,7 +177,7 @@
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="large-6 columns">
|
<div class="large-6 columns">
|
||||||
<a class="panel db" ng-repeat="addr in addrs" ng-click="selectAddr(addr)">{{addr}} <span class="right"> ></span></a>
|
<a class="panel db" ng-repeat="addr in addrs" ng-click="selectAddr(addr)">{{addr}} <span class="right">({{addrBalance[addr]}} BTC) ></span></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="large-3 columns line-dashed-v text-center">
|
<div class="large-3 columns line-dashed-v text-center">
|
||||||
<qrcode size="160" data="{{selectedAddr}}"></qrcode>
|
<qrcode size="160" data="{{selectedAddr}}"></qrcode>
|
||||||
|
|
|
||||||
|
|
@ -5,20 +5,32 @@ angular.module('copay.home').controller('HomeController',
|
||||||
$scope.title = 'Home';
|
$scope.title = 'Home';
|
||||||
|
|
||||||
$scope.oneAtATime = true;
|
$scope.oneAtATime = true;
|
||||||
|
$scope.addrBalance = {};
|
||||||
|
|
||||||
|
var _getBalance = function() {
|
||||||
|
$scope.addrs.forEach(function(addr) {
|
||||||
|
$rootScope.wallet.blockchain.listUnspent([addr], function(unspent) {
|
||||||
|
var balance = $rootScope.wallet.blockchain.getBalance(unspent);
|
||||||
|
$scope.addrBalance[addr] = balance;
|
||||||
|
$scope.$digest();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
if (!$rootScope.wallet || !$rootScope.wallet.id) {
|
if (!$rootScope.wallet || !$rootScope.wallet.id) {
|
||||||
$location.path('signin');
|
$location.path('signin');
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$scope.addrs = $rootScope.wallet.getAddressesStr();
|
$scope.addrs = $rootScope.wallet.getAddressesStr();
|
||||||
$scope.selectedAddr = $scope.addrs[0];
|
$scope.selectedAddr = $scope.addrs[0];
|
||||||
|
|
||||||
|
_getBalance();
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.newAddr = function() {
|
$scope.newAddr = function() {
|
||||||
console.log('[home.js.17:newAddr:]'); //TODO
|
var a = $rootScope.wallet.generateAddress().toString();
|
||||||
var a = $rootScope.wallet.generateAddress();
|
$scope.addrs.push(a);
|
||||||
console.log('[home.js.19]',a); //TODO
|
|
||||||
$scope.addrs.push({ addrStr: a.toString() });
|
_getBalance();
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.selectAddr = function(addr) {
|
$scope.selectAddr = function(addr) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue