From 2fc3a8e8faf01956b9de02efa86753e907dd7182 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Mon, 21 Apr 2014 12:37:32 -0300 Subject: [PATCH] safe unspent --- index.html | 6 ++++-- js/controllers/addresses.js | 3 +-- js/models/core/Wallet.js | 27 ++++++++++++++++++++++----- js/services/controllerUtils.js | 18 +++++++++++------- test/test.TxProposals.js | 3 --- 5 files changed, 38 insertions(+), 19 deletions(-) diff --git a/index.html b/index.html index fb498ba3a..cb440eeab 100644 --- a/index.html +++ b/index.html @@ -18,8 +18,10 @@
Wallet ID: {{$root.wallet.id}}
-

{{totalBalance}}

-

0

+

+ Balance: {{totalBalance || 0}}
+ Available to Spend:{{availableBalance || 0}} +

diff --git a/js/controllers/addresses.js b/js/controllers/addresses.js index c92c7ea76..af3a7ee01 100644 --- a/js/controllers/addresses.js +++ b/js/controllers/addresses.js @@ -10,8 +10,7 @@ angular.module('copay.addresses').controller('AddressesController', var _updateBalance = function () { controllerUtils.setSocketHandlers(); - - w.getBalance(function (balance, balanceByAddr, isMain) { + w.getBalance(true, function (balance, balanceByAddr, isMain) { if (balanceByAddr && Object.keys(balanceByAddr).length) { $rootScope.balanceByAddr = balanceByAddr; $scope.isMain = isMain; diff --git a/js/models/core/Wallet.js b/js/models/core/Wallet.js index d86e3adf1..707e7f3db 100644 --- a/js/models/core/Wallet.js +++ b/js/models/core/Wallet.js @@ -410,7 +410,7 @@ Wallet.prototype.addressIsOwn = function(addrStr) { return ret; }; -Wallet.prototype.getBalance = function(cb) { +Wallet.prototype.getBalance = function(safe, cb) { var balance = 0; var balanceByAddr = {}; var isMain = {}; @@ -424,7 +424,8 @@ Wallet.prototype.getBalance = function(cb) { balanceByAddr[a]=0; isMain[a]=1; }); - this.getUnspent(function(utxos) { + var f = safe ? this.getSafeUnspent.bind(this):this.getUnspent.bind(this); + f(function(utxos) { for(var i=0;i