Replace opennode usd price source with wiz api.

fixes #166
This commit is contained in:
softsimon 2020-11-22 16:48:55 +07:00
parent 30fb0bad78
commit 1521d47cc7
No known key found for this signature in database
GPG Key ID: 488D7DCFB5A430D7
2 changed files with 11 additions and 10 deletions

View File

@ -2,10 +2,8 @@ import logger from '../logger';
import axios from 'axios'; import axios from 'axios';
class FiatConversion { class FiatConversion {
private tickers = { private conversionRates = {
'BTCUSD': { 'USD': 0
'USD': 4110.78
},
}; };
constructor() { } constructor() { }
@ -16,16 +14,19 @@ class FiatConversion {
this.updateCurrency(); this.updateCurrency();
} }
public getTickers() { public getConversionRates() {
return this.tickers; return this.conversionRates;
} }
private async updateCurrency(): Promise<void> { private async updateCurrency(): Promise<void> {
try { try {
const response = await axios.get('https://api.opennode.co/v1/rates'); const response = await axios.get('https://price.bisq.wiz.biz/getAllMarketPrices ');
this.tickers = response.data.data; const usd = response.data.data.find((item: any) => item.currencyCode === 'USD');
this.conversionRates = {
'USD': usd.price,
};
} catch (e) { } catch (e) {
logger.err('Error updating currency from OpenNode: ' + e); logger.err('Error updating fiat conversion rates: ' + e);
} }
} }
} }

View File

@ -86,7 +86,7 @@ class WebsocketHandler {
'vBytesPerSecond': memPool.getVBytesPerSecond(), 'vBytesPerSecond': memPool.getVBytesPerSecond(),
'lastDifficultyAdjustment': blocks.getLastDifficultyAdjustmentTime(), 'lastDifficultyAdjustment': blocks.getLastDifficultyAdjustmentTime(),
'blocks': _blocks, 'blocks': _blocks,
'conversions': fiatConversion.getTickers()['BTCUSD'], 'conversions': fiatConversion.getConversionRates(),
'mempool-blocks': mempoolBlocks.getMempoolBlocks(), 'mempool-blocks': mempoolBlocks.getMempoolBlocks(),
'transactions': memPool.getLatestTransactions(), 'transactions': memPool.getLatestTransactions(),
'git-commit': backendInfo.gitCommitHash, 'git-commit': backendInfo.gitCommitHash,