Merge pull request #4108 from mempool/simon/disable-historical-testnets

Handle historical price API calls when using any testnet
This commit is contained in:
softsimon
2023-08-09 10:51:58 +04:00
committed by GitHub
3 changed files with 22 additions and 1 deletions

View File

@@ -42,6 +42,10 @@ class MiningRoutes {
res.header('Pragma', 'public');
res.header('Cache-control', 'public');
res.setHeader('Expires', new Date(Date.now() + 1000 * 300).toUTCString());
if (['testnet', 'signet', 'liquidtestnet'].includes(config.MEMPOOL.NETWORK)) {
res.status(400).send('Prices are not available on testnets.');
return;
}
if (req.query.timestamp) {
res.status(200).send(await PricesRepository.$getNearestHistoricalPrice(
parseInt(<string>req.query.timestamp ?? 0, 10)