From 98d5314ef25e886ea51677c741eb79d627d6f806 Mon Sep 17 00:00:00 2001 From: Braydon Fuller Date: Tue, 10 May 2016 16:55:16 -0400 Subject: [PATCH] transactions: switch to use req.param so that the last argument is the next callback --- lib/transactions.js | 7 ++++--- test/transactions.js | 16 ++++++++++++---- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/transactions.js b/lib/transactions.js index 5682ddf..9765ede 100644 --- a/lib/transactions.js +++ b/lib/transactions.js @@ -21,8 +21,9 @@ TxController.prototype.show = function(req, res) { /** * Find transaction by hash ... */ -TxController.prototype.transaction = function(req, res, next, txid) { +TxController.prototype.transaction = function(req, res, next) { var self = this; + var txid = req.params.txid; this.node.getTransactionWithBlockInfo(txid, function(err, transaction) { if (err && err.code === -5) { @@ -189,8 +190,8 @@ TxController.prototype.transformInvTransaction = function(transaction) { return transformed; }; -TxController.prototype.rawTransaction = function(req, res, next, txid) { - var self = this; +TxController.prototype.rawTransaction = function(req, res, next) { + var txid = req.params.txid; this.node.getTransaction(txid, function(err, transaction) { if (err && err.code === -5) { diff --git a/test/transactions.js b/test/transactions.js index 75a7926..5758a3a 100644 --- a/test/transactions.js +++ b/test/transactions.js @@ -187,7 +187,11 @@ describe('Transactions', function() { }; var transactions = new TxController(node); - var req = {}; + var req = { + params: { + txid: txid + } + }; var res = {}; var next = function() { var merged = _.merge(req.transaction, todos); @@ -196,7 +200,7 @@ describe('Transactions', function() { }; var txid = 'b85334bf2df35c6dd5b294efe92ffc793a78edff75a2ca666fc296ffb04bbba0'; - transactions.transaction(req, res, next, txid); + transactions.transaction(req, res, next); }); }); @@ -849,13 +853,17 @@ describe('Transactions', function() { var transactions = new TxController(node); var res = {}; - var req = {}; + var req = { + params: { + txid: txid + } + }; var next = function() { should(req.rawTransaction.rawtx).eql(hex); done(); }; var txid = '25a988e54b02e0e5df146a0f8fa7b9db56210533a9f04bdfda5f4ceb6f77aadd'; - transactions.rawTransaction(req, res, next, txid); + transactions.rawTransaction(req, res, next); }); });