From c9c3790b5db63bb57d2ec4618551206f5b27621d Mon Sep 17 00:00:00 2001 From: junderw Date: Sun, 31 May 2026 09:52:38 +0900 Subject: [PATCH 1/3] feat: Overwrite the esplora API for fees always --- backend/src/api/bitcoin/bitcoin.routes.ts | 41 +++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/backend/src/api/bitcoin/bitcoin.routes.ts b/backend/src/api/bitcoin/bitcoin.routes.ts index 4b8aecab8..c0fe41b7e 100644 --- a/backend/src/api/bitcoin/bitcoin.routes.ts +++ b/backend/src/api/bitcoin/bitcoin.routes.ts @@ -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,46 @@ 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({ + '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(); From 2f70d4e59e01e7a2fb1754a1bee0e91df7f47691 Mon Sep 17 00:00:00 2001 From: junderw Date: Sun, 31 May 2026 10:06:30 +0900 Subject: [PATCH 2/3] Add nginx proxy to fee-estimates --- production/nginx/location-api.conf | 6 ++++++ production/nginx/location-signet-api.conf | 6 ++++++ production/nginx/location-testnet-api.conf | 6 ++++++ production/nginx/location-testnet4-api.conf | 6 ++++++ 4 files changed, 24 insertions(+) diff --git a/production/nginx/location-api.conf b/production/nginx/location-api.conf index c7fabfb69..686b80dca 100644 --- a/production/nginx/location-api.conf +++ b/production/nginx/location-api.conf @@ -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; diff --git a/production/nginx/location-signet-api.conf b/production/nginx/location-signet-api.conf index d3292b424..c184c4272 100644 --- a/production/nginx/location-signet-api.conf +++ b/production/nginx/location-signet-api.conf @@ -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; diff --git a/production/nginx/location-testnet-api.conf b/production/nginx/location-testnet-api.conf index d43a51ce5..4b9433bb8 100644 --- a/production/nginx/location-testnet-api.conf +++ b/production/nginx/location-testnet-api.conf @@ -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; diff --git a/production/nginx/location-testnet4-api.conf b/production/nginx/location-testnet4-api.conf index 1df502317..11600d9e2 100644 --- a/production/nginx/location-testnet4-api.conf +++ b/production/nginx/location-testnet4-api.conf @@ -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; From ee55d33e6a80b3ac569280ddf66dda9eddb52891 Mon Sep 17 00:00:00 2001 From: junderw Date: Sun, 31 May 2026 10:22:05 +0900 Subject: [PATCH 3/3] Deprecation warning to esplora fees --- backend/src/api/bitcoin/bitcoin.routes.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/src/api/bitcoin/bitcoin.routes.ts b/backend/src/api/bitcoin/bitcoin.routes.ts index c0fe41b7e..050af99fd 100644 --- a/backend/src/api/bitcoin/bitcoin.routes.ts +++ b/backend/src/api/bitcoin/bitcoin.routes.ts @@ -144,6 +144,7 @@ class BitcoinRoutes { 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,