From 6e17d411a1563068c750d06d50684a4b9329d7f8 Mon Sep 17 00:00:00 2001 From: Mati OS Date: Mon, 14 Sep 2026 20:56:21 -0300 Subject: [PATCH 1/3] feat(ai): add zcash analysis types, prompts and worker allowlist --- src/services/AIPromptTemplates.ts | 82 +++++++++++++++++++++++++++++++ src/types/index.ts | 3 ++ worker/src/types.ts | 3 ++ 3 files changed, 88 insertions(+) diff --git a/src/services/AIPromptTemplates.ts b/src/services/AIPromptTemplates.ts index 0d189f23..b6ced178 100644 --- a/src/services/AIPromptTemplates.ts +++ b/src/services/AIPromptTemplates.ts @@ -57,6 +57,10 @@ export function buildPrompt( return buildBitcoinBlockPrompt(config, context, promptContext); case "bitcoin_address": return buildBitcoinAddressPrompt(config, context, promptContext); + case "zcash_transaction": + case "zcash_block": + case "zcash_address": + return buildZcashPrompt(config, context, promptContext); case "solana_transaction": case "solana_block": case "solana_account": @@ -188,6 +192,43 @@ const POWER_STABLE_CONFIGS: Record = { sections: ["Address Analysis", "Balance and UTXOs", "Activity", "Notable Aspects"], customRules: "Express amounts in BTC. Never use gas, wei, Gwei, or EVM terminology.", }, + zcash_transaction: { + role: "Zcash blockchain analyst", + conciseness: "6-8 sentences", + focusAreas: + "how value moves between the transparent and shielded pools (Sprout, Sapling, Orchard, Ironwood), transparent inputs and outputs, the fee derived from value balances, coinbase vs regular, and expiry height", + audience: "senior Zcash developer", + task: "Analyze this Zcash transaction", + sections: [ + "Transaction Analysis", + "Transparent and Shielded Flow", + "Fee Analysis", + "Notable Aspects", + ], + customRules: + "Express amounts in ZEC. A positive value balance means value left that shielded pool; a negative one means value entered it. Shielded amounts, senders and recipients are encrypted: never guess them, and do not treat empty transparent inputs or outputs as an error. Never use gas, wei, Gwei, or EVM terminology.", + }, + zcash_block: { + role: "Zcash blockchain analyst", + conciseness: "3-5 sentences", + focusAreas: + "transaction count, how many transactions use each shielded pool, coinbase outputs (miner reward and funding streams), difficulty, and the value pool balances after the block", + audience: "senior Zcash developer", + task: "Analyze this Zcash block", + sections: ["Block Analysis", "Shielded Activity", "Reward and Value Pools", "Notable Aspects"], + customRules: "Express amounts in ZEC. Never use gas, wei, Gwei, or EVM terminology.", + }, + zcash_address: { + role: "Zcash blockchain analyst", + conciseness: "4-6 sentences", + focusAreas: + "address type (transparent, Sapling, unified, Sprout, TEX), its receivers, transparent balance and history when available, and the privacy implications of the address type", + audience: "senior Zcash developer", + task: "Analyze this Zcash address", + sections: ["Address Analysis", "Balance and Activity", "Privacy", "Notable Aspects"], + customRules: + "Express amounts in ZEC. Shielded balances are not publicly visible. If the address index was unavailable, say the data could not be loaded rather than implying a zero balance. Never use gas, wei, Gwei, or EVM terminology.", + }, solana_transaction: { role: "Solana blockchain analyst", conciseness: "6-8 sentences", @@ -287,6 +328,36 @@ const REGULAR_STABLE_CONFIGS: Record = { sections: ["Overview", "Balance"], customRules: "Express amounts in BTC. No EVM terminology.", }, + zcash_transaction: { + role: "Zcash educator", + conciseness: "4-6 sentences", + focusAreas: "what happened, whether funds moved publicly or privately, and the fee paid", + audience: "general user", + task: "Explain this Zcash transaction in simple, easy-to-understand language", + sections: ["What Happened", "Public or Private", "Fee Details"], + customRules: + "Use simple language. Express amounts in ZEC. Explain that shielded amounts and parties are private instead of guessing them. Never use gas, wei, or EVM terminology.", + }, + zcash_block: { + role: "Zcash educator", + conciseness: "2-3 sentences", + focusAreas: + "what happened in this block, how many transactions it included, and how many were private", + audience: "general user", + task: "Summarize this Zcash block in simple terms", + sections: ["Block Summary", "Activity"], + customRules: "Express amounts in ZEC. No EVM terminology.", + }, + zcash_address: { + role: "Zcash educator", + conciseness: "3-4 sentences", + focusAreas: + "what kind of address this is, whether its balance is public, and its balance when available", + audience: "general user", + task: "Provide a simple overview of this Zcash address", + sections: ["Overview", "Privacy", "Balance"], + customRules: "Express amounts in ZEC. No EVM terminology.", + }, solana_transaction: { role: "Solana educator", conciseness: "4-6 sentences", @@ -449,6 +520,17 @@ function buildBitcoinAddressPrompt( }; } +function buildZcashPrompt( + config: PromptConfig, + context: Record, + promptContext: PromptContext, +): PromptPair { + return { + system: buildSystemPrompt(config, promptContext), + user: formatContext(context), + }; +} + function formatContext(context: Record): string { const sanitized = sanitizeContextForPrompt(context); const json = safeJsonStringify(sanitized, 2); diff --git a/src/types/index.ts b/src/types/index.ts index caa09c62..f0f93fc1 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -950,6 +950,9 @@ export type AIAnalysisType = | "bitcoin_transaction" | "bitcoin_block" | "bitcoin_address" + | "zcash_transaction" + | "zcash_block" + | "zcash_address" | "solana_transaction" | "solana_block" | "solana_account"; diff --git a/worker/src/types.ts b/worker/src/types.ts index e3ae75ad..e032dd5e 100644 --- a/worker/src/types.ts +++ b/worker/src/types.ts @@ -6,6 +6,9 @@ export const VALID_ANALYSIS_TYPES = [ "bitcoin_transaction", "bitcoin_block", "bitcoin_address", + "zcash_transaction", + "zcash_block", + "zcash_address", ] as const; export type AIAnalysisType = (typeof VALID_ANALYSIS_TYPES)[number]; From 9349c706ae7d4b18115b0c13c461f1100e06338d Mon Sep 17 00:00:00 2001 From: Mati OS Date: Mon, 14 Sep 2026 20:56:22 -0300 Subject: [PATCH 2/3] feat(zcash): add AI analysis panel to block, tx and address pages --- .../pages/zcash/ZcashAddressDisplay.tsx | 479 ++++++++-------- .../pages/zcash/ZcashBlockDisplay.tsx | 521 +++++++++-------- .../pages/zcash/ZcashTransactionDisplay.tsx | 532 +++++++++--------- src/components/pages/zcash/aiContext.test.ts | 128 +++++ src/components/pages/zcash/aiContext.ts | 132 +++++ src/utils/zcashUtils.ts | 7 + 6 files changed, 1063 insertions(+), 736 deletions(-) create mode 100644 src/components/pages/zcash/aiContext.test.ts create mode 100644 src/components/pages/zcash/aiContext.ts diff --git a/src/components/pages/zcash/ZcashAddressDisplay.tsx b/src/components/pages/zcash/ZcashAddressDisplay.tsx index e8c3dc7e..d4300454 100644 --- a/src/components/pages/zcash/ZcashAddressDisplay.tsx +++ b/src/components/pages/zcash/ZcashAddressDisplay.tsx @@ -1,10 +1,13 @@ -import React, { useState } from "react"; +import React, { useMemo, useState } from "react"; import { useTranslation } from "react-i18next"; import { Link } from "react-router-dom"; +import { getNetworkById } from "../../../config/networks"; import type { ZcashAddress, ZcashRpcAvailability, ZcashUnifiedReceivers } from "../../../types"; import { formatNumber, formatZEC, truncateHash } from "../../../utils/zcashFormatters"; +import AIAnalysisPanel from "../../common/AIAnalysis/AIAnalysisPanel"; import CopyButton from "../../common/CopyButton"; import FieldLabel from "../../common/FieldLabel"; +import { buildAddressAnalysisContext } from "./aiContext"; import { ADDRESS_TYPE_LABEL_KEYS } from "./labels"; const RECEIVER_ORDER = ["orchard", "sapling", "p2pkh", "p2sh"] as const; @@ -58,260 +61,274 @@ const ZcashAddressDisplay: React.FC = React.memo( ); - return ( -
-
- {t("address.title")} - - {t(ADDRESS_TYPE_LABEL_KEYS[type])} - -
- - {type === "unknown" && ( -
- {t("address.unknownNotice")} -
- )} - {isShielded && ( -
{t("address.shieldedNotice")}
- )} - {unifiedWithoutTransparent && ( -
{t("address.unifiedShieldedNotice")}
- )} - {type === "tex" && ( -
{t("address.texNotice")}
- )} - {(indexUnsupported || receiversUnsupported) && ( -
-

- {indexUnsupported ? t("address.indexUnsupported") : t("address.receiversUnsupported")} -

- - {t("address.configureRpc")} - -
- )} + const network = getNetworkById(networkId); + const aiContext = useMemo(() => buildAddressAnalysisContext(address), [address]); -
-
- - - {address.address} - + return ( +
+
+
+ {t("address.title")} + + {t(ADDRESS_TYPE_LABEL_KEYS[type])}
- {receivers && ( -
- - {receivers.availability === "ok" && receivers.data ? ( -
    - {RECEIVER_ORDER.flatMap((kind) => { - const value = receivers.data?.[kind]; - if (!value) return []; - const isTransparent = kind === "p2pkh" || kind === "p2sh"; - return [ -
  • - {t(RECEIVER_LABEL_KEYS[kind])} - {isTransparent ? ( - - {value} - - ) : ( - - {truncateHash(value, "long")} - - )} - -
  • , - ]; - })} -
- ) : ( - unavailable(receivers.availability) - )} + {type === "unknown" && ( +
+ {t("address.unknownNotice")}
)} - - {balance && !indexUnsupported && ( -
- - {balance.availability === "ok" && balance.data ? ( - - - {formatZEC(balance.data.balanceZat, currency)} - - {type === "unified" && transparentAddress && ( - - {" "} - {t("address.transparentReceiverNote", { - address: truncateHash(transparentAddress, "short"), - })} - - )} - - ) : ( - unavailable(balance.availability) - )} + {isShielded && ( +
{t("address.shieldedNotice")}
+ )} + {unifiedWithoutTransparent && ( +
{t("address.unifiedShieldedNotice")}
+ )} + {type === "tex" && ( +
{t("address.texNotice")}
+ )} + {(indexUnsupported || receiversUnsupported) && ( +
+

+ {indexUnsupported + ? t("address.indexUnsupported") + : t("address.receiversUnsupported")} +

+ + {t("address.configureRpc")} +
)} - {balance?.availability === "ok" && balance.data?.receivedZat !== undefined && ( +
- {formatZEC(balance.data.receivedZat, currency)} + + {address.address} + +
- )} - {utxos && !indexUnsupported && utxos.availability !== "ok" && ( -
- - {unavailable(utxos.availability)} -
- )} + {receivers && ( +
+ + {receivers.availability === "ok" && receivers.data ? ( +
    + {RECEIVER_ORDER.flatMap((kind) => { + const value = receivers.data?.[kind]; + if (!value) return []; + const isTransparent = kind === "p2pkh" || kind === "p2sh"; + return [ +
  • + {t(RECEIVER_LABEL_KEYS[kind])} + {isTransparent ? ( + + {value} + + ) : ( + + {truncateHash(value, "long")} + + )} + +
  • , + ]; + })} +
+ ) : ( + unavailable(receivers.availability) + )} +
+ )} - {txids && !indexUnsupported && txids.availability !== "ok" && ( -
- - {unavailable(txids.availability)} -
- )} + {balance && !indexUnsupported && ( +
+ + {balance.availability === "ok" && balance.data ? ( + + + {formatZEC(balance.data.balanceZat, currency)} + + {type === "unified" && transparentAddress && ( + + {" "} + {t("address.transparentReceiverNote", { + address: truncateHash(transparentAddress, "short"), + })} + + )} + + ) : ( + unavailable(balance.availability) + )} +
+ )} - {hasError && ( -
- + {balance?.availability === "ok" && balance.data?.receivedZat !== undefined && ( +
+ + {formatZEC(balance.data.receivedZat, currency)} +
+ )} + + {utxos && !indexUnsupported && utxos.availability !== "ok" && ( +
+ + {unavailable(utxos.availability)} +
+ )} + + {txids && !indexUnsupported && txids.availability !== "ok" && ( +
+ + {unavailable(txids.availability)} +
+ )} + + {hasError && ( +
+ +
+ )} +
+ + {utxos?.availability === "ok" && utxos.data && ( +
+
+ +
+ {showUtxos && + (utxos.data.length === 0 ? ( +

{t("address.noUtxos")}

+ ) : ( +
+ {utxos.data.map((utxo, index) => ( +
+ {index} +
+ + + {truncateHash(utxo.txid, "long")}:{utxo.outputIndex} + + + + {formatZEC(utxo.valueZat, currency)} + + + + {t("address.atHeight", { height: formatNumber(utxo.height) })} + + +
+
+ ))} +
+ ))}
)} -
- {utxos?.availability === "ok" && utxos.data && ( -
-
- -
- {showUtxos && - (utxos.data.length === 0 ? ( -

{t("address.noUtxos")}

- ) : ( -
- {utxos.data.map((utxo, index) => ( -
- {index} -
- - - {truncateHash(utxo.txid, "long")}:{utxo.outputIndex} - - - - {formatZEC(utxo.valueZat, currency)} - - - - {t("address.atHeight", { height: formatNumber(utxo.height) })} - - -
+ {txids?.availability === "ok" && recentTxids.length > 0 && ( +
+
+ +
+ {showTransactions && ( +
+ {pageTxids.map((txid, index) => ( +
+ {pageStart + index} + + + {txid} + +
))} + {txPages > 1 && ( +
+ + + {t("txsPage.pageInfo", { page: currentTxPage, totalPages: txPages })} + + +
+ )}
- ))} -
- )} - - {txids?.availability === "ok" && recentTxids.length > 0 && ( -
-
- + )}
- {showTransactions && ( -
- {pageTxids.map((txid, index) => ( -
- {pageStart + index} - - - {txid} - - -
- ))} - {txPages > 1 && ( -
- - - {t("txsPage.pageInfo", { page: currentTxPage, totalPages: txPages })} - - -
- )} -
- )} -
- )} + )} +
+
); }, diff --git a/src/components/pages/zcash/ZcashBlockDisplay.tsx b/src/components/pages/zcash/ZcashBlockDisplay.tsx index f6f8d1b4..e1961508 100644 --- a/src/components/pages/zcash/ZcashBlockDisplay.tsx +++ b/src/components/pages/zcash/ZcashBlockDisplay.tsx @@ -1,6 +1,7 @@ -import React, { useState } from "react"; +import React, { useMemo, useState } from "react"; import { useTranslation } from "react-i18next"; import { Link } from "react-router-dom"; +import { getNetworkById } from "../../../config/networks"; import { ZCASH_SHIELDED_POOLS, ZCASH_TREE_POOLS } from "../../../config/zcashConstants"; import { useSettings } from "../../../context/SettingsContext"; import { useTimeAgo } from "../../../hooks/useTimeAgo"; @@ -13,10 +14,12 @@ import { formatZEC, truncateBlockHash, } from "../../../utils/zcashFormatters"; +import AIAnalysisPanel from "../../common/AIAnalysis/AIAnalysisPanel"; import CopyButton from "../../common/CopyButton"; import FieldLabel from "../../common/FieldLabel"; import HelperTooltip from "../../common/HelperTooltip"; import LongString from "../../common/LongString"; +import { buildBlockAnalysisContext } from "./aiContext"; import { VALUE_POOL_LABEL_KEYS } from "./labels"; import { ZcashPoolChip } from "./ZcashCells"; import ZcashValuePools from "./ZcashValuePools"; @@ -84,305 +87,323 @@ const ZcashBlockDisplay: React.FC = React.memo( ]; }); + const network = getNetworkById(networkId); + const aiContext = useMemo(() => buildBlockAnalysisContext(block), [block]); + return ( -
-
-
- {block.height > 0 && ( - - ← - - )} -
- {t("block.title")} - #{block.height.toLocaleString()} +
+
+
+
+ {block.height > 0 && ( + + ← + + )} +
+ {t("block.title")} + #{block.height.toLocaleString()} +
+ {block.nextBlockHash && ( + + → + + )} + • + + {timeAgo(block.time)} + ({formatTimestamp(block.time)}) +
- {block.nextBlockHash && ( - - → - + {block.confirmations !== undefined && ( + + {confirmationsAtLeast + ? t("block.confirmationsAtLeast", { count: block.confirmations }) + : t("block.confirmations", { count: block.confirmations })} + {showTooltips && ( + + )} + )} - • - - {timeAgo(block.time)} - ({formatTimestamp(block.time)}) -
- {block.confirmations !== undefined && ( - - {confirmationsAtLeast - ? t("block.confirmationsAtLeast", { count: block.confirmations }) - : t("block.confirmations", { count: block.confirmations })} - {showTooltips && ( - - )} - - )} -
-
-
- - - {block.hash} - - -
+
+
+ + + {block.hash} + + +
+ +
+
+ {rewardZat > 0 && ( +
+ + + {formatZEC(rewardZat, currency)} + {coinbaseShieldedZat > 0 && ( + + {" "} + {t("block.shieldedReward", { + amount: formatZEC(coinbaseShieldedZat, currency), + })} + + )} + +
+ )} -
-
- {rewardZat > 0 && (
- - {formatZEC(rewardZat, currency)} - {coinbaseShieldedZat > 0 && ( - - {" "} - {t("block.shieldedReward", { - amount: formatZEC(coinbaseShieldedZat, currency), - })} + + {t("block.txCount", { count: block.nTx })} + {poolCounts.length > 0 && ( + + {poolCounts.map(({ pool, count }) => ( + + {t("block.poolTxCount", { + count, + pool: t(VALUE_POOL_LABEL_KEYS[pool]), + })} + + ))} )}
- )} -
- - - {t("block.txCount", { count: block.nTx })} - {poolCounts.length > 0 && ( - - {poolCounts.map(({ pool, count }) => ( - - {t("block.poolTxCount", { count, pool: t(VALUE_POOL_LABEL_KEYS[pool]) })} - - ))} + {block.transparentOutputZat !== undefined && ( +
+ + + {formatZEC(block.transparentOutputZat, currency)} - )} - +
+ )}
- {block.transparentOutputZat !== undefined && ( +
- - {formatZEC(block.transparentOutputZat, currency)} - + {formatDifficulty(block.difficulty)}
- )} -
- -
-
- - {formatDifficulty(block.difficulty)} -
- -
- - {formatSize(block.size)} -
- {block.previousBlockHash && (
- - - {truncateBlockHash(block.previousBlockHash)} - - + {formatSize(block.size)}
- )} - {block.nextBlockHash && ( -
- - - - {truncateBlockHash(block.nextBlockHash)} - - -
- )} -
-
+ {block.previousBlockHash && ( +
+ + + + {truncateBlockHash(block.previousBlockHash)} + + +
+ )} - {coinbaseOutputs.length > 0 && ( -
- -
    - {coinbaseOutputs.map((output, index) => ( - // biome-ignore lint/suspicious/noArrayIndexKey: outputs keep their on-chain order -
  • - {output.address ? ( - - {output.address} + {block.nextBlockHash && ( +
    + + + + {truncateBlockHash(block.nextBlockHash)} - ) : ( - {t("block.noAddress")} - )} - - {formatZEC(output.valueZat, currency)} -
  • - ))} -
+
+ )} +
- )} - -
- - {showMoreDetails && ( -
- - {block.merkleRoot} - - {block.blockCommitments && ( - - {block.blockCommitments} - - )} - {block.finalSaplingRoot && ( - - {block.finalSaplingRoot} - - )} - {block.finalOrchardRoot && ( - - {block.finalOrchardRoot} - - )} - - {block.version} - - - {block.bits} - - - {block.nonce} - - {block.solution && ( - - - - )} - {treeSizes.length > 0 && ( - - {treeSizes.join(" · ")} - - )} + {coinbaseOutputs.length > 0 && ( +
+ +
    + {coinbaseOutputs.map((output, index) => ( + // biome-ignore lint/suspicious/noArrayIndexKey: outputs keep their on-chain order +
  • + {output.address ? ( + + {output.address} + + ) : ( + {t("block.noAddress")} + )} + + {formatZEC(output.valueZat, currency)} + +
  • + ))} +
)} -
- {txids.length > 0 && (
- {showTransactions && ( + {showMoreDetails && (
-
- {txids.map((txid, index) => ( -
- {index} - - - {txid} - - -
- ))} -
+ + {block.merkleRoot} + + {block.blockCommitments && ( + + {block.blockCommitments} + + )} + {block.finalSaplingRoot && ( + + {block.finalSaplingRoot} + + )} + {block.finalOrchardRoot && ( + + {block.finalOrchardRoot} + + )} + + {block.version} + + + {block.bits} + + + {block.nonce} + + {block.solution && ( + + + + )} + {treeSizes.length > 0 && ( + + {treeSizes.join(" · ")} + + )}
)}
+ + {txids.length > 0 && ( +
+ + + {showTransactions && ( +
+
+ {txids.map((txid, index) => ( +
+ {index} + + + {txid} + + +
+ ))} +
+
+ )} +
+ )} +
+ + {block.valuePools && block.valuePools.length > 0 && ( + )}
- - {block.valuePools && block.valuePools.length > 0 && ( - - )} +
); }, diff --git a/src/components/pages/zcash/ZcashTransactionDisplay.tsx b/src/components/pages/zcash/ZcashTransactionDisplay.tsx index 04e6952a..38ce037f 100644 --- a/src/components/pages/zcash/ZcashTransactionDisplay.tsx +++ b/src/components/pages/zcash/ZcashTransactionDisplay.tsx @@ -1,6 +1,7 @@ -import React from "react"; +import React, { useMemo } from "react"; import { useTranslation } from "react-i18next"; import { Link } from "react-router-dom"; +import { getNetworkById } from "../../../config/networks"; import { MAX_INPUT_LOOKUPS } from "../../../config/zcashConstants"; import { useSettings } from "../../../context/SettingsContext"; import { useTimeAgo } from "../../../hooks/useTimeAgo"; @@ -20,9 +21,11 @@ import { getTransactionPools, getTransparentOutputZat, } from "../../../utils/zcashUtils"; +import AIAnalysisPanel from "../../common/AIAnalysis/AIAnalysisPanel"; import CopyButton from "../../common/CopyButton"; import FieldLabel from "../../common/FieldLabel"; import HelperTooltip from "../../common/HelperTooltip"; +import { buildTransactionAnalysisContext } from "./aiContext"; import { ZcashKindBadge, ZcashPoolChip } from "./ZcashCells"; import ZcashShieldedBundles from "./ZcashShieldedBundles"; @@ -128,312 +131,331 @@ const ZcashTransactionDisplay: React.FC = React.me ); }; - return ( -
-
- {t("tx.title")} - {isUnconfirmed ? ( - {t("tx.inMempool")} - ) : ( - - {confirmationsAtLeast - ? t("tx.confirmationsAtLeast", { count: transaction.confirmations ?? 0 }) - : t("tx.confirmations", { count: transaction.confirmations ?? 0 })} - {showTooltips && ( - - )} - - )} -
+ const network = getNetworkById(networkId); + const aiContext = useMemo(() => buildTransactionAnalysisContext(transaction), [transaction]); -
-
- - - {transaction.txid} - - + return ( +
+
+
+ {t("tx.title")} + {isUnconfirmed ? ( + {t("tx.inMempool")} + ) : ( + + {confirmationsAtLeast + ? t("tx.confirmationsAtLeast", { count: transaction.confirmations ?? 0 }) + : t("tx.confirmations", { count: transaction.confirmations ?? 0 })} + {showTooltips && ( + + )} + + )}
- {transaction.blockhash && ( +
- - - - {transaction.blockheight !== undefined - ? `#${formatNumber(transaction.blockheight)}` - : truncateBlockHash(transaction.blockhash)} - + + + {transaction.txid} +
- )} -
-
+ {transaction.blockhash && (
- - - - {pools.map((pool) => ( - - ))} + + + + {transaction.blockheight !== undefined + ? `#${formatNumber(transaction.blockheight)}` + : truncateBlockHash(transaction.blockhash)} +
+ )} - {isUnconfirmed ? ( +
+
- - - {t("tx.waiting")} + + + + {pools.map((pool) => ( + + ))}
- ) : ( - transaction.blocktime !== undefined && ( + + {isUnconfirmed ? ( +
+ + + {t("tx.waiting")} + +
+ ) : ( + transaction.blocktime !== undefined && ( + <> +
+ + {formatTimestamp(transaction.blocktime)} +
+
+ + {timeAgo(transaction.blocktime)} +
+ + ) + )} + + {hasTransparent && ( <>
- - {formatTimestamp(transaction.blocktime)} + + + {transaction.vin.length} + {inputTotalZat !== null && inputTotalZat > 0 && ( + + {" "} + ({formatZEC(inputTotalZat, currency)}) + + )} +
- - {timeAgo(transaction.blocktime)} + + + {transaction.vout.length} + {outputTotalZat > 0 && ( + + {" "} + ({formatZEC(outputTotalZat, currency)}) + + )} +
- ) - )} + )} - {hasTransparent && ( - <> + {!isCoinbase && (
- - {transaction.vin.length} - {inputTotalZat !== null && inputTotalZat > 0 && ( - - {" "} - ({formatZEC(inputTotalZat, currency)}) - - )} - + {renderFee()}
-
- - - {transaction.vout.length} - {outputTotalZat > 0 && ( - - {" "} - ({formatZEC(outputTotalZat, currency)}) - - )} - -
- - )} + )} +
- {!isCoinbase && ( +
- {renderFee()} + {formatSize(transaction.size)}
- )} -
- -
-
- - {formatSize(transaction.size)} -
-
- - {transaction.version} -
- {transaction.versionGroupId && (
- - {transaction.versionGroupId} + + {transaction.version}
- )} - {transaction.expiryHeight !== undefined && transaction.expiryHeight > 0 && ( + {transaction.versionGroupId && ( +
+ + {transaction.versionGroupId} +
+ )} + {transaction.expiryHeight !== undefined && transaction.expiryHeight > 0 && ( +
+ + {formatNumber(transaction.expiryHeight)} +
+ )}
- {formatNumber(transaction.expiryHeight)} + {formatNumber(transaction.locktime)}
- )} -
- - {formatNumber(transaction.locktime)}
-
- + - {hasTransparent && ( -
-
-
- - {t("tx.inputsColumn", { count: transaction.vin.length })} - - {inputTotalZat !== null && inputTotalZat > 0 && ( -
- - {formatZEC(inputTotalZat, currency)} - -
- )} -
-
- {transaction.vin.length === 0 && ( -
{t("tx.noTransparentInputs")}
- )} - {transaction.vin.map((input, index) => ( - // biome-ignore lint/suspicious/noArrayIndexKey: inputs keep their on-chain order -
-
{index}
-
- {input.coinbase !== undefined ? ( -
{t("tx.newCoins")}
- ) : ( - <> -
- {input.address ? ( - <> - - {input.address} - - - - ) : ( - {t("tx.unknownAddress")} - )} -
-
- - {input.valueZat !== undefined - ? formatZEC(input.valueZat, currency) - : t("tx.unknownValue")} - - {input.txid && ( - - - {t("tx.spends", { - outpoint: `${truncateHash(input.txid, "short")}:${input.vout}`, - })} - - - )} -
- - )} + {hasTransparent && ( +
+
+
+ + {t("tx.inputsColumn", { count: transaction.vin.length })} + + {inputTotalZat !== null && inputTotalZat > 0 && ( +
+ + {formatZEC(inputTotalZat, currency)} +
-
- ))} -
-
- -
- - {t("tx.flowArrow")} - - -
- -
-
- - {t("tx.outputsColumn", { count: transaction.vout.length })} - - {outputTotalZat > 0 && ( -
- - {formatZEC(outputTotalZat, currency)} - -
- )} -
-
- {transaction.vout.length === 0 && ( -
{t("tx.noTransparentOutputs")}
- )} - {transaction.vout.map((output) => ( -
-
{output.n}
-
-
- {output.address ? ( + )} +
+
+ {transaction.vin.length === 0 && ( +
{t("tx.noTransparentInputs")}
+ )} + {transaction.vin.map((input, index) => ( + // biome-ignore lint/suspicious/noArrayIndexKey: inputs keep their on-chain order +
+
{index}
+
+ {input.coinbase !== undefined ? ( +
{t("tx.newCoins")}
+ ) : ( <> - - {output.address} - - +
+ {input.address ? ( + <> + + {input.address} + + + + ) : ( + {t("tx.unknownAddress")} + )} +
+
+ + {input.valueZat !== undefined + ? formatZEC(input.valueZat, currency) + : t("tx.unknownValue")} + + {input.txid && ( + + + {t("tx.spends", { + outpoint: `${truncateHash(input.txid, "short")}:${input.vout}`, + })} + + + )} +
- ) : ( - {t("tx.nonStandard")} )}
-
- - {formatZEC(output.valueZat, currency)} - - {output.scriptType} +
+ ))} +
+
+ +
+ + {t("tx.flowArrow")} + + +
+ +
+
+ + {t("tx.outputsColumn", { count: transaction.vout.length })} + + {outputTotalZat > 0 && ( +
+ + {formatZEC(outputTotalZat, currency)} + +
+ )} +
+
+ {transaction.vout.length === 0 && ( +
{t("tx.noTransparentOutputs")}
+ )} + {transaction.vout.map((output) => ( +
+
{output.n}
+
+
+ {output.address ? ( + <> + + {output.address} + + + + ) : ( + {t("tx.nonStandard")} + )} +
+
+ + {formatZEC(output.valueZat, currency)} + + {output.scriptType} +
-
- ))} + ))} +
-
- )} + )} +
+
); }, diff --git a/src/components/pages/zcash/aiContext.test.ts b/src/components/pages/zcash/aiContext.test.ts new file mode 100644 index 00000000..e6d3d242 --- /dev/null +++ b/src/components/pages/zcash/aiContext.test.ts @@ -0,0 +1,128 @@ +import { describe, expect, it } from "vitest"; +import type { ZcashAddress, ZcashBlock, ZcashTransaction } from "../../../types"; +import { + buildAddressAnalysisContext, + buildBlockAnalysisContext, + buildTransactionAnalysisContext, +} from "./aiContext"; + +const T_ADDRESS = "t1KAuVfS2r2hc7RwSh6GTuyfqCGMFEpwkZ2"; + +// Mainnet tx 36a167f6…ce2e3, block 3,483,400 +const ironwoodOnly: ZcashTransaction = { + txid: "36a167f602a15015593130974e0942179e7e394e0e0e6e239752533e2b5ce2e3", + version: 6, + size: 9_170, + locktime: 0, + expiryHeight: 3483438, + vin: [], + vout: [], + shielded: { ironwood: { actions: 2, valueBalanceZat: 10_000 } }, + blockhash: "0".repeat(64), + blockheight: 3483400, + confirmations: 66, +}; + +describe("buildTransactionAnalysisContext", () => { + it("describes a fully shielded transaction with its fee in ZEC", () => { + const context = buildTransactionAnalysisContext(ironwoodOnly); + + expect(context).toMatchObject({ + status: "confirmed", + kind: "shielded", + pools: ["ironwood"], + transparentInputCount: 0, + transparentOutputCount: 0, + feeZEC: 0.0001, + shieldedBundles: { ironwood: { actions: 2, valueBalanceZEC: 0.0001 } }, + }); + expect(context.transparentInputsZEC).toBeUndefined(); + }); + + it("leaves the fee out while transparent input values are unknown", () => { + const context = buildTransactionAnalysisContext({ + ...ironwoodOnly, + vin: [{ txid: "a".repeat(64), vout: 0, sequence: 0 }], + shielded: { sapling: { spends: 0, outputs: 2, valueBalanceZat: -500_000 } }, + blockhash: undefined, + confirmations: undefined, + }); + + expect(context).toMatchObject({ status: "unconfirmed (in mempool)", kind: "shielding" }); + expect(context.feeZEC).toBeUndefined(); + }); +}); + +describe("buildBlockAnalysisContext", () => { + it("converts the coinbase outputs and value pools to ZEC", () => { + const block: ZcashBlock = { + hash: "0".repeat(64), + height: 3483400, + time: 1789411472, + nTx: 18, + size: 84_186, + version: 4, + merkleRoot: "0".repeat(64), + bits: "1c008816", + nonce: "a9a1", + difficulty: 252_490_000, + coinbaseOutputs: [ + { address: "t1SqwRAAdSig6dE4EBPLonAait219VmkUjP", valueZat: 125_490_751 }, + { address: "t3cFfPt1Bcvgez9ZbMBFWeZsskxTkPzGCow", valueZat: 12_500_000 }, + ], + shieldedTxCounts: { sapling: 2, ironwood: 2 }, + valuePools: [{ id: "sapling", valueZat: 51_144_292_792_244 }], + }; + + expect(buildBlockAnalysisContext(block)).toMatchObject({ + transactionCount: 18, + coinbaseTotalZEC: 1.37990751, + shieldedTransactionCounts: { sapling: 2, ironwood: 2 }, + valuePoolsZEC: { sapling: 511442.92792244 }, + }); + }); +}); + +describe("buildAddressAnalysisContext", () => { + it("reports a blocked address index instead of a zero balance", () => { + const address: ZcashAddress = { + address: T_ADDRESS, + type: "p2pkh", + transparentAddress: T_ADDRESS, + balance: { availability: "unsupported" }, + utxos: { availability: "unsupported" }, + txids: { availability: "unsupported" }, + }; + + const context = buildAddressAnalysisContext(address); + + expect(context).toMatchObject({ + addressType: "p2pkh", + addressIndex: { + balance: "unsupported", + unspentOutputs: "unsupported", + history: "unsupported", + }, + }); + expect(context.balanceZEC).toBeUndefined(); + expect(context.transparentReceiver).toBeUndefined(); + }); + + it("describes a unified address through its transparent receiver, newest transactions first", () => { + const context = buildAddressAnalysisContext({ + address: `u1${"q".repeat(100)}`, + type: "unified", + transparentAddress: T_ADDRESS, + receivers: { availability: "ok", data: { orchard: `u1${"p".repeat(60)}`, p2pkh: T_ADDRESS } }, + balance: { availability: "ok", data: { balanceZat: 9_514_810 } }, + txids: { availability: "ok", data: ["older", "newer"] }, + }); + + expect(context).toMatchObject({ + transparentReceiver: T_ADDRESS, + receiverTypes: ["orchard", "p2pkh"], + balanceZEC: 0.0951481, + recentTxids: ["newer", "older"], + }); + }); +}); diff --git a/src/components/pages/zcash/aiContext.ts b/src/components/pages/zcash/aiContext.ts new file mode 100644 index 00000000..217146ab --- /dev/null +++ b/src/components/pages/zcash/aiContext.ts @@ -0,0 +1,132 @@ +/** + * Compact contexts for the AI analysis panel. Amounts are converted to ZEC and field names carry + * the unit, so the model never has to infer one. + */ + +import type { + ZcashAddress, + ZcashBlock, + ZcashShieldedBundles, + ZcashTransaction, +} from "../../../types"; +import { + classifyTransaction, + computeFeeZat, + getTransactionPools, + getTransparentOutputZat, + isCoinbaseTransaction, + zatToZec, +} from "../../../utils/zcashUtils"; + +function summarizeShieldedBundles({ sprout, sapling, orchard, ironwood }: ZcashShieldedBundles) { + return { + sprout: sprout && { + joinSplits: sprout.joinSplits, + enteredSproutZEC: zatToZec(sprout.vpubOldZat), + leftSproutZEC: zatToZec(sprout.vpubNewZat), + }, + sapling: sapling && { + spends: sapling.spends, + outputs: sapling.outputs, + valueBalanceZEC: zatToZec(sapling.valueBalanceZat), + }, + orchard: orchard && { + actions: orchard.actions, + valueBalanceZEC: zatToZec(orchard.valueBalanceZat), + }, + ironwood: ironwood && { + actions: ironwood.actions, + valueBalanceZEC: zatToZec(ironwood.valueBalanceZat), + }, + }; +} + +export function buildTransactionAnalysisContext(tx: ZcashTransaction): Record { + const feeZat = computeFeeZat(tx); + const inputValuesKnown = + tx.vin.length > 0 && tx.vin.every((input) => input.valueZat !== undefined); + + return { + txid: tx.txid, + status: tx.blockhash && tx.confirmations ? "confirmed" : "unconfirmed (in mempool)", + confirmations: tx.confirmations, + blockHeight: tx.blockheight, + kind: classifyTransaction(tx), + pools: getTransactionPools(tx), + isCoinbase: isCoinbaseTransaction(tx), + version: tx.version, + expiryHeight: tx.expiryHeight, + sizeBytes: tx.size, + transparentInputCount: tx.vin.length, + transparentOutputCount: tx.vout.length, + transparentInputsZEC: inputValuesKnown + ? zatToZec(tx.vin.reduce((sum, input) => sum + (input.valueZat ?? 0), 0)) + : undefined, + transparentOutputsZEC: zatToZec(getTransparentOutputZat(tx)), + feeZEC: feeZat === null ? undefined : zatToZec(feeZat), + feeRateZatPerByte: + feeZat !== null && tx.size > 0 ? Number((feeZat / tx.size).toFixed(2)) : undefined, + shieldedBundles: summarizeShieldedBundles(tx.shielded), + transparentOutputs: tx.vout.map((output) => ({ + address: output.address, + amountZEC: zatToZec(output.valueZat), + scriptType: output.scriptType, + })), + }; +} + +export function buildBlockAnalysisContext(block: ZcashBlock): Record { + const coinbaseOutputs = block.coinbaseOutputs ?? []; + + return { + height: block.height, + hash: block.hash, + time: block.time, + confirmations: block.confirmations, + transactionCount: block.nTx, + sizeBytes: block.size, + difficulty: block.difficulty, + coinbaseTotalZEC: + coinbaseOutputs.length > 0 + ? zatToZec(coinbaseOutputs.reduce((sum, output) => sum + output.valueZat, 0)) + : undefined, + coinbaseOutputs: coinbaseOutputs.map((output) => ({ + address: output.address, + amountZEC: zatToZec(output.valueZat), + })), + transparentOutputZEC: + block.transparentOutputZat === undefined ? undefined : zatToZec(block.transparentOutputZat), + shieldedTransactionCounts: block.shieldedTxCounts, + noteCommitmentTreeSizes: block.trees, + valuePoolsZEC: + block.valuePools && + Object.fromEntries(block.valuePools.map((pool) => [pool.id, zatToZec(pool.valueZat)])), + chainSupplyZEC: block.chainSupplyZat === undefined ? undefined : zatToZec(block.chainSupplyZat), + }; +} + +export function buildAddressAnalysisContext(address: ZcashAddress): Record { + const { balance, utxos, txids, receivers } = address; + + return { + address: address.address, + addressType: address.type, + transparentReceiver: + address.transparentAddress !== address.address ? address.transparentAddress : undefined, + receiverTypes: receivers?.data && Object.keys(receivers.data), + receiversLookup: receivers?.availability, + // Availability per address-index section, so a blocked index isn't read as a zero balance + addressIndex: balance && { + balance: balance.availability, + unspentOutputs: utxos?.availability, + history: txids?.availability, + }, + balanceZEC: balance?.data === undefined ? undefined : zatToZec(balance.data.balanceZat), + totalReceivedZEC: + balance?.data?.receivedZat === undefined ? undefined : zatToZec(balance.data.receivedZat), + unspentOutputCount: utxos?.data?.length, + transactionCount: txids?.data?.length, + // getaddresstxids returns chain order, oldest first + recentTxids: txids?.data && [...txids.data].reverse().slice(0, 10), + }; +} diff --git a/src/utils/zcashUtils.ts b/src/utils/zcashUtils.ts index 2d139cb0..263d54a1 100644 --- a/src/utils/zcashUtils.ts +++ b/src/utils/zcashUtils.ts @@ -98,6 +98,13 @@ export function zecToZat(value: number): number { return Math.round(value * ZATOSHIS_PER_ZEC); } +/** + * Convert integer zatoshis to a ZEC amount + */ +export function zatToZec(valueZat: number): number { + return valueZat / ZATOSHIS_PER_ZEC; +} + /** * Zebra marks the coinbase input with a `coinbase` field, so check for it directly rather than * Bitcoin's "single input without a txid" heuristic (shielded transactions can have no inputs) From 6fd695d63041eb383bd2d72df8bb9ee53596b071 Mon Sep 17 00:00:00 2001 From: Mati OS Date: Fri, 20 Nov 2026 20:36:25 -0300 Subject: [PATCH 3/3] fix(ai): keep zcash analysis to public data and label it precisely - 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. --- e2e/tests/shared/mocked/zcash-address.spec.ts | 12 +++++ .../pages/zcash/ZcashAddressDisplay.tsx | 18 ++++--- src/components/pages/zcash/aiContext.test.ts | 51 ++++++++++++++++++- src/components/pages/zcash/aiContext.ts | 28 +++++----- src/services/AIPromptTemplates.ts | 2 +- 5 files changed, 89 insertions(+), 22 deletions(-) diff --git a/e2e/tests/shared/mocked/zcash-address.spec.ts b/e2e/tests/shared/mocked/zcash-address.spec.ts index 8eaa1723..31bba6fe 100644 --- a/e2e/tests/shared/mocked/zcash-address.spec.ts +++ b/e2e/tests/shared/mocked/zcash-address.spec.ts @@ -140,4 +140,16 @@ test.describe("Zcash address", () => { await expect(items).toHaveCount(10); await expect(items.last()).toContainText(history[0] ?? ""); }); + + test("offers AI analysis only when the address has public data", async ({ page }) => { + await mockZcashRpc(page); + + await page.goto(addressUrl(T_ADDRESS)); + await expect(page.locator(".ai-analysis-panel")).toHaveCount(1); + + // A Sapling address has nothing public to analyze, so it isn't sent to the AI provider + await page.goto(addressUrl(SAPLING_ADDRESS)); + await expect(page.getByText("Shielded addresses don't reveal balances")).toBeVisible(); + await expect(page.locator(".ai-analysis-panel")).toHaveCount(0); + }); }); diff --git a/src/components/pages/zcash/ZcashAddressDisplay.tsx b/src/components/pages/zcash/ZcashAddressDisplay.tsx index d4300454..c7d0edeb 100644 --- a/src/components/pages/zcash/ZcashAddressDisplay.tsx +++ b/src/components/pages/zcash/ZcashAddressDisplay.tsx @@ -322,13 +322,17 @@ const ZcashAddressDisplay: React.FC = React.memo(
)}
- + {/* Without a transparent receiver there's nothing public to analyze, so a shielded + address isn't sent to the AI provider */} + {transparentAddress && ( + + )}
); }, diff --git a/src/components/pages/zcash/aiContext.test.ts b/src/components/pages/zcash/aiContext.test.ts index e6d3d242..9a41946f 100644 --- a/src/components/pages/zcash/aiContext.test.ts +++ b/src/components/pages/zcash/aiContext.test.ts @@ -53,6 +53,28 @@ describe("buildTransactionAnalysisContext", () => { }); }); +describe("buildTransactionAnalysisContext for Sprout", () => { + it("reports JoinSplit public values and the fee once inputs are known", () => { + const sprout: ZcashTransaction = { + txid: "5".repeat(64), + version: 2, + size: 1_802, + locktime: 0, + vin: [{ txid: "a".repeat(64), vout: 0, sequence: 0, valueZat: 30_000 }], + vout: [], + shielded: { sprout: { joinSplits: 1, vpubOldZat: 20_000, vpubNewZat: 0 } }, + }; + + expect(buildTransactionAnalysisContext(sprout)).toMatchObject({ + kind: "shielding", + pools: ["transparent", "sprout"], + isCoinbase: false, + feeZEC: 0.0001, + shieldedBundles: { sprout: { joinSplits: 1, enteredSproutZEC: 0.0002, leftSproutZEC: 0 } }, + }); + }); +}); + describe("buildBlockAnalysisContext", () => { it("converts the coinbase outputs and value pools to ZEC", () => { const block: ZcashBlock = { @@ -77,12 +99,37 @@ describe("buildBlockAnalysisContext", () => { expect(buildBlockAnalysisContext(block)).toMatchObject({ transactionCount: 18, coinbaseTotalZEC: 1.37990751, + coinbaseShieldedZEC: undefined, shieldedTransactionCounts: { sapling: 2, ironwood: 2 }, valuePoolsZEC: { sapling: 511442.92792244 }, }); }); }); +describe("buildBlockAnalysisContext for a shielded coinbase", () => { + it("includes the reward paid into the shielded pools", () => { + const block: ZcashBlock = { + hash: "0".repeat(64), + height: 3483401, + time: 1789411547, + nTx: 1, + size: 2_000, + version: 4, + merkleRoot: "0".repeat(64), + bits: "1c008816", + nonce: "a9a1", + difficulty: 252_490_000, + coinbaseOutputs: [{ address: "t3cFfPt1Bcvgez9ZbMBFWeZsskxTkPzGCow", valueZat: 12_500_000 }], + coinbaseShieldedZat: 125_490_751, + }; + + expect(buildBlockAnalysisContext(block)).toMatchObject({ + coinbaseTotalZEC: 1.37990751, + coinbaseShieldedZEC: 1.25490751, + }); + }); +}); + describe("buildAddressAnalysisContext", () => { it("reports a blocked address index instead of a zero balance", () => { const address: ZcashAddress = { @@ -104,7 +151,7 @@ describe("buildAddressAnalysisContext", () => { history: "unsupported", }, }); - expect(context.balanceZEC).toBeUndefined(); + expect(context.transparentBalanceZEC).toBeUndefined(); expect(context.transparentReceiver).toBeUndefined(); }); @@ -121,7 +168,7 @@ describe("buildAddressAnalysisContext", () => { expect(context).toMatchObject({ transparentReceiver: T_ADDRESS, receiverTypes: ["orchard", "p2pkh"], - balanceZEC: 0.0951481, + transparentBalanceZEC: 0.0951481, recentTxids: ["newer", "older"], }); }); diff --git a/src/components/pages/zcash/aiContext.ts b/src/components/pages/zcash/aiContext.ts index 217146ab..bac54fba 100644 --- a/src/components/pages/zcash/aiContext.ts +++ b/src/components/pages/zcash/aiContext.ts @@ -11,10 +11,9 @@ import type { } from "../../../types"; import { classifyTransaction, - computeFeeZat, + computeFee, getTransactionPools, getTransparentOutputZat, - isCoinbaseTransaction, zatToZec, } from "../../../utils/zcashUtils"; @@ -42,7 +41,8 @@ function summarizeShieldedBundles({ sprout, sapling, orchard, ironwood }: ZcashS } export function buildTransactionAnalysisContext(tx: ZcashTransaction): Record { - const feeZat = computeFeeZat(tx); + const fee = computeFee(tx); + const feeZat = fee.kind === "known" ? fee.zat : undefined; const inputValuesKnown = tx.vin.length > 0 && tx.vin.every((input) => input.valueZat !== undefined); @@ -53,7 +53,7 @@ export function buildTransactionAnalysisContext(tx: ZcashTransaction): Record sum + (input.valueZat ?? 0), 0)) : undefined, transparentOutputsZEC: zatToZec(getTransparentOutputZat(tx)), - feeZEC: feeZat === null ? undefined : zatToZec(feeZat), + feeZEC: feeZat === undefined ? undefined : zatToZec(feeZat), feeRateZatPerByte: - feeZat !== null && tx.size > 0 ? Number((feeZat / tx.size).toFixed(2)) : undefined, + feeZat !== undefined && tx.size > 0 ? Number((feeZat / tx.size).toFixed(2)) : undefined, shieldedBundles: summarizeShieldedBundles(tx.shielded), transparentOutputs: tx.vout.map((output) => ({ address: output.address, @@ -77,6 +77,9 @@ export function buildTransactionAnalysisContext(tx: ZcashTransaction): Record { const coinbaseOutputs = block.coinbaseOutputs ?? []; + const coinbaseShieldedZat = block.coinbaseShieldedZat ?? 0; + const coinbaseTotalZat = + coinbaseOutputs.reduce((sum, output) => sum + output.valueZat, 0) + coinbaseShieldedZat; return { height: block.height, @@ -86,10 +89,9 @@ export function buildBlockAnalysisContext(block: ZcashBlock): Record 0 - ? zatToZec(coinbaseOutputs.reduce((sum, output) => sum + output.valueZat, 0)) - : undefined, + coinbaseTotalZEC: coinbaseTotalZat > 0 ? zatToZec(coinbaseTotalZat) : undefined, + // Reward paid into Sapling or Orchard by a shielded coinbase (not in coinbaseOutputs) + coinbaseShieldedZEC: coinbaseShieldedZat > 0 ? zatToZec(coinbaseShieldedZat) : undefined, coinbaseOutputs: coinbaseOutputs.map((output) => ({ address: output.address, amountZEC: zatToZec(output.valueZat), @@ -121,8 +123,10 @@ export function buildAddressAnalysisContext(address: ZcashAddress): Record = { role: "Zcash blockchain analyst", conciseness: "3-5 sentences", focusAreas: - "transaction count, how many transactions use each shielded pool, coinbase outputs (miner reward and funding streams), difficulty, and the value pool balances after the block", + "transaction count, how many transactions use each shielded pool, the coinbase reward (transparent outputs for the miner and funding streams, plus any reward paid into a shielded pool), difficulty, and the value pool balances after the block", audience: "senior Zcash developer", task: "Analyze this Zcash block", sections: ["Block Analysis", "Shielded Activity", "Reward and Value Pools", "Notable Aspects"],