@@ -1,4 +1,4 @@
|
||||
const config = require('../../../mempool-config.json');
|
||||
import config from '../../config';
|
||||
import { Transaction, Block, MempoolInfo } from '../../interfaces';
|
||||
import * as request from 'request';
|
||||
|
||||
@@ -9,7 +9,7 @@ class ElectrsApi {
|
||||
|
||||
getMempoolInfo(): Promise<MempoolInfo> {
|
||||
return new Promise((resolve, reject) => {
|
||||
request(config.ELECTRS_API_URL + '/mempool', { json: true, timeout: 10000 }, (err, res, response) => {
|
||||
request(config.ELECTRS.REST_API_URL + '/mempool', { json: true, timeout: 10000 }, (err, res, response) => {
|
||||
if (err) {
|
||||
reject('getMempoolInfo error: ' + err.message || err);
|
||||
} else if (res.statusCode !== 200) {
|
||||
@@ -30,7 +30,7 @@ class ElectrsApi {
|
||||
|
||||
getRawMempool(): Promise<Transaction['txid'][]> {
|
||||
return new Promise((resolve, reject) => {
|
||||
request(config.ELECTRS_API_URL + '/mempool/txids', { json: true, timeout: 10000, forever: true }, (err, res, response) => {
|
||||
request(config.ELECTRS.REST_API_URL + '/mempool/txids', { json: true, timeout: 10000, forever: true }, (err, res, response) => {
|
||||
if (err) {
|
||||
reject('getRawMempool error: ' + err.message || err);
|
||||
} else if (res.statusCode !== 200) {
|
||||
@@ -48,7 +48,7 @@ class ElectrsApi {
|
||||
|
||||
getRawTransaction(txId: string): Promise<Transaction> {
|
||||
return new Promise((resolve, reject) => {
|
||||
request(config.ELECTRS_API_URL + '/tx/' + txId, { json: true, timeout: 10000, forever: true }, (err, res, response) => {
|
||||
request(config.ELECTRS.REST_API_URL + '/tx/' + txId, { json: true, timeout: 10000, forever: true }, (err, res, response) => {
|
||||
if (err) {
|
||||
reject('getRawTransaction error: ' + err.message || err);
|
||||
} else if (res.statusCode !== 200) {
|
||||
@@ -66,7 +66,7 @@ class ElectrsApi {
|
||||
|
||||
getBlockHeightTip(): Promise<number> {
|
||||
return new Promise((resolve, reject) => {
|
||||
request(config.ELECTRS_API_URL + '/blocks/tip/height', { json: true, timeout: 10000 }, (err, res, response) => {
|
||||
request(config.ELECTRS.REST_API_URL + '/blocks/tip/height', { json: true, timeout: 10000 }, (err, res, response) => {
|
||||
if (err) {
|
||||
reject('getBlockHeightTip error: ' + err.message || err);
|
||||
} else if (res.statusCode !== 200) {
|
||||
@@ -80,7 +80,7 @@ class ElectrsApi {
|
||||
|
||||
getTxIdsForBlock(hash: string): Promise<string[]> {
|
||||
return new Promise((resolve, reject) => {
|
||||
request(config.ELECTRS_API_URL + '/block/' + hash + '/txids', { json: true, timeout: 10000 }, (err, res, response) => {
|
||||
request(config.ELECTRS.REST_API_URL + '/block/' + hash + '/txids', { json: true, timeout: 10000 }, (err, res, response) => {
|
||||
if (err) {
|
||||
reject('getTxIdsForBlock error: ' + err.message || err);
|
||||
} else if (res.statusCode !== 200) {
|
||||
@@ -98,7 +98,7 @@ class ElectrsApi {
|
||||
|
||||
getBlockHash(height: number): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
request(config.ELECTRS_API_URL + '/block-height/' + height, { json: true, timeout: 10000 }, (err, res, response) => {
|
||||
request(config.ELECTRS.REST_API_URL + '/block-height/' + height, { json: true, timeout: 10000 }, (err, res, response) => {
|
||||
if (err) {
|
||||
reject('getBlockHash error: ' + err.message || err);
|
||||
} else if (res.statusCode !== 200) {
|
||||
@@ -112,7 +112,7 @@ class ElectrsApi {
|
||||
|
||||
getBlocksFromHeight(height: number): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
request(config.ELECTRS_API_URL + '/blocks/' + height, { json: true, timeout: 10000 }, (err, res, response) => {
|
||||
request(config.ELECTRS.REST_API_URL + '/blocks/' + height, { json: true, timeout: 10000 }, (err, res, response) => {
|
||||
if (err) {
|
||||
reject('getBlocksFromHeight error: ' + err.message || err);
|
||||
} else if (res.statusCode !== 200) {
|
||||
@@ -126,7 +126,7 @@ class ElectrsApi {
|
||||
|
||||
getBlock(hash: string): Promise<Block> {
|
||||
return new Promise((resolve, reject) => {
|
||||
request(config.ELECTRS_API_URL + '/block/' + hash, { json: true, timeout: 10000 }, (err, res, response) => {
|
||||
request(config.ELECTRS.REST_API_URL + '/block/' + hash, { json: true, timeout: 10000 }, (err, res, response) => {
|
||||
if (err) {
|
||||
reject('getBlock error: ' + err.message || err);
|
||||
} else if (res.statusCode !== 200) {
|
||||
|
||||
Reference in New Issue
Block a user