Merge pull request #6535 from mempool/junderw/esplora-fee-estimates-overwrite

feat: Overwrite the esplora API for fees always
This commit is contained in:
wiz 2026-05-31 10:23:06 +09:00 committed by GitHub
commit fbb46e1c4f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 66 additions and 0 deletions

View file

@ -38,6 +38,7 @@ class BitcoinRoutes {
.get(config.MEMPOOL.API_URL_PREFIX + 'difficulty-adjustment', this.getDifficultyChange)
.get(config.MEMPOOL.API_URL_PREFIX + 'fees/recommended', this.getRecommendedFees)
.get(config.MEMPOOL.API_URL_PREFIX + 'fees/precise', this.getPreciseRecommendedFees)
.get(config.MEMPOOL.API_URL_PREFIX + 'fee-estimates', this.getPreciseRecommendedFeesEsploraTransformed)
.get(config.MEMPOOL.API_URL_PREFIX + 'fees/mempool-blocks', this.getMempoolBlocks)
.get(config.MEMPOOL.API_URL_PREFIX + 'backend-info', this.getBackendInfo)
.get(config.MEMPOOL.API_URL_PREFIX + 'init-data', this.getInitData)
@ -134,6 +135,47 @@ class BitcoinRoutes {
res.json(result);
}
private getPreciseRecommendedFeesEsploraTransformed(req: Request, res: Response) {
if (!mempool.isInSync()) {
res.statusCode = 503;
res.send('Service Unavailable');
return;
}
const result = feeApi.getPreciseRecommendedFee();
res.json({
'warning': 'This endpoint is deprecated and will be removed in a future release. Please use /api/v1/fees/precise instead.',
'1': result.fastestFee,
'2': result.fastestFee,
'3': result.halfHourFee,
'4': result.halfHourFee,
'5': result.halfHourFee,
'6': result.hourFee,
'7': result.hourFee,
'8': result.hourFee,
'9': result.hourFee,
'10': result.hourFee,
'11': result.hourFee,
'12': result.hourFee,
'13': result.hourFee,
'14': result.hourFee,
'15': result.hourFee,
'16': result.hourFee,
'17': result.hourFee,
'18': result.hourFee,
'19': result.hourFee,
'20': result.hourFee,
'21': result.hourFee,
'22': result.hourFee,
'23': result.hourFee,
'24': result.hourFee,
'25': result.hourFee,
'144': result.economyFee,
'504': result.economyFee,
'1008': result.minimumFee,
});
}
private getMempoolBlocks(req: Request, res: Response) {
try {
const result = mempoolBlocks.getMempoolBlocks();

View file

@ -50,6 +50,12 @@ location /api/v1 {
# esplora #
###########
# route /api/fee-estimates to mempool backend instead of esplora
location = /api/fee-estimates {
rewrite ^/api/(.*) /api/v1/$1 break;
try_files /dev/null @mempool-api-v1-cache-hot;
}
# it's ok to cache blockchain data "forever", so we do 30d
location /api/block/ {
rewrite ^/api/(.*) /$1 break;

View file

@ -42,6 +42,12 @@ location /signet/api/v1 {
# esplora #
###########
# route /signet/api/fee-estimates to mempool backend instead of esplora
location = /signet/api/fee-estimates {
rewrite ^/signet/api/(.*) /api/v1/$1 break;
try_files /dev/null @mempool-signet-api-v1-cache-normal;
}
# it's ok to cache blockchain data "forever", so we do 30d
location /signet/api/block/ {
rewrite ^/signet/api/(.*) /$1 break;

View file

@ -42,6 +42,12 @@ location /testnet/api/v1 {
# esplora #
###########
# route /testnet/api/fee-estimates to mempool backend instead of esplora
location = /testnet/api/fee-estimates {
rewrite ^/testnet/api/(.*) /api/v1/$1 break;
try_files /dev/null @mempool-testnet-api-v1-cache-normal;
}
# it's ok to cache blockchain data "forever", so we do 30d
location /testnet/api/block/ {
rewrite ^/testnet/api/(.*) /$1 break;

View file

@ -42,6 +42,12 @@ location /testnet4/api/v1 {
# esplora #
###########
# route /testnet4/api/fee-estimates to mempool backend instead of esplora
location = /testnet4/api/fee-estimates {
rewrite ^/testnet4/api/(.*) /api/v1/$1 break;
try_files /dev/null @mempool-testnet4-api-v1-cache-normal;
}
# it's ok to cache blockchain data "forever", so we do 30d
location /testnet4/api/block/ {
rewrite ^/testnet4/api/(.*) /$1 break;