Skip to content

feat(zcash): add AI analysis for blocks, transactions and addresses - #413

Merged
MatiasOS merged 3 commits into
issue-398-zcash-addressfrom
issue-398-zcash-ai-analysis
Nov 21, 2026
Merged

MatiasOS merged 3 commits into
issue-398-zcash-addressfrom
issue-398-zcash-ai-analysis

Conversation

@MatiasOS

@MatiasOS MatiasOS commented Sep 14, 2026 •

Copy link
Copy Markdown
Member

Description

Adds AI analysis to the Zcash block, transaction and address pages. It's the last PR in the Zcash stack. The panel is the same AIAnalysisPanel the Bitcoin pages use, placed in the same spot.

Prompt rules, for both the power-user and regular-user configs:

  • Amounts are in ZEC.
  • Value balances are explained with their sign: positive means value left a shielded pool, negative means it entered one.
  • Shielded amounts, senders and recipients are never guessed.
  • Empty transparent inputs and outputs are not treated as errors.
  • No EVM terminology.
  • For addresses, a blocked address index is reported as data that couldn't be loaded, not as a zero balance.

Context sent to the model. Each page builds a compact context in aiContext.ts:

  • Amounts are converted from zatoshis, and every field name carries its unit (feeZEC, valueBalanceZEC, …).
  • Proofs, signatures, ciphertexts and the Equihash solution are left out.
  • A fee is only included when every transparent input value is known. Before input lookup, the model sees no fee instead of a wrong one.

Related Issue

Closes #398. Stacked on #412.

Type of Change

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

Changes Made

  • AIAnalysisType gains zcash_transaction, zcash_block and zcash_address.
  • The worker's VALID_ANALYSIS_TYPES allowlist gains the same three types.
  • AIPromptTemplates.ts: Zcash configs in the power and regular maps, plus the buildPrompt cases.
  • src/components/pages/zcash/aiContext.ts builds the three contexts; unit tests are in aiContext.test.ts.
  • zatToZec added to zcashUtils.
  • AIAnalysisPanel added to ZcashBlockDisplay, ZcashTransactionDisplay and ZcashAddressDisplay, each wrapped in page-with-analysis. Cache keys follow the Bitcoin pattern, e.g. openscan_ai_zcash_block_${networkId}_${hash}.

Screenshots (if applicable)

Checked locally against mocked RPC data:

  • the block page
  • the Ironwood-only transaction, at desktop width and at 400px
  • a transparent address with the address index available

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

  • Most of the diff in the three display components is re-indentation from the new wrapper; git diff -w shows the real change.
  • The panel sends nothing until the user clicks Analyze, so it adds no RPC calls against the 5 req/min budget.
  • The worker allowlist also lacks the solana_* types. That's a pre-existing gap and out of scope here.
  • Dropped from this PR: the Bun 1.4 lockfile commit (already on dev via build(deps): regenerate bun.lock for bun 1.4 and clear npm audit #423) and the metadata bump (moved to feat(adapter): add Zcash data layer #406, which needs it).
  • Tests (before the review follow-up):
    • npm run test:run: 156 passing.
    • Hermetic Zcash e2e specs (dashboard, blocks, transactions, mempool, search, address): 20 passed.

Review follow-up

  • Only public data goes to the AI provider. The address panel is shown only when the address has a transparent receiver; a Sapling, Sprout or receiver-less unified address has nothing public to analyze.
  • Address balance fields are transparentBalanceZEC and transparentReceivedZEC, so the model can't present a unified address's transparent receiver as its whole balance.
  • The block context includes the shielded coinbase reward, matching the block page.
  • The transaction context uses the coinbase | unknown | known fee result.
  • Deploy the worker first: its VALID_ANALYSIS_TYPES allowlist must include the three Zcash types before this frontend ships.
  • buildZcashPrompt follows the existing per-chain builders; folding all of them into one is out of scope here.
  • Tests: a Sprout transaction, a shielded coinbase, and the panel shown only for addresses with public data.

Tests after the follow-up

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

@MatiasOS
MatiasOS added this pull request to stack #414 September 15, 2026 00:17
@github-actions

github-actions Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

🚀 Preview: https://pr-413--openscan.netlify.app
📝 Commit: 6fd695d63041eb383bd2d72df8bb9ee53596b071

- The address panel is shown only when the address has a transparent
  receiver: a Sapling, Sprout or receiver-less unified address has
  nothing public to analyze, so it isn't sent to the AI provider.
- Address balance fields become transparentBalanceZEC and
  transparentReceivedZEC, so the model can't report a unified
  address's transparent receiver as its whole balance.
- Block context includes the shielded coinbase reward, matching the
  block page.
- Transaction context uses the coinbase | unknown | known fee result.
- Tests: a Sprout transaction, a shielded coinbase, and the panel
  shown only for addresses with public data.
@MatiasOS
MatiasOS force-pushed the issue-398-zcash-ai-analysis branch from 6c67dde to 6fd695d 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