filter out change address. Better refresh

This commit is contained in:
Matias Alejo Garcia 2014-04-17 17:22:50 -03:00
parent 9ead0f69f4
commit 5eca1a63c2
3 changed files with 13 additions and 12 deletions

View File

@ -19,7 +19,7 @@ angular.module('copay.home').controller('HomeController',
if (!$rootScope.wallet || !$rootScope.wallet.id) {
$location.path('signin');
} else {
$scope.addrs = $rootScope.wallet.getAddressesStr();
$scope.addrs = $rootScope.wallet.getAddressesStr(true);
$scope.selectedAddr = $scope.addrs[0];
_getBalance();

View File

@ -192,16 +192,18 @@ PublicKeyRing.prototype.generateAddress = function(isChange) {
};
PublicKeyRing.prototype.getAddresses = function() {
PublicKeyRing.prototype.getAddresses = function(onlyMain) {
var ret = [];
for (var i=0; i<this.changeAddressIndex; i++) {
ret.push(this.getAddress(i,true));
}
for (var i=0; i<this.addressIndex; i++) {
ret.push(this.getAddress(i,false));
}
if (!onlyMain) {
for (var i=0; i<this.changeAddressIndex; i++) {
ret.push(this.getAddress(i,true));
}
}
return ret;
};

View File

@ -194,7 +194,6 @@ Wallet.prototype.sendPublicKeyRing = function(recipients) {
Wallet.prototype.generateAddress = function() {
var addr = this.publicKeyRing.generateAddress();
this.store();
this.sendPublicKeyRing();
return addr;
};
@ -272,13 +271,13 @@ Wallet.prototype.addSeenToTxProposals = function() {
};
Wallet.prototype.getAddresses = function() {
return this.publicKeyRing.getAddresses();
Wallet.prototype.getAddresses = function(onlyMain) {
return this.publicKeyRing.getAddresses(onlyMain);
};
Wallet.prototype.getAddressesStr = function() {
Wallet.prototype.getAddressesStr = function(onlyMain) {
var ret = [];
this.publicKeyRing.getAddresses().forEach(function(a) {
this.publicKeyRing.getAddresses(onlyMain).forEach(function(a) {
ret.push(a.toString());
});
return ret;
@ -334,8 +333,8 @@ Wallet.prototype.createTx = function(toAddress, amountSatStr, opts, cb) {
self.listUnspent(self.getAddressesStr(), function(utxos) {
// TODO check enough funds, etc.
self.createTxSync(toAddress, amountSatStr, utxos, opts);
self.store();
self.sendTxProposals();
self.store();
return cb();
});
};