diff --git a/index.html b/index.html index 5b0c9405a..736109142 100644 --- a/index.html +++ b/index.html @@ -249,15 +249,23 @@
-

Addresses (available to spend)

-

{{balanceByAddr[addr]}}

+

+ {{balanceByAddr[addr]}} +

diff --git a/js/app.js b/js/app.js index 6f64a9b30..aa9cdfde1 100644 --- a/js/app.js +++ b/js/app.js @@ -1,5 +1,8 @@ 'use strict'; + +var copay = require('copay'); + var copayApp = window.copayApp = angular.module('copay',[ 'ngRoute', 'mm.foundation', diff --git a/js/controllers/addresses.js b/js/controllers/addresses.js index 6b2ee0e3c..1c5771288 100644 --- a/js/controllers/addresses.js +++ b/js/controllers/addresses.js @@ -3,21 +3,22 @@ angular.module('copay.addresses').controller('AddressesController', function($scope, $rootScope, controllerUtils) { $scope.title = 'Home'; - $scope.oneAtATime = true; $scope.addrBalance = {}; var w = $rootScope.wallet; - var _updateBalance = function () { + var _updateBalance = function() { + $scope.addrs = w.getAddressesStr(true); controllerUtils.setSocketHandlers(); - w.getBalance(true, function (balance, balanceByAddr, isMain) { - if (balanceByAddr && Object.keys(balanceByAddr).length) { + w.getBalance(true, function(balance, balanceByAddr, isMain) { + if (balanceByAddr && Object.keys(balanceByAddr).length) { $rootScope.balanceByAddr = balanceByAddr; $scope.isMain = isMain; - $scope.addrs = Object.keys(balanceByAddr); + $scope.addrs = Object.keys(balanceByAddr); $scope.selectedAddr = $scope.addrs[0]; $scope.loading = false; $rootScope.$digest(); + alert('digest'); } }); }; @@ -26,6 +27,7 @@ angular.module('copay.addresses').controller('AddressesController', $scope.loading = true; w.generateAddress(); _updateBalance(); + alert('new address'); }; $scope.selectAddr = function(addr) { diff --git a/js/init.js b/js/init.js index d9e3481d8..4c8f29b30 100644 --- a/js/init.js +++ b/js/init.js @@ -1,5 +1,5 @@ 'use strict'; -var copay = require('copay'); + angular.element(document).ready(function() { // Init the app angular.bootstrap(document, ['copay']); diff --git a/js/models/core/PublicKeyRing.js b/js/models/core/PublicKeyRing.js index fc73e784c..3b1a9ae60 100644 --- a/js/models/core/PublicKeyRing.js +++ b/js/models/core/PublicKeyRing.js @@ -143,7 +143,6 @@ PublicKeyRing.prototype.addCopayer = function (newEpk) { return newEpk; }; - PublicKeyRing.prototype.getPubKeys = function (index, isChange) { this._checkKeys(); @@ -159,6 +158,7 @@ PublicKeyRing.prototype.getPubKeys = function (index, isChange) { this.publicKeysCache[path] = pubKeys.map(function(pk){return pk.toString('hex');}); } else { pubKeys = pubKeys.map(function(s){return new Buffer(s,'hex')}); + //console.log('public keys cache HIT'); } return pubKeys; @@ -183,21 +183,12 @@ PublicKeyRing.prototype.getRedeemScript = function (index, isChange) { // TODO this could be cached PublicKeyRing.prototype.getAddress = function (index, isChange) { - this._checkIndexRange(index, isChange); var script = this.getRedeemScript(index,isChange); return Address.fromScript(script, this.network.name); }; -// TODO this could be cached -PublicKeyRing.prototype._addScriptMap = function (map, index, isChange) { - this._checkIndexRange(index, isChange); - var script = this.getRedeemScript(index,isChange); - map[Address.fromScript(script, this.network.name).toString()] = script.getBuffer().toString('hex'); -}; - // TODO this could be cached PublicKeyRing.prototype.getScriptPubKeyHex = function (index, isChange) { - this._checkIndexRange(index, isChange); var addr = this.getAddress(index,isChange); return Script.createP2SH(addr.payload()).getBuffer().toString('hex'); }; @@ -218,14 +209,14 @@ PublicKeyRing.prototype.generateAddress = function(isChange) { }; -PublicKeyRing.prototype.getAddresses = function(onlyMain) { +PublicKeyRing.prototype.getAddresses = function(excludeChange) { var ret = []; for (var i=0; i