Skip to content

feat: add Bitcoin network support and migrate to networkId-based system#190

Merged
AugustoL merged 22 commits intoopenscan-explorer:release/v1.2.0-afrom
AugustoL:feat/bitcoin-network-integration
Feb 5, 2026
Merged

feat: add Bitcoin network support and migrate to networkId-based system#190
AugustoL merged 22 commits intoopenscan-explorer:release/v1.2.0-afrom
AugustoL:feat/bitcoin-network-integration

Conversation

@AugustoL
Copy link
Collaborator

@AugustoL AugustoL commented Jan 30, 2026

Description

Add Bitcoin network support including mainnet (/btc) and Testnet4 (/tbtc), with full page implementations for blocks, transactions, addresses, and mempool. Also includes architecture improvements, code reorganization, and comprehensive e2e tests.

Related Issue

Type of Change

  • Bug fix
  • New feature
  • Refactoring

Changes Made

  • Add Bitcoin mainnet and Testnet4 network support
  • Add Bitcoin mempool page with pagination (100 txs per page, auto-refresh)
  • Add Mempool link to navbar dropdown for Bitcoin networks
  • Fix Bitcoin block page showing 0 transactions
  • Migrate RPC storage from chainId to networkId (CAIP-2 format)
  • Add networkResolver utility for network resolution by slug, chainId, or networkId
  • Remove NetworkAwareRouters in favor of explicit routes
  • Reorganize EVM pages into pages/evm/ subfolder
  • Add comprehensive e2e tests for Bitcoin network pages
  • Add separate GitHub Actions workflow for Bitcoin e2e tests

E2E Test Coverage

24 new tests in separate workflow (e2e-bitcoin.yml):

Category Tests
Block Page Genesis block, SegWit era (481,824), Taproot era (709,632), recent blocks, navigation, error handling
Transaction Page Coinbase, legacy, SegWit, Taproot, OP_RETURN, fee calculations, error handling
Address Page Legacy (P2PKH), P2SH, SegWit (P2WPKH), Taproot (P2TR), UTXOs, transaction history, error handling

Screenshots (if applicable)

Checklist

  • I have run npm run format:fix and npm run lint:fix
  • I have run npm run typecheck with no errors
  • I have run tests with npm run test:run
  • I have tested my changes locally
  • I have updated documentation if needed
  • My code follows the project's architecture patterns

Additional Notes

  • Bitcoin pages mirror the structure of EVM pages for consistency
  • E2E tests use real mainnet data to verify correct handling of different transaction types and address formats across network upgrade eras
  • Bitcoin e2e tests run in separate GitHub Actions workflow to avoid mixing with EVM chain tests

- Add Bitcoin network integration (Phase 1 - Dashboard only)
  - New BitcoinAdapter for JSON-RPC communication
  - Bitcoin dashboard with network stats and recent blocks
  - useBitcoinDashboard hook with 60s refresh interval
  - NetworkRouter component for network type routing

- Migrate from chainId to networkId (CAIP-2 format)
  - RPC storage now uses networkId as keys (e.g., "eip155:1")
  - Add networkResolver utility for network resolution
  - Extract chainId from networkId for EVM networks
  - Update settings page to use networkId-based storage
  - Bump RPC storage version to V3

- Add NetworkType and slug support
  - Networks now have "type" field ("evm" | "bitcoin")
  - Add "slug" field for URL routing (e.g., "btc", "eth")
  - getNetworkUrlPath prefers chainId for EVMs, slug for others

- Update all components to use networkId for RPC lookups
  - Address pages, token displays, contract interactions
  - Network dashboard, block indicator, devtools
@AugustoL AugustoL marked this pull request as draft January 30, 2026 16:55
@github-actions
Copy link

github-actions bot commented Jan 30, 2026

🚀 Preview: https://pr-190--openscan.netlify.app
📝 Commit: 24299336bae577e331bbb07dd9912947bcdbd440

- Add BitcoinBlockDisplay/Page with navigation, stats, and tx list
- Add BitcoinTransactionDisplay/Page with inputs/outputs two-column layout
- Add BitcoinAddressDisplay/Page with balance and UTXO display
- Add BTC price fetching via WBTC pools on Ethereum
- Add fee estimates (fast/medium/slow) to dashboard
- Add USD values alongside BTC values in transaction display
- Add mempool transaction support with multiple RPC fallbacks
- Add Bitcoin address/txid pattern recognition in search
- Update navbar to hide blocks/txs links on Bitcoin networks
- Center search bar in navbar using absolute positioning
- Simplify dashboard stats to show only price, mempool, and fees
- Unify Bitcoin page styling with EVM pages (block-display-card)
- Add network dropdown for all networks (including Bitcoin) with links
  to network home, blocks, transactions, and OpenScan home
