add getTransaction method

This commit is contained in:
Ivan Socolsky 2015-05-28 12:50:58 -03:00
parent 62bdb543e7
commit 33827c5b18
1 changed files with 14 additions and 0 deletions

View File

@ -22,6 +22,7 @@ function BlockChainExplorer(opts) {
switch (provider) {
case 'insight':
var explorer = new Explorers.Insight(url, network);
explorer.getTransaction = _.bind(getTransactionInsight, explorer, url);
explorer.getTransactions = _.bind(getTransactionsInsight, explorer, url);
explorer.getAddressActivity = _.bind(getAddressActivityInsight, explorer, url);
explorer.initSocket = _.bind(initSocketInsight, explorer, url);
@ -31,6 +32,19 @@ function BlockChainExplorer(opts) {
};
};
function getTransactionInsight(url, txid, cb) {
var url = url + '/api/tx/' + txid;
var args = {
method: "GET",
url: url,
};
request(args, function(err, res, tx) {
if (err || res.statusCode != 200) return cb(err || res);
return cb(null, tx);
});
};
function getTransactionsInsight(url, addresses, from, to, cb) {
var qs = [];
if (_.isNumber(from)) qs.push('from=' + from);