Skip to content

feat(search): route Zcash addresses and block hashes - #411

Merged
MatiasOS merged 4 commits into
issue-398-zcash-mempoolfrom
issue-398-zcash-search
Nov 21, 2026
Merged

MatiasOS merged 4 commits into
issue-398-zcash-mempoolfrom
issue-398-zcash-search

Conversation

@MatiasOS

@MatiasOS MatiasOS commented Sep 14, 2026 •

Copy link
Copy Markdown
Member

Description

Makes the network search box work on Zcash networks.

  • Addresses: transparent (t1/t3, tm/t2), Sapling (zs1, ztestsapling1), unified (u1, utest1), Sprout (zc, zt) and TEX (tex1, textest1) addresses go to /{network}/address/:address. Before this change they were rejected as an invalid search. They're only recognized while a Zcash network is selected.
  • Heights: go to the block page, as before.
  • 64-character hashes: Zcash block hashes and txids have the same shape, so a hash still goes to the transaction page. When no transaction matches, that page now looks the hash up as a block and redirects to it.

Related Issue

Part of #398. Stacked on #410.

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactoring
  • Performance improvement
  • Other (please describe):

Changes Made

  • useSearch: recognizes Zcash addresses, using the existing isZcashAddress util, when the selected network is Zcash.
  • ZcashTransactionPage: if getrawtransaction fails for a 64-character hex hash, it tries getblock with that hash and redirects to the block page. Otherwise it shows the original error.
  • e2e/fixtures/rpcMock.ts: function handlers can now return rpcError(code, message), which answers with a JSON-RPC error instead of a result.
  • The Zcash RPC mock now fails the way Zebra does for unknown transactions and block hashes. It still serves:
    • the transactions spent by the fixture's inputs
    • pending transactions for mempool txids
  • A hermetic e2e spec at e2e/tests/shared/mocked/zcash-search.spec.ts. It covers:
    • searching by height and by txid
    • a block-hash redirect
    • a hash that matches nothing
    • an invalid search term

Screenshots (if applicable)

N/A (no visual changes)

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

  • Redirect cost: redirecting a block hash takes at most three calls: the failed transaction lookup, the block lookup, and the block page's own fetch.
  • Address pages: address search now routes correctly, but the address page itself arrives in the next PR of the stack. Its e2e coverage lands there too.
  • Tests (before the review follow-up):
    • npm run test:run: 151 passing.
    • Hermetic Zcash e2e specs (dashboard, blocks, transactions, mempool, search): 16 passed.

Review follow-up

  • Block-hash fallback only after a definitive answer. The transaction page tries a hash as a block only when the node answered that no such transaction exists. A rate-limited or unreachable endpoint said nothing about the hash, so it no longer triggers a second round of retries (~90s and up to six requests).
  • One getblock per block-hash search. The page redirects to /block/<height> and hands the block it already fetched to the block page, which doesn't refetch it.
  • isBitcoinTxid is now isHex64Hash (shared with the transaction page); Zcash networks are matched with isZcashNetwork; addresses are checked against the selected network, and all-uppercase Bech32m addresses are lowercased.
  • The "Zcash address on the home page" case from the review doesn't apply: the home page uses HomeSearchBar (EVM-only, with its own network picker), and useSearch only runs on network pages. useSearch still asks for a network when there isn't one.
  • E2E: one getblock per block-hash search, no block lookup for a rate-limited hash, and an uppercase unified address.

Tests after the follow-up

  • npm run test:run: 199 passing.
  • Hermetic Zcash e2e specs at this PR: 30 passed, no retries.

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

🚀 Preview: https://pr-411--openscan.netlify.app
📝 Commit: d72ca162c9f0edbef7f37add46955d0b418912c6

Zcash block hashes and txids are both 64 hex characters, so search keeps sending hashes to the transaction page, which now looks the hash up as a block and redirects when no transaction matches.
- The transaction page only tries a hash as a block when the node
  answered that no such transaction exists. A rate-limited or
  unreachable endpoint said nothing about the hash, so it no longer
  triggers a second round of retries (~90s and up to six requests).
- A hash that is a block redirects to /block/<height> and hands the
  block it already fetched to the block page, which doesn't refetch it
  (and caches it when it already has a successor).
- ZcashRpcError.answered tells definitive JSON-RPC answers apart from
  HTTP and network failures.
- Search: isBitcoinTxid becomes isHex64Hash (shared in hashUtils with
  the transaction page), Zcash networks are matched with
  isZcashNetwork, addresses are checked against the selected network,
  and all-uppercase Bech32m addresses are lowercased.
- E2E: one getblock per block-hash search, no block lookup for a
  rate-limited hash, and uppercase unified addresses.
@MatiasOS
MatiasOS force-pushed the issue-398-zcash-search branch from f4e3bb8 to d72ca16 Compare November 20, 2026 23:44
@MatiasOS
MatiasOS merged commit 7ae49ff into dev Nov 21, 2026
7 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.

1 participant