Initial getBalance of all your addresses. Socket-io that listening if your address receives btc.

Known bug: if you add new the address you can to recall socket-io. Socket-io should be listening on headerController.
This commit is contained in:
Gustavo Cortez 2014-04-17 06:43:30 -03:00
commit eaa1bc37e0
7 changed files with 54 additions and 10 deletions

View file

@ -276,7 +276,15 @@ Wallet.prototype.getAddressesStr = function() {
return ret;
};
Wallet.prototype.getBalance = function(cb) {
var balance = 0;
this.blockchain.listUnspent(this.getAddressesStr(), function(unspent) {
for(var i=0;i<unspent.length; i++) {
balance = balance + unspent[i].amount;
}
return cb(balance);
});
};
Wallet.prototype.listUnspent = function(cb) {
this.blockchain.listUnspent(this.getAddressesStr(), cb);