diff --git a/lib/blockchainmonitor.js b/lib/blockchainmonitor.js index 481dcf0..9496578 100644 --- a/lib/blockchainmonitor.js +++ b/lib/blockchainmonitor.js @@ -71,9 +71,11 @@ BlockchainMonitor._handleIncommingTx = function(data) { if (_.isEmpty(outs)) return; async.each(outs, function(out, next) { - storage.fetchWalletIdByAddress(out.address, function(err, walletId) { - if (err || !walletId) return next(err); + storage.fetchAddress(out.address, function(err, address) { + if (err || !address) return next(err); + if (address.isChange) return next(); + var walletId = address.walletId; log.info('Incoming tx for wallet ' + walletId + ' (' + out.address + ' -> ' + out.amount + ')'); BlockchainMonitor._createNotification(walletId, data.txid, out.address, out.amount, next); }); diff --git a/lib/storage.js b/lib/storage.js index e7b1160..11740d5 100644 --- a/lib/storage.js +++ b/lib/storage.js @@ -312,7 +312,7 @@ Storage.prototype.storeAddressAndWallet = function(wallet, addresses, cb) { }); }; -Storage.prototype.fetchWalletIdByAddress = function(address, cb) { +Storage.prototype.fetchAddress = function(address, cb) { var self = this; this.db.collection(collections.ADDRESSES).findOne({ @@ -321,7 +321,7 @@ Storage.prototype.fetchWalletIdByAddress = function(address, cb) { if (err) return cb(err); if (!result) return cb(); - return cb(null, result.walletId); + return cb(null, Model.Address.fromObj(result)); }); };