2020-10-19 06:57:02 +02:00
|
|
|
const configFile = require('../mempool-config.json');
|
|
|
|
|
2020-10-19 13:36:29 +02:00
|
|
|
interface IConfig {
|
2020-10-19 06:57:02 +02:00
|
|
|
MEMPOOL: {
|
|
|
|
NETWORK: 'mainnet' | 'testnet' | 'liquid';
|
2020-12-20 16:36:36 +01:00
|
|
|
BACKEND: 'electrs' | 'bitcoind' | 'bitcoind-electrs';
|
2020-10-19 06:57:02 +02:00
|
|
|
HTTP_PORT: number;
|
|
|
|
SPAWN_CLUSTER_PROCS: number;
|
|
|
|
API_URL_PREFIX: string;
|
|
|
|
WEBSOCKET_REFRESH_RATE_MS: number;
|
|
|
|
};
|
|
|
|
ELECTRS: {
|
|
|
|
REST_API_URL: string;
|
|
|
|
POLL_RATE_MS: number;
|
2020-12-20 16:36:36 +01:00
|
|
|
HOST: string;
|
|
|
|
PORT: number;
|
2020-10-19 06:57:02 +02:00
|
|
|
};
|
2020-12-20 16:36:36 +01:00
|
|
|
BITCOIND: {
|
|
|
|
HOST: string;
|
|
|
|
PORT: number;
|
|
|
|
USERNAME: string;
|
|
|
|
PASSWORD: string;
|
|
|
|
},
|
2020-10-19 06:57:02 +02:00
|
|
|
DATABASE: {
|
|
|
|
ENABLED: boolean;
|
|
|
|
HOST: string,
|
|
|
|
PORT: number;
|
|
|
|
DATABASE: string;
|
|
|
|
USERNAME: string;
|
|
|
|
PASSWORD: string;
|
|
|
|
};
|
|
|
|
STATISTICS: {
|
|
|
|
ENABLED: boolean;
|
|
|
|
TX_PER_SECOND_SAMPLE_PERIOD: number;
|
|
|
|
};
|
|
|
|
BISQ_BLOCKS: {
|
|
|
|
ENABLED: boolean;
|
|
|
|
DATA_PATH: string;
|
|
|
|
};
|
|
|
|
BISQ_MARKETS: {
|
|
|
|
ENABLED: boolean;
|
|
|
|
DATA_PATH: string;
|
|
|
|
};
|
|
|
|
SPONSORS: {
|
|
|
|
ENABLED: boolean;
|
|
|
|
BTCPAY_URL: string;
|
|
|
|
BTCPAY_AUTH: string;
|
|
|
|
BTCPAY_WEBHOOK_URL: string;
|
|
|
|
TWITTER_BEARER_AUTH: string;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-10-19 13:36:29 +02:00
|
|
|
const defaults: IConfig = {
|
|
|
|
'MEMPOOL': {
|
|
|
|
'NETWORK': 'mainnet',
|
2020-12-20 16:36:36 +01:00
|
|
|
'BACKEND': 'electrs',
|
2020-10-19 13:36:29 +02:00
|
|
|
'HTTP_PORT': 8999,
|
|
|
|
'SPAWN_CLUSTER_PROCS': 0,
|
|
|
|
'API_URL_PREFIX': '/api/v1/',
|
|
|
|
'WEBSOCKET_REFRESH_RATE_MS': 2000
|
|
|
|
},
|
|
|
|
'ELECTRS': {
|
|
|
|
'REST_API_URL': 'http://127.0.0.1:3000',
|
2020-12-20 16:36:36 +01:00
|
|
|
'POLL_RATE_MS': 2000,
|
|
|
|
'HOST': '127.0.0.1',
|
|
|
|
'PORT': 3306
|
|
|
|
},
|
|
|
|
'BITCOIND': {
|
|
|
|
'HOST': "127.0.0.1",
|
|
|
|
'PORT': 8332,
|
|
|
|
'USERNAME': "mempoo",
|
|
|
|
'PASSWORD': "mempool"
|
2020-10-19 13:36:29 +02:00
|
|
|
},
|
|
|
|
'DATABASE': {
|
|
|
|
'ENABLED': true,
|
|
|
|
'HOST': 'localhost',
|
|
|
|
'PORT': 3306,
|
|
|
|
'DATABASE': 'mempool',
|
|
|
|
'USERNAME': 'mempool',
|
|
|
|
'PASSWORD': 'mempool'
|
|
|
|
},
|
|
|
|
'STATISTICS': {
|
|
|
|
'ENABLED': true,
|
|
|
|
'TX_PER_SECOND_SAMPLE_PERIOD': 150
|
|
|
|
},
|
|
|
|
'BISQ_BLOCKS': {
|
|
|
|
'ENABLED': false,
|
|
|
|
'DATA_PATH': '/bisq/statsnode-data/btc_mainnet/db/json'
|
|
|
|
},
|
|
|
|
'BISQ_MARKETS': {
|
|
|
|
'ENABLED': false,
|
|
|
|
'DATA_PATH': '/bisq/statsnode-data/btc_mainnet/db'
|
|
|
|
},
|
|
|
|
'SPONSORS': {
|
|
|
|
'ENABLED': false,
|
|
|
|
'BTCPAY_URL': '',
|
|
|
|
'BTCPAY_AUTH': '',
|
|
|
|
'BTCPAY_WEBHOOK_URL': '',
|
|
|
|
'TWITTER_BEARER_AUTH': ''
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-10-19 06:57:02 +02:00
|
|
|
class Config implements IConfig {
|
|
|
|
MEMPOOL: IConfig['MEMPOOL'];
|
|
|
|
ELECTRS: IConfig['ELECTRS'];
|
2020-12-20 16:36:36 +01:00
|
|
|
BITCOIND: IConfig['BITCOIND'];
|
2020-10-19 06:57:02 +02:00
|
|
|
DATABASE: IConfig['DATABASE'];
|
|
|
|
STATISTICS: IConfig['STATISTICS'];
|
|
|
|
BISQ_BLOCKS: IConfig['BISQ_BLOCKS'];
|
|
|
|
BISQ_MARKETS: IConfig['BISQ_MARKETS'];
|
|
|
|
SPONSORS: IConfig['SPONSORS'];
|
|
|
|
|
|
|
|
constructor() {
|
2020-10-19 13:36:29 +02:00
|
|
|
const configs = this.merge(configFile, defaults);
|
|
|
|
this.MEMPOOL = configs.MEMPOOL;
|
|
|
|
this.ELECTRS = configs.ELECTRS;
|
2020-12-20 16:36:36 +01:00
|
|
|
this.BITCOIND = configs.BITCOIND;
|
2020-10-19 13:36:29 +02:00
|
|
|
this.DATABASE = configs.DATABASE;
|
|
|
|
this.STATISTICS = configs.STATISTICS;
|
|
|
|
this.BISQ_BLOCKS = configs.BISQ_BLOCKS;
|
|
|
|
this.BISQ_MARKETS = configs.BISQ_MARKETS;
|
|
|
|
this.SPONSORS = configs.SPONSORS;
|
|
|
|
}
|
|
|
|
|
|
|
|
merge = (...objects: object[]): IConfig => {
|
|
|
|
// @ts-ignore
|
|
|
|
return objects.reduce((prev, next) => {
|
|
|
|
Object.keys(prev).forEach(key => {
|
|
|
|
next[key] = { ...next[key], ...prev[key] };
|
|
|
|
});
|
|
|
|
return next;
|
|
|
|
});
|
2020-10-19 06:57:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default new Config();
|