getBalance returns total unspent

This commit is contained in:
Wei Lu 2014-03-25 11:04:27 +08:00
parent 9fc5505730
commit 58ab0b631e
2 changed files with 52 additions and 19 deletions

View file

@ -60,6 +60,12 @@ var Wallet = function (seed, options) {
return this.changeAddresses[this.changeAddresses.length - 1]
}
this.getBalance = function() {
return this.getUnspentOutputs().reduce(function(memo, output){
return memo + output.value
}, 0)
}
this.getUnspentOutputs = function() {
var utxo = []