- Remove BLOCKS and TRANSACTIONS links from navbar (now in dropdown)
- Move search bar to left side next to network logo
- Move search button inside input with smaller icon
- Fix dropdown hover gap issue with padding approach
- Clean up duplicate CSS styles and unused code
- Add BitcoinBlocksPage for /btc/blocks route with pagination
- Add BitcoinTransactionsPage for /btc/txs route showing recent txs
- Add BlocksPageRouter and TxsPageRouter for network-aware routing
- Fix navbar dropdown links to use getNetworkUrlPath for correct URLs
- Create bitcoinFormatters.ts with formatting functions
- Create bitcoinUtils.ts with business logic functions
- Create bitcoinConstants.ts with shared constants
- Update all Bitcoin components to use shared utilities
- Remove ~230 lines of duplicated code
- Add explicit /btc/* routes before :networkId catch-all
- Remove NetworkRouter component (no longer needed)
- EVM routes use LazyChain directly
- Add Bitcoin Testnet4 network configuration (slug: tbtc)
- Add /tbtc/* routes for testnet4 pages
- Update Bitcoin page components to extract network slug from URL path
  instead of useParams (required since routes don't have :networkId param)
- Add Mempool link to navbar dropdown for Bitcoin networks
- Add BitcoinMempoolPage component showing pending transactions
- Add getMempoolSummary and getMempoolTransactions methods to BitcoinAdapter
- Paginate by 100 transactions per page for faster loading
- Fetch transaction details in parallel for current page only
- Show page indicator in header and clean pagination controls
- Auto-refresh every 30 seconds
- Add pagination-info CSS class
- Fix NetworkAwareRouters to extract network from URL path segment
  instead of only useParams (which was undefined for /btc/* routes)
- Fetch block header in parallel with block data for reliable nTx count
- Use header's nTx as primary source with fallbacks
…utes

- Remove NetworkAwareRouters.tsx - no longer needed
- Use lazy components directly in App.tsx routes
- Bitcoin routes (btc/*, tbtc/*) use Bitcoin-specific components
- EVM routes (:networkId/*) use EVM components
- Simpler and more explicit routing
- Move EVM-specific pages to pages/evm/: address, block, blocks,
  tx, txs, network, gastracker, tokenDetails, mempool
- Update all imports in LazyComponents.tsx
- Fix relative imports in moved files
- Keep shared pages (about, contact, home, etc.) at pages/ root
- Mirrors existing pages/bitcoin/ organization
@AugustoL AugustoL marked this pull request as ready for review February 2, 2026 16:33
@AugustoL AugustoL requested a review from MatiasOS February 2, 2026 16:33
- Add fixture data with real mainnet blocks, transactions, and addresses
- Test different eras: Genesis, SegWit (481824), Taproot (709632)
- Test all address types: Legacy (P2PKH), P2SH, SegWit (P2WPKH), Taproot (P2TR)
- Test transaction types: coinbase, legacy, SegWit, Taproot, OP_RETURN
- Add page object models for Bitcoin block, transaction, and address pages
- Add wait helpers for Bitcoin page content
- Create e2e-bitcoin.yml to run Bitcoin tests independently
- Update e2e.yml to exclude Bitcoin tests (--ignore-pattern)
Prevents 'No transactions found' flash while transactions are still loading
Update all Bitcoin pages to use truncateBlockHash for block hashes
@AugustoL
Copy link
Collaborator Author

AugustoL commented Feb 3, 2026

@MatiasOS ready for review

├── services/ # Blockchain data services
│ ├── adapters # General reusable adapters
│ ├── adapters/ # General reusable adapters
│ │ └── BitcoinAdapter/ # Bitcoin network adapter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is a typo. But Bitcoion should be at same level as EVM right?

Resolve merge conflicts in package.json (bump @openscan/network-connectors
to ^1.3.0) and bun.lock.
Resolve merge conflict in navbar imports (keep Link and useSettings).
@AugustoL AugustoL merged commit 9bdec21 into openscan-explorer:release/v1.2.0-a Feb 5, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants