Merge pull request #5739 from matiu/bug/getTx
better error handling of getTx
This commit is contained in:
commit
6d7afcac00
2 changed files with 12 additions and 17 deletions
|
|
@ -93,9 +93,9 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
|
||||||
walletService.getTx($scope.wallet, txId, function(err, tx) {
|
walletService.getTx($scope.wallet, txId, function(err, tx) {
|
||||||
ongoingProcess.set('loadingTxInfo', false);
|
ongoingProcess.set('loadingTxInfo', false);
|
||||||
if (err) {
|
if (err) {
|
||||||
$log.warn('Could not get tx');
|
$log.warn('Error getting transaction' + err);
|
||||||
$ionicHistory.goBack();
|
$ionicHistory.goBack();
|
||||||
return popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Transaction not found'));
|
return popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Transaction not available at this time'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.btx = txFormatService.processTx(tx);
|
$scope.btx = txFormatService.processTx(tx);
|
||||||
|
|
|
||||||
|
|
@ -523,32 +523,27 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
};
|
};
|
||||||
|
|
||||||
root.getTx = function(wallet, txid, cb) {
|
root.getTx = function(wallet, txid, cb) {
|
||||||
var tx;
|
|
||||||
|
|
||||||
if (wallet.completeHistory && wallet.completeHistory.isValid) {
|
function finish(list){
|
||||||
tx = lodash.find(wallet.completeHistory, {
|
var tx = lodash.find(list, {
|
||||||
txid: txid
|
txid: txid
|
||||||
});
|
});
|
||||||
|
|
||||||
finish();
|
if (!tx) return cb('Could not get transaction');
|
||||||
|
return cb(null, tx);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (wallet.completeHistory && wallet.completeHistory.isValid) {
|
||||||
|
finish(wallet.completeHistory);
|
||||||
} else {
|
} else {
|
||||||
root.getTxHistory(wallet, {
|
root.getTxHistory(wallet, {
|
||||||
limitTx: txid
|
limitTx: txid
|
||||||
}, function(err, txHistory) {
|
}, function(err, txHistory) {
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
|
|
||||||
tx = lodash.find(txHistory, {
|
finish(txHistory);
|
||||||
txid: txid
|
|
||||||
});
|
|
||||||
|
|
||||||
finish();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function finish() {
|
|
||||||
if (tx) return cb(null, tx);
|
|
||||||
else return cb();
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue