From 9ce67ed68a5f1445427e97fd0a3040a2e3d52692 Mon Sep 17 00:00:00 2001 From: Javier Date: Tue, 20 Sep 2016 16:45:43 -0300 Subject: [PATCH] use cached history first --- src/js/services/walletService.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/js/services/walletService.js b/src/js/services/walletService.js index 0af28637b..7f2f76e20 100644 --- a/src/js/services/walletService.js +++ b/src/js/services/walletService.js @@ -503,15 +503,23 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim }; root.getTx = function(wallet, txid, cb) { - root.getTxHistory(wallet, {}, function(err, txHistory) { - if (err) return cb(err); - - var tx = lodash.find(txHistory, { + if (wallet.completeHistory && wallet.completeHistory.isValid) { + var tx = lodash.find(wallet.completeHistory, { txid: txid }); return cb(null, tx); - }); + } else { + root.getTxHistory(wallet, {}, function(err, txHistory) { + if (err) return cb(err); + + var tx = lodash.find(txHistory, { + txid: txid + }); + + return cb(null, tx); + }); + } }; root.getTxHistory = function(wallet, opts, cb) {