add getTransaction method
This commit is contained in:
parent
62bdb543e7
commit
33827c5b18
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue