transactions: switch to use req.param

so that the last argument is the next callback
This commit is contained in:
Braydon Fuller 2016-05-10 16:55:16 -04:00
parent 7973e2398a
commit 98d5314ef2
2 changed files with 16 additions and 7 deletions

View File

@ -21,8 +21,9 @@ TxController.prototype.show = function(req, res) {
/** /**
* Find transaction by hash ... * Find transaction by hash ...
*/ */
TxController.prototype.transaction = function(req, res, next, txid) { TxController.prototype.transaction = function(req, res, next) {
var self = this; var self = this;
var txid = req.params.txid;
this.node.getTransactionWithBlockInfo(txid, function(err, transaction) { this.node.getTransactionWithBlockInfo(txid, function(err, transaction) {
if (err && err.code === -5) { if (err && err.code === -5) {
@ -189,8 +190,8 @@ TxController.prototype.transformInvTransaction = function(transaction) {
return transformed; return transformed;
}; };
TxController.prototype.rawTransaction = function(req, res, next, txid) { TxController.prototype.rawTransaction = function(req, res, next) {
var self = this; var txid = req.params.txid;
this.node.getTransaction(txid, function(err, transaction) { this.node.getTransaction(txid, function(err, transaction) {
if (err && err.code === -5) { if (err && err.code === -5) {

View File

@ -187,7 +187,11 @@ describe('Transactions', function() {
}; };
var transactions = new TxController(node); var transactions = new TxController(node);
var req = {}; var req = {
params: {
txid: txid
}
};
var res = {}; var res = {};
var next = function() { var next = function() {
var merged = _.merge(req.transaction, todos); var merged = _.merge(req.transaction, todos);
@ -196,7 +200,7 @@ describe('Transactions', function() {
}; };
var txid = 'b85334bf2df35c6dd5b294efe92ffc793a78edff75a2ca666fc296ffb04bbba0'; 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 transactions = new TxController(node);
var res = {}; var res = {};
var req = {}; var req = {
params: {
txid: txid
}
};
var next = function() { var next = function() {
should(req.rawTransaction.rawtx).eql(hex); should(req.rawTransaction.rawtx).eql(hex);
done(); done();
}; };
var txid = '25a988e54b02e0e5df146a0f8fa7b9db56210533a9f04bdfda5f4ceb6f77aadd'; var txid = '25a988e54b02e0e5df146a0f8fa7b9db56210533a9f04bdfda5f4ceb6f77aadd';
transactions.rawTransaction(req, res, next, txid); transactions.rawTransaction(req, res, next);
}); });
}); });