From f55d243bedd0045c398588338f7a664f3158be69 Mon Sep 17 00:00:00 2001 From: Gustavo Cortez Date: Thu, 17 Apr 2014 16:42:27 -0300 Subject: [PATCH 1/2] Refactory get balance 's methods --- js/controllers/home.js | 3 +-- js/models/blockchain/Insight.js | 11 ----------- js/models/core/Wallet.js | 26 +++++++++++++++++++++----- js/services/controllerUtils.js | 4 ++-- test/test.blockchain.Insight.js | 6 ------ 5 files changed, 24 insertions(+), 26 deletions(-) diff --git a/js/controllers/home.js b/js/controllers/home.js index 75f059d01..8519571ea 100644 --- a/js/controllers/home.js +++ b/js/controllers/home.js @@ -9,8 +9,7 @@ angular.module('copay.home').controller('HomeController', var _getBalance = function() { $scope.addrs.forEach(function(addr) { - $rootScope.wallet.blockchain.listUnspent([addr], function(unspent) { - var balance = $rootScope.wallet.blockchain.getBalance(unspent); + $rootScope.wallet.getBalance([addr], function(balance) { $scope.addrBalance[addr] = balance; $scope.$digest(); }); diff --git a/js/models/blockchain/Insight.js b/js/models/blockchain/Insight.js index 3db6a1b06..e2fe60c72 100644 --- a/js/models/blockchain/Insight.js +++ b/js/models/blockchain/Insight.js @@ -29,17 +29,6 @@ function _asyncForEach(array, fn, callback) { } }; -Insight.prototype.getBalance = function(unspent) { - var balance = 0; - for(var i=0;i Date: Thu, 17 Apr 2014 17:01:45 -0300 Subject: [PATCH 2/2] Fix refactory for createTx. --- js/models/core/Wallet.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/js/models/core/Wallet.js b/js/models/core/Wallet.js index df720d418..b30de0771 100644 --- a/js/models/core/Wallet.js +++ b/js/models/core/Wallet.js @@ -285,9 +285,9 @@ Wallet.prototype.getTotalBalance = function(cb) { Wallet.prototype.getBalance = function(addrs, cb) { var balance = 0; - this.listUnspent(addrs, function(unspent) { - for(var i=0;i