-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Summary
The new worker proxy routes for Bitcoin RPC are present in the codebase, but the development deployment on GitHub Pages does not actually use them for /#/btc.
Problem
The frontend defines worker-based Bitcoin RPC defaults in src/utils/rpcStorage.ts:
${OPENSCAN_WORKER_URL}/btc/alchemy${OPENSCAN_WORKER_URL}/btc/drpc${OPENSCAN_WORKER_URL}/btc/ankr${OPENSCAN_WORKER_URL}/btc/onfinality/bip122:000000000019d6689c085ae165831e93
However, those defaults are later overwritten by metadata RPC endpoints in getEffectiveRpcUrls():
const defaults = { ...BUILTIN_RPC_DEFAULTS, ...getDefaultRpcEndpoints() };Because getDefaultRpcEndpoints() is spread after BUILTIN_RPC_DEFAULTS, metadata wins.
At runtime, AppContext fetches metadata RPCs on startup and then recalculates the effective RPC map:
fetchAllRpcs()saveMetadataRpcsToStorage(rpcs)setRpcUrlsState(getEffectiveRpcUrls())
As a result, the BTC explorer pages use metadata-provided public endpoints instead of the worker proxy.
Evidence
Current published metadata for BTC mainnet (@openscan/[email protected]/dist/rpcs/btc/mainnet.json) contains direct endpoints such as:
https://mempool.space/apihttps://blockstream.info/apihttps://blockchain.infohttps://btc.drpc.org
So even though the worker routes exist, /#/btc ends up calling direct providers instead of openscan-worker-proxy.
Impact
- GitHub Pages dev deployment does not exercise the new worker BTC proxy routes
- API keys / proxy infrastructure are bypassed for BTC reads
- This makes it look like the worker integration is not working when browsing
/#/btc
Expected behavior
If the intent is for GitHub Pages / default explorer traffic to use the worker proxy for BTC, the effective RPC resolution should preserve worker URLs as the highest-priority defaults.
Suggested fixes
Option A: Give built-in worker defaults higher priority
Change merge order in getEffectiveRpcUrls():
const defaults = { ...getDefaultRpcEndpoints(), ...BUILTIN_RPC_DEFAULTS };This would make worker defaults override metadata defaults.
Option B: Special-case BTC worker priority
Keep metadata priority globally, but for bip122:* networks ensure worker URLs stay first / take precedence.
Option C: Make the behavior explicit
If metadata is intended to override worker defaults, then the UI/dev deployment should not expect worker traffic on /#/btc unless the RPC map is explicitly configured to use worker routes.
Additional issue found
There is also a Bitcoin testnet network ID mismatch:
src/config/networks.json
Uses:
bip122:00000000da84f2bafbbc53dee25a72ae(Testnet4)
src/utils/rpcStorage.ts and worker/src/routes/onfinalityRpc.ts
Use:
bip122:000000000933ea01ad0ee984209779ba
So tbtc and the worker OnFinality route are not using the same CAIP-2 network ID. This should likely be fixed as part of the same cleanup.