diff --git a/backend/mempool-config.sample.json b/backend/mempool-config.sample.json index b6ab77f8d..8fb428447 100644 --- a/backend/mempool-config.sample.json +++ b/backend/mempool-config.sample.json @@ -20,6 +20,6 @@ "BITCOIN_NODE_USER": "", "BITCOIN_NODE_PASS": "", "BACKEND_API": "bitcoind", - "ESPLORA_API_URL": "https://www.blockstream.info/api", + "ELECTRS_API_URL": "https://www.blockstream.info/api", "TX_PER_SECOND_SPAN_SECONDS": 150 } diff --git a/backend/src/api/bitcoin/bitcoin-api-factory.ts b/backend/src/api/bitcoin/bitcoin-api-factory.ts index e97812440..19b2dc091 100644 --- a/backend/src/api/bitcoin/bitcoin-api-factory.ts +++ b/backend/src/api/bitcoin/bitcoin-api-factory.ts @@ -1,12 +1,12 @@ const config = require('../../../mempool-config.json'); import { AbstractBitcoinApi } from './bitcoin-api-abstract-factory'; import BitcoindApi from './bitcoind-api'; -import EsploraApi from './esplora-api'; +import ElectrsApi from './electrs-api'; function factory(): AbstractBitcoinApi { switch (config.BACKEND_API) { - case 'esplora': - return new EsploraApi(); + case 'electrs': + return new ElectrsApi(); case 'bitcoind': default: return new BitcoindApi(); diff --git a/backend/src/api/bitcoin/esplora-api.ts b/backend/src/api/bitcoin/electrs-api.ts similarity index 80% rename from backend/src/api/bitcoin/esplora-api.ts rename to backend/src/api/bitcoin/electrs-api.ts index e9f47688d..a378bdef4 100644 --- a/backend/src/api/bitcoin/esplora-api.ts +++ b/backend/src/api/bitcoin/electrs-api.ts @@ -3,14 +3,14 @@ import { ITransaction, IMempoolInfo, IBlock } from '../../interfaces'; import { AbstractBitcoinApi } from './bitcoin-api-abstract-factory'; import * as request from 'request'; -class EsploraApi implements AbstractBitcoinApi { +class ElectrsApi implements AbstractBitcoinApi { constructor() { } getMempoolInfo(): Promise { return new Promise(async (resolve, reject) => { - request(config.ESPLORA_API_URL + '/mempool', { json: true }, (err, res, response) => { + request(config.ELECTRS_API_URL + '/mempool', { json: true }, (err, res, response) => { if (err) { reject(err); } @@ -24,7 +24,7 @@ class EsploraApi implements AbstractBitcoinApi { getRawMempool(): Promise { return new Promise(async (resolve, reject) => { - request(config.ESPLORA_API_URL + '/mempool/txids', { json: true }, (err, res, response) => { + request(config.ELECTRS_API_URL + '/mempool/txids', { json: true }, (err, res, response) => { if (err) { reject(err); } @@ -35,7 +35,7 @@ class EsploraApi implements AbstractBitcoinApi { getRawTransaction(txId: string): Promise { return new Promise(async (resolve, reject) => { - request(config.ESPLORA_API_URL + '/tx/' + txId, { json: true }, (err, res, response) => { + request(config.ELECTRS_API_URL + '/tx/' + txId, { json: true }, (err, res, response) => { if (err) { reject(err); } @@ -50,7 +50,7 @@ class EsploraApi implements AbstractBitcoinApi { getBlockCount(): Promise { return new Promise(async (resolve, reject) => { - request(config.ESPLORA_API_URL + '/blocks/tip/height', { json: true }, (err, res, response) => { + request(config.ELECTRS_API_URL + '/blocks/tip/height', { json: true }, (err, res, response) => { if (err) { reject(err); } @@ -61,11 +61,11 @@ class EsploraApi implements AbstractBitcoinApi { getBlockAndTransactions(hash: string): Promise { return new Promise(async (resolve, reject) => { - request(config.ESPLORA_API_URL + '/block/' + hash, { json: true }, (err, res, response) => { + request(config.ELECTRS_API_URL + '/block/' + hash, { json: true }, (err, res, response) => { if (err) { reject(err); } - request(config.ESPLORA_API_URL + '/block/' + hash + '/txids', { json: true }, (err2, res2, response2) => { + request(config.ELECTRS_API_URL + '/block/' + hash + '/txids', { json: true }, (err2, res2, response2) => { if (err2) { reject(err2); } @@ -83,7 +83,7 @@ class EsploraApi implements AbstractBitcoinApi { getBlockHash(height: number): Promise { return new Promise(async (resolve, reject) => { - request(config.ESPLORA_API_URL + '/block-height/' + height, { json: true }, (err, res, response) => { + request(config.ELECTRS_API_URL + '/block-height/' + height, { json: true }, (err, res, response) => { if (err) { reject(err); } @@ -94,7 +94,7 @@ class EsploraApi implements AbstractBitcoinApi { getBlocks(): Promise { return new Promise(async (resolve, reject) => { - request(config.ESPLORA_API_URL + '/blocks', { json: true }, (err, res, response) => { + request(config.ELECTRS_API_URL + '/blocks', { json: true }, (err, res, response) => { if (err) { reject(err); } @@ -105,7 +105,7 @@ class EsploraApi implements AbstractBitcoinApi { getBlocksFromHeight(height: number): Promise { return new Promise(async (resolve, reject) => { - request(config.ESPLORA_API_URL + '/blocks/' + height, { json: true }, (err, res, response) => { + request(config.ELECTRS_API_URL + '/blocks/' + height, { json: true }, (err, res, response) => { if (err) { reject(err); } @@ -116,7 +116,7 @@ class EsploraApi implements AbstractBitcoinApi { getBlock(hash: string): Promise { return new Promise(async (resolve, reject) => { - request(config.ESPLORA_API_URL + '/block/' + hash, { json: true }, (err, res, response) => { + request(config.ELECTRS_API_URL + '/block/' + hash, { json: true }, (err, res, response) => { if (err) { reject(err); } @@ -127,7 +127,7 @@ class EsploraApi implements AbstractBitcoinApi { getBlockTransactions(hash: string): Promise { return new Promise(async (resolve, reject) => { - request(config.ESPLORA_API_URL + '/block/' + hash + '/txs', { json: true }, (err, res, response) => { + request(config.ELECTRS_API_URL + '/block/' + hash + '/txs', { json: true }, (err, res, response) => { if (err) { reject(err); } @@ -138,7 +138,7 @@ class EsploraApi implements AbstractBitcoinApi { getBlockTransactionsFromIndex(hash: string, index: number): Promise { return new Promise(async (resolve, reject) => { - request(config.ESPLORA_API_URL + '/block/' + hash + '/txs/' + index, { json: true }, (err, res, response) => { + request(config.ELECTRS_API_URL + '/block/' + hash + '/txs/' + index, { json: true }, (err, res, response) => { if (err) { reject(err); } @@ -149,7 +149,7 @@ class EsploraApi implements AbstractBitcoinApi { getAddress(address: string): Promise { return new Promise(async (resolve, reject) => { - request(config.ESPLORA_API_URL + '/address/' + address, { json: true }, (err, res, response) => { + request(config.ELECTRS_API_URL + '/address/' + address, { json: true }, (err, res, response) => { if (err) { reject(err); } @@ -160,7 +160,7 @@ class EsploraApi implements AbstractBitcoinApi { getAddressTransactions(address: string): Promise { return new Promise(async (resolve, reject) => { - request(config.ESPLORA_API_URL + '/address/' + address + '/txs', { json: true }, (err, res, response) => { + request(config.ELECTRS_API_URL + '/address/' + address + '/txs', { json: true }, (err, res, response) => { if (err) { reject(err); } @@ -171,7 +171,7 @@ class EsploraApi implements AbstractBitcoinApi { getAddressTransactionsFromLastSeenTxid(address: string, lastSeenTxid: string): Promise { return new Promise(async (resolve, reject) => { - request(config.ESPLORA_API_URL + '/address/' + address + '/txs/chain/' + lastSeenTxid, { json: true }, (err, res, response) => { + request(config.ELECTRS_API_URL + '/address/' + address + '/txs/chain/' + lastSeenTxid, { json: true }, (err, res, response) => { if (err) { reject(err); } @@ -181,4 +181,4 @@ class EsploraApi implements AbstractBitcoinApi { } } -export default EsploraApi; +export default ElectrsApi; diff --git a/backend/src/api/mempool.ts b/backend/src/api/mempool.ts index f96ce9ee6..13d988d5c 100644 --- a/backend/src/api/mempool.ts +++ b/backend/src/api/mempool.ts @@ -56,7 +56,7 @@ class Mempool { let totalOut = 0; transaction.vout.forEach((output) => totalOut += output.value); - if (config.BACKEND_API === 'esplora') { + if (config.BACKEND_API === 'electrs') { transaction.feePerWeightUnit = (transaction.fee * 100000000) / transaction.weight || 0; transaction.feePerVsize = (transaction.fee * 100000000) / (transaction.vsize) || 0; transaction.totalOut = totalOut / 100000000; diff --git a/backend/src/index.ts b/backend/src/index.ts index f2dfa02dd..635c76d30 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -264,7 +264,7 @@ class MempoolSpace { .get(config.API_ENDPOINT + 'statistics/6m', routes.get6MStatistics.bind(routes)) ; - if (config.BACKEND_API === 'esplora') { + if (config.BACKEND_API === 'electrs') { this.app .get(config.API_ENDPOINT + 'explorer/blocks', routes.getBlocks) .get(config.API_ENDPOINT + 'explorer/blocks/:height', routes.getBlocks) diff --git a/frontend/angular.json b/frontend/angular.json index 378711229..e634c1cb6 100644 --- a/frontend/angular.json +++ b/frontend/angular.json @@ -49,11 +49,11 @@ "vendorChunk": false, "buildOptimizer": true }, - "esplora": { + "electrs": { "fileReplacements": [ { "replace": "src/environments/environment.ts", - "with": "src/environments/environment-esplora.prod.ts" + "with": "src/environments/environment-electrs.prod.ts" } ], "optimization": true, diff --git a/frontend/package.json b/frontend/package.json index 09739c1a9..8e0ba9d98 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -6,7 +6,7 @@ "ng": "ng", "start": "ng serve --aot --proxy-config proxy.conf.json", "build": "ng build --prod", - "build-esplora": "ng build --prod --configuration=esplora", + "build-electrs": "ng build --prod --configuration=electrs", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e" diff --git a/frontend/src/app/blockchain-blocks/block-modal/block-modal.component.html b/frontend/src/app/blockchain-blocks/block-modal/block-modal.component.html index 5cd09ed9e..7366f8024 100644 --- a/frontend/src/app/blockchain-blocks/block-modal/block-modal.component.html +++ b/frontend/src/app/blockchain-blocks/block-modal/block-modal.component.html @@ -1,7 +1,7 @@