|
|
@ -2864,6 +2864,34 @@ WalletService.prototype.getTxHistory = function(opts, cb) { |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
function tagLowFees(wallet, txs, cb) { |
|
|
|
var unconfirmed = _.filter(txs, { |
|
|
|
confirmations: 0 |
|
|
|
}); |
|
|
|
if (_.isEmpty(unconfirmed)) return cb(); |
|
|
|
|
|
|
|
self.getFeeLevels({ |
|
|
|
network: wallet.network |
|
|
|
}, function(err, levels) { |
|
|
|
if (err) { |
|
|
|
log.warn('Could not fetch fee levels', err); |
|
|
|
} else { |
|
|
|
var level = _.find(levels, { |
|
|
|
level: 'superEconomy' |
|
|
|
}); |
|
|
|
if (!level || !level.nbBlocks) { |
|
|
|
log.debug('Cannot compute super economy fee level from blockchain'); |
|
|
|
} else { |
|
|
|
var minFeePerKb = level.feePerKb; |
|
|
|
_.each(unconfirmed, function(tx) { |
|
|
|
tx.lowFees = tx.feePerKb < minFeePerKb; |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
return cb(); |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
self.getWallet({}, function(err, wallet) { |
|
|
|
if (err) return cb(err); |
|
|
|
|
|
|
@ -2912,24 +2940,9 @@ WalletService.prototype.getTxHistory = function(opts, cb) { |
|
|
|
|
|
|
|
var finalTxs = decorate(wallet, res.txs.items, addresses, res.txps, res.notes); |
|
|
|
|
|
|
|
self.getFeeLevels({ |
|
|
|
network: wallet.network |
|
|
|
}, function(err, levels) { |
|
|
|
if (err) { |
|
|
|
log.warn('Could not fetch fee levels', err); |
|
|
|
} else { |
|
|
|
var level = _.find(levels, { |
|
|
|
level: 'superEconomy' |
|
|
|
}); |
|
|
|
if (!level || !level.nbBlocks) { |
|
|
|
log.debug('Cannot compute super economy fee level from blockchain'); |
|
|
|
} else { |
|
|
|
var minFeePerKb = level.feePerKb; |
|
|
|
_.each(finalTxs, function(tx) { |
|
|
|
tx.lowFees = tx.feePerKb < minFeePerKb; |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
tagLowFees(wallet, finalTxs, function(err) { |
|
|
|
if (err) |
|
|
|
log.warn('Failed to tag unconfirmed with low fee'); |
|
|
|
|
|
|
|
if (res.txs.fromCache) |
|
|
|
log.debug("History from cache for:", self.walletId, from, to); |
|
|
|