diff --git a/js/controllers/home.js b/js/controllers/home.js index bfdcdd026..9f6d0bc41 100644 --- a/js/controllers/home.js +++ b/js/controllers/home.js @@ -15,7 +15,7 @@ angular.module('copay.home').controller('HomeController', } $scope.newAddr = function() { - var a = $rootScope.wallet.publicKeyRing.generateAddress(); + var a = $rootScope.wallet.generateAddress(); $scope.addrs.push({ addrStr: a.toString('hex') }); }; diff --git a/js/models/core/Wallet.js b/js/models/core/Wallet.js index de9400166..dd4a03e2a 100644 --- a/js/models/core/Wallet.js +++ b/js/models/core/Wallet.js @@ -125,6 +125,18 @@ Wallet.prototype.sendPublicKeyRing = function(recipients) { }); }; +Wallet.prototype.generateAddress = function() { + var addr = this.publicKeyRing.generateAddress(); + this.store(); + + this.network.send(null, { + type: 'publicKeyRing', + publicKeyRing: this.publicKeyRing.toObj(), + walletId: this.id + }); + + return addr; +}; // // HERE? not sure // Wallet.prototype.cleanPeers = function() {