|
|
@ -160,18 +160,30 @@ BlockchainMonitor.prototype._handleTxOuts = function(data) { |
|
|
|
var walletId = address.walletId; |
|
|
|
log.info('Incoming tx for wallet ' + walletId + ' [' + out.amount + 'sat -> ' + out.address + ']'); |
|
|
|
|
|
|
|
var notification = Notification.create({ |
|
|
|
type: 'NewIncomingTx', |
|
|
|
data: { |
|
|
|
txid: data.txid, |
|
|
|
address: out.address, |
|
|
|
amount: out.amount, |
|
|
|
}, |
|
|
|
walletId: walletId, |
|
|
|
}); |
|
|
|
self.storage.softResetTxHistoryCache(walletId, function() { |
|
|
|
self._updateActiveAddresses(address, function() { |
|
|
|
self._storeAndBroadcastNotification(notification, next); |
|
|
|
var fromTs = Date.now() - 24 * 3600 * 1000; |
|
|
|
self.storage.fetchNotifications(walletId, null, fromTs, function(err, notifications) { |
|
|
|
if (err) return next(err); |
|
|
|
var alreadyNotified = _.any(notifications, function(n) { |
|
|
|
return n.type == 'NewIncomingTx' && n.data && n.data.txid == data.txid; |
|
|
|
}); |
|
|
|
if (alreadyNotified) { |
|
|
|
log.info('The incoming tx ' + data.txid + ' was already notified'); |
|
|
|
return next(); |
|
|
|
} |
|
|
|
|
|
|
|
var notification = Notification.create({ |
|
|
|
type: 'NewIncomingTx', |
|
|
|
data: { |
|
|
|
txid: data.txid, |
|
|
|
address: out.address, |
|
|
|
amount: out.amount, |
|
|
|
}, |
|
|
|
walletId: walletId, |
|
|
|
}); |
|
|
|
self.storage.softResetTxHistoryCache(walletId, function() { |
|
|
|
self._updateActiveAddresses(address, function() { |
|
|
|
self._storeAndBroadcastNotification(notification, next); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|