Merge pull request #759 from matiu/bug/bch-monitor

Bug/bch monitor
This commit is contained in:
Matias Alejo Garcia 2018-01-19 18:23:29 -03:00 committed by GitHub
commit 1333dd6ab7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View File

@ -14,7 +14,9 @@ var Lock = require('./lock');
var Notification = require('./model/notification');
var WalletService = require('./server');
var Constants = require('./common/constants');
var Common = require('./common');
var Constants = Common.Constants;
var Utils = Common.Utils;
function BlockchainMonitor() {};
@ -157,6 +159,11 @@ BlockchainMonitor.prototype._handleIncomingPayments = function(coin, network, da
var outs = _.compact(_.map(data.vout, function(v) {
var addr = _.keys(v)[0];
// This is because a bug on insight, that always return no copay addr
if (coin == 'bch' && Utils.getAddressCoin(addr) !='bch') {
addr = Utils.translateAddress(addr, coin);
}
return {
address: addr,
amount: +v[addr]
@ -165,6 +172,8 @@ BlockchainMonitor.prototype._handleIncomingPayments = function(coin, network, da
if (_.isEmpty(outs)) return;
async.each(outs, function(out, next) {
// toDo, remove coin here: no more same address for diff coins
self.storage.fetchAddressByCoin(coin, out.address, function(err, address) {
if (err) {
log.error('Could not fetch addresses from the db');

View File

@ -189,7 +189,7 @@ PushNotificationsService.prototype._checkShouldSendNotif = function(notification
if (notification.type != 'NewTxProposal') return cb(null, true);
self.storage.fetchWallet(notification.walletId, function(err, wallet) {
return cb(err, wallet.m > 1);
return cb(err, wallet && wallet.m > 1);
});
};
@ -297,7 +297,7 @@ PushNotificationsService.prototype._getDataForTemplate = function(notification,
}
self.storage.fetchWallet(notification.walletId, function(err, wallet) {
if (err) return cb(err);
if (err || !wallet) return cb(err);
data.walletId = wallet.id;
data.walletName = wallet.name;