diff --git a/lib/model/addressmanager.js b/lib/model/addressmanager.js index 6d21db2..736e5cf 100644 --- a/lib/model/addressmanager.js +++ b/lib/model/addressmanager.js @@ -45,16 +45,6 @@ AddressManager.prototype.getCurrentAddressPath = function(isChange) { (isChange ? this.changeAddressIndex : this.receiveAddressIndex); }; -AddressManager.getIndexesForPath = function(path) { - var s = path.split('/'); - var l = s.length; - return { - isChange: s[l - 2] === '1', - addressIndex: parseInt(s[l - 1], 10), - copayerIndex: parseInt(s[l - 3], 10) - }; -}; - AddressManager.prototype.getNewAddressPath = function(isChange) { var ret = this.getCurrentAddressPath(isChange); this._incrementIndex(isChange); diff --git a/lib/server.js b/lib/server.js index 9b3342f..f114052 100644 --- a/lib/server.js +++ b/lib/server.js @@ -22,7 +22,6 @@ var WalletUtils = require('./walletutils'); var Wallet = require('./model/wallet'); var Copayer = require('./model/copayer'); var Address = require('./model/address'); -var AddressManager = require('./model/addressmanager'); var TxProposal = require('./model/txproposal'); var Notification = require('./model/notification'); @@ -290,8 +289,8 @@ WalletService.prototype.getMainAddresses = function(opts, cb) { self.storage.fetchAddresses(self.walletId, function(err, addresses) { if (err) return cb(err); - var mainAddresses = _.filter(addresses, function(x) { - return !AddressManager.getIndexesForPath(x.path).isChange; + var mainAddresses = _.filter(addresses, { + isChange: false }); return cb(null, mainAddresses); diff --git a/test/integration/server.js b/test/integration/server.js index c555574..d090af4 100644 --- a/test/integration/server.js +++ b/test/integration/server.js @@ -107,7 +107,9 @@ helpers.stubUtxos = function(server, wallet, amounts, cb) { scriptPubKey: address.getScriptPubKey(wallet.m).toBuffer().toString('hex'), address: address.address, }; - obj.toObject = function() {return obj;}; + obj.toObject = function() { + return obj; + }; return obj; }); blockExplorer.getUnspentUtxos = sinon.stub().callsArgWith(1, null, utxos); @@ -670,7 +672,7 @@ describe('Copay server', function() { should.not.exist(err); balance.totalAmount.should.equal(helpers.toSatoshi(300)); balance.lockedAmount.should.equal(helpers.toSatoshi(100)); - server.getAddresses({}, function(err, addresses) { + server.storage.fetchAddresses(wallet.id, function(err, addresses) { should.not.exist(err); var change = _.filter(addresses, { isChange: true