From 5cd9f7a93b16a550f9a4da8e252a1f05d6db287d Mon Sep 17 00:00:00 2001 From: Gustavo Cortez Date: Fri, 18 Apr 2014 11:16:10 -0300 Subject: [PATCH 1/2] Fix read from backup address. --- js/models/core/PublicKeyRing.js | 6 ++---- js/models/core/Wallet.js | 1 + 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/js/models/core/PublicKeyRing.js b/js/models/core/PublicKeyRing.js index 9a52cb9cf..b55d7568b 100644 --- a/js/models/core/PublicKeyRing.js +++ b/js/models/core/PublicKeyRing.js @@ -129,10 +129,9 @@ PublicKeyRing.prototype.getPubKeys = function (index, isChange) { var bip32 = this.copayersBIP32[i].derive(path); pubKeys[i] = bip32.eckey.public; } - this.publicKeysCache[path] = pubKeys; - //console.log('cache fill['+path+']='+pubKeys.length); + this.publicKeysCache[path] = pubKeys.map(function(pk){return pk.toString('hex')}); } else { - //console.log('cache hit!'); + pubKeys = pubKeys.map(function(s){return new Buffer(s,'hex')}); } return pubKeys; @@ -157,7 +156,6 @@ PublicKeyRing.prototype.getRedeemScript = function (index, isChange) { PublicKeyRing.prototype.getAddress = function (index, isChange) { this._checkIndexRange(index, isChange); - var script = this.getRedeemScript(index,isChange); return Address.fromScript(script, this.network.name); }; diff --git a/js/models/core/Wallet.js b/js/models/core/Wallet.js index a2ed268e2..c813c8682 100644 --- a/js/models/core/Wallet.js +++ b/js/models/core/Wallet.js @@ -222,6 +222,7 @@ Wallet.prototype.sendPublicKeyRing = function(recipients) { Wallet.prototype.generateAddress = function() { var addr = this.publicKeyRing.generateAddress(); this.sendPublicKeyRing(); + this.store(); return addr; }; From 4a8f543bf9ae12ba0fea0a9f523885d78883ee25 Mon Sep 17 00:00:00 2001 From: Gustavo Cortez Date: Fri, 18 Apr 2014 11:20:06 -0300 Subject: [PATCH 2/2] Fix $digest() when generateAddress --- js/services/controllerUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/services/controllerUtils.js b/js/services/controllerUtils.js index 1c5cde907..ec17748f6 100644 --- a/js/services/controllerUtils.js +++ b/js/services/controllerUtils.js @@ -40,7 +40,7 @@ angular.module('copay.controllerUtils').factory('controllerUtils', function ($ro }); w.on('refresh', function() { console.log('[controllerUtils.js] Refreshing'); //TODO - $rootScope.$digest(); + // Do not use $digest() here. }); w.on('openError', root.onErrorDigest); w.on('close', root.onErrorDigest);