From 9827f9a6809feff5994a54e2e800109c0dcbd9e0 Mon Sep 17 00:00:00 2001 From: kenshin-samourai Date: Sat, 19 Oct 2019 17:13:07 +0200 Subject: [PATCH] removed unused wrapper for insight api --- keys/index-example.js | 3 - lib/remote-importer/insight-wrapper.js | 90 -------------------------- 2 files changed, 93 deletions(-) delete mode 100644 lib/remote-importer/insight-wrapper.js diff --git a/keys/index-example.js b/keys/index-example.js index e356bb4..56b9503 100644 --- a/keys/index-example.js +++ b/keys/index-example.js @@ -272,9 +272,6 @@ module.exports = { indexer: { active: 'third_party_explorer', socks5Proxy: null, - insight: [ - 'https://testnet-api.example.com' - ], esplora: 'https://blockstream.info/testnet' }, addrFilterThreshold: 1000, diff --git a/lib/remote-importer/insight-wrapper.js b/lib/remote-importer/insight-wrapper.js deleted file mode 100644 index 54a4935..0000000 --- a/lib/remote-importer/insight-wrapper.js +++ /dev/null @@ -1,90 +0,0 @@ -/*! - * lib/remote-importer/insight-wrapper.js - * Copyright © 2019 – Katana Cryptographic Ltd. All Rights Reserved. - */ -'use strict' - -const rp = require('request-promise-native') -const Logger = require('../logger') -const network = require('../bitcoin/network') -const keys = require('../../keys')[network.key] -const Wrapper = require('./wrapper') - - -/** - * Wrapper for the Insight block explorer APIs - */ -class InsightWrapper extends Wrapper { - - /** - * Constructor - */ - constructor(url) { - super(url, keys.indexer.socks5Proxy) - } - - /** - * Send a GET request to the API - * @param {string} route - * @returns {Promise} - */ - async _get(route) { - const params = { - url: `${this.base}${route}`, - method: 'GET', - json: true, - timeout: 15000 - } - - // Sets socks proxy agent if required - if (keys.indexer.socks5Proxy != null) - params['agent'] = this.socksProxyAgent - - return rp(params) - } - - /** - * Retrieve information for a given address - * @param {string} address - bitcoin address - * @param {boolean} filterAddr - True if an upper bound should be used - * for #transactions associated to the address, False otherwise - * @returns {Promise} returns an object - * { address: , txids: , ntx: } - */ - async getAddress(address, filterAddr) { - const uri = `/addr/${address}` - // Param filterAddr isn't used for insight - const result = await this._get(uri) - - const ret = { - address: result.addrStr, - txids: [], - ntx: result.txApperances - } - - // Check if we should filter this address - if (filterAddr && ret.ntx > keys.addrFilterThreshold) { - Logger.info(` import of ${ret.address} rejected (too many transactions - ${ret.ntx})`) - return ret - } - - ret.txids = result.transactions - return ret - } - - /** - * Retrieve information for a given list of addresses - * @param {string} addresses - array of bitcoin addresses - * @param {boolean} filterAddr - True if an upper bound should be used - * for #transactions associated to the address, False otherwise - * @returns {Promise} returns an array of objects - * { address: , txids: , ntx: } - */ - async getAddresses(addresses, filterAddr) { - // Not implemented for this api - throw "Not implemented" - } - -} - -module.exports = InsightWrapper