<commit_before>'use strict';

var request = require('request');
var async = require('async');

var bitcore = require('bitcore-lib');
var _ = bitcore.deps._;

var $ = bitcore.util.preconditions;
var Address = bitcore.Address;
var JSUtil = bitcore.util.js;
var Networks = bitcore.Networks;
var Transaction = bitcore.Transaction;
var UnspentOutput = Transaction.UnspentOutput;
var AddressInfo = require('./models/addressinfo');
var FeeEstimation = require('./models/feeestimation');

/**
 * @param {string=} url the url of the Smoogs server
 * @param {Network=} network whether to use livenet or testnet
 * @constructor
 */
function Smoogs(url, network) {
  if (!url && !network) {
    return new Smoogs(Networks.defaultNetwork);
  }
  if (Networks.get(url)) {
    network = Networks.get(url);
    url = 'https://smoogs.io/api/' + (
      network === Networks.livenet ? 'v1' : 'testing'
    ) + '/blockchain'
  }
  this.url = url;
  this.network = Networks.get(network) || Networks.defaultNetwork;
  this.request = request;
  return this;
}

/**
 * @callback Smoogs.GetUnspentUtxosCallback
 * @param {Error} err
 * @param {Array.UnspentOutput} utxos
 */

/**
 * Retrieve a list of unspent outputs associated with an address or set of addresses
 * @param {Address|string|Array.Address|Array.string} addresses
 * @param {GetUnspentUtxosCallback} callback
 */
Smoogs.prototype.getUnspentUtxos = function(addresses, callback) {
  $.checkArgument(_.isFunction(callback));
  if (!_.isArray(addresses)) {
    addresses = [addresses];
  }
  addresses = _.map(addresses, function(address) {
    return new Address(address);
  });

  this.requestGet('/utxos?addresses=' + (
    _.map(addresses, function(address) {
      return address.toString();
    }).join(',')
  ), function(err, res, unspent) {
    if (err || res.statusCode !== 200) {
      return callback(err || res);
    }<commit_msg>Added getTransaction to smoogs explorer<commit_after>'use strict';

var request = require('request');
var async = require('async');

var bitcore = require('bitcore-lib');
var _ = bitcore.deps._;

var $ = bitcore.util.preconditions;
var Address = bitcore.Address;
var JSUtil = bitcore.util.js;
var Networks = bitcore.Networks;
var Transaction = bitcore.Transaction;
var UnspentOutput = Transaction.UnspentOutput;
var AddressInfo = require('./models/addressinfo');
var FeeEstimation = require('./models/feeestimation');

/**
 * @param {string=} url the url of the Smoogs server
 * @param {Network=} network whether to use livenet or testnet
 * @constructor
 */
function Smoogs(url, network) {
  if (!url && !network) {
    return new Smoogs(Networks.defaultNetwork);
  }
  if (Networks.get(url)) {
    network = Networks.get(url);
    url = 'https://smoogs.io/api/' + (
      network === Networks.livenet ? 'v1' : 'testing'
    ) + '/blockchain'
  }
  this.url = url;
  this.network = Networks.get(network) || Networks.defaultNetwork;
  this.request = request;
  return this;
}

/**
 * @callback Smoogs.GetTransactionCallback
 * @param {Error} err
 * @param {Object} transaction
 */

/**
 * Get transaction by txid
 * @param {string} txid
 * @param {GetTransactionCallback} callback
 */
Smoogs.prototype.getTransaction = function(txid, callback) {
  $.checkArgument(_.isFunction(callback));
  $.checkArgument(_.isString(txid));
  $.checkArgument(txid.length === 64);

  this.requestGet('/tx/' + txid, function(err, res, body) {
    if (err || res.statusCode !== 200) {
      return callback(err || res);
    }
    var tx = new Transaction(body);

    return callback(null, tx);
  });
};

/**
 * @callback Smoogs.GetUnspentUtxosCallback
 * @param {Error} err
 * @param {Array.UnspentOutput} utxos
 */

/**
 * Retrieve a list of unspent outputs associated with an address or set of addresses
 * @param {Address|string|Array.Address|Array.string} addresses
 * @param {GetUnspentUtxosCallback} callback
 */
Smoogs.prototype.getUnspentUtxos = function(addresses, callback) {
  $.checkArgument(_.isFunction(callback));
  if (!_.isArray(addresses)) {
    addresses = [addresses];
  }
  addresses = _.map(addresses, function(address) {
    return new Address(address);
  });

  this.requestGet('/utxos?addresses=' + (
    _.map(addresses, function(address) {
      return address.toString();
    }).join(',')
  ), function(err, res, unspent) {
    if (err || res.statusCode !== 200) {
      return callback(err || res);
    }
{'fraction_non_alphanumeric': 0.15130830489192265, 'fraction_numerical': 0.0029579067121729237, 'mean_word_length': 4.04707233065442, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7607751', 'n_tokens_mistral': 1433, 'n_tokens_neox': 1412, 'n_words': 332}