From 0523d99eda9a39407f1c73b203990703c95fbe59 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Mon, 21 Apr 2014 12:00:14 -0300 Subject: [PATCH 1/3] add getUsedUnspent to txproposals --- js/models/core/PublicKeyRing.js | 1 - js/models/core/TxProposals.js | 10 ++++++++++ js/models/core/Wallet.js | 2 +- test/test.TxProposals.js | 30 +++++++++++++++++++++++++++--- 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/js/models/core/PublicKeyRing.js b/js/models/core/PublicKeyRing.js index a2a26ce58..32cd4d5c9 100644 --- a/js/models/core/PublicKeyRing.js +++ b/js/models/core/PublicKeyRing.js @@ -212,7 +212,6 @@ PublicKeyRing.prototype.getAddresses = function(onlyMain) { PublicKeyRing.prototype.getRedeemScriptMap = function () { var ret = {}; -console.log('[PublicKeyRing.js.216]', this.changeAddressIndex, this.addressIndex); //TODO for (var i=0; i Date: Mon, 21 Apr 2014 12:37:32 -0300 Subject: [PATCH 2/3] 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 Date: Mon, 21 Apr 2014 13:16:15 -0300 Subject: [PATCH 3/3] available address --- index.html | 4 ++-- js/controllers/header.js | 6 +----- js/controllers/transactions.js | 5 ++--- js/services/controllerUtils.js | 38 ++++++++++++++-------------------- 4 files changed, 21 insertions(+), 32 deletions(-) diff --git a/index.html b/index.html index cb440eeab..f437762e3 100644 --- a/index.html +++ b/index.html @@ -214,13 +214,13 @@