diff --git a/README.md b/README.md index fe27cf01..1794195b 100644 --- a/README.md +++ b/README.md @@ -255,8 +255,8 @@ addrs: 2NF2baYuJAkCKo5onjUKEPdARQkZ6SYyKd5,2NAre8sX2povnjy4aeiHKeEh97Qhn97tB1f ### Transactions for multiple addresses GET method: ``` - /api/addrs/[:addrs]/txs - /api/addrs/2NF2baYuJAkCKo5onjUKEPdARQkZ6SYyKd5,2NAre8sX2povnjy4aeiHKeEh97Qhn97tB1f/txs + /api/addrs/[:addrs]/txs[?from=&to=] + /api/addrs/2NF2baYuJAkCKo5onjUKEPdARQkZ6SYyKd5,2NAre8sX2povnjy4aeiHKeEh97Qhn97tB1f/txs?from=0&to=20 ``` POST method: @@ -267,8 +267,41 @@ POST method: POST params: ``` addrs: 2NF2baYuJAkCKo5onjUKEPdARQkZ6SYyKd5,2NAre8sX2povnjy4aeiHKeEh97Qhn97tB1f +from (optional): 0 +to (optional): 20 ``` +Sample output: +``` +{ totalItems: 100, + from: 0, + to: 20, + items: + [ { txid: '3e81723d069b12983b2ef694c9782d32fca26cc978de744acbc32c3d3496e915', + version: 1, + locktime: 0, + vin: [Object], + vout: [Object], + blockhash: '00000000011a135e5277f5493c52c66829792392632b8b65429cf07ad3c47a6c', + confirmations: 109367, + time: 1393659685, + blocktime: 1393659685, + valueOut: 0.3453, + size: 225, + firstSeenTs: undefined, + valueIn: 0.3454, + fees: 0.0001 }, + { ... }, + { ... }, + ... + { ... } + ] + } +``` + +Note: if pagination params are not specified, the result is an array of transactions. + + ### Transaction broadcasting POST method: ``` diff --git a/app/controllers/addresses.js b/app/controllers/addresses.js index e9929a9b..6855adee 100644 --- a/app/controllers/addresses.js +++ b/app/controllers/addresses.js @@ -132,8 +132,8 @@ exports.multitxs = function(req, res, next) { }); }; - var from = req.query.from; - var to = req.query.to; + var from = req.param('from'); + var to = req.param('to'); var as = getAddrs(req, res, next); if (as) { diff --git a/test/integration/txs.js b/test/integration/txs.js index 33f54bea..7e92ab74 100644 --- a/test/integration/txs.js +++ b/test/integration/txs.js @@ -34,22 +34,19 @@ describe('Transactions for multiple addresses', function() { beforeEach(function(c) { req = {}; res = {}; - req.query = {}; res.jsonp = sinon.spy(); return c(); }); - describe('All', function () { + describe('Transactions from multiple addresses', function () { _.each(fixture, function (f) { it(f.test, function (done) { - req.param = sinon.stub().withArgs('addrs').returns(f.addrs.join(',')); + req.param = sinon.stub(); + req.param.withArgs('addrs').returns(f.addrs.join(',')); + req.param.withArgs('from').returns(f.from); + req.param.withArgs('to').returns(f.to); + var paginated = !_.isUndefined(f.from) || !_.isUndefined(f.to); - if (paginated) { - req.query = { - from: f.from, - to: f.to - }; - } addresses.multitxs(req, res, function() { var txs = res.jsonp.getCall(0).args[0]; txs.should.exist;