diff --git a/api/controllers/transactions.js b/api/controllers/transactions.js index 70bb0f98..ec280637 100644 --- a/api/controllers/transactions.js +++ b/api/controllers/transactions.js @@ -21,14 +21,15 @@ Transactions.setNode = function(aNode) { * Finds a transaction by its hash */ Transactions.txHashParam = function(req, res, next, txHash) { - var tx = node.getTransaction(txHash); - - if (_.isUndefined(tx)) { - res.status(404).send('Transaction with id ' + txHash + ' not found'); - return; - } - req.tx = tx; - next(); + node.getTransaction(txHash) + .then(function(tx) { + if (_.isUndefined(tx)) { + res.status(404).send('Transaction with id ' + txHash + ' not found'); + return; + } + req.tx = tx; + }) + .then(next); }; diff --git a/api/test/v1/transactions.js b/api/test/v1/transactions.js index 1883586f..a186e4d2 100644 --- a/api/test/v1/transactions.js +++ b/api/test/v1/transactions.js @@ -22,7 +22,7 @@ describe('BitcoreHTTP v1 transactions routes', function() { beforeEach(function() { nodeMock = new EventEmitter(); nodeMock.getTransaction = function(txHash) { - return mockTransactions[txHash]; + return Promise.resolve(mockTransactions[txHash]); }; nodeMock.broadcast = function(tx) { if (mockTransactions[tx.id]) {