better error handling of getTx
This commit is contained in:
parent
48e829d989
commit
c062232976
2 changed files with 12 additions and 17 deletions
|
|
@ -523,32 +523,27 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
};
|
||||
|
||||
root.getTx = function(wallet, txid, cb) {
|
||||
var tx;
|
||||
|
||||
if (wallet.completeHistory && wallet.completeHistory.isValid) {
|
||||
tx = lodash.find(wallet.completeHistory, {
|
||||
txid: txid
|
||||
function finish(list){
|
||||
var tx = lodash.find(list, {
|
||||
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 {
|
||||
root.getTxHistory(wallet, {
|
||||
limitTx: txid
|
||||
}, function(err, txHistory) {
|
||||
if (err) return cb(err);
|
||||
|
||||
tx = lodash.find(txHistory, {
|
||||
txid: txid
|
||||
});
|
||||
|
||||
finish();
|
||||
finish(txHistory);
|
||||
});
|
||||
}
|
||||
|
||||
function finish() {
|
||||
if (tx) return cb(null, tx);
|
||||
else return cb();
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue