fix url for get transactions
This commit is contained in:
parent
ab635332cc
commit
dc6e64f8bc
@ -51,36 +51,40 @@ var getTransaction = function(txid, cb) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.getTransactionsByBlock = function(req, res, next, bId) {
|
exports.transactions = function(req, res, next) {
|
||||||
Block.fromHashWithInfo(bId, function(err, block) {
|
var bId = req.query.block;
|
||||||
if (err && !block) {
|
var aId = req.query.address;
|
||||||
console.log(err);
|
|
||||||
res.status(404).send('Not found');
|
|
||||||
return next();
|
|
||||||
}
|
|
||||||
|
|
||||||
async.mapSeries(block.info.tx, getTransaction,
|
if (bId) {
|
||||||
function(err, results) {
|
Block.fromHashWithInfo(bId, function(err, block) {
|
||||||
res.jsonp(results);
|
if (err && !block) {
|
||||||
});
|
console.log(err);
|
||||||
});
|
res.status(404).send('Not found');
|
||||||
};
|
return next();
|
||||||
|
}
|
||||||
exports.getTransactionsByAddress = function(req, res, next, aId) {
|
|
||||||
|
async.mapSeries(block.info.tx, getTransaction,
|
||||||
var a = Address.new(aId);
|
function(err, results) {
|
||||||
|
res.jsonp(results);
|
||||||
a.update(function(err) {
|
});
|
||||||
if (err && !a.totalReceivedSat) {
|
});
|
||||||
console.log(err);
|
}
|
||||||
res.status(404).send('Invalid address');
|
else {
|
||||||
return next();
|
var a = Address.new(aId);
|
||||||
}
|
|
||||||
|
a.update(function(err) {
|
||||||
async.mapSeries(a.transactions, getTransaction,
|
if (err && !a.totalReceivedSat) {
|
||||||
function(err, results) {
|
console.log(err);
|
||||||
res.jsonp(results);
|
res.status(404).send('Invalid address');
|
||||||
});
|
return next();
|
||||||
});
|
}
|
||||||
|
|
||||||
|
async.mapSeries(a.transactions, getTransaction,
|
||||||
|
function(err, results) {
|
||||||
|
res.jsonp(results);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -19,13 +19,9 @@ module.exports = function(app) {
|
|||||||
app.get('/api/tx/:txid', transactions.show);
|
app.get('/api/tx/:txid', transactions.show);
|
||||||
app.param('txid', transactions.transaction);
|
app.param('txid', transactions.transaction);
|
||||||
|
|
||||||
app.get('/api/txb/:bId', transactions.getTransactionsByBlock);
|
app.get('/api/txs', transactions.transactions);
|
||||||
app.param('bId', transactions.getTransactionsByBlock);
|
|
||||||
|
|
||||||
app.get('/api/txa/:aId', transactions.getTransactionsByAddress);
|
|
||||||
app.param('aId', transactions.getTransactionsByAddress);
|
|
||||||
|
|
||||||
|
|
||||||
|
// Address routes
|
||||||
var addresses = require('../app/controllers/addresses');
|
var addresses = require('../app/controllers/addresses');
|
||||||
app.get('/api/addr/:addr', addresses.show);
|
app.get('/api/addr/:addr', addresses.show);
|
||||||
app.param('addr', addresses.address);
|
app.param('addr', addresses.address);
|
||||||
|
|||||||
@ -13,7 +13,7 @@ angular.module('mystery.transactions').controller('transactionsController', ['$s
|
|||||||
|
|
||||||
$scope.byBlock = function(bId) {
|
$scope.byBlock = function(bId) {
|
||||||
TransactionsByBlock.query({
|
TransactionsByBlock.query({
|
||||||
bId: bId
|
block: bId
|
||||||
}, function(txs) {
|
}, function(txs) {
|
||||||
$scope.txs = txs;
|
$scope.txs = txs;
|
||||||
});
|
});
|
||||||
@ -21,7 +21,7 @@ angular.module('mystery.transactions').controller('transactionsController', ['$s
|
|||||||
|
|
||||||
$scope.byAddress = function(aId) {
|
$scope.byAddress = function(aId) {
|
||||||
TransactionsByAddress.query({
|
TransactionsByAddress.query({
|
||||||
aId: aId
|
address: aId
|
||||||
}, function(txs) {
|
}, function(txs) {
|
||||||
$scope.txs = txs;
|
$scope.txs = txs;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -21,14 +21,14 @@ angular.module('mystery.transactions').factory('Transaction', ['$resource', func
|
|||||||
}]);
|
}]);
|
||||||
|
|
||||||
angular.module('mystery.transactions').factory('TransactionsByBlock', ['$resource', function($resource) {
|
angular.module('mystery.transactions').factory('TransactionsByBlock', ['$resource', function($resource) {
|
||||||
return $resource('/api/txb/:bId', {
|
return $resource('/api/txs', {
|
||||||
bId: '@bId'
|
block: '@block'
|
||||||
});
|
});
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
angular.module('mystery.transactions').factory('TransactionsByAddress', ['$resource', function($resource) {
|
angular.module('mystery.transactions').factory('TransactionsByAddress', ['$resource', function($resource) {
|
||||||
return $resource('/api/txa/:aId', {
|
return $resource('/api/txs', {
|
||||||
aId: '@aId'
|
address: '@address'
|
||||||
});
|
});
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user