@anywalletkit/wallet-zcash 0.2.2 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/types.ts","../src/address.ts","../src/fee.ts","../src/tx.ts","../src/encoding.ts","../src/describe.ts","../src/blockchair.ts","../src/http.ts","../src/blockbook.ts","../src/client.ts","../src/message.ts","../src/manager.ts","../src/account.ts","../src/read-only-account.ts","../src/history.ts"],"sourcesContent":["export * from './types.js'\nexport { UnsafeTransactionError, assertSafe, describeTransaction, DEFAULT_MAX_FEE, type DescribeContext, type UnsafeTransactionCode } from './describe.js'\nexport { BlockchairClient, BLOCKCHAIR_URL, blockchairTime, type BlockchairTxDashboard } from './blockchair.js'\nexport { ZcashBlockbookClient, type BlockbookTxDetails, type BlockbookVin, type BlockbookVout } from './blockbook.js'\nexport { createClient } from './client.js'\nexport { magicHash, signMessageWith, encodeMessageSignature, recoverMessagePublicKey } from './message.js'\nexport { selectCoins, selectAll, spendableUtxos, conventionalFee, logicalActions, estimateSize, TooManyInputsError, MARGINAL_FEE, GRACE_ACTIONS, P2PKH_INPUT_SIZE, MAX_UTXO_INPUTS, type CoinSelection, type CoinSelectOptions } from './fee.js'\nexport {\n serializeTx, parseTx, txid, txidDigest, sighashAll, p2pkhScriptSig, parseP2pkhScriptSig, branchIdForHeight, txHashPersonalization,\n headerDigest, transparentDigest, prevoutsDigest, sequenceDigest, outputsDigest,\n TX_VERSION_V5, VERSION_GROUP_ID_V5, SIGHASH_ALL, FINAL_SEQUENCE, MAX_SEQUENCE, MAINNET_UPGRADES, CURRENT_BRANCH_ID,\n type TransparentTxV5, type TxInput, type TxOutput,\n} from './tx.js'\nexport { decodeAddress, encodeAddress, addressFromScript, addressFromPublicKey, addressPrefix, scriptFor, scriptKind, hash160, outputSize, DUST_LIMIT, type DecodedAddress, type ScriptKind } from './address.js'\nexport { coinType, WalletManagerZcash } from './manager.js'\nexport { WalletAccountReadOnlyZcash, type SpendPlan } from './read-only-account.js'\nexport { WalletAccountZcash, addressFor, DEFAULT_EXPIRY_DELTA } from './account.js'\nexport {\n createZcashHistory, mapDashboardTx, zcashExplorerTxUrl, HistoryUnavailableError,\n encodeCursor as encodeHistoryCursor, decodeCursor as decodeHistoryCursor,\n type ZcashHistoryOptions, type ZcashHistorySource, type ZcashHistoryPage, type ZcashChainTx, type ZcashHistoryRaw, type ZcashHistoryCursor,\n} from './history.js'\nexport { WalletManagerZcash as default } from './manager.js'\n","/** Zcash mainnet or testnet. */\nexport type ZcashNetwork = 'mainnet' | 'testnet'\n\n/** CAIP-2 ids the SDK uses for Zcash (the swap2 catalog already names `zcash:mainnet`). */\nexport const CAIP2: Record<ZcashNetwork, string> = { mainnet: 'zcash:mainnet', testnet: 'zcash:testnet' }\n\n/** An unspent transparent output the account can spend. */\nexport interface Utxo {\n txid: string\n vout: number\n /** Zatoshis. */\n value: bigint\n /** Block height; -1 while in the mempool. */\n height: number\n}\n\n/** A previous output a transaction spends — ZIP-244 signs its value AND script. */\nexport interface SpentOutput {\n value: bigint\n script: Uint8Array\n}\n\n/** Transport-neutral transaction record (receipts, confirmations). */\nexport interface ZcashTxInfo {\n txid: string\n /** -1 or 0 while unconfirmed. */\n blockHeight: number\n confirmations: number\n fee?: bigint\n /** Unix seconds. */\n blockTime?: number\n}\n\n/** Minimal chain-data client every transport implements. Values in zatoshis. */\nexport interface ZcashClient {\n connect(): Promise<void>\n close(): Promise<void>\n getBalance(address: string): Promise<{ confirmed: bigint; unconfirmed: bigint }>\n listUnspent(address: string): Promise<Utxo[]>\n /** Raw transaction hex (any version — only used to read prevouts and for receipts). */\n getTransaction(txid: string): Promise<string>\n /** Value + scriptPubKey of one output of an existing transaction (what signing a spend of it needs). */\n getOutput(txid: string, vout: number): Promise<SpentOutput | undefined>\n getTransactionInfo(txid: string): Promise<ZcashTxInfo | undefined>\n /** Broadcast raw hex; returns the txid. */\n broadcast(rawTx: string): Promise<string>\n /** Current chain tip height (expiry height, anti-fee-sniping lock time, consensus branch selection). */\n getBlockHeight(): Promise<number>\n}\n\n/** One transport to a Zcash indexer: Blockchair or a Blockbook instance. */\nexport type ZcashClientConfig =\n /** Blockchair's public REST API (`https://api.blockchair.com/zcash`; optional API key). Mainnet only. */\n | { type: 'blockchair'; clientConfig?: { url?: string; key?: string } }\n /** A Zcash Blockbook (NOWNodes `https://zec-blockbook.nownodes.io` with an `api-key` header, a self-hosted instance, …). */\n | { type: 'blockbook-http'; clientConfig: { url: string; headers?: Record<string, string> } }\n\n/**\n * Options for a Zcash wallet manager or account: transports, network and fee limits. Transparent\n * addresses only.\n */\nexport interface ZcashConfig {\n /** One or more transports (config objects or ready `ZcashClient`s). A list fails over in order. Omit for an offline (sign-only) wallet. */\n client?: ZcashClientConfig | ZcashClient | Array<ZcashClientConfig | ZcashClient>\n network?: ZcashNetwork\n /** Extra attempts across the client list after the first failure (default 3). */\n retries?: number\n /** Per-request timeout in ms (default 15000). */\n timeoutMs?: number\n /** Max fee (zatoshis) for `transfer`. */\n transferMaxFee?: bigint | number\n /** Max fee (zatoshis) for `sendTransaction` / `signTransaction`. */\n transactionMaxFee?: bigint | number\n /** Hard fee ceiling in zatoshis for any transaction this account signs or broadcasts (default 1 000 000 = 0.01 ZEC). */\n maxFee?: bigint | number\n /** Blocks after the tip at which an unmined transaction expires (ZIP-203; default 40, the zcashd/Zebra default). 0 = never. */\n expiryDelta?: number\n /** Set nLockTime to the tip height so the transaction cannot be mined into a reorged block (default true). */\n antiFeeSniping?: boolean\n /**\n * Consensus branch id to sign under. Default: picked from the tip height\n * (`branchIdForHeight`) — set this when a network upgrade activates before\n * the package learns its id.\n */\n consensusBranchId?: number\n /** Coin-selection input cap (default 200). */\n maxInputs?: number\n /** Injectable fetch (tests, custom agents). Defaults to globalThis.fetch. */\n fetch?: typeof fetch\n}\n\n/** A spend. `value` in zatoshis. `fee` overrides the ZIP-317 conventional fee (still subject to `maxFee`). */\nexport interface ZcashSpend {\n to: string\n value: bigint | number | string\n fee?: bigint | number\n}\n\n/** `sendTransaction` accepts a spend or an already signed raw transaction hex. */\nexport type ZcashTransaction = ZcashSpend | string\n\n/** A transparent ZEC transfer. Amount in zatoshis. */\nexport interface ZcashTransferOptions {\n /** Not supported on Zcash; present for the shared account interface. */\n token?: string\n recipient: string\n amount: bigint | number | string\n}\n\n/** A mined Zcash transaction. */\nexport interface ZcashReceipt {\n hash: string\n /** Always 1 once mined — a transparent transaction cannot fail after inclusion. */\n status: 1\n blockNumber: bigint\n confirmations: number\n fee?: bigint\n}\n\n/** The most one transaction can send (a sweep of every UTXO), after the fee. */\nexport interface ZcashMaxSpendableResult {\n /** Max zatoshis one transaction can send after the fee. 0n when nothing is spendable. */\n amount: bigint\n fee: bigint\n /** Always 0n: a sweep leaves no change. */\n changeValue: bigint\n inputs: number\n}\n\n/** Problems a described transaction is flagged with. */\nexport type ZcashWarning =\n /** Fee exceeds 10 % of the amount sent. */\n | 'fee-over-10pct-of-amount'\n /** Fee is below the ZIP-317 conventional fee — nodes may not relay it. */\n | 'fee-below-conventional'\n /** An output is below the dust floor. */\n | 'dust-output'\n /** Change was below dust and folded into the fee. */\n | 'no-change'\n /** No expiry height: the transaction stays valid in mempools indefinitely. */\n | 'no-expiry'\n\n/** One input of a described transaction: the UTXO it spends. */\nexport interface ZcashTxInputDescription {\n txid: string\n vout: number\n value: bigint\n address: string | undefined\n}\n\n/** One output of a described transaction, tagged as the recipient, our change, or unknown. */\nexport interface ZcashTxOutputDescription {\n /** Undefined for scripts without an address form. */\n address: string | undefined\n value: bigint\n role: 'recipient' | 'change' | 'unknown'\n}\n\n/** \"What you sign\": the fully resolved transaction before (or after) signing. */\nexport interface ZcashTxDescription {\n kind: 'zcash-transfer'\n version: 5\n consensusBranchId: number\n inputs: ZcashTxInputDescription[]\n outputs: ZcashTxOutputDescription[]\n /** Zatoshis sent to non-change outputs. */\n amount: bigint\n fee: bigint\n /** The ZIP-317 fee this transaction's shape calls for. */\n conventionalFee: bigint\n /** Serialized size in bytes. */\n size: number\n lockTime: number\n expiryHeight: number\n /** Present once the transaction is signed. */\n txid?: string\n warnings: ZcashWarning[]\n}\n","/**\n * Zcash transparent addresses: Base58Check with a two-byte version prefix.\n * mainnet t1… P2PKH 0x1CB8 t3… P2SH 0x1CBD\n * testnet tm… P2PKH 0x1D25 t2… P2SH 0x1CBA\n * Shielded (zs…, u1…) and Sprout (zc…) addresses are recognised and refused\n * with a message — this package sends transparent value only.\n */\nimport { sha256 } from '@noble/hashes/sha2.js'\nimport { ripemd160 } from '@noble/hashes/legacy.js'\nimport { base58check } from '@scure/base'\nimport type { ZcashNetwork } from './types.js'\n\nconst b58 = base58check(sha256)\n\n/** Transparent address type: pay-to-pubkey-hash (`t1…`) or pay-to-script-hash (`t3…`). */\nexport type ScriptKind = 'p2pkh' | 'p2sh'\n\n/** A transparent address decoded to its type and 20-byte hash. */\nexport interface DecodedAddress {\n kind: ScriptKind\n /** 20-byte hash (pubkey hash or script hash). */\n hash: Uint8Array\n /** The scriptPubKey. */\n script: Uint8Array\n}\n\nconst PREFIX: Record<ZcashNetwork, Record<ScriptKind, readonly [number, number]>> = {\n mainnet: { p2pkh: [0x1c, 0xb8], p2sh: [0x1c, 0xbd] },\n testnet: { p2pkh: [0x1d, 0x25], p2sh: [0x1c, 0xba] },\n}\n\n/** Base58Check version prefix for a transparent address kind on a network (exported for tests / tooling). */\nexport function addressPrefix(network: ZcashNetwork, kind: ScriptKind): readonly [number, number] {\n return PREFIX[network][kind]\n}\n\n/** RIPEMD-160 of SHA-256, the hash inside a transparent address. */\nexport function hash160(data: Uint8Array): Uint8Array {\n return ripemd160(sha256(data))\n}\n\n/** OP_DUP OP_HASH160 <20> OP_EQUALVERIFY OP_CHECKSIG, or OP_HASH160 <20> OP_EQUAL. */\nexport function scriptFor(kind: ScriptKind, hash: Uint8Array): Uint8Array {\n if (hash.length !== 20) throw new Error('A transparent script needs a 20-byte hash')\n if (kind === 'p2pkh') return Uint8Array.of(0x76, 0xa9, 0x14, ...hash, 0x88, 0xac)\n return Uint8Array.of(0xa9, 0x14, ...hash, 0x87)\n}\n\n/** Type of an output script; `unknown` for anything but p2pkh and p2sh. */\nexport function scriptKind(script: Uint8Array): ScriptKind | 'unknown' {\n if (script.length === 25 && script[0] === 0x76 && script[1] === 0xa9 && script[2] === 0x14 && script[23] === 0x88 && script[24] === 0xac) return 'p2pkh'\n if (script.length === 23 && script[0] === 0xa9 && script[1] === 0x14 && script[22] === 0x87) return 'p2sh'\n return 'unknown'\n}\n\n/** Transparent address of a 20-byte hash. */\nexport function encodeAddress(kind: ScriptKind, hash: Uint8Array, network: ZcashNetwork): string {\n if (hash.length !== 20) throw new Error('A transparent address needs a 20-byte hash')\n const [a, b] = PREFIX[network][kind]\n return b58.encode(Uint8Array.of(a, b, ...hash))\n}\n\n/** Decode and validate a transparent address for `network`; throws a message that names the problem. */\nexport function decodeAddress(address: string, network: ZcashNetwork): DecodedAddress {\n const a = address.trim()\n if (/^u1|^utest/i.test(a)) throw new Error(`Unified address (${a.slice(0, 6)}…) — shielded receivers are not supported; use a transparent t-address.`)\n if (/^zs1|^ztestsapling/i.test(a)) throw new Error('Sapling shielded address (zs1…) — this wallet sends to transparent t-addresses only.')\n if (/^zc/i.test(a) && a.length > 90) throw new Error('Sprout address (zc…) — the Sprout pool is deprecated; use a transparent t-address.')\n let payload: Uint8Array\n try { payload = b58.decode(a) } catch (e) {\n throw new Error(`Invalid Zcash address: ${a}`, { cause: e })\n }\n if (payload.length !== 22) throw new Error(`Invalid Zcash address: ${a}`)\n const p0 = payload[0]!, p1 = payload[1]!\n for (const net of ['mainnet', 'testnet'] as const) {\n for (const kind of ['p2pkh', 'p2sh'] as const) {\n const [a0, a1] = PREFIX[net][kind]\n if (p0 === a0 && p1 === a1) {\n if (net !== network) throw new Error(`${a} is a Zcash ${net} address; this wallet is on ${network}.`)\n const hash = payload.slice(2)\n return { kind, hash, script: scriptFor(kind, hash) }\n }\n }\n }\n throw new Error(`Invalid Zcash address: ${a} (unknown version prefix)`)\n}\n\n/** Address for an output script, or undefined when the script has no address form. */\nexport function addressFromScript(script: Uint8Array, network: ZcashNetwork): string | undefined {\n const kind = scriptKind(script)\n if (kind === 'unknown') return undefined\n return encodeAddress(kind, kind === 'p2pkh' ? script.slice(3, 23) : script.slice(2, 22), network)\n}\n\n/** P2PKH address of a compressed secp256k1 public key (what `m/44'/133'/0'/0/i` yields). */\nexport function addressFromPublicKey(publicKey: Uint8Array, network: ZcashNetwork = 'mainnet'): string {\n if (publicKey.length !== 33) throw new Error('Expected a 33-byte compressed public key')\n return encodeAddress('p2pkh', hash160(publicKey), network)\n}\n\n/** Output size in bytes: 8 (value) + CompactSize + script. */\nexport function outputSize(script: Uint8Array): number {\n return 8 + (script.length < 0xfd ? 1 : 3) + script.length\n}\n\n/** Below this an output is uneconomic to spend (Bitcoin Core's P2PKH dust floor; zatoshis). */\nexport const DUST_LIMIT = 546n\n","/**\n * ZIP-317 fees and coin selection.\n *\n * conventional_fee = marginal_fee · max(grace_actions, logical_actions)\n * marginal_fee = 5000 zatoshis, grace_actions = 2,\n * transparent logical actions = max(ceil(Σ tx_in bytes / 150), ceil(Σ tx_out bytes / 34)).\n *\n * The fee depends on the number of inputs and outputs, not on a market rate,\n * so selection is simple: largest-first accumulation until the inputs cover\n * amount + fee, change kept when it clears the dust floor.\n */\nimport { InsufficientFundsError } from '@anywalletkit/core'\nimport { DUST_LIMIT } from './address.js'\nimport type { Utxo } from './types.js'\n\nexport const MARGINAL_FEE = 5_000n\nexport const GRACE_ACTIONS = 2\nexport const P2PKH_STANDARD_INPUT_SIZE = 150\nexport const P2PKH_STANDARD_OUTPUT_SIZE = 34\n/** Serialized size of one signed P2PKH input: prevout 36 + CompactSize 1 + scriptSig (1+73+1+33) + sequence 4. */\nexport const P2PKH_INPUT_SIZE = 149\n/** Most inputs one spend may use. */\nexport const MAX_UTXO_INPUTS = 200\n\nexport function logicalActions(inputSizes: readonly number[], outputSizes: readonly number[]): number {\n const inBytes = inputSizes.reduce((s, n) => s + n, 0)\n const outBytes = outputSizes.reduce((s, n) => s + n, 0)\n return Math.max(Math.ceil(inBytes / P2PKH_STANDARD_INPUT_SIZE), Math.ceil(outBytes / P2PKH_STANDARD_OUTPUT_SIZE))\n}\n\n/** The fee a transaction of this shape should pay (zatoshis). */\nexport function conventionalFee(inputSizes: readonly number[], outputSizes: readonly number[]): bigint {\n return MARGINAL_FEE * BigInt(Math.max(GRACE_ACTIONS, logicalActions(inputSizes, outputSizes)))\n}\n\n/** Transaction size estimate: v5 header 20 + counts 2 + inputs + outputs + 3 empty bundle counts. */\nexport function estimateSize(inputs: number, outputSizes: readonly number[]): number {\n const cs = (n: number) => (n < 0xfd ? 1 : 3)\n return 20 + cs(inputs) + inputs * P2PKH_INPUT_SIZE + cs(outputSizes.length) + outputSizes.reduce((s, n) => s + n, 0) + 3\n}\n\n/** A spend would need more inputs than allowed; consolidate the UTXOs first. */\nexport class TooManyInputsError extends Error {\n readonly maxInputs: number\n constructor(maxInputs: number) {\n super(`The spend needs more than ${maxInputs} inputs; consolidate the UTXOs first or raise maxInputs.`)\n this.name = 'TooManyInputsError'\n this.maxInputs = maxInputs\n }\n}\n\n/** Input to {@link selectCoins}. */\nexport interface CoinSelectOptions {\n utxos: Utxo[]\n /** Zatoshis the recipient gets. */\n target: bigint\n /** Serialized size of the recipient output. */\n recipientOutputSize: number\n /** Serialized size of a change output to our own address. */\n changeOutputSize: number\n changeDust?: bigint\n maxInputs?: number\n /** Caller-chosen fee (replaces the conventional fee; still has to be covered by the inputs). */\n fee?: bigint\n}\n\n/** UTXOs chosen for a spend, the ZIP-317 fee and the change. */\nexport interface CoinSelection {\n utxos: Utxo[]\n fee: bigint\n /** The ZIP-317 fee for the chosen shape (equals `fee` unless the caller overrode it or change was folded in). */\n conventionalFee: bigint\n /** Change back to us; 0n when folded into the fee. */\n change: bigint\n /** True when change existed but fell below dust and became fee. */\n changeFolded: boolean\n size: number\n}\n\nconst cmpUtxo = (a: Utxo, b: Utxo): number =>\n a.value > b.value ? -1 : a.value < b.value ? 1 : a.txid < b.txid ? -1 : a.txid > b.txid ? 1 : a.vout - b.vout\n\n/** UTXOs worth spending (each adds at most one logical action = 5000 zatoshis), largest first. */\nexport function spendableUtxos(utxos: Utxo[]): Utxo[] {\n return utxos.filter((u) => u.value > MARGINAL_FEE).sort(cmpUtxo)\n}\n\n/**\n * Pick UTXOs to fund `target` at the ZIP-317 fee; change below dust joins the fee.\n *\n * @throws `InsufficientFundsError` (core) when the UTXOs cannot cover target plus fee,\n * `TooManyInputsError` above `maxInputs`.\n */\nexport function selectCoins(o: CoinSelectOptions): CoinSelection {\n const maxInputs = o.maxInputs ?? MAX_UTXO_INPUTS\n const dust = o.changeDust ?? DUST_LIMIT\n const candidates = spendableUtxos(o.utxos)\n const available = o.utxos.reduce((s, u) => s + u.value, 0n)\n const inputs = (n: number) => Array.from({ length: n }, () => P2PKH_INPUT_SIZE)\n const selected: Utxo[] = []\n let sum = 0n\n for (const u of candidates) {\n if (selected.length >= maxInputs) throw new TooManyInputsError(maxInputs)\n selected.push(u)\n sum += u.value\n const n = selected.length\n const convNoChange = conventionalFee(inputs(n), [o.recipientOutputSize])\n const feeNoChange = o.fee ?? convNoChange\n if (sum < o.target + feeNoChange) continue\n const convWithChange = conventionalFee(inputs(n), [o.recipientOutputSize, o.changeOutputSize])\n const feeWithChange = o.fee ?? convWithChange\n const change = sum - o.target - feeWithChange\n if (change >= dust) {\n return { utxos: selected, fee: feeWithChange, conventionalFee: convWithChange, change, changeFolded: false, size: estimateSize(n, [o.recipientOutputSize, o.changeOutputSize]) }\n }\n return { utxos: selected, fee: sum - o.target, conventionalFee: convNoChange, change: 0n, changeFolded: sum - o.target > feeNoChange, size: estimateSize(n, [o.recipientOutputSize]) }\n }\n const need = o.target + (o.fee ?? conventionalFee(inputs(Math.max(selected.length, 1)), [o.recipientOutputSize]))\n throw new InsufficientFundsError(need, available, 'ZEC')\n}\n\n/** Sweep: every spendable input (largest first, capped), one output, no change. */\nexport function selectAll(o: { utxos: Utxo[]; outputSize: number; maxInputs?: number; fee?: bigint }): { utxos: Utxo[]; fee: bigint; amount: bigint; size: number } {\n const maxInputs = o.maxInputs ?? MAX_UTXO_INPUTS\n const utxos = spendableUtxos(o.utxos).slice(0, maxInputs)\n if (utxos.length === 0) return { utxos, fee: 0n, amount: 0n, size: 0 }\n const fee = o.fee ?? conventionalFee(Array.from({ length: utxos.length }, () => P2PKH_INPUT_SIZE), [o.outputSize])\n const amount = utxos.reduce((s, u) => s + u.value, 0n) - fee\n return { utxos, fee, amount: amount > 0n ? amount : 0n, size: estimateSize(utxos.length, [o.outputSize]) }\n}\n","/**\n * Zcash v5 transactions (ZIP-225 format) carrying transparent inputs and\n * outputs only — the shielded bundles are serialized empty. Transaction ids and\n * signature hashes follow ZIP-244 (BLAKE2b-256 digest tree); the consensus\n * branch id is part of both, so a transaction signed for one network upgrade\n * is invalid under the next.\n */\nimport { blake2b } from '@noble/hashes/blake2.js'\nimport { Reader, Writer, bytesToHex, compactSize, hexToBytes, i64le, reverseBytes, u32le, utf8ToBytes } from './encoding.js'\nimport type { SpentOutput } from './types.js'\n\nexport const TX_VERSION_V5 = 0x80000005 // fOverwintered | 5\nexport const VERSION_GROUP_ID_V5 = 0x26a7270a\nexport const SIGHASH_ALL = 0x01\n\n/** Mainnet network upgrades and their consensus branch ids (ZIP-200 table), oldest first. */\nexport const MAINNET_UPGRADES: ReadonlyArray<{ name: string; height: number; branchId: number }> = Object.freeze([\n { name: 'NU5', height: 1_687_104, branchId: 0xc2d6d0b4 },\n { name: 'NU6', height: 2_726_400, branchId: 0xc8e71055 },\n { name: 'NU6.1', height: 3_146_400, branchId: 0x4dec4df0 },\n { name: 'NU6.3', height: 3_428_143, branchId: 0x37a5165b },\n])\n\n/** The branch id the current mainnet tip signs under (NU6.3 \"Ironwood\", active since block 3 428 143, 2026-07-28). */\nexport const CURRENT_BRANCH_ID = MAINNET_UPGRADES[MAINNET_UPGRADES.length - 1]!.branchId\n\n/** Branch id in force at `height` on mainnet (the newest upgrade when the height is unknown or ahead of the table). */\nexport function branchIdForHeight(height: number | undefined): number {\n if (height === undefined || !Number.isFinite(height)) return CURRENT_BRANCH_ID\n let id = MAINNET_UPGRADES[0]!.branchId\n for (const u of MAINNET_UPGRADES) if (height >= u.height) id = u.branchId\n return id\n}\n\nexport interface TxInput {\n /** Display-order hex (as explorers show it). */\n txid: string\n vout: number\n scriptSig: Uint8Array\n sequence: number\n}\n\nexport interface TxOutput {\n value: bigint\n script: Uint8Array\n}\n\n/**\n * A v5 (NU5) transaction with transparent inputs and outputs only, as signed and serialized here.\n */\nexport interface TransparentTxV5 {\n consensusBranchId: number\n lockTime: number\n expiryHeight: number\n inputs: TxInput[]\n outputs: TxOutput[]\n}\n\nexport const FINAL_SEQUENCE = 0xfffffffe\nexport const MAX_SEQUENCE = 0xffffffff\n\nconst assertTxid = (txid: string) => { if (!/^[0-9a-fA-F]{64}$/.test(txid)) throw new Error(`Invalid txid: ${txid}`) }\n\nfunction writeTransparent(w: Writer, tx: TransparentTxV5): void {\n w.compact(tx.inputs.length)\n for (const i of tx.inputs) {\n assertTxid(i.txid)\n w.bytes(reverseBytes(hexToBytes(i.txid))).u32(i.vout).varBytes(i.scriptSig).u32(i.sequence)\n }\n w.compact(tx.outputs.length)\n for (const o of tx.outputs) {\n if (o.value < 0n) throw new Error('Negative output value')\n w.i64(o.value).varBytes(o.script)\n }\n}\n\n/** ZIP-225 wire format with empty Sapling and Orchard bundles. */\nexport function serializeTx(tx: TransparentTxV5): Uint8Array {\n const w = new Writer()\n w.u32(TX_VERSION_V5).u32(VERSION_GROUP_ID_V5).u32(tx.consensusBranchId >>> 0).u32(tx.lockTime).u32(tx.expiryHeight)\n writeTransparent(w, tx)\n w.compact(0) // nSpendsSapling\n w.compact(0) // nOutputsSapling (no valueBalanceSapling / anchor / proofs when both are zero)\n w.compact(0) // nActionsOrchard\n return w.finish()\n}\n\n/** Parse raw hex / bytes. Accepts v5 transactions whose shielded bundles are empty; anything else is refused by name. */\nexport function parseTx(raw: string | Uint8Array): TransparentTxV5 {\n const r = new Reader(typeof raw === 'string' ? hexToBytes(raw) : raw)\n const header = r.u32()\n const overwintered = (header & 0x80000000) !== 0\n const version = header & 0x7fffffff\n if (!overwintered || version !== 5) throw new Error(`Only v5 Zcash transactions are supported here (got version ${version}${overwintered ? '' : ', not overwintered'}).`)\n const vgid = r.u32()\n if (vgid !== VERSION_GROUP_ID_V5) throw new Error(`Unexpected version group id 0x${vgid.toString(16)} for a v5 transaction.`)\n const consensusBranchId = r.u32()\n const lockTime = r.u32()\n const expiryHeight = r.u32()\n const nIn = r.compact()\n const inputs: TxInput[] = []\n for (let i = 0; i < nIn; i++) {\n const txid = bytesToHex(reverseBytes(r.bytes(32)))\n const vout = r.u32()\n const scriptSig = r.varBytes()\n const sequence = r.u32()\n inputs.push({ txid, vout, scriptSig, sequence })\n }\n const nOut = r.compact()\n const outputs: TxOutput[] = []\n for (let i = 0; i < nOut; i++) outputs.push({ value: r.i64(), script: r.varBytes() })\n const nSpends = r.compact()\n const nOutputs = r.compact()\n if (nSpends !== 0 || nOutputs !== 0) throw new Error('This transaction carries a Sapling bundle; shielded transactions are not supported.')\n const nActions = r.compact()\n if (nActions !== 0) throw new Error('This transaction carries an Orchard bundle; shielded transactions are not supported.')\n if (r.remaining !== 0) throw new Error(`Trailing bytes after the transaction (${r.remaining}).`)\n return { consensusBranchId, lockTime, expiryHeight, inputs, outputs }\n}\n\n// ── ZIP-244 digests ──────────────────────────────────────────────────────────\n\nfunction personal(tag: string): Uint8Array {\n const p = utf8ToBytes(tag)\n if (p.length !== 16) throw new Error(`BLAKE2b personalization must be 16 bytes: ${tag}`)\n return p\n}\n\nfunction h(tag: string | Uint8Array, data: Uint8Array): Uint8Array {\n return blake2b(data, { dkLen: 32, personalization: typeof tag === 'string' ? personal(tag) : tag })\n}\n\nconst EMPTY = new Uint8Array(0)\n\n/** `ZcashTxHash_` ‖ consensus branch id (LE) — the personalization of both the txid and the signature digest. */\nexport function txHashPersonalization(consensusBranchId: number): Uint8Array {\n const p = new Uint8Array(16)\n p.set(utf8ToBytes('ZcashTxHash_'), 0)\n p.set(u32le(consensusBranchId >>> 0), 12)\n return p\n}\n\nexport function headerDigest(tx: TransparentTxV5): Uint8Array {\n const w = new Writer().u32(TX_VERSION_V5).u32(VERSION_GROUP_ID_V5).u32(tx.consensusBranchId >>> 0).u32(tx.lockTime).u32(tx.expiryHeight)\n return h('ZTxIdHeadersHash', w.finish())\n}\n\nexport function prevoutsDigest(tx: TransparentTxV5): Uint8Array {\n const w = new Writer()\n for (const i of tx.inputs) { assertTxid(i.txid); w.bytes(reverseBytes(hexToBytes(i.txid))).u32(i.vout) }\n return h('ZTxIdPrevoutHash', w.finish())\n}\n\nexport function sequenceDigest(tx: TransparentTxV5): Uint8Array {\n const w = new Writer()\n for (const i of tx.inputs) w.u32(i.sequence)\n return h('ZTxIdSequencHash', w.finish())\n}\n\nexport function outputsDigest(tx: TransparentTxV5): Uint8Array {\n const w = new Writer()\n for (const o of tx.outputs) w.i64(o.value).varBytes(o.script)\n return h('ZTxIdOutputsHash', w.finish())\n}\n\n/** T.2: hash of the three transparent digests; the hash of the empty string when there are no inputs AND no outputs. */\nexport function transparentDigest(tx: TransparentTxV5): Uint8Array {\n if (tx.inputs.length === 0 && tx.outputs.length === 0) return h('ZTxIdTranspaHash', EMPTY)\n const w = new Writer().bytes(prevoutsDigest(tx)).bytes(sequenceDigest(tx)).bytes(outputsDigest(tx))\n return h('ZTxIdTranspaHash', w.finish())\n}\n\nexport const saplingDigestEmpty = (): Uint8Array => h('ZTxIdSaplingHash', EMPTY)\nexport const orchardDigestEmpty = (): Uint8Array => h('ZTxIdOrchardHash', EMPTY)\n\n/** Non-malleable transaction id (ZIP-244 T.1 … T.4), internal byte order. */\nexport function txidDigest(tx: TransparentTxV5): Uint8Array {\n const w = new Writer().bytes(headerDigest(tx)).bytes(transparentDigest(tx)).bytes(saplingDigestEmpty()).bytes(orchardDigestEmpty())\n return h(txHashPersonalization(tx.consensusBranchId), w.finish())\n}\n\n/** Transaction id as explorers display it (byte-reversed hex). */\nexport function txid(tx: TransparentTxV5): string {\n return bytesToHex(reverseBytes(txidDigest(tx)))\n}\n\n/**\n * ZIP-244 S.2 transparent signature digest + S.1 … S.4 wrapper for SIGHASH_ALL\n * over input `index`. `spent[i]` is the output input `i` spends (value and\n * scriptPubKey are both committed to, so a lying transport cannot make us sign\n * for a different amount).\n */\nexport function sighashAll(tx: TransparentTxV5, index: number, spent: SpentOutput[]): Uint8Array {\n if (spent.length !== tx.inputs.length) throw new Error(`sighash: ${tx.inputs.length} inputs but ${spent.length} spent outputs`)\n const input = tx.inputs[index]\n const coin = spent[index]\n if (!input || !coin) throw new Error(`sighash: input ${index} does not exist`)\n const amounts = new Writer()\n const scripts = new Writer()\n for (const s of spent) { amounts.i64(s.value); scripts.varBytes(s.script) }\n const txin = new Writer().bytes(reverseBytes(hexToBytes(input.txid))).u32(input.vout).i64(coin.value).varBytes(coin.script).u32(input.sequence)\n const t = new Writer()\n .u8(SIGHASH_ALL)\n .bytes(prevoutsDigest(tx))\n .bytes(h('ZTxTrAmountsHash', amounts.finish()))\n .bytes(h('ZTxTrScriptsHash', scripts.finish()))\n .bytes(sequenceDigest(tx))\n .bytes(outputsDigest(tx))\n .bytes(h('Zcash___TxInHash', txin.finish()))\n const transparentSig = h('ZTxIdTranspaHash', t.finish())\n const w = new Writer().bytes(headerDigest(tx)).bytes(transparentSig).bytes(saplingDigestEmpty()).bytes(orchardDigestEmpty())\n return h(txHashPersonalization(tx.consensusBranchId), w.finish())\n}\n\n/** `<sig ‖ 0x01> <pubkey>` — the scriptSig of a P2PKH spend. */\nexport function p2pkhScriptSig(derSignature: Uint8Array, publicKey: Uint8Array): Uint8Array {\n const sig = new Uint8Array(derSignature.length + 1)\n sig.set(derSignature, 0)\n sig[derSignature.length] = SIGHASH_ALL\n return new Writer().bytes(compactSize(sig.length)).bytes(sig).bytes(compactSize(publicKey.length)).bytes(publicKey).finish()\n}\n\n/** Split a P2PKH scriptSig back into DER signature (hash type stripped) and public key; undefined when it is not one. */\nexport function parseP2pkhScriptSig(scriptSig: Uint8Array): { signature: Uint8Array; hashType: number; publicKey: Uint8Array } | undefined {\n try {\n const r = new Reader(scriptSig)\n const sig = r.varBytes()\n const pub = r.varBytes()\n if (r.remaining !== 0 || sig.length < 9 || (pub.length !== 33 && pub.length !== 65)) return undefined\n return { signature: sig.slice(0, -1), hashType: sig[sig.length - 1]!, publicKey: pub }\n } catch { return undefined }\n}\n\nexport { i64le }\n","/** Byte helpers for the Zcash wire format (little-endian integers, Bitcoin CompactSize). */\nexport { bytesToHex, hexToBytes, concatBytes, utf8ToBytes } from '@noble/hashes/utils.js'\n\nexport function compactSize(n: number): Uint8Array {\n if (!Number.isInteger(n) || n < 0) throw new Error(`CompactSize: ${n} is not a non-negative integer`)\n if (n < 0xfd) return Uint8Array.of(n)\n if (n <= 0xffff) return Uint8Array.of(0xfd, n & 0xff, n >>> 8)\n if (n <= 0xffffffff) return Uint8Array.of(0xfe, n & 0xff, (n >>> 8) & 0xff, (n >>> 16) & 0xff, n >>> 24)\n throw new Error('CompactSize: value too large')\n}\n\nexport function u32le(n: number): Uint8Array {\n if (!Number.isInteger(n) || n < 0 || n > 0xffffffff) throw new Error(`u32: ${n} out of range`)\n return Uint8Array.of(n & 0xff, (n >>> 8) & 0xff, (n >>> 16) & 0xff, n >>> 24)\n}\n\n/** Signed 64-bit little-endian (two's complement). Amounts are never negative here, but ZIP-244 types the field as signed. */\nexport function i64le(v: bigint): Uint8Array {\n if (v < -(1n << 63n) || v >= 1n << 63n) throw new Error(`i64: ${v} out of range`)\n let x = v < 0n ? v + (1n << 64n) : v\n const out = new Uint8Array(8)\n for (let i = 0; i < 8; i++) { out[i] = Number(x & 0xffn); x >>= 8n }\n return out\n}\n\nexport class Writer {\n private readonly parts: Uint8Array[] = []\n u8(n: number): this { this.parts.push(Uint8Array.of(n & 0xff)); return this }\n u32(n: number): this { this.parts.push(u32le(n)); return this }\n i64(v: bigint): this { this.parts.push(i64le(v)); return this }\n bytes(b: Uint8Array): this { this.parts.push(b); return this }\n compact(n: number): this { this.parts.push(compactSize(n)); return this }\n /** CompactSize length prefix + bytes (the \"field encoding\" of a script). */\n varBytes(b: Uint8Array): this { return this.compact(b.length).bytes(b) }\n finish(): Uint8Array {\n const len = this.parts.reduce((s, p) => s + p.length, 0)\n const out = new Uint8Array(len)\n let o = 0\n for (const p of this.parts) { out.set(p, o); o += p.length }\n return out\n }\n}\n\nexport class Reader {\n offset = 0\n constructor(private readonly buf: Uint8Array) {}\n get remaining(): number { return this.buf.length - this.offset }\n private need(n: number): void {\n if (this.offset + n > this.buf.length) throw new Error('Transaction truncated')\n }\n u8(): number { this.need(1); return this.buf[this.offset++]! }\n u32(): number {\n this.need(4)\n const b = this.buf\n const o = this.offset\n this.offset += 4\n return (b[o]! | (b[o + 1]! << 8) | (b[o + 2]! << 16)) + b[o + 3]! * 0x1000000\n }\n i64(): bigint {\n this.need(8)\n let v = 0n\n for (let i = 7; i >= 0; i--) v = (v << 8n) | BigInt(this.buf[this.offset + i]!)\n this.offset += 8\n return v >= 1n << 63n ? v - (1n << 64n) : v\n }\n bytes(n: number): Uint8Array { this.need(n); const out = this.buf.slice(this.offset, this.offset + n); this.offset += n; return out }\n compact(): number {\n const first = this.u8()\n if (first < 0xfd) return first\n if (first === 0xfd) { this.need(2); const v = this.buf[this.offset]! | (this.buf[this.offset + 1]! << 8); this.offset += 2; return v }\n if (first === 0xfe) return this.u32()\n throw new Error('CompactSize: 64-bit lengths are not supported')\n }\n varBytes(): Uint8Array { return this.bytes(this.compact()) }\n}\n\n/** Display ↔ internal byte order of a 32-byte hash (Bitcoin convention: hex is shown reversed). */\nexport function reverseBytes(b: Uint8Array): Uint8Array {\n return Uint8Array.from(b).reverse()\n}\n","import { DUST_LIMIT, addressFromScript, outputSize, scriptKind } from './address.js'\nimport { conventionalFee } from './fee.js'\nimport { serializeTx, txid as txidOf, type TransparentTxV5 } from './tx.js'\nimport type { SpentOutput, ZcashNetwork, ZcashTxDescription, ZcashTxOutputDescription, ZcashWarning } from './types.js'\n\n/** Default hard fee ceiling: 0.01 ZEC. */\nexport const DEFAULT_MAX_FEE = 1_000_000n\n\n/** Why a spend was refused before signing. */\nexport type UnsafeTransactionCode =\n /** Fee above `maxFee`. */\n | 'fee-too-high'\n /** Outputs exceed inputs. */\n | 'outputs-exceed-inputs'\n /** An output that is neither the requested recipient/amount nor our change. */\n | 'unexpected-output'\n /** The recipient output is missing or carries a different amount. */\n | 'recipient-mismatch'\n /** A change output pays an address that is not ours. */\n | 'change-not-ours'\n\n/** A transaction failed a hard safety check and was not signed / broadcast. */\nexport class UnsafeTransactionError extends Error {\n readonly code: UnsafeTransactionCode\n constructor(code: UnsafeTransactionCode, message: string) {\n super(message)\n this.name = 'UnsafeTransactionError'\n this.code = code\n }\n}\n\n/** What a description needs to tell recipient, change and unknown outputs apart. */\nexport interface DescribeContext {\n network: ZcashNetwork\n /** Our own address: outputs paying it are tagged `change`. */\n ownAddress: string\n /** The spend the caller asked for. Outputs matching it are `recipient`; anything else is `unknown`. */\n intended?: { to: string; value: bigint } | undefined\n maxFee?: bigint | undefined\n}\n\n/** Byte size of a serialized input (what ZIP-317 counts). */\nfunction inputSizes(tx: TransparentTxV5): number[] {\n return tx.inputs.map((i) => 32 + 4 + (i.scriptSig.length < 0xfd ? 1 : 3) + i.scriptSig.length + 4)\n}\n\n/** Describe a (signed or unsigned) transaction given the output every input spends. Pure: no network, no signing. */\nexport function describeTransaction(tx: TransparentTxV5, spent: SpentOutput[], ctx: DescribeContext): ZcashTxDescription {\n if (spent.length !== tx.inputs.length) throw new Error(`describeTransaction: ${tx.inputs.length} inputs but ${spent.length} spent outputs`)\n const inputs = tx.inputs.map((i, k) => ({ txid: i.txid, vout: i.vout, value: spent[k]!.value, address: addressFromScript(spent[k]!.script, ctx.network) }))\n const outputs: ZcashTxOutputDescription[] = []\n const warnings = new Set<ZcashWarning>()\n for (const o of tx.outputs) {\n const address = addressFromScript(o.script, ctx.network)\n const role: ZcashTxOutputDescription['role'] =\n address !== undefined && address === ctx.ownAddress ? 'change'\n : ctx.intended === undefined ? 'recipient'\n : address !== undefined && address === ctx.intended.to && o.value === ctx.intended.value ? 'recipient'\n : 'unknown'\n if (scriptKind(o.script) !== 'unknown' && o.value < DUST_LIMIT) warnings.add('dust-output')\n outputs.push({ address, value: o.value, role })\n }\n const inputSum = spent.reduce((s, c) => s + c.value, 0n)\n const outputSum = tx.outputs.reduce((s, o) => s + o.value, 0n)\n const fee = inputSum - outputSum\n const amount = outputs.filter((o) => o.role !== 'change').reduce((s, o) => s + o.value, 0n)\n const conv = conventionalFee(inputSizes(tx), tx.outputs.map((o) => outputSize(o.script)))\n if (fee < conv) warnings.add('fee-below-conventional')\n if (amount > 0n && fee * 10n > amount) warnings.add('fee-over-10pct-of-amount')\n if (!outputs.some((o) => o.role === 'change')) warnings.add('no-change')\n if (tx.expiryHeight === 0) warnings.add('no-expiry')\n const signed = tx.inputs.length > 0 && tx.inputs.every((i) => i.scriptSig.length > 0)\n const desc: ZcashTxDescription = {\n kind: 'zcash-transfer', version: 5, consensusBranchId: tx.consensusBranchId, inputs, outputs, amount, fee, conventionalFee: conv,\n size: serializeTx(tx).length, lockTime: tx.lockTime, expiryHeight: tx.expiryHeight, warnings: [...warnings],\n }\n if (signed) desc.txid = txidOf(tx)\n return desc\n}\n\n/**\n * Hard checks run before signing and before broadcasting. Throws UnsafeTransactionError;\n * never mutates. With `intended`, exactly one output must be the requested\n * recipient/amount and every other output must be our change.\n */\nexport function assertSafe(desc: ZcashTxDescription, ctx: DescribeContext): void {\n const maxFee = ctx.maxFee ?? DEFAULT_MAX_FEE\n if (desc.fee < 0n) throw new UnsafeTransactionError('outputs-exceed-inputs', 'Outputs exceed inputs.')\n if (desc.fee > maxFee) throw new UnsafeTransactionError('fee-too-high', `Fee ${desc.fee} zatoshis exceeds the ${maxFee} zatoshi ceiling (maxFee).`)\n for (const o of desc.outputs) {\n if (o.role === 'change' && o.address !== ctx.ownAddress) throw new UnsafeTransactionError('change-not-ours', `Change output pays ${o.address ?? '<no address>'}, not ${ctx.ownAddress}.`)\n }\n if (ctx.intended) {\n const recipients = desc.outputs.filter((o) => o.role === 'recipient')\n if (recipients.length !== 1) throw new UnsafeTransactionError('recipient-mismatch', `Expected one output of ${ctx.intended.value} zatoshis to ${ctx.intended.to}, found ${recipients.length}.`)\n const unknown = desc.outputs.filter((o) => o.role === 'unknown')\n if (unknown.length) throw new UnsafeTransactionError('unexpected-output', `Transaction carries ${unknown.length} output(s) that are neither the recipient nor our change.`)\n }\n}\n","/**\n * Blockchair REST transport (`https://api.blockchair.com/zcash`): public, CORS\n * open, no key needed at wallet volumes (one request every couple of seconds;\n * a `key` lifts the quota). Mainnet only — Blockchair indexes no Zcash\n * testnet. Address dashboards carry the UTXO set (mempool included, block_id\n * -1), `raw/transaction` the hex, `push/transaction` broadcasts.\n */\nimport { NetworkError } from '@anywalletkit/core'\nimport { hexToBytes } from './encoding.js'\nimport { DEFAULT_TIMEOUT_MS, fetchWithTimeout, isInt, isRecord } from './http.js'\nimport type { SpentOutput, Utxo, ZcashClient, ZcashTxInfo } from './types.js'\n\n/** Default Blockchair API root for Zcash. */\nexport const BLOCKCHAIR_URL = 'https://api.blockchair.com/zcash'\n/** Blockchair caps the `utxo` list of an address dashboard at this many rows. */\nconst UTXO_LIMIT = 1000\n\ninterface BlockchairUtxo { block_id: number; transaction_hash: string; index: number; value: number }\ninterface BlockchairAddress { balance: number; unspent_output_count?: number; transaction_count?: number }\ninterface BlockchairTxRow { block_id: number; hash: string; time?: string; fee?: number; input_count?: number; output_count?: number }\ninterface BlockchairOutput { index: number; value: number; script_hex: string; recipient?: string }\ninterface BlockchairInput extends BlockchairOutput { transaction_hash: string; spending_index?: number; spending_sequence?: number }\nexport interface BlockchairTxDashboard { transaction: BlockchairTxRow; inputs: BlockchairInput[]; outputs: BlockchairOutput[] }\ninterface Envelope<T> { data: T; context: { code: number; state?: number; error?: string } }\n\nconst isUtxo = (v: unknown): v is BlockchairUtxo => isRecord(v) && isInt(v.block_id) && typeof v.transaction_hash === 'string' && isInt(v.index) && typeof v.value === 'number'\nconst isOutput = (v: unknown): v is BlockchairOutput => isRecord(v) && isInt(v.index) && typeof v.value === 'number' && typeof v.script_hex === 'string'\nconst isDashboard = (v: unknown): v is BlockchairTxDashboard =>\n isRecord(v) && isRecord(v.transaction) && isInt(v.transaction.block_id) && typeof v.transaction.hash === 'string' && Array.isArray(v.inputs) && v.inputs.every(isOutput) && Array.isArray(v.outputs) && v.outputs.every(isOutput)\n\n/** \"2026-10-18 10:05:14\" (UTC) → unix seconds. */\nexport function blockchairTime(s: string | undefined): number | undefined {\n if (!s) return undefined\n const t = Date.parse(`${s.replace(' ', 'T')}Z`)\n return Number.isFinite(t) ? Math.floor(t / 1000) : undefined\n}\n\nexport class BlockchairClient implements ZcashClient {\n private readonly base: string\n private readonly key: string | undefined\n private readonly fetchFn: typeof fetch\n private readonly timeoutMs: number\n\n constructor(config: { url?: string; key?: string } = {}, fetchFn: typeof fetch = globalThis.fetch, timeoutMs = DEFAULT_TIMEOUT_MS) {\n this.base = (config.url ?? BLOCKCHAIR_URL).replace(/\\/+$/, '')\n this.key = config.key\n this.fetchFn = fetchFn\n this.timeoutMs = timeoutMs\n }\n\n async connect(): Promise<void> {}\n async close(): Promise<void> {}\n\n private url(path: string, query: Record<string, string> = {}): string {\n const q = new URLSearchParams(query)\n if (this.key) q.set('key', this.key)\n const s = q.toString()\n return `${this.base}/${path}${s ? `?${s}` : ''}`\n }\n\n private async request<T>(path: string, query: Record<string, string>, init: RequestInit | undefined, check: (v: unknown) => v is T): Promise<{ data: T; state: number | undefined }> {\n const url = this.url(path, query)\n const res = await fetchWithTimeout(this.fetchFn, url, init, this.timeoutMs, this.base)\n let body: unknown\n try { body = await res.json() } catch (e) {\n if (res.status === 402 || res.status === 429 || res.status === 430) throw new NetworkError(`Blockchair rate limit (${res.status})`, { provider: this.base })\n throw new NetworkError(`Blockchair returned non-JSON (${res.status}) for ${url}`, { provider: this.base, cause: e })\n }\n const env = body as Partial<Envelope<unknown>>\n const code = env.context?.code ?? res.status\n if (code === 402 || code === 429 || code === 430) throw new NetworkError(`Blockchair rate limit (${code})`, { provider: this.base })\n if (code === 404) throw new NotFound()\n if (code !== 200 || !res.ok) throw new NetworkError(`Blockchair request failed: ${code} ${env.context?.error ?? res.statusText} (${url})`, { provider: this.base })\n if (!check(env.data)) throw new NetworkError(`Blockchair returned an unexpected shape for ${url}`, { provider: this.base })\n return { data: env.data, state: env.context?.state }\n }\n\n private async dashboard(address: string): Promise<{ address: BlockchairAddress; utxo: BlockchairUtxo[]; transactions: string[]; state: number | undefined }> {\n const { data, state } = await this.request(`dashboards/address/${address}`, { limit: `0,${UTXO_LIMIT}` }, undefined, (v): v is Record<string, { address: BlockchairAddress; utxo: BlockchairUtxo[]; transactions?: string[] }> =>\n isRecord(v) && Object.values(v).every((a) => isRecord(a) && isRecord(a.address) && typeof a.address.balance === 'number' && Array.isArray(a.utxo) && a.utxo.every(isUtxo)))\n const entry = data[address] ?? Object.values(data)[0]\n if (!entry) throw new NetworkError(`Blockchair knows no address ${address}`, { provider: this.base })\n return { address: entry.address, utxo: entry.utxo, transactions: entry.transactions ?? [], state }\n }\n\n /** Transaction hashes of an address, newest first, paged by offset (what the activity history walks). */\n async listTransactions(address: string, limit: number, offset: number): Promise<{ hashes: string[]; total: number | undefined }> {\n const { data } = await this.request(`dashboards/address/${address}`, { limit: `${limit},0`, offset: `${offset},0` }, undefined, (v): v is Record<string, { address: BlockchairAddress; transactions?: string[] }> =>\n isRecord(v) && Object.values(v).every((a) => isRecord(a) && isRecord(a.address) && (a.transactions === undefined || Array.isArray(a.transactions))))\n const entry = data[address] ?? Object.values(data)[0]\n if (!entry) throw new NetworkError(`Blockchair knows no address ${address}`, { provider: this.base })\n return { hashes: (entry.transactions ?? []).filter((h): h is string => typeof h === 'string'), total: entry.address.transaction_count }\n }\n\n /** Confirmed = the UTXOs mined so far; unconfirmed = incoming mempool outputs. (Beyond 1000 UTXOs the dashboard balance is used.) */\n async getBalance(address: string): Promise<{ confirmed: bigint; unconfirmed: bigint }> {\n const d = await this.dashboard(address)\n let confirmed = 0n, unconfirmed = 0n\n for (const u of d.utxo) { if (u.block_id > 0) confirmed += BigInt(u.value); else unconfirmed += BigInt(u.value) }\n if ((d.address.unspent_output_count ?? d.utxo.length) > d.utxo.length) confirmed = BigInt(d.address.balance) - unconfirmed\n return { confirmed, unconfirmed }\n }\n\n async listUnspent(address: string): Promise<Utxo[]> {\n const d = await this.dashboard(address)\n return d.utxo.map((u) => ({ txid: u.transaction_hash, vout: u.index, value: BigInt(u.value), height: u.block_id > 0 ? u.block_id : -1 }))\n }\n\n async getTransaction(txid: string): Promise<string> {\n const { data } = await this.request(`raw/transaction/${txid}`, {}, undefined, (v): v is Record<string, { raw_transaction: string }> =>\n isRecord(v) && Object.values(v).every((t) => isRecord(t) && typeof t.raw_transaction === 'string'))\n const hex = (data[txid] ?? Object.values(data)[0])?.raw_transaction\n if (!hex) throw new NetworkError(`Transaction ${txid} has no raw data`, { provider: this.base })\n return hex\n }\n\n /** Inputs / outputs with addresses, values and scripts — what the activity history and prevout lookups read. */\n async getTransactionDashboard(txid: string): Promise<BlockchairTxDashboard | undefined> {\n try {\n const { data, state } = await this.request(`dashboards/transaction/${txid}`, {}, undefined, (v): v is Record<string, BlockchairTxDashboard | null> =>\n isRecord(v) && Object.values(v).every((t) => t === null || isDashboard(t)))\n const t = data[txid] ?? Object.values(data)[0]\n if (!t) return undefined\n return { ...t, transaction: { ...t.transaction, ...(state !== undefined ? { confirmations: t.transaction.block_id > 0 ? state - t.transaction.block_id + 1 : 0 } : {}) } } as BlockchairTxDashboard\n } catch (e) {\n if (e instanceof NotFound) return undefined\n throw e\n }\n }\n\n /** Several transactions in one call (Blockchair takes up to 10 comma-separated hashes). */\n async getTransactionDashboards(txids: string[]): Promise<Map<string, BlockchairTxDashboard>> {\n const out = new Map<string, BlockchairTxDashboard>()\n for (let i = 0; i < txids.length; i += 10) {\n const slice = txids.slice(i, i + 10)\n const { data, state } = await this.request(`dashboards/transactions/${slice.join(',')}`, {}, undefined, (v): v is Record<string, BlockchairTxDashboard | null> =>\n isRecord(v) && Object.values(v).every((t) => t === null || isDashboard(t)))\n for (const [hash, t] of Object.entries(data)) {\n if (!t) continue\n const confirmations = state !== undefined && t.transaction.block_id > 0 ? state - t.transaction.block_id + 1 : 0\n out.set(hash, { ...t, transaction: { ...t.transaction, confirmations } } as BlockchairTxDashboard)\n }\n }\n return out\n }\n\n async getOutput(txid: string, vout: number): Promise<SpentOutput | undefined> {\n const d = await this.getTransactionDashboard(txid)\n const o = d?.outputs.find((x) => x.index === vout)\n return o ? { value: BigInt(o.value), script: hexToBytes(o.script_hex) } : undefined\n }\n\n async getTransactionInfo(txid: string): Promise<ZcashTxInfo | undefined> {\n const d = await this.getTransactionDashboard(txid)\n if (!d) return undefined\n const t = d.transaction as BlockchairTxRow & { confirmations?: number }\n const info: ZcashTxInfo = { txid: t.hash, blockHeight: t.block_id > 0 ? t.block_id : -1, confirmations: t.confirmations ?? 0 }\n if (typeof t.fee === 'number') info.fee = BigInt(t.fee)\n const time = blockchairTime(t.time)\n if (time !== undefined) info.blockTime = time\n return info\n }\n\n async broadcast(rawTx: string): Promise<string> {\n const body = `data=${encodeURIComponent(rawTx)}`\n const url = this.url('push/transaction')\n const res = await fetchWithTimeout(this.fetchFn, url, { method: 'POST', headers: { 'content-type': 'application/x-www-form-urlencoded' }, body }, this.timeoutMs, this.base)\n let env: Partial<Envelope<{ transaction_hash?: string } | null>> = {}\n try { env = (await res.json()) as typeof env } catch { /* handled below */ }\n const hash = env.data?.transaction_hash\n if (hash) return hash\n const reason = env.context?.error ?? `${res.status} ${res.statusText}`\n // A rejected transaction is the node's verdict, not a transport failure — a plain Error (not NetworkError), so failover does not retry it elsewhere.\n throw new Error(`Broadcast rejected: ${reason}`)\n }\n\n async getBlockHeight(): Promise<number> {\n const { data } = await this.request('stats', {}, undefined, (v): v is { best_block_height: number } => isRecord(v) && isInt(v.best_block_height))\n if (data.best_block_height <= 0) throw new NetworkError('Blockchair reported no block height', { provider: this.base })\n return data.best_block_height\n }\n}\n\nclass NotFound extends Error { constructor() { super('not found'); this.name = 'NotFound' } }\n","import { NetworkError } from '@anywalletkit/core'\n\nexport const DEFAULT_TIMEOUT_MS = 15_000\n\n/** fetch with a per-request timeout when the runtime has `AbortSignal.timeout` (Hermes needs runtime-hermes for it). */\nexport async function fetchWithTimeout(fetchFn: typeof fetch, url: string, init: RequestInit | undefined, timeoutMs: number, provider: string): Promise<Response> {\n const signal = typeof AbortSignal !== 'undefined' && typeof AbortSignal.timeout === 'function' ? AbortSignal.timeout(timeoutMs) : undefined\n try {\n return await fetchFn(url, { ...init, ...(signal ? { signal } : {}) })\n } catch (e) {\n throw new NetworkError(`Request failed: ${url}`, { provider, cause: e })\n }\n}\n\nexport const isRecord = (v: unknown): v is Record<string, unknown> => typeof v === 'object' && v !== null && !Array.isArray(v)\nexport const isHex64 = (v: unknown): v is string => typeof v === 'string' && /^[0-9a-fA-F]{64}$/.test(v)\nexport const isIntString = (v: unknown): v is string => typeof v === 'string' && /^-?\\d+$/.test(v)\nexport const isInt = (v: unknown): v is number => typeof v === 'number' && Number.isInteger(v)\n","/**\n * Zcash Blockbook REST transport — the same `/api/v2` surface as Bitcoin's\n * (NOWNodes `https://zec-blockbook.nownodes.io` with an `api-key` header, any\n * self-hosted Blockbook built for Zcash). Serves testnet too.\n */\nimport { NetworkError } from '@anywalletkit/core'\nimport { hexToBytes } from './encoding.js'\nimport { DEFAULT_TIMEOUT_MS, fetchWithTimeout, isInt, isIntString, isRecord } from './http.js'\nimport type { SpentOutput, Utxo, ZcashClient, ZcashTxInfo } from './types.js'\n\nexport interface BlockbookVin { txid?: string; vout?: number; n?: number; isAddress?: boolean; addresses?: string[]; value?: string }\nexport interface BlockbookVout { n: number; isAddress?: boolean; addresses?: string[]; value?: string; hex?: string }\nexport interface BlockbookTxDetails {\n txid: string\n blockHeight: number\n confirmations: number\n blockTime?: number\n fees?: string\n hex?: string\n vin?: BlockbookVin[]\n vout?: BlockbookVout[]\n}\n\nexport class ZcashBlockbookClient implements ZcashClient {\n private readonly base: string\n private readonly headers: Record<string, string>\n private readonly fetchFn: typeof fetch\n private readonly timeoutMs: number\n\n constructor(config: { url: string; headers?: Record<string, string> }, fetchFn: typeof fetch = globalThis.fetch, timeoutMs = DEFAULT_TIMEOUT_MS) {\n this.base = config.url.replace(/\\/+$/, '').replace(/\\/api$/, '')\n this.headers = { accept: 'application/json', ...(config.headers ?? {}) }\n this.fetchFn = fetchFn\n this.timeoutMs = timeoutMs\n }\n\n async connect(): Promise<void> {}\n async close(): Promise<void> {}\n\n private async get<T>(path: string, check: (v: unknown) => v is T): Promise<T> {\n const url = `${this.base}/api${path}`\n const res = await fetchWithTimeout(this.fetchFn, url, { headers: this.headers }, this.timeoutMs, this.base)\n if (!res.ok) throw new NetworkError(`Blockbook request failed: ${res.status} ${res.statusText} (${url})`, { provider: this.base })\n let body: unknown\n try { body = await res.json() } catch (e) { throw new NetworkError(`Blockbook returned non-JSON for ${url}`, { provider: this.base, cause: e }) }\n if (!check(body)) throw new NetworkError(`Blockbook returned an unexpected shape for ${url}`, { provider: this.base })\n return body\n }\n\n async getBalance(address: string) {\n const data = await this.get(`/v2/address/${address}?details=basic`, (v): v is { balance: string; unconfirmedBalance: string } => isRecord(v) && isIntString(v.balance) && isIntString(v.unconfirmedBalance))\n return { confirmed: BigInt(data.balance), unconfirmed: BigInt(data.unconfirmedBalance) }\n }\n\n async listUnspent(address: string): Promise<Utxo[]> {\n const data = await this.get(`/v2/utxo/${address}`, (v): v is Array<{ txid: string; vout: number; value: string; height?: number }> =>\n Array.isArray(v) && v.every((u) => isRecord(u) && typeof u.txid === 'string' && isInt(u.vout) && isIntString(u.value)))\n return data.map((u) => ({ txid: u.txid, vout: u.vout, value: BigInt(u.value), height: u.height && u.height > 0 ? u.height : -1 }))\n }\n\n private static isTx(v: unknown): v is BlockbookTxDetails {\n return isRecord(v) && typeof v.txid === 'string' && isInt(v.blockHeight) && isInt(v.confirmations)\n }\n\n async getTransactionDetails(txid: string): Promise<BlockbookTxDetails | undefined> {\n try { return await this.get(`/v2/tx/${txid}`, ZcashBlockbookClient.isTx) } catch (e) {\n if (e instanceof NetworkError && /\\b(400|404)\\b/.test(e.message)) return undefined\n throw e\n }\n }\n\n async getTransaction(txid: string): Promise<string> {\n const tx = await this.get(`/v2/tx/${txid}`, ZcashBlockbookClient.isTx)\n if (typeof tx.hex !== 'string' || !tx.hex) throw new NetworkError(`Transaction ${txid} has no hex data`, { provider: this.base })\n return tx.hex\n }\n\n async getOutput(txid: string, vout: number): Promise<SpentOutput | undefined> {\n const tx = await this.getTransactionDetails(txid)\n const o = tx?.vout?.find((x) => x.n === vout)\n if (!o || !isIntString(o.value) || typeof o.hex !== 'string') return undefined\n return { value: BigInt(o.value), script: hexToBytes(o.hex) }\n }\n\n async getTransactionInfo(txid: string): Promise<ZcashTxInfo | undefined> {\n const tx = await this.getTransactionDetails(txid)\n if (!tx) return undefined\n const info: ZcashTxInfo = { txid: tx.txid, blockHeight: tx.blockHeight > 0 ? tx.blockHeight : -1, confirmations: tx.confirmations }\n if (isIntString(tx.fees)) info.fee = BigInt(tx.fees)\n if (typeof tx.blockTime === 'number') info.blockTime = tx.blockTime\n return info\n }\n\n async broadcast(rawTx: string): Promise<string> {\n const data = await this.get(`/v2/sendtx/${rawTx}`, (v): v is { result?: string; error?: { message?: string } | string } => isRecord(v))\n if (data.error) throw new Error(`Broadcast rejected: ${typeof data.error === 'string' ? data.error : data.error.message ?? 'broadcast failed'}`)\n if (!data.result) throw new NetworkError('Blockbook returned no txid', { provider: this.base })\n return data.result\n }\n\n async getBlockHeight(): Promise<number> {\n const data = await this.get('/v2', (v): v is { blockbook?: { bestHeight?: number } } => isRecord(v))\n const h = data.blockbook?.bestHeight\n if (typeof h !== 'number' || h <= 0) throw new NetworkError('Blockbook did not report a block height', { provider: this.base })\n return h\n }\n}\n","import { NetworkError } from '@anywalletkit/core'\nimport { BlockchairClient } from './blockchair.js'\nimport { ZcashBlockbookClient } from './blockbook.js'\nimport { DEFAULT_TIMEOUT_MS } from './http.js'\nimport type { ZcashClient, ZcashClientConfig, ZcashConfig } from './types.js'\n\nconst isClient = (c: unknown): c is ZcashClient => typeof c === 'object' && c !== null && typeof (c as ZcashClient).listUnspent === 'function'\n\nfunction toClient(c: ZcashClientConfig | ZcashClient, fetchFn: typeof fetch | undefined, timeoutMs: number): ZcashClient {\n if (isClient(c)) return c\n switch (c.type) {\n case 'blockchair': return new BlockchairClient(c.clientConfig ?? {}, fetchFn, timeoutMs)\n case 'blockbook-http': return new ZcashBlockbookClient(c.clientConfig, fetchFn, timeoutMs)\n default: throw new Error(`Unknown Zcash client type: ${String((c as { type: string }).type)}`)\n }\n}\n\nconst METHODS = ['connect', 'close', 'getBalance', 'listUnspent', 'getTransaction', 'getOutput', 'getTransactionInfo', 'broadcast', 'getBlockHeight'] as const\n\n/**\n * One client, or a failover client over the list: each call walks the list in\n * order, `retries` extra rounds. A node's rejection of a broadcast (plain\n * Error) is final — only transport failures (NetworkError) move on.\n */\nexport function createClient(config: ZcashConfig): ZcashClient | undefined {\n if (config.client === undefined) return undefined\n const timeoutMs = config.timeoutMs ?? DEFAULT_TIMEOUT_MS\n const list = (Array.isArray(config.client) ? config.client : [config.client]).map((c) => toClient(c, config.fetch, timeoutMs))\n if (list.length === 0) return undefined\n if (list.length === 1) return list[0]!\n const attempts = list.length + (config.retries ?? 3)\n const call = (method: (typeof METHODS)[number]) => async (...args: unknown[]) => {\n let last: unknown\n for (let i = 0; i < attempts; i++) {\n const c = list[i % list.length]! as unknown as Record<string, (...a: unknown[]) => Promise<unknown>>\n try { return await c[method]!.apply(c, args) } catch (e) {\n if (method === 'broadcast' && !(e instanceof NetworkError)) throw e\n last = e\n }\n }\n throw new NetworkError(`All Zcash clients failed for ${method}`, { cause: last })\n }\n const out = {} as Record<(typeof METHODS)[number], (...args: unknown[]) => Promise<unknown>>\n for (const m of METHODS) out[m] = call(m)\n return out as unknown as ZcashClient\n}\n","/**\n * Zcash signed messages (zcashd `signmessage` / `verifymessage`): the Bitcoin\n * scheme with the `Zcash Signed Message:\\n` magic. hash = sha256d(varint(prefix)\n * ‖ prefix ‖ varint(len) ‖ message); header byte = 27 + recovery + 4\n * (compressed key); output base64 of header ‖ r ‖ s. RFC-6979 deterministic, low-S.\n */\nimport { sha256 } from '@noble/hashes/sha2.js'\nimport { secp256k1 } from '@noble/curves/secp256k1.js'\nimport { base64 } from '@scure/base'\nimport type { Signer } from '@anywalletkit/core'\nimport { compactSize, utf8ToBytes } from './encoding.js'\n\nconst MAGIC = 'Zcash Signed Message:\\n'\nconst PREFIX = utf8ToBytes(MAGIC)\n\n/** Hash of a signed message (`Zcash Signed Message:` prefix, double SHA-256). */\nexport function magicHash(message: string | Uint8Array): Uint8Array {\n const msg = typeof message === 'string' ? utf8ToBytes(message) : message\n const p = compactSize(PREFIX.length), l = compactSize(msg.length)\n const buf = new Uint8Array(p.length + PREFIX.length + l.length + msg.length)\n let o = 0\n for (const part of [p, PREFIX, l, msg]) { buf.set(part, o); o += part.length }\n return sha256(sha256(buf))\n}\n\n/** Encode `r‖s` + recovery id as a base64 signature (compressed-key header 31 + recovery). */\nexport function encodeMessageSignature(rs: Uint8Array, recovery: number): string {\n if (rs.length !== 64 || recovery > 3) throw new Error('Expected a 64-byte r‖s signature and a recovery id 0..3.')\n const out = new Uint8Array(65)\n out[0] = 27 + 4 + recovery\n out.set(rs, 1)\n return base64.encode(out)\n}\n\n/** Sign through a {@link Signer} (`ecdsa-recoverable`, context `zcash-message`). */\nexport async function signMessageWith(message: string | Uint8Array, signer: Signer): Promise<string> {\n const sig = await signer.sign(magicHash(message), { scheme: 'ecdsa-recoverable', context: 'zcash-message' })\n return encodeMessageSignature(sig.subarray(0, 64), sig[64]!)\n}\n\n/** Recover the compressed public key from a message signature, or undefined when malformed. */\nexport function recoverMessagePublicKey(message: string | Uint8Array, signature: string): Uint8Array | undefined {\n let bytes: Uint8Array\n try { bytes = base64.decode(signature) } catch { return undefined }\n if (bytes.length !== 65) return undefined\n const flag = bytes[0]! - 27\n if (flag < 0 || flag > 15) return undefined\n const recovered = new Uint8Array(65)\n recovered[0] = flag & 3\n recovered.set(bytes.subarray(1), 1)\n try {\n const pub = secp256k1.recoverPublicKey(recovered, magicHash(message), { prehash: false })\n return pub.length === 33 ? pub : secp256k1.Point.fromBytes(pub).toBytes(true)\n } catch { return undefined }\n}\n","import { LocalSigner, SignerError, WalletManager, isSeedSigner, type FeeRates, type Signer } from '@anywalletkit/core'\nimport { WalletAccountZcash } from './account.js'\nimport { MARGINAL_FEE } from './fee.js'\nimport { WalletAccountReadOnlyZcash } from './read-only-account.js'\nimport type { ZcashConfig, ZcashNetwork } from './types.js'\n\n/** SLIP-44 coin type: 133 for mainnet, 1 for testnet. */\nexport const coinType = (network: ZcashNetwork): 133 | 1 => (network === 'mainnet' ? 133 : 1)\n\n/**\n * One seed → Zcash transparent accounts at m/44'/133'/0'/0/i (BIP-44, the path\n * Zashi, YWallet, Ledger and Trezor use for the transparent receiver) — t1… on\n * mainnet, tm… on testnet. Paths may be relative to the purpose/coin prefix\n * (\"0'/0/i\") or given in full.\n *\n * Built with a secp256k1 `Signer` instead of a seed, the manager wraps it:\n * a derivable `SeedSigner` yields `getAccount(i)` children below its path; a\n * leaf or external signer is `getAccount(0)`.\n */\nexport class WalletManagerZcash extends WalletManager<WalletAccountZcash, ZcashConfig> {\n constructor(seedOrSigner: string | Uint8Array | Signer, config: ZcashConfig = {}) {\n super(seedOrSigner, config)\n }\n\n /** `m/44'/133'` on mainnet (coin type 1 on testnet); account `i` is at `basePath/0'/0/i`. */\n get basePath(): string {\n return `m/44'/${coinType(this._config.network ?? 'mainnet')}'`\n }\n\n async getAccount(index = 0): Promise<WalletAccountZcash> {\n return this.getAccountByPath(`${this.basePath}/0'/0/${index}`)\n }\n\n async getAccountByPath(path: string): Promise<WalletAccountZcash> {\n const full = path.startsWith('m/') ? path : `${this.basePath}/${path}`\n const cached = this._accounts.get(full)\n if (cached) return cached\n const external = this.externalSigner()\n if (external) return this.fromSigner(external, full)\n const signer = LocalSigner.leafFromSeed(this.seedBytes(), 'secp256k1', full)\n const account = new WalletAccountZcash(signer, signer.publicKey, full, this._config)\n this._accounts.set(full, account)\n return account\n }\n\n private async fromSigner(signer: Signer, path: string): Promise<WalletAccountZcash> {\n this.requireSigner('secp256k1')\n let leaf: Signer = signer\n let key = 'external'\n if (isSeedSigner(signer)) {\n if (path === signer.path) key = path\n else if (path.startsWith(`${signer.path}/`)) { leaf = await (signer.deriveLeaf ?? signer.derive).call(signer, path.slice(signer.path.length + 1)); key = path }\n else throw new SignerError(`The injected signer sits at ${signer.path}; it cannot provide ${path}.`)\n } else if (path !== `${this.basePath}/0'/0/0` && path !== 'external') {\n throw new SignerError(`An external signer has one account; ${path} is not derivable from it.`)\n }\n const cached = this._accounts.get(key)\n if (cached) return cached\n const account = new WalletAccountZcash(leaf, await leaf.getPublicKey(), key, this._config)\n this._accounts.set(key, account)\n return account\n }\n\n /** A read-only account for any transparent address, with this manager's config. */\n getReadOnlyAccount(address: string): WalletAccountReadOnlyZcash {\n return new WalletAccountReadOnlyZcash(address, this._config)\n }\n\n /** ZIP-317 has no fee market: every tier is the 5000-zatoshi marginal fee per logical action. */\n async getFeeRates(): Promise<FeeRates> {\n return { slow: MARGINAL_FEE, normal: MARGINAL_FEE, fast: MARGINAL_FEE }\n }\n}\n","import { InsufficientFundsError, LocalSigner, SignerError, requireCurve, type IWalletAccount, type IWalletAccountReadOnly, type Signer, type TransferResult } from '@anywalletkit/core'\nimport { secp256k1 } from '@noble/curves/secp256k1.js'\nimport { DUST_LIMIT, addressFromPublicKey } from './address.js'\nimport { UnsafeTransactionError, assertSafe, describeTransaction, type DescribeContext } from './describe.js'\nimport { bytesToHex } from './encoding.js'\nimport { signMessageWith } from './message.js'\nimport { WalletAccountReadOnlyZcash, type SpendPlan } from './read-only-account.js'\nimport { FINAL_SEQUENCE, branchIdForHeight, p2pkhScriptSig, parseTx, serializeTx, sighashAll, txid as txidOf, type TransparentTxV5 } from './tx.js'\nimport type { SpentOutput, ZcashConfig, ZcashNetwork, ZcashSpend, ZcashTransaction, ZcashTransferOptions, ZcashTxDescription } from './types.js'\n\nexport { addressFromPublicKey }\n\n/** t-address for a compressed public key. */\nexport function addressFor(publicKey: Uint8Array, network: ZcashNetwork = 'mainnet'): string {\n return addressFromPublicKey(publicKey, network)\n}\n\n/** ZIP-203 default: a transaction expires 40 blocks (~50 min) after it was built. */\nexport const DEFAULT_EXPIRY_DELTA = 40\n\ninterface Built {\n tx: TransparentTxV5\n hex: string\n txid: string\n fee: bigint\n plan: SpendPlan\n desc: ZcashTxDescription\n}\n\n/**\n * Signing Zcash account — BIP-44 P2PKH at m/44'/133'/0'/0/i (t1…). The key never\n * enters this package: every input is one `signer.sign(...)` call over the\n * ZIP-244 signature digest computed here (`ecdsa`, DER-encoded + SIGHASH_ALL\n * into the scriptSig); messages are `ecdsa-recoverable` over the Zcash magic hash.\n *\n * Every spend is resolved to a full description (\"what you sign\") and run through\n * the hard safety checks (fee ceiling, recipient/amount exactness, change\n * ownership) before signing AND before broadcast — also for caller-supplied raw hex.\n */\nexport class WalletAccountZcash extends WalletAccountReadOnlyZcash implements IWalletAccount {\n /** UTXOs and the tip height come from the network before signing. */\n readonly needsNetwork = true\n /** Derivation path, or `external` for an external signer. */\n readonly path: string\n /** Compressed secp256k1 public key. */\n readonly publicKey: Uint8Array\n /** The signer that holds the key. */\n readonly signer: Signer\n private _disposed = false\n private _readOnly: WalletAccountReadOnlyZcash | undefined\n\n /** `publicKey` is the signer's compressed secp256k1 key (33 bytes); it is needed synchronously for the address. */\n constructor(signer: Signer, publicKey: Uint8Array, path: string, config: ZcashConfig = {}) {\n super(addressFromPublicKey(publicKey, config.network ?? 'mainnet'), config)\n this.signer = requireCurve(signer, 'secp256k1')\n if (!this.signer.schemes.includes('ecdsa')) throw new SignerError(`A Zcash account needs a signer with the 'ecdsa' scheme (has: ${this.signer.schemes.join(', ')}).`)\n this.publicKey = publicKey\n this.path = path\n }\n\n /** Back-compat: wrap a raw derived key in a {@link LocalSigner} (the account takes ownership; it cannot derive). */\n static fromPrivateKey(privateKey: Uint8Array, publicKey: Uint8Array, path: string, config: ZcashConfig = {}): WalletAccountZcash {\n return new WalletAccountZcash(LocalSigner.fromPrivateKey('secp256k1', privateKey, publicKey, path), publicKey, path, config)\n }\n\n /** Account index for the standard m/44'/133'/0'/0/i path. */\n get index(): number | undefined {\n const m = /^m\\/44'\\/(133|1)'\\/0'\\/0\\/(\\d+)$/.exec(this.path)\n return m ? Number(m[2]) : undefined\n }\n\n private live(): void {\n if (this._disposed) throw new SignerError('This account has been disposed.')\n }\n\n /** Zcash message signature (zcashd `signmessage` encoding), base64. */\n async sign(message: string | Uint8Array): Promise<string> {\n this.live()\n return signMessageWith(message, this.signer)\n }\n\n private ctx(intended?: { to: string; value: bigint }): DescribeContext {\n return { network: this._network, ownAddress: this.address, intended, maxFee: this.maxFee }\n }\n\n /** Lock time + expiry + branch id from the tip (or the config override). */\n private async chainParams(): Promise<{ lockTime: number; expiryHeight: number; consensusBranchId: number }> {\n const tip = await this.tipHeight()\n const delta = this._config.expiryDelta ?? DEFAULT_EXPIRY_DELTA\n const consensusBranchId = this._config.consensusBranchId ?? branchIdForHeight(tip)\n const lockTime = tip !== undefined && this._config.antiFeeSniping !== false ? tip : 0\n const expiryHeight = tip !== undefined && delta > 0 ? tip + delta : 0\n return { lockTime, expiryHeight, consensusBranchId }\n }\n\n /** Sign every input through the signer; the scriptSig is `<DER ‖ 0x01> <pubkey>`. */\n private async signInputs(tx: TransparentTxV5, spent: SpentOutput[]): Promise<void> {\n for (let i = 0; i < tx.inputs.length; i++) {\n const digest = sighashAll(tx, i, spent)\n const rs = await this.signer.sign(digest, { scheme: 'ecdsa', context: 'zcash-sighash' })\n const der = secp256k1.Signature.fromBytes(rs, 'compact').toBytes('der')\n tx.inputs[i]!.scriptSig = p2pkhScriptSig(der, this.publicKey)\n }\n }\n\n protected async buildSignedTransaction(spend: ZcashSpend): Promise<Built> {\n this.live()\n const plan = await this.planSpend(spend)\n const params = await this.chainParams()\n const tx: TransparentTxV5 = {\n ...params,\n inputs: plan.utxos.map((u) => ({ txid: u.txid, vout: u.vout, scriptSig: new Uint8Array(0), sequence: FINAL_SEQUENCE })),\n outputs: [{ value: plan.amount, script: plan.recipient.script }, ...(plan.change > 0n ? [{ value: plan.change, script: this.scriptPubKey }] : [])],\n }\n const spent: SpentOutput[] = plan.utxos.map((u) => ({ value: u.value, script: this.scriptPubKey }))\n const have = plan.utxos.reduce((s, u) => s + u.value, 0n)\n if (have < plan.amount + plan.fee) throw new InsufficientFundsError(plan.amount + plan.fee, have, 'ZEC')\n await this.signInputs(tx, spent)\n const ctx = this.ctx({ to: spend.to, value: plan.amount })\n const desc = describeTransaction(tx, spent, ctx)\n assertSafe(desc, ctx)\n const bytes = serializeTx(tx)\n return { tx, hex: bytesToHex(bytes), txid: txidOf(tx), fee: plan.fee, plan, desc }\n }\n\n private checkMax(fee: bigint, limit: bigint | number | undefined, op: string) {\n if (limit !== undefined && fee > BigInt(limit)) throw new Error(`Exceeded maximum fee cost for ${op} operation.`)\n }\n\n /** The outputs a raw transaction spends, fetched through the client (the wire format carries no values). */\n private async spentOutputs(tx: TransparentTxV5): Promise<SpentOutput[]> {\n const client = this.requireClient('inspect a raw transaction')\n const out: SpentOutput[] = []\n for (const i of tx.inputs) {\n const o = await client.getOutput(i.txid, i.vout)\n if (!o) throw new Error(`Prevout ${i.txid}:${i.vout} not found.`)\n out.push(o)\n }\n return out\n }\n\n /** Describe a raw signed tx (needs the network for prevouts) and run the safety checks. */\n private async describeRaw(rawHex: string): Promise<{ tx: TransparentTxV5; desc: ZcashTxDescription }> {\n const tx = parseTx(rawHex)\n const ctx = this.ctx()\n const desc = describeTransaction(tx, await this.spentOutputs(tx), ctx)\n assertSafe(desc, ctx)\n return { tx, desc }\n }\n\n /** \"What you sign\": the fully resolved spend (signed, NOT broadcast) or a caller's raw hex. */\n async describeTransaction(tx: ZcashTransaction): Promise<ZcashTxDescription> {\n if (typeof tx === 'string') return (await this.describeRaw(tx)).desc\n return (await this.buildSignedTransaction(tx)).desc\n }\n\n /** Sign without broadcasting. Returns the raw transaction hex. Raw hex input is returned unchanged. */\n async signTransaction(tx: ZcashTransaction): Promise<string> {\n this.live()\n if (typeof tx === 'string') return tx\n const built = await this.buildSignedTransaction(tx)\n this.checkMax(built.fee, this._config.transactionMaxFee, 'transaction')\n return built.hex\n }\n\n override async quoteSendTransaction(tx: ZcashTransaction): Promise<{ fee: bigint }> {\n if (typeof tx === 'string') return { fee: (await this.describeRaw(tx)).desc.fee }\n return super.quoteSendTransaction(tx)\n }\n\n async sendTransaction(tx: ZcashTransaction): Promise<TransferResult> {\n this.live()\n const client = this.requireClient('send transactions')\n let rawHex: string, hash: string, fee: bigint\n if (typeof tx === 'string') {\n const { tx: parsed, desc } = await this.describeRaw(tx)\n rawHex = tx; hash = txidOf(parsed); fee = desc.fee\n } else {\n const built = await this.buildSignedTransaction(tx)\n rawHex = built.hex; hash = built.txid; fee = built.fee\n }\n this.checkMax(fee, this._config.transactionMaxFee, 'transaction')\n const id = await client.broadcast(rawHex)\n return { hash: id || hash, fee }\n }\n\n /** Native ZEC only (`token` is rejected). Subject to `transferMaxFee`. */\n async transfer(o: ZcashTransferOptions): Promise<TransferResult> {\n if (o.token) throw new Error('Tokens are not supported on the zcash blockchain.')\n this.live()\n const client = this.requireClient('transfer')\n const built = await this.buildSignedTransaction({ to: o.recipient, value: o.amount })\n this.checkMax(built.fee, this._config.transferMaxFee, 'transfer')\n const id = await client.broadcast(built.hex)\n return { hash: id || built.txid, fee: built.fee }\n }\n\n /** The same address as a {@link WalletAccountReadOnlyZcash}. */\n toReadOnlyAccount(): IWalletAccountReadOnly {\n this._readOnly ??= new WalletAccountReadOnlyZcash(this.address, this._config)\n return this._readOnly\n }\n\n dispose(): void {\n this._disposed = true\n this.signer.dispose()\n }\n}\n\nexport { DUST_LIMIT, UnsafeTransactionError }\n","import { InsufficientFundsError, NetworkError, type IWalletAccountReadOnly } from '@anywalletkit/core'\nimport { DUST_LIMIT, addressFromPublicKey, decodeAddress, outputSize, type DecodedAddress } from './address.js'\nimport { createClient } from './client.js'\nimport { DEFAULT_MAX_FEE } from './describe.js'\nimport { MAX_UTXO_INPUTS, selectAll, selectCoins, type CoinSelection } from './fee.js'\nimport { recoverMessagePublicKey } from './message.js'\nimport { CAIP2, type ZcashClient, type ZcashConfig, type ZcashMaxSpendableResult, type ZcashNetwork, type ZcashReceipt, type ZcashSpend, type ZcashTransferOptions } from './types.js'\n\n/** A coin selection for one spend, with the decoded recipient. */\nexport interface SpendPlan extends CoinSelection {\n /** Zatoshis the recipient gets (the requested value — never reduced). */\n amount: bigint\n recipient: DecodedAddress\n}\n\nconst toBig = (v: bigint | number | string): bigint => (typeof v === 'bigint' ? v : BigInt(typeof v === 'string' ? v.trim() : Math.round(v)))\n\n/** Watch-only Zcash account: balances, quotes, receipts, message verification. No key. */\nexport class WalletAccountReadOnlyZcash implements IWalletAccountReadOnly {\n /** The transparent address. */\n readonly address: string\n readonly chain: string\n /** The address's scriptPubKey. */\n readonly scriptPubKey: Uint8Array\n /** Script type of the address. */\n readonly scriptKind: DecodedAddress['kind']\n protected readonly _config: ZcashConfig\n protected readonly _client: ZcashClient | undefined\n protected readonly _network: ZcashNetwork\n\n constructor(address: string, config: ZcashConfig = {}) {\n this._config = config\n this._network = config.network ?? 'mainnet'\n const decoded = decodeAddress(address, this._network)\n this.address = address.trim()\n this.scriptPubKey = decoded.script\n this.scriptKind = decoded.kind\n this.chain = CAIP2[this._network]\n this._client = createClient(config)\n }\n\n protected requireClient(what: string): ZcashClient {\n if (!this._client) throw new NetworkError(`The wallet must be connected to a client to ${what}.`)\n return this._client\n }\n\n /** Fee ceiling in zatoshis: `ZcashConfig.maxFee` or the default. */\n get maxFee(): bigint {\n return this._config.maxFee !== undefined ? toBig(this._config.maxFee) : DEFAULT_MAX_FEE\n }\n\n /** The transparent address. */\n async getAddress(): Promise<string> { return this.address }\n\n /** Confirmed plus incoming mempool value (the transports do not expose pending spends of our own outputs). */\n async getBalance(): Promise<bigint> {\n const { confirmed, unconfirmed } = await this.requireClient('read balances').getBalance(this.address)\n return confirmed + unconfirmed\n }\n\n /** Always throws: Zcash has no tokens. */\n async getTokenBalance(_token: string): Promise<bigint> {\n throw new Error(\"The 'getTokenBalance' method is not supported on the zcash blockchain.\")\n }\n\n /** Coin selection for a spend (ZIP-317 fee). Validates the recipient and the dust floor first. */\n protected async planSpend(spend: ZcashSpend): Promise<SpendPlan> {\n if (this.scriptKind !== 'p2pkh') throw new Error(`Cannot build spends from a ${this.scriptKind} address; only P2PKH (t1…) accounts spend.`)\n const amount = toBig(spend.value)\n const recipient = decodeAddress(spend.to, this._network)\n if (amount < DUST_LIMIT) throw new Error(`The amount must be at least the dust limit (${DUST_LIMIT} zatoshis).`)\n const utxos = await this.requireClient('plan a spend').listUnspent(this.address)\n if (utxos.length === 0) throw new InsufficientFundsError(amount, 0n, 'ZEC')\n const selection = selectCoins({\n utxos,\n target: amount,\n recipientOutputSize: outputSize(recipient.script),\n changeOutputSize: outputSize(this.scriptPubKey),\n maxInputs: this._config.maxInputs ?? MAX_UTXO_INPUTS,\n ...(spend.fee !== undefined ? { fee: toBig(spend.fee) } : {}),\n })\n return { ...selection, amount, recipient }\n }\n\n /** ZIP-317 fee of a spend in zatoshis. */\n async quoteSendTransaction(tx: ZcashSpend): Promise<{ fee: bigint }> {\n const { fee } = await this.planSpend(tx)\n return { fee }\n }\n\n /** ZIP-317 fee of a transfer in zatoshis. */\n async quoteTransfer(o: ZcashTransferOptions): Promise<{ fee: bigint }> {\n if (o.token) throw new Error('Tokens are not supported on the zcash blockchain.')\n return this.quoteSendTransaction({ to: o.recipient, value: o.amount })\n }\n\n /** Everything spendable in ONE transaction to a single output, no change. */\n async getMaxSpendable(opts: { to?: string; fee?: bigint | number } = {}): Promise<ZcashMaxSpendableResult> {\n const utxos = await this.requireClient('plan a spend').listUnspent(this.address)\n const outScript = opts.to ? decodeAddress(opts.to, this._network).script : this.scriptPubKey\n const sweep = selectAll({ utxos, outputSize: outputSize(outScript), maxInputs: this._config.maxInputs ?? MAX_UTXO_INPUTS, ...(opts.fee !== undefined ? { fee: toBig(opts.fee) } : {}) })\n const amount = sweep.amount >= DUST_LIMIT ? sweep.amount : 0n\n return { amount, fee: amount > 0n ? sweep.fee : 0n, changeValue: 0n, inputs: amount > 0n ? sweep.utxos.length : 0 }\n }\n\n /** Undefined until the transaction is mined. */\n async getTransactionReceipt(hash: string): Promise<ZcashReceipt | undefined> {\n if (!/^[0-9a-fA-F]{64}$/.test(hash)) throw new Error(\"The 'getTransactionReceipt(hash)' method requires a valid transaction hash.\")\n const info = await this.requireClient('fetch transaction receipts').getTransactionInfo(hash)\n if (!info || info.blockHeight <= 0) return undefined\n return { hash, status: 1, blockNumber: BigInt(info.blockHeight), confirmations: info.confirmations, ...(info.fee !== undefined ? { fee: info.fee } : {}) }\n }\n\n /** Recover the key from a Zcash message signature and compare its P2PKH address with ours. */\n async verify(message: string | Uint8Array, signature: string): Promise<boolean> {\n const pub = recoverMessagePublicKey(message, signature)\n if (!pub) return false\n try { return addressFromPublicKey(pub, this._network) === this.address } catch { return false }\n }\n\n /** Chain tip for lock time / expiry; undefined when the transport cannot tell. */\n protected async tipHeight(): Promise<number | undefined> {\n if (!this._client) return undefined\n try { return await this._client.getBlockHeight() } catch { return undefined }\n }\n}\n","/**\n * Activity history for Zcash transparent addresses: a `HistorySource` over\n * Blockchair's address dashboard (transaction hashes, newest first) and\n * transaction dashboards (inputs / outputs with addresses and values, fetched\n * ten at a time). Shielded legs of a transaction show up only as the\n * transparent value that entered or left it.\n */\nimport type { ChainTransfer, ChainTx, HistoryPage, HistoryQuery, HistorySource } from '@anywalletkit/core'\nimport { BlockchairClient, blockchairTime, type BlockchairTxDashboard } from './blockchair.js'\nimport { DEFAULT_TIMEOUT_MS } from './http.js'\nimport { CAIP2 } from './types.js'\n\n/** Options for {@link createZcashHistory}. */\nexport interface ZcashHistoryOptions {\n /** Blockchair base (`https://api.blockchair.com/zcash`); optional API key. */\n blockchairUrl?: string\n key?: string\n fetch?: typeof fetch\n timeoutMs?: number\n /** Rows per page (max 100). Default: the query limit, capped at 100. */\n pageSize?: number\n}\n\nexport interface ZcashHistoryRaw {\n tx: BlockchairTxDashboard\n ownIn: bigint\n ownOut: bigint\n}\n\nexport interface ZcashChainTx extends ChainTx { raw: ZcashHistoryRaw }\n\nexport interface ZcashHistoryPage extends HistoryPage {\n items: ZcashChainTx[]\n offset: number\n total?: number\n}\n\n/** Zcash transparent-address history from Blockchair. Build it with {@link createZcashHistory}. */\nexport interface ZcashHistorySource extends HistorySource {\n listActivity(address: string, query?: HistoryQuery): Promise<ZcashHistoryPage>\n getTransaction(hash: string, address: string): Promise<ZcashChainTx | undefined>\n}\n\n/** The history backend failed. */\nexport class HistoryUnavailableError extends Error {\n readonly chain: string\n readonly reason: string\n constructor(chain: string, reason: string) {\n super(`History unavailable for ${chain}: ${reason}`)\n this.name = 'HistoryUnavailableError'\n this.chain = chain\n this.reason = reason\n }\n}\n\nconst DEFAULT_LIMIT = 25\nconst MAX_PAGE_SIZE = 100\n\nexport interface ZcashHistoryCursor { v: 1; o: number; s: number }\n\nexport function encodeCursor(c: ZcashHistoryCursor): string {\n return `${c.v}:${c.o}:${c.s}`\n}\n\nexport function decodeCursor(s: string): ZcashHistoryCursor {\n const m = /^1:(\\d+):(\\d+)$/.exec(s)\n if (!m) throw new Error('@anywalletkit/wallet-zcash: malformed history cursor')\n const o = Number(m[1]), size = Number(m[2])\n if (size < 1) throw new Error('@anywalletkit/wallet-zcash: malformed history cursor')\n return { v: 1, o, s: size }\n}\n\nexport function mapDashboardTx(chain: string, address: string, d: BlockchairTxDashboard): ZcashChainTx {\n let ownIn = 0n, ownOut = 0n, sentToOthers = 0n\n for (const i of d.inputs) if (i.recipient === address) ownIn += BigInt(i.value)\n for (const o of d.outputs) { if (o.recipient === address) ownOut += BigInt(o.value); else sentToOthers += BigInt(o.value) }\n const firstInput = d.inputs.find((i) => i.recipient)?.recipient\n const firstOther = d.outputs.find((o) => o.recipient && o.recipient !== address)?.recipient\n const transfers: ChainTransfer[] = []\n let from: string, to: string | null, nativeValue: bigint\n if (ownIn > 0n) {\n from = address\n to = firstOther ?? address\n nativeValue = firstOther ? sentToOthers : ownOut\n if (nativeValue > 0n) transfers.push({ token: null, from: address, to, amount: nativeValue })\n } else {\n from = firstInput ?? (d.inputs.length === 0 ? 'shielded' : 'coinbase')\n to = address\n nativeValue = ownOut\n if (nativeValue > 0n) transfers.push({ token: null, from, to: address, amount: nativeValue })\n }\n const t = d.transaction as BlockchairTxDashboard['transaction'] & { confirmations?: number }\n const confirmed = t.block_id > 0\n const out: ZcashChainTx = {\n chain, hash: t.hash, time: blockchairTime(t.time) ?? 0, status: confirmed ? 'confirmed' : 'pending', address, from, to, nativeValue, transfers,\n raw: { tx: d, ownIn, ownOut },\n }\n if (typeof t.fee === 'number') out.fee = BigInt(t.fee)\n if (confirmed) out.block = BigInt(t.block_id)\n return out\n}\n\n/** Blockchair link for a transaction. */\nexport function zcashExplorerTxUrl(hash: string): string {\n return `https://blockchair.com/zcash/transaction/${hash}`\n}\n\n/**\n * A history source for transparent Zcash addresses backed by Blockchair (mainnet).\n *\n * @throws Error when no `fetch` is available.\n */\nexport function createZcashHistory(options: ZcashHistoryOptions = {}): ZcashHistorySource {\n const chain = CAIP2.mainnet\n const fetchFn = options.fetch ?? globalThis.fetch\n if (typeof fetchFn !== 'function') throw new Error('@anywalletkit/wallet-zcash: no global fetch; pass `fetch` in the options')\n const client = new BlockchairClient({ ...(options.blockchairUrl ? { url: options.blockchairUrl } : {}), ...(options.key ? { key: options.key } : {}) }, fetchFn, options.timeoutMs ?? DEFAULT_TIMEOUT_MS)\n const wrap = async <T>(run: () => Promise<T>): Promise<T> => {\n try { return await run() } catch (e) { throw new HistoryUnavailableError(chain, e instanceof Error ? e.message : String(e)) }\n }\n\n return {\n chain,\n\n async listActivity(address: string, query: HistoryQuery = {}): Promise<ZcashHistoryPage> {\n const cursor = query.cursor ? decodeCursor(query.cursor) : undefined\n const pageSize = cursor?.s ?? Math.min(MAX_PAGE_SIZE, Math.max(1, Math.floor(options.pageSize ?? query.limit ?? DEFAULT_LIMIT)))\n const offset = cursor?.o ?? 0\n const { hashes, total } = await wrap(() => client.listTransactions(address, pageSize, offset))\n const dashboards = hashes.length ? await wrap(() => client.getTransactionDashboards(hashes)) : new Map()\n let items = hashes.map((h) => dashboards.get(h)).filter((d): d is BlockchairTxDashboard => !!d).map((d) => mapDashboardTx(chain, address, d))\n items.sort((a, b) => (b.block === undefined ? 1 : a.block === undefined ? -1 : Number(b.block - a.block)) || b.time - a.time)\n let more = total !== undefined ? offset + hashes.length < total : hashes.length === pageSize\n if (query.since !== undefined) {\n const since = query.since\n if (items.some((t) => t.status === 'confirmed' && t.time < since)) more = false\n items = items.filter((t) => t.status !== 'confirmed' || t.time >= since)\n }\n const page: ZcashHistoryPage = { items, offset, ...(total !== undefined ? { total } : {}) }\n if (more) page.cursor = encodeCursor({ v: 1, o: offset + hashes.length, s: pageSize })\n return page\n },\n\n async getTransaction(hash: string, address: string): Promise<ZcashChainTx | undefined> {\n const d = await wrap(() => client.getTransactionDashboard(hash))\n return d ? mapDashboardTx(chain, address, d) : undefined\n },\n\n explorerTxUrl: zcashExplorerTxUrl,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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A,IAEA,eAAe;AAAA,EACjB;AACF;","names":["inputSizes","txid","import_core","import_core","h","txid","t","import_core","txid","h","import_core","import_sha2","import_base","PREFIX","import_core","import_core","import_secp256k1","import_core","h"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/types.ts","../src/address.ts","../src/fee.ts","../src/tx.ts","../src/encoding.ts","../src/describe.ts","../src/blockchair.ts","../src/http.ts","../src/blockbook.ts","../src/client.ts","../src/message.ts","../src/manager.ts","../src/account.ts","../src/read-only-account.ts","../src/history.ts"],"sourcesContent":["export * from './types.js'\nexport { UnsafeTransactionError, assertSafe, describeTransaction, DEFAULT_MAX_FEE, type DescribeContext, type UnsafeTransactionCode } from './describe.js'\nexport { BlockchairClient, BLOCKCHAIR_URL, blockchairTime, type BlockchairTxDashboard } from './blockchair.js'\nexport { ZcashBlockbookClient, type BlockbookTxDetails, type BlockbookVin, type BlockbookVout } from './blockbook.js'\nexport { createClient } from './client.js'\nexport { magicHash, signMessageWith, encodeMessageSignature, recoverMessagePublicKey } from './message.js'\nexport { selectCoins, selectAll, spendableUtxos, conventionalFee, logicalActions, estimateSize, TooManyInputsError, MARGINAL_FEE, GRACE_ACTIONS, P2PKH_INPUT_SIZE, MAX_UTXO_INPUTS, type CoinSelection, type CoinSelectOptions } from './fee.js'\nexport {\n serializeTx, parseTx, txid, txidDigest, sighashAll, p2pkhScriptSig, parseP2pkhScriptSig, branchIdForHeight, txHashPersonalization,\n headerDigest, transparentDigest, prevoutsDigest, sequenceDigest, outputsDigest,\n TX_VERSION_V5, VERSION_GROUP_ID_V5, SIGHASH_ALL, FINAL_SEQUENCE, MAX_SEQUENCE, MAINNET_UPGRADES, CURRENT_BRANCH_ID,\n type TransparentTxV5, type TxInput, type TxOutput,\n} from './tx.js'\nexport { decodeAddress, encodeAddress, addressFromScript, addressFromPublicKey, addressPrefix, scriptFor, scriptKind, hash160, outputSize, DUST_LIMIT, type DecodedAddress, type ScriptKind } from './address.js'\nexport { coinType, WalletManagerZcash } from './manager.js'\nexport { WalletAccountReadOnlyZcash, type SpendPlan } from './read-only-account.js'\nexport { WalletAccountZcash, addressFor, DEFAULT_EXPIRY_DELTA } from './account.js'\nexport {\n createZcashHistory, mapDashboardTx, zcashExplorerTxUrl, HistoryUnavailableError,\n encodeCursor as encodeHistoryCursor, decodeCursor as decodeHistoryCursor,\n type ZcashHistoryOptions, type ZcashHistorySource, type ZcashHistoryPage, type ZcashChainTx, type ZcashHistoryRaw, type ZcashHistoryCursor,\n} from './history.js'\nexport { WalletManagerZcash as default } from './manager.js'\n","/** Zcash mainnet or testnet. */\nexport type ZcashNetwork = 'mainnet' | 'testnet'\n\n/** CAIP-2 ids the SDK uses for Zcash (the swap2 catalog already names `zcash:mainnet`). */\nexport const CAIP2: Record<ZcashNetwork, string> = { mainnet: 'zcash:mainnet', testnet: 'zcash:testnet' }\n\n/** An unspent transparent output the account can spend. */\nexport interface Utxo {\n txid: string\n vout: number\n /** Zatoshis. */\n value: bigint\n /** Block height; -1 while in the mempool. */\n height: number\n}\n\n/** A previous output a transaction spends — ZIP-244 signs its value AND script. */\nexport interface SpentOutput {\n value: bigint\n script: Uint8Array\n}\n\n/** Transport-neutral transaction record (receipts, confirmations). */\nexport interface ZcashTxInfo {\n txid: string\n /** -1 or 0 while unconfirmed. */\n blockHeight: number\n confirmations: number\n fee?: bigint\n /** Unix seconds. */\n blockTime?: number\n}\n\n/** Minimal chain-data client every transport implements. Values in zatoshis. */\nexport interface ZcashClient {\n connect(): Promise<void>\n close(): Promise<void>\n getBalance(address: string): Promise<{ confirmed: bigint; unconfirmed: bigint }>\n listUnspent(address: string): Promise<Utxo[]>\n /** Raw transaction hex (any version — only used to read prevouts and for receipts). */\n getTransaction(txid: string): Promise<string>\n /** Value + scriptPubKey of one output of an existing transaction (what signing a spend of it needs). */\n getOutput(txid: string, vout: number): Promise<SpentOutput | undefined>\n getTransactionInfo(txid: string): Promise<ZcashTxInfo | undefined>\n /** Broadcast raw hex; returns the txid. */\n broadcast(rawTx: string): Promise<string>\n /** Current chain tip height (expiry height, anti-fee-sniping lock time, consensus branch selection). */\n getBlockHeight(): Promise<number>\n}\n\n/** One transport to a Zcash indexer: Blockchair or a Blockbook instance. */\nexport type ZcashClientConfig =\n /** Blockchair's public REST API (`https://api.blockchair.com/zcash`; optional API key). Mainnet only. */\n | { type: 'blockchair'; clientConfig?: { url?: string; key?: string } }\n /** A Zcash Blockbook (NOWNodes `https://zec-blockbook.nownodes.io` with an `api-key` header, a self-hosted instance, …). */\n | { type: 'blockbook-http'; clientConfig: { url: string; headers?: Record<string, string> } }\n\n/**\n * Options for a Zcash wallet manager or account: transports, network and fee limits. Transparent\n * addresses only.\n */\nexport interface ZcashConfig {\n /** One or more transports (config objects or ready `ZcashClient`s). A list fails over in order. Omit for an offline (sign-only) wallet. */\n client?: ZcashClientConfig | ZcashClient | Array<ZcashClientConfig | ZcashClient>\n network?: ZcashNetwork\n /** Extra attempts across the client list after the first failure (default 3). */\n retries?: number\n /** Per-request timeout in ms (default 15000). */\n timeoutMs?: number\n /** Max fee (zatoshis) for `transfer`. */\n transferMaxFee?: bigint | number\n /** Max fee (zatoshis) for `sendTransaction` / `signTransaction`. */\n transactionMaxFee?: bigint | number\n /** Hard fee ceiling in zatoshis for any transaction this account signs or broadcasts (default 1 000 000 = 0.01 ZEC). */\n maxFee?: bigint | number\n /** Blocks after the tip at which an unmined transaction expires (ZIP-203; default 40, the zcashd/Zebra default). 0 = never. */\n expiryDelta?: number\n /** Set nLockTime to the tip height so the transaction cannot be mined into a reorged block (default true). */\n antiFeeSniping?: boolean\n /**\n * Consensus branch id to sign under. Default: picked from the tip height\n * (`branchIdForHeight`) — set this when a network upgrade activates before\n * the package learns its id.\n */\n consensusBranchId?: number\n /** Coin-selection input cap (default 200). */\n maxInputs?: number\n /** Injectable fetch (tests, custom agents). Defaults to globalThis.fetch. */\n fetch?: typeof fetch\n}\n\n/** A spend. `value` in zatoshis. `fee` overrides the ZIP-317 conventional fee (still subject to `maxFee`). */\nexport interface ZcashSpend {\n to: string\n value: bigint | number | string\n fee?: bigint | number\n}\n\n/** `sendTransaction` accepts a spend or an already signed raw transaction hex. */\nexport type ZcashTransaction = ZcashSpend | string\n\n/** A transparent ZEC transfer. Amount in zatoshis. */\nexport interface ZcashTransferOptions {\n /** Not supported on Zcash; present for the shared account interface. */\n token?: string\n recipient: string\n amount: bigint | number | string\n}\n\n/** A mined Zcash transaction. */\nexport interface ZcashReceipt {\n hash: string\n /** Always 1 once mined — a transparent transaction cannot fail after inclusion. */\n status: 1\n blockNumber: bigint\n confirmations: number\n fee?: bigint\n}\n\n/** The most one transaction can send (a sweep of every UTXO), after the fee. */\nexport interface ZcashMaxSpendableResult {\n /** Max zatoshis one transaction can send after the fee. 0n when nothing is spendable. */\n amount: bigint\n fee: bigint\n /** Always 0n: a sweep leaves no change. */\n changeValue: bigint\n inputs: number\n}\n\n/** Problems a described transaction is flagged with. */\nexport type ZcashWarning =\n /** Fee exceeds 10 % of the amount sent. */\n | 'fee-over-10pct-of-amount'\n /** Fee is below the ZIP-317 conventional fee — nodes may not relay it. */\n | 'fee-below-conventional'\n /** An output is below the dust floor. */\n | 'dust-output'\n /** Change was below dust and folded into the fee. */\n | 'no-change'\n /** No expiry height: the transaction stays valid in mempools indefinitely. */\n | 'no-expiry'\n\n/** One input of a described transaction: the UTXO it spends. */\nexport interface ZcashTxInputDescription {\n txid: string\n vout: number\n value: bigint\n address: string | undefined\n}\n\n/** One output of a described transaction, tagged as the recipient, our change, or unknown. */\nexport interface ZcashTxOutputDescription {\n /** Undefined for scripts without an address form. */\n address: string | undefined\n value: bigint\n role: 'recipient' | 'change' | 'unknown'\n}\n\n/** \"What you sign\": the fully resolved transaction before (or after) signing. */\nexport interface ZcashTxDescription {\n kind: 'zcash-transfer'\n version: 5\n consensusBranchId: number\n inputs: ZcashTxInputDescription[]\n outputs: ZcashTxOutputDescription[]\n /** Zatoshis sent to non-change outputs. */\n amount: bigint\n fee: bigint\n /** The ZIP-317 fee this transaction's shape calls for. */\n conventionalFee: bigint\n /** Serialized size in bytes. */\n size: number\n lockTime: number\n expiryHeight: number\n /** Present once the transaction is signed. */\n txid?: string\n warnings: ZcashWarning[]\n}\n","/**\n * Zcash transparent addresses: Base58Check with a two-byte version prefix.\n * mainnet t1… P2PKH 0x1CB8 t3… P2SH 0x1CBD\n * testnet tm… P2PKH 0x1D25 t2… P2SH 0x1CBA\n * Shielded (zs…, u1…) and Sprout (zc…) addresses are recognised and refused\n * with a message — this package sends transparent value only.\n */\nimport { sha256 } from '@noble/hashes/sha2.js'\nimport { ripemd160 } from '@noble/hashes/legacy.js'\nimport { base58check } from '@scure/base'\nimport type { ZcashNetwork } from './types.js'\n\nconst b58 = base58check(sha256)\n\n/** Transparent address type: pay-to-pubkey-hash (`t1…`) or pay-to-script-hash (`t3…`). */\nexport type ScriptKind = 'p2pkh' | 'p2sh'\n\n/** A transparent address decoded to its type and 20-byte hash. */\nexport interface DecodedAddress {\n kind: ScriptKind\n /** 20-byte hash (pubkey hash or script hash). */\n hash: Uint8Array\n /** The scriptPubKey. */\n script: Uint8Array\n}\n\nconst PREFIX: Record<ZcashNetwork, Record<ScriptKind, readonly [number, number]>> = {\n mainnet: { p2pkh: [0x1c, 0xb8], p2sh: [0x1c, 0xbd] },\n testnet: { p2pkh: [0x1d, 0x25], p2sh: [0x1c, 0xba] },\n}\n\n/** Base58Check version prefix for a transparent address kind on a network (exported for tests / tooling). */\nexport function addressPrefix(network: ZcashNetwork, kind: ScriptKind): readonly [number, number] {\n return PREFIX[network][kind]\n}\n\n/** RIPEMD-160 of SHA-256, the hash inside a transparent address. */\nexport function hash160(data: Uint8Array): Uint8Array {\n return ripemd160(sha256(data))\n}\n\n/** OP_DUP OP_HASH160 <20> OP_EQUALVERIFY OP_CHECKSIG, or OP_HASH160 <20> OP_EQUAL. */\nexport function scriptFor(kind: ScriptKind, hash: Uint8Array): Uint8Array {\n if (hash.length !== 20) throw new Error('A transparent script needs a 20-byte hash')\n if (kind === 'p2pkh') return Uint8Array.of(0x76, 0xa9, 0x14, ...hash, 0x88, 0xac)\n return Uint8Array.of(0xa9, 0x14, ...hash, 0x87)\n}\n\n/** Type of an output script; `unknown` for anything but p2pkh and p2sh. */\nexport function scriptKind(script: Uint8Array): ScriptKind | 'unknown' {\n if (script.length === 25 && script[0] === 0x76 && script[1] === 0xa9 && script[2] === 0x14 && script[23] === 0x88 && script[24] === 0xac) return 'p2pkh'\n if (script.length === 23 && script[0] === 0xa9 && script[1] === 0x14 && script[22] === 0x87) return 'p2sh'\n return 'unknown'\n}\n\n/** Transparent address of a 20-byte hash. */\nexport function encodeAddress(kind: ScriptKind, hash: Uint8Array, network: ZcashNetwork): string {\n if (hash.length !== 20) throw new Error('A transparent address needs a 20-byte hash')\n const [a, b] = PREFIX[network][kind]\n return b58.encode(Uint8Array.of(a, b, ...hash))\n}\n\n/** Decode and validate a transparent address for `network`; throws a message that names the problem. */\nexport function decodeAddress(address: string, network: ZcashNetwork): DecodedAddress {\n const a = address.trim()\n if (/^u1|^utest/i.test(a)) throw new Error(`Unified address (${a.slice(0, 6)}…) — shielded receivers are not supported; use a transparent t-address.`)\n if (/^zs1|^ztestsapling/i.test(a)) throw new Error('Sapling shielded address (zs1…) — this wallet sends to transparent t-addresses only.')\n if (/^zc/i.test(a) && a.length > 90) throw new Error('Sprout address (zc…) — the Sprout pool is deprecated; use a transparent t-address.')\n let payload: Uint8Array\n try { payload = b58.decode(a) } catch (e) {\n throw new Error(`Invalid Zcash address: ${a}`, { cause: e })\n }\n if (payload.length !== 22) throw new Error(`Invalid Zcash address: ${a}`)\n const p0 = payload[0]!, p1 = payload[1]!\n for (const net of ['mainnet', 'testnet'] as const) {\n for (const kind of ['p2pkh', 'p2sh'] as const) {\n const [a0, a1] = PREFIX[net][kind]\n if (p0 === a0 && p1 === a1) {\n if (net !== network) throw new Error(`${a} is a Zcash ${net} address; this wallet is on ${network}.`)\n const hash = payload.slice(2)\n return { kind, hash, script: scriptFor(kind, hash) }\n }\n }\n }\n throw new Error(`Invalid Zcash address: ${a} (unknown version prefix)`)\n}\n\n/** Address for an output script, or undefined when the script has no address form. */\nexport function addressFromScript(script: Uint8Array, network: ZcashNetwork): string | undefined {\n const kind = scriptKind(script)\n if (kind === 'unknown') return undefined\n return encodeAddress(kind, kind === 'p2pkh' ? script.slice(3, 23) : script.slice(2, 22), network)\n}\n\n/** P2PKH address of a compressed secp256k1 public key (what `m/44'/133'/0'/0/i` yields). */\nexport function addressFromPublicKey(publicKey: Uint8Array, network: ZcashNetwork = 'mainnet'): string {\n if (publicKey.length !== 33) throw new Error('Expected a 33-byte compressed public key')\n return encodeAddress('p2pkh', hash160(publicKey), network)\n}\n\n/** Output size in bytes: 8 (value) + CompactSize + script. */\nexport function outputSize(script: Uint8Array): number {\n return 8 + (script.length < 0xfd ? 1 : 3) + script.length\n}\n\n/** Below this an output is uneconomic to spend (Bitcoin Core's P2PKH dust floor; zatoshis). */\nexport const DUST_LIMIT = 546n\n","/**\n * ZIP-317 fees and coin selection.\n *\n * conventional_fee = marginal_fee · max(grace_actions, logical_actions)\n * marginal_fee = 5000 zatoshis, grace_actions = 2,\n * transparent logical actions = max(ceil(Σ tx_in bytes / 150), ceil(Σ tx_out bytes / 34)).\n *\n * The fee depends on the number of inputs and outputs, not on a market rate,\n * so selection is simple: largest-first accumulation until the inputs cover\n * amount + fee, change kept when it clears the dust floor.\n */\nimport { InsufficientFundsError } from '@anywalletkit/core'\nimport { DUST_LIMIT } from './address.js'\nimport type { Utxo } from './types.js'\n\nexport const MARGINAL_FEE = 5_000n\nexport const GRACE_ACTIONS = 2\nexport const P2PKH_STANDARD_INPUT_SIZE = 150\nexport const P2PKH_STANDARD_OUTPUT_SIZE = 34\n/** Serialized size of one signed P2PKH input: prevout 36 + CompactSize 1 + scriptSig (1+73+1+33) + sequence 4. */\nexport const P2PKH_INPUT_SIZE = 149\n/** Most inputs one spend may use. */\nexport const MAX_UTXO_INPUTS = 200\n\nexport function logicalActions(inputSizes: readonly number[], outputSizes: readonly number[]): number {\n const inBytes = inputSizes.reduce((s, n) => s + n, 0)\n const outBytes = outputSizes.reduce((s, n) => s + n, 0)\n return Math.max(Math.ceil(inBytes / P2PKH_STANDARD_INPUT_SIZE), Math.ceil(outBytes / P2PKH_STANDARD_OUTPUT_SIZE))\n}\n\n/** The fee a transaction of this shape should pay (zatoshis). */\nexport function conventionalFee(inputSizes: readonly number[], outputSizes: readonly number[]): bigint {\n return MARGINAL_FEE * BigInt(Math.max(GRACE_ACTIONS, logicalActions(inputSizes, outputSizes)))\n}\n\n/** Transaction size estimate: v5 header 20 + counts 2 + inputs + outputs + 3 empty bundle counts. */\nexport function estimateSize(inputs: number, outputSizes: readonly number[]): number {\n const cs = (n: number) => (n < 0xfd ? 1 : 3)\n return 20 + cs(inputs) + inputs * P2PKH_INPUT_SIZE + cs(outputSizes.length) + outputSizes.reduce((s, n) => s + n, 0) + 3\n}\n\n/** A spend would need more inputs than allowed; consolidate the UTXOs first. */\nexport class TooManyInputsError extends Error {\n readonly maxInputs: number\n constructor(maxInputs: number) {\n super(`The spend needs more than ${maxInputs} inputs; consolidate the UTXOs first or raise maxInputs.`)\n this.name = 'TooManyInputsError'\n this.maxInputs = maxInputs\n }\n}\n\n/** Input to {@link selectCoins}. */\nexport interface CoinSelectOptions {\n utxos: Utxo[]\n /** Zatoshis the recipient gets. */\n target: bigint\n /** Serialized size of the recipient output. */\n recipientOutputSize: number\n /** Serialized size of a change output to our own address. */\n changeOutputSize: number\n changeDust?: bigint\n maxInputs?: number\n /** Caller-chosen fee (replaces the conventional fee; still has to be covered by the inputs). */\n fee?: bigint\n}\n\n/** UTXOs chosen for a spend, the ZIP-317 fee and the change. */\nexport interface CoinSelection {\n utxos: Utxo[]\n fee: bigint\n /** The ZIP-317 fee for the chosen shape (equals `fee` unless the caller overrode it or change was folded in). */\n conventionalFee: bigint\n /** Change back to us; 0n when folded into the fee. */\n change: bigint\n /** True when change existed but fell below dust and became fee. */\n changeFolded: boolean\n size: number\n}\n\nconst cmpUtxo = (a: Utxo, b: Utxo): number =>\n a.value > b.value ? -1 : a.value < b.value ? 1 : a.txid < b.txid ? -1 : a.txid > b.txid ? 1 : a.vout - b.vout\n\n/** UTXOs worth spending (each adds at most one logical action = 5000 zatoshis), largest first. */\nexport function spendableUtxos(utxos: Utxo[]): Utxo[] {\n return utxos.filter((u) => u.value > MARGINAL_FEE).sort(cmpUtxo)\n}\n\n/**\n * Pick UTXOs to fund `target` at the ZIP-317 fee; change below dust joins the fee.\n *\n * @throws `InsufficientFundsError` (core) when the UTXOs cannot cover target plus fee,\n * `TooManyInputsError` above `maxInputs`.\n */\nexport function selectCoins(o: CoinSelectOptions): CoinSelection {\n const maxInputs = o.maxInputs ?? MAX_UTXO_INPUTS\n const dust = o.changeDust ?? DUST_LIMIT\n const candidates = spendableUtxos(o.utxos)\n const available = o.utxos.reduce((s, u) => s + u.value, 0n)\n const inputs = (n: number) => Array.from({ length: n }, () => P2PKH_INPUT_SIZE)\n const selected: Utxo[] = []\n let sum = 0n\n for (const u of candidates) {\n if (selected.length >= maxInputs) throw new TooManyInputsError(maxInputs)\n selected.push(u)\n sum += u.value\n const n = selected.length\n const convNoChange = conventionalFee(inputs(n), [o.recipientOutputSize])\n const feeNoChange = o.fee ?? convNoChange\n if (sum < o.target + feeNoChange) continue\n const convWithChange = conventionalFee(inputs(n), [o.recipientOutputSize, o.changeOutputSize])\n const feeWithChange = o.fee ?? convWithChange\n const change = sum - o.target - feeWithChange\n if (change >= dust) {\n return { utxos: selected, fee: feeWithChange, conventionalFee: convWithChange, change, changeFolded: false, size: estimateSize(n, [o.recipientOutputSize, o.changeOutputSize]) }\n }\n return { utxos: selected, fee: sum - o.target, conventionalFee: convNoChange, change: 0n, changeFolded: sum - o.target > feeNoChange, size: estimateSize(n, [o.recipientOutputSize]) }\n }\n const need = o.target + (o.fee ?? conventionalFee(inputs(Math.max(selected.length, 1)), [o.recipientOutputSize]))\n throw new InsufficientFundsError(need, available, 'ZEC')\n}\n\n/** Sweep: every spendable input (largest first, capped), one output, no change. */\nexport function selectAll(o: { utxos: Utxo[]; outputSize: number; maxInputs?: number; fee?: bigint }): { utxos: Utxo[]; fee: bigint; amount: bigint; size: number } {\n const maxInputs = o.maxInputs ?? MAX_UTXO_INPUTS\n const utxos = spendableUtxos(o.utxos).slice(0, maxInputs)\n if (utxos.length === 0) return { utxos, fee: 0n, amount: 0n, size: 0 }\n const fee = o.fee ?? conventionalFee(Array.from({ length: utxos.length }, () => P2PKH_INPUT_SIZE), [o.outputSize])\n const amount = utxos.reduce((s, u) => s + u.value, 0n) - fee\n return { utxos, fee, amount: amount > 0n ? amount : 0n, size: estimateSize(utxos.length, [o.outputSize]) }\n}\n","/**\n * Zcash v5 transactions (ZIP-225 format) carrying transparent inputs and\n * outputs only — the shielded bundles are serialized empty. Transaction ids and\n * signature hashes follow ZIP-244 (BLAKE2b-256 digest tree); the consensus\n * branch id is part of both, so a transaction signed for one network upgrade\n * is invalid under the next.\n */\nimport { blake2b } from '@noble/hashes/blake2.js'\nimport { Reader, Writer, bytesToHex, compactSize, hexToBytes, i64le, reverseBytes, u32le, utf8ToBytes } from './encoding.js'\nimport type { SpentOutput } from './types.js'\n\nexport const TX_VERSION_V5 = 0x80000005 // fOverwintered | 5\nexport const VERSION_GROUP_ID_V5 = 0x26a7270a\nexport const SIGHASH_ALL = 0x01\n\n/** Mainnet network upgrades and their consensus branch ids (ZIP-200 table), oldest first. */\nexport const MAINNET_UPGRADES: ReadonlyArray<{ name: string; height: number; branchId: number }> = Object.freeze([\n { name: 'NU5', height: 1_687_104, branchId: 0xc2d6d0b4 },\n { name: 'NU6', height: 2_726_400, branchId: 0xc8e71055 },\n { name: 'NU6.1', height: 3_146_400, branchId: 0x4dec4df0 },\n { name: 'NU6.3', height: 3_428_143, branchId: 0x37a5165b },\n])\n\n/** The branch id the current mainnet tip signs under (NU6.3 \"Ironwood\", active since block 3 428 143, 2026-07-28). */\nexport const CURRENT_BRANCH_ID = MAINNET_UPGRADES[MAINNET_UPGRADES.length - 1]!.branchId\n\n/** Branch id in force at `height` on mainnet (the newest upgrade when the height is unknown or ahead of the table). */\nexport function branchIdForHeight(height: number | undefined): number {\n if (height === undefined || !Number.isFinite(height)) return CURRENT_BRANCH_ID\n let id = MAINNET_UPGRADES[0]!.branchId\n for (const u of MAINNET_UPGRADES) if (height >= u.height) id = u.branchId\n return id\n}\n\nexport interface TxInput {\n /** Display-order hex (as explorers show it). */\n txid: string\n vout: number\n scriptSig: Uint8Array\n sequence: number\n}\n\nexport interface TxOutput {\n value: bigint\n script: Uint8Array\n}\n\n/**\n * A v5 (NU5) transaction with transparent inputs and outputs only, as signed and serialized here.\n */\nexport interface TransparentTxV5 {\n consensusBranchId: number\n lockTime: number\n expiryHeight: number\n inputs: TxInput[]\n outputs: TxOutput[]\n}\n\nexport const FINAL_SEQUENCE = 0xfffffffe\nexport const MAX_SEQUENCE = 0xffffffff\n\nconst assertTxid = (txid: string) => { if (!/^[0-9a-fA-F]{64}$/.test(txid)) throw new Error(`Invalid txid: ${txid}`) }\n\nfunction writeTransparent(w: Writer, tx: TransparentTxV5): void {\n w.compact(tx.inputs.length)\n for (const i of tx.inputs) {\n assertTxid(i.txid)\n w.bytes(reverseBytes(hexToBytes(i.txid))).u32(i.vout).varBytes(i.scriptSig).u32(i.sequence)\n }\n w.compact(tx.outputs.length)\n for (const o of tx.outputs) {\n if (o.value < 0n) throw new Error('Negative output value')\n w.i64(o.value).varBytes(o.script)\n }\n}\n\n/** ZIP-225 wire format with empty Sapling and Orchard bundles. */\nexport function serializeTx(tx: TransparentTxV5): Uint8Array {\n const w = new Writer()\n w.u32(TX_VERSION_V5).u32(VERSION_GROUP_ID_V5).u32(tx.consensusBranchId >>> 0).u32(tx.lockTime).u32(tx.expiryHeight)\n writeTransparent(w, tx)\n w.compact(0) // nSpendsSapling\n w.compact(0) // nOutputsSapling (no valueBalanceSapling / anchor / proofs when both are zero)\n w.compact(0) // nActionsOrchard\n return w.finish()\n}\n\n/** Parse raw hex / bytes. Accepts v5 transactions whose shielded bundles are empty; anything else is refused by name. */\nexport function parseTx(raw: string | Uint8Array): TransparentTxV5 {\n const r = new Reader(typeof raw === 'string' ? hexToBytes(raw) : raw)\n const header = r.u32()\n const overwintered = (header & 0x80000000) !== 0\n const version = header & 0x7fffffff\n if (!overwintered || version !== 5) throw new Error(`Only v5 Zcash transactions are supported here (got version ${version}${overwintered ? '' : ', not overwintered'}).`)\n const vgid = r.u32()\n if (vgid !== VERSION_GROUP_ID_V5) throw new Error(`Unexpected version group id 0x${vgid.toString(16)} for a v5 transaction.`)\n const consensusBranchId = r.u32()\n const lockTime = r.u32()\n const expiryHeight = r.u32()\n const nIn = r.compact()\n const inputs: TxInput[] = []\n for (let i = 0; i < nIn; i++) {\n const txid = bytesToHex(reverseBytes(r.bytes(32)))\n const vout = r.u32()\n const scriptSig = r.varBytes()\n const sequence = r.u32()\n inputs.push({ txid, vout, scriptSig, sequence })\n }\n const nOut = r.compact()\n const outputs: TxOutput[] = []\n for (let i = 0; i < nOut; i++) outputs.push({ value: r.i64(), script: r.varBytes() })\n const nSpends = r.compact()\n const nOutputs = r.compact()\n if (nSpends !== 0 || nOutputs !== 0) throw new Error('This transaction carries a Sapling bundle; shielded transactions are not supported.')\n const nActions = r.compact()\n if (nActions !== 0) throw new Error('This transaction carries an Orchard bundle; shielded transactions are not supported.')\n if (r.remaining !== 0) throw new Error(`Trailing bytes after the transaction (${r.remaining}).`)\n return { consensusBranchId, lockTime, expiryHeight, inputs, outputs }\n}\n\n// ── ZIP-244 digests ──────────────────────────────────────────────────────────\n\nfunction personal(tag: string): Uint8Array {\n const p = utf8ToBytes(tag)\n if (p.length !== 16) throw new Error(`BLAKE2b personalization must be 16 bytes: ${tag}`)\n return p\n}\n\nfunction h(tag: string | Uint8Array, data: Uint8Array): Uint8Array {\n return blake2b(data, { dkLen: 32, personalization: typeof tag === 'string' ? personal(tag) : tag })\n}\n\nconst EMPTY = new Uint8Array(0)\n\n/** `ZcashTxHash_` ‖ consensus branch id (LE) — the personalization of both the txid and the signature digest. */\nexport function txHashPersonalization(consensusBranchId: number): Uint8Array {\n const p = new Uint8Array(16)\n p.set(utf8ToBytes('ZcashTxHash_'), 0)\n p.set(u32le(consensusBranchId >>> 0), 12)\n return p\n}\n\nexport function headerDigest(tx: TransparentTxV5): Uint8Array {\n const w = new Writer().u32(TX_VERSION_V5).u32(VERSION_GROUP_ID_V5).u32(tx.consensusBranchId >>> 0).u32(tx.lockTime).u32(tx.expiryHeight)\n return h('ZTxIdHeadersHash', w.finish())\n}\n\nexport function prevoutsDigest(tx: TransparentTxV5): Uint8Array {\n const w = new Writer()\n for (const i of tx.inputs) { assertTxid(i.txid); w.bytes(reverseBytes(hexToBytes(i.txid))).u32(i.vout) }\n return h('ZTxIdPrevoutHash', w.finish())\n}\n\nexport function sequenceDigest(tx: TransparentTxV5): Uint8Array {\n const w = new Writer()\n for (const i of tx.inputs) w.u32(i.sequence)\n return h('ZTxIdSequencHash', w.finish())\n}\n\nexport function outputsDigest(tx: TransparentTxV5): Uint8Array {\n const w = new Writer()\n for (const o of tx.outputs) w.i64(o.value).varBytes(o.script)\n return h('ZTxIdOutputsHash', w.finish())\n}\n\n/** T.2: hash of the three transparent digests; the hash of the empty string when there are no inputs AND no outputs. */\nexport function transparentDigest(tx: TransparentTxV5): Uint8Array {\n if (tx.inputs.length === 0 && tx.outputs.length === 0) return h('ZTxIdTranspaHash', EMPTY)\n const w = new Writer().bytes(prevoutsDigest(tx)).bytes(sequenceDigest(tx)).bytes(outputsDigest(tx))\n return h('ZTxIdTranspaHash', w.finish())\n}\n\nexport const saplingDigestEmpty = (): Uint8Array => h('ZTxIdSaplingHash', EMPTY)\nexport const orchardDigestEmpty = (): Uint8Array => h('ZTxIdOrchardHash', EMPTY)\n\n/** Non-malleable transaction id (ZIP-244 T.1 … T.4), internal byte order. */\nexport function txidDigest(tx: TransparentTxV5): Uint8Array {\n const w = new Writer().bytes(headerDigest(tx)).bytes(transparentDigest(tx)).bytes(saplingDigestEmpty()).bytes(orchardDigestEmpty())\n return h(txHashPersonalization(tx.consensusBranchId), w.finish())\n}\n\n/** Transaction id as explorers display it (byte-reversed hex). */\nexport function txid(tx: TransparentTxV5): string {\n return bytesToHex(reverseBytes(txidDigest(tx)))\n}\n\n/**\n * ZIP-244 S.2 transparent signature digest + S.1 … S.4 wrapper for SIGHASH_ALL\n * over input `index`. `spent[i]` is the output input `i` spends (value and\n * scriptPubKey are both committed to, so a lying transport cannot make us sign\n * for a different amount).\n */\nexport function sighashAll(tx: TransparentTxV5, index: number, spent: SpentOutput[]): Uint8Array {\n if (spent.length !== tx.inputs.length) throw new Error(`sighash: ${tx.inputs.length} inputs but ${spent.length} spent outputs`)\n const input = tx.inputs[index]\n const coin = spent[index]\n if (!input || !coin) throw new Error(`sighash: input ${index} does not exist`)\n const amounts = new Writer()\n const scripts = new Writer()\n for (const s of spent) { amounts.i64(s.value); scripts.varBytes(s.script) }\n const txin = new Writer().bytes(reverseBytes(hexToBytes(input.txid))).u32(input.vout).i64(coin.value).varBytes(coin.script).u32(input.sequence)\n const t = new Writer()\n .u8(SIGHASH_ALL)\n .bytes(prevoutsDigest(tx))\n .bytes(h('ZTxTrAmountsHash', amounts.finish()))\n .bytes(h('ZTxTrScriptsHash', scripts.finish()))\n .bytes(sequenceDigest(tx))\n .bytes(outputsDigest(tx))\n .bytes(h('Zcash___TxInHash', txin.finish()))\n const transparentSig = h('ZTxIdTranspaHash', t.finish())\n const w = new Writer().bytes(headerDigest(tx)).bytes(transparentSig).bytes(saplingDigestEmpty()).bytes(orchardDigestEmpty())\n return h(txHashPersonalization(tx.consensusBranchId), w.finish())\n}\n\n/** `<sig ‖ 0x01> <pubkey>` — the scriptSig of a P2PKH spend. */\nexport function p2pkhScriptSig(derSignature: Uint8Array, publicKey: Uint8Array): Uint8Array {\n const sig = new Uint8Array(derSignature.length + 1)\n sig.set(derSignature, 0)\n sig[derSignature.length] = SIGHASH_ALL\n return new Writer().bytes(compactSize(sig.length)).bytes(sig).bytes(compactSize(publicKey.length)).bytes(publicKey).finish()\n}\n\n/** Split a P2PKH scriptSig back into DER signature (hash type stripped) and public key; undefined when it is not one. */\nexport function parseP2pkhScriptSig(scriptSig: Uint8Array): { signature: Uint8Array; hashType: number; publicKey: Uint8Array } | undefined {\n try {\n const r = new Reader(scriptSig)\n const sig = r.varBytes()\n const pub = r.varBytes()\n if (r.remaining !== 0 || sig.length < 9 || (pub.length !== 33 && pub.length !== 65)) return undefined\n return { signature: sig.slice(0, -1), hashType: sig[sig.length - 1]!, publicKey: pub }\n } catch { return undefined }\n}\n\nexport { i64le }\n","/** Byte helpers for the Zcash wire format (little-endian integers, Bitcoin CompactSize). */\nexport { bytesToHex, hexToBytes, concatBytes, utf8ToBytes } from '@noble/hashes/utils.js'\n\nexport function compactSize(n: number): Uint8Array {\n if (!Number.isInteger(n) || n < 0) throw new Error(`CompactSize: ${n} is not a non-negative integer`)\n if (n < 0xfd) return Uint8Array.of(n)\n if (n <= 0xffff) return Uint8Array.of(0xfd, n & 0xff, n >>> 8)\n if (n <= 0xffffffff) return Uint8Array.of(0xfe, n & 0xff, (n >>> 8) & 0xff, (n >>> 16) & 0xff, n >>> 24)\n throw new Error('CompactSize: value too large')\n}\n\nexport function u32le(n: number): Uint8Array {\n if (!Number.isInteger(n) || n < 0 || n > 0xffffffff) throw new Error(`u32: ${n} out of range`)\n return Uint8Array.of(n & 0xff, (n >>> 8) & 0xff, (n >>> 16) & 0xff, n >>> 24)\n}\n\n/** Signed 64-bit little-endian (two's complement). Amounts are never negative here, but ZIP-244 types the field as signed. */\nexport function i64le(v: bigint): Uint8Array {\n if (v < -(1n << 63n) || v >= 1n << 63n) throw new Error(`i64: ${v} out of range`)\n let x = v < 0n ? v + (1n << 64n) : v\n const out = new Uint8Array(8)\n for (let i = 0; i < 8; i++) { out[i] = Number(x & 0xffn); x >>= 8n }\n return out\n}\n\nexport class Writer {\n private readonly parts: Uint8Array[] = []\n u8(n: number): this { this.parts.push(Uint8Array.of(n & 0xff)); return this }\n u32(n: number): this { this.parts.push(u32le(n)); return this }\n i64(v: bigint): this { this.parts.push(i64le(v)); return this }\n bytes(b: Uint8Array): this { this.parts.push(b); return this }\n compact(n: number): this { this.parts.push(compactSize(n)); return this }\n /** CompactSize length prefix + bytes (the \"field encoding\" of a script). */\n varBytes(b: Uint8Array): this { return this.compact(b.length).bytes(b) }\n finish(): Uint8Array {\n const len = this.parts.reduce((s, p) => s + p.length, 0)\n const out = new Uint8Array(len)\n let o = 0\n for (const p of this.parts) { out.set(p, o); o += p.length }\n return out\n }\n}\n\nexport class Reader {\n offset = 0\n constructor(private readonly buf: Uint8Array) {}\n get remaining(): number { return this.buf.length - this.offset }\n private need(n: number): void {\n if (this.offset + n > this.buf.length) throw new Error('Transaction truncated')\n }\n u8(): number { this.need(1); return this.buf[this.offset++]! }\n u32(): number {\n this.need(4)\n const b = this.buf\n const o = this.offset\n this.offset += 4\n return (b[o]! | (b[o + 1]! << 8) | (b[o + 2]! << 16)) + b[o + 3]! * 0x1000000\n }\n i64(): bigint {\n this.need(8)\n let v = 0n\n for (let i = 7; i >= 0; i--) v = (v << 8n) | BigInt(this.buf[this.offset + i]!)\n this.offset += 8\n return v >= 1n << 63n ? v - (1n << 64n) : v\n }\n bytes(n: number): Uint8Array { this.need(n); const out = this.buf.slice(this.offset, this.offset + n); this.offset += n; return out }\n compact(): number {\n const first = this.u8()\n if (first < 0xfd) return first\n if (first === 0xfd) { this.need(2); const v = this.buf[this.offset]! | (this.buf[this.offset + 1]! << 8); this.offset += 2; return v }\n if (first === 0xfe) return this.u32()\n throw new Error('CompactSize: 64-bit lengths are not supported')\n }\n varBytes(): Uint8Array { return this.bytes(this.compact()) }\n}\n\n/** Display ↔ internal byte order of a 32-byte hash (Bitcoin convention: hex is shown reversed). */\nexport function reverseBytes(b: Uint8Array): Uint8Array {\n return Uint8Array.from(b).reverse()\n}\n","import { DUST_LIMIT, addressFromScript, outputSize, scriptKind } from './address.js'\nimport { conventionalFee } from './fee.js'\nimport { serializeTx, txid as txidOf, type TransparentTxV5 } from './tx.js'\nimport type { SpentOutput, ZcashNetwork, ZcashTxDescription, ZcashTxOutputDescription, ZcashWarning } from './types.js'\n\n/** Default hard fee ceiling: 0.01 ZEC. */\nexport const DEFAULT_MAX_FEE = 1_000_000n\n\n/** Why a spend was refused before signing. */\nexport type UnsafeTransactionCode =\n /** Fee above `maxFee`. */\n | 'fee-too-high'\n /** Outputs exceed inputs. */\n | 'outputs-exceed-inputs'\n /** An output that is neither the requested recipient/amount nor our change. */\n | 'unexpected-output'\n /** The recipient output is missing or carries a different amount. */\n | 'recipient-mismatch'\n /** A change output pays an address that is not ours. */\n | 'change-not-ours'\n\n/** A transaction failed a hard safety check and was not signed / broadcast. */\nexport class UnsafeTransactionError extends Error {\n readonly code: UnsafeTransactionCode\n constructor(code: UnsafeTransactionCode, message: string) {\n super(message)\n this.name = 'UnsafeTransactionError'\n this.code = code\n }\n}\n\n/** What a description needs to tell recipient, change and unknown outputs apart. */\nexport interface DescribeContext {\n network: ZcashNetwork\n /** Our own address: outputs paying it are tagged `change`. */\n ownAddress: string\n /** The spend the caller asked for. Outputs matching it are `recipient`; anything else is `unknown`. */\n intended?: { to: string; value: bigint } | undefined\n maxFee?: bigint | undefined\n}\n\n/** Byte size of a serialized input (what ZIP-317 counts). */\nfunction inputSizes(tx: TransparentTxV5): number[] {\n return tx.inputs.map((i) => 32 + 4 + (i.scriptSig.length < 0xfd ? 1 : 3) + i.scriptSig.length + 4)\n}\n\n/** Describe a (signed or unsigned) transaction given the output every input spends. Pure: no network, no signing. */\nexport function describeTransaction(tx: TransparentTxV5, spent: SpentOutput[], ctx: DescribeContext): ZcashTxDescription {\n if (spent.length !== tx.inputs.length) throw new Error(`describeTransaction: ${tx.inputs.length} inputs but ${spent.length} spent outputs`)\n const inputs = tx.inputs.map((i, k) => ({ txid: i.txid, vout: i.vout, value: spent[k]!.value, address: addressFromScript(spent[k]!.script, ctx.network) }))\n const outputs: ZcashTxOutputDescription[] = []\n const warnings = new Set<ZcashWarning>()\n for (const o of tx.outputs) {\n const address = addressFromScript(o.script, ctx.network)\n const role: ZcashTxOutputDescription['role'] =\n address !== undefined && address === ctx.ownAddress ? 'change'\n : ctx.intended === undefined ? 'recipient'\n : address !== undefined && address === ctx.intended.to && o.value === ctx.intended.value ? 'recipient'\n : 'unknown'\n if (scriptKind(o.script) !== 'unknown' && o.value < DUST_LIMIT) warnings.add('dust-output')\n outputs.push({ address, value: o.value, role })\n }\n const inputSum = spent.reduce((s, c) => s + c.value, 0n)\n const outputSum = tx.outputs.reduce((s, o) => s + o.value, 0n)\n const fee = inputSum - outputSum\n const amount = outputs.filter((o) => o.role !== 'change').reduce((s, o) => s + o.value, 0n)\n const conv = conventionalFee(inputSizes(tx), tx.outputs.map((o) => outputSize(o.script)))\n if (fee < conv) warnings.add('fee-below-conventional')\n if (amount > 0n && fee * 10n > amount) warnings.add('fee-over-10pct-of-amount')\n if (!outputs.some((o) => o.role === 'change')) warnings.add('no-change')\n if (tx.expiryHeight === 0) warnings.add('no-expiry')\n const signed = tx.inputs.length > 0 && tx.inputs.every((i) => i.scriptSig.length > 0)\n const desc: ZcashTxDescription = {\n kind: 'zcash-transfer', version: 5, consensusBranchId: tx.consensusBranchId, inputs, outputs, amount, fee, conventionalFee: conv,\n size: serializeTx(tx).length, lockTime: tx.lockTime, expiryHeight: tx.expiryHeight, warnings: [...warnings],\n }\n if (signed) desc.txid = txidOf(tx)\n return desc\n}\n\n/**\n * Hard checks run before signing and before broadcasting. Throws UnsafeTransactionError;\n * never mutates. With `intended`, exactly one output must be the requested\n * recipient/amount and every other output must be our change.\n */\nexport function assertSafe(desc: ZcashTxDescription, ctx: DescribeContext): void {\n const maxFee = ctx.maxFee ?? DEFAULT_MAX_FEE\n if (desc.fee < 0n) throw new UnsafeTransactionError('outputs-exceed-inputs', 'Outputs exceed inputs.')\n if (desc.fee > maxFee) throw new UnsafeTransactionError('fee-too-high', `Fee ${desc.fee} zatoshis exceeds the ${maxFee} zatoshi ceiling (maxFee).`)\n for (const o of desc.outputs) {\n if (o.role === 'change' && o.address !== ctx.ownAddress) throw new UnsafeTransactionError('change-not-ours', `Change output pays ${o.address ?? '<no address>'}, not ${ctx.ownAddress}.`)\n }\n if (ctx.intended) {\n const recipients = desc.outputs.filter((o) => o.role === 'recipient')\n if (recipients.length !== 1) throw new UnsafeTransactionError('recipient-mismatch', `Expected one output of ${ctx.intended.value} zatoshis to ${ctx.intended.to}, found ${recipients.length}.`)\n const unknown = desc.outputs.filter((o) => o.role === 'unknown')\n if (unknown.length) throw new UnsafeTransactionError('unexpected-output', `Transaction carries ${unknown.length} output(s) that are neither the recipient nor our change.`)\n }\n}\n","/**\n * Blockchair REST transport (`https://api.blockchair.com/zcash`): public, CORS\n * open, no key needed at wallet volumes (one request every couple of seconds;\n * a `key` lifts the quota). Mainnet only — Blockchair indexes no Zcash\n * testnet. Address dashboards carry the UTXO set (mempool included, block_id\n * -1), `raw/transaction` the hex, `push/transaction` broadcasts.\n */\nimport { NetworkError } from '@anywalletkit/core'\nimport { hexToBytes } from './encoding.js'\nimport { DEFAULT_TIMEOUT_MS, fetchWithTimeout, isInt, isRecord } from './http.js'\nimport type { SpentOutput, Utxo, ZcashClient, ZcashTxInfo } from './types.js'\n\n/** Default Blockchair API root for Zcash. */\nexport const BLOCKCHAIR_URL = 'https://api.blockchair.com/zcash'\n/** Blockchair caps the `utxo` list of an address dashboard at this many rows. */\nconst UTXO_LIMIT = 1000\n\ninterface BlockchairUtxo { block_id: number; transaction_hash: string; index: number; value: number }\ninterface BlockchairAddress { balance: number; unspent_output_count?: number; transaction_count?: number }\ninterface BlockchairTxRow { block_id: number; hash: string; time?: string; fee?: number; input_count?: number; output_count?: number }\ninterface BlockchairOutput { index: number; value: number; script_hex: string; recipient?: string }\ninterface BlockchairInput extends BlockchairOutput { transaction_hash: string; spending_index?: number; spending_sequence?: number }\nexport interface BlockchairTxDashboard { transaction: BlockchairTxRow; inputs: BlockchairInput[]; outputs: BlockchairOutput[] }\ninterface Envelope<T> { data: T; context: { code: number; state?: number; error?: string } }\n\nconst isUtxo = (v: unknown): v is BlockchairUtxo => isRecord(v) && isInt(v.block_id) && typeof v.transaction_hash === 'string' && isInt(v.index) && typeof v.value === 'number'\nconst isOutput = (v: unknown): v is BlockchairOutput => isRecord(v) && isInt(v.index) && typeof v.value === 'number' && typeof v.script_hex === 'string'\nconst isDashboard = (v: unknown): v is BlockchairTxDashboard =>\n isRecord(v) && isRecord(v.transaction) && isInt(v.transaction.block_id) && typeof v.transaction.hash === 'string' && Array.isArray(v.inputs) && v.inputs.every(isOutput) && Array.isArray(v.outputs) && v.outputs.every(isOutput)\n\n/** \"2026-10-18 10:05:14\" (UTC) → unix seconds. */\nexport function blockchairTime(s: string | undefined): number | undefined {\n if (!s) return undefined\n const t = Date.parse(`${s.replace(' ', 'T')}Z`)\n return Number.isFinite(t) ? Math.floor(t / 1000) : undefined\n}\n\nexport class BlockchairClient implements ZcashClient {\n private readonly base: string\n private readonly key: string | undefined\n private readonly fetchFn: typeof fetch\n private readonly timeoutMs: number\n\n constructor(config: { url?: string; key?: string } = {}, fetchFn: typeof fetch = globalThis.fetch, timeoutMs = DEFAULT_TIMEOUT_MS) {\n this.base = (config.url ?? BLOCKCHAIR_URL).replace(/\\/+$/, '')\n this.key = config.key\n this.fetchFn = fetchFn\n this.timeoutMs = timeoutMs\n }\n\n async connect(): Promise<void> {}\n async close(): Promise<void> {}\n\n private url(path: string, query: Record<string, string> = {}): string {\n const q = new URLSearchParams(query)\n if (this.key) q.set('key', this.key)\n const s = q.toString()\n return `${this.base}/${path}${s ? `?${s}` : ''}`\n }\n\n private async request<T>(path: string, query: Record<string, string>, init: RequestInit | undefined, check: (v: unknown) => v is T): Promise<{ data: T; state: number | undefined }> {\n const url = this.url(path, query)\n const res = await fetchWithTimeout(this.fetchFn, url, init, this.timeoutMs, this.base)\n let body: unknown\n try { body = await res.json() } catch (e) {\n if (res.status === 402 || res.status === 429 || res.status === 430) throw new NetworkError(`Blockchair rate limit (${res.status})`, { provider: this.base })\n throw new NetworkError(`Blockchair returned non-JSON (${res.status}) for ${url}`, { provider: this.base, cause: e })\n }\n const env = body as Partial<Envelope<unknown>>\n const code = env.context?.code ?? res.status\n if (code === 402 || code === 429 || code === 430) throw new NetworkError(`Blockchair rate limit (${code})`, { provider: this.base })\n if (code === 404) throw new NotFound()\n if (code !== 200 || !res.ok) throw new NetworkError(`Blockchair request failed: ${code} ${env.context?.error ?? res.statusText} (${url})`, { provider: this.base })\n if (!check(env.data)) throw new NetworkError(`Blockchair returned an unexpected shape for ${url}`, { provider: this.base })\n return { data: env.data, state: env.context?.state }\n }\n\n private async dashboard(address: string): Promise<{ address: BlockchairAddress; utxo: BlockchairUtxo[]; transactions: string[]; state: number | undefined }> {\n const { data, state } = await this.request(`dashboards/address/${address}`, { limit: `0,${UTXO_LIMIT}` }, undefined, (v): v is Record<string, { address: BlockchairAddress; utxo: BlockchairUtxo[]; transactions?: string[] }> =>\n isRecord(v) && Object.values(v).every((a) => isRecord(a) && isRecord(a.address) && typeof a.address.balance === 'number' && Array.isArray(a.utxo) && a.utxo.every(isUtxo)))\n const entry = data[address] ?? Object.values(data)[0]\n if (!entry) throw new NetworkError(`Blockchair knows no address ${address}`, { provider: this.base })\n return { address: entry.address, utxo: entry.utxo, transactions: entry.transactions ?? [], state }\n }\n\n /** Transaction hashes of an address, newest first, paged by offset (what the activity history walks). */\n async listTransactions(address: string, limit: number, offset: number): Promise<{ hashes: string[]; total: number | undefined }> {\n const { data } = await this.request(`dashboards/address/${address}`, { limit: `${limit},0`, offset: `${offset},0` }, undefined, (v): v is Record<string, { address: BlockchairAddress; transactions?: string[] }> =>\n isRecord(v) && Object.values(v).every((a) => isRecord(a) && isRecord(a.address) && (a.transactions === undefined || Array.isArray(a.transactions))))\n const entry = data[address] ?? Object.values(data)[0]\n if (!entry) throw new NetworkError(`Blockchair knows no address ${address}`, { provider: this.base })\n return { hashes: (entry.transactions ?? []).filter((h): h is string => typeof h === 'string'), total: entry.address.transaction_count }\n }\n\n /** Confirmed = the UTXOs mined so far; unconfirmed = incoming mempool outputs. (Beyond 1000 UTXOs the dashboard balance is used.) */\n async getBalance(address: string): Promise<{ confirmed: bigint; unconfirmed: bigint }> {\n const d = await this.dashboard(address)\n let confirmed = 0n, unconfirmed = 0n\n for (const u of d.utxo) { if (u.block_id > 0) confirmed += BigInt(u.value); else unconfirmed += BigInt(u.value) }\n if ((d.address.unspent_output_count ?? d.utxo.length) > d.utxo.length) confirmed = BigInt(d.address.balance) - unconfirmed\n return { confirmed, unconfirmed }\n }\n\n async listUnspent(address: string): Promise<Utxo[]> {\n const d = await this.dashboard(address)\n return d.utxo.map((u) => ({ txid: u.transaction_hash, vout: u.index, value: BigInt(u.value), height: u.block_id > 0 ? u.block_id : -1 }))\n }\n\n async getTransaction(txid: string): Promise<string> {\n const { data } = await this.request(`raw/transaction/${txid}`, {}, undefined, (v): v is Record<string, { raw_transaction: string }> =>\n isRecord(v) && Object.values(v).every((t) => isRecord(t) && typeof t.raw_transaction === 'string'))\n const hex = (data[txid] ?? Object.values(data)[0])?.raw_transaction\n if (!hex) throw new NetworkError(`Transaction ${txid} has no raw data`, { provider: this.base })\n return hex\n }\n\n /** Inputs / outputs with addresses, values and scripts — what the activity history and prevout lookups read. */\n async getTransactionDashboard(txid: string): Promise<BlockchairTxDashboard | undefined> {\n try {\n const { data, state } = await this.request(`dashboards/transaction/${txid}`, {}, undefined, (v): v is Record<string, BlockchairTxDashboard | null> =>\n isRecord(v) && Object.values(v).every((t) => t === null || isDashboard(t)))\n const t = data[txid] ?? Object.values(data)[0]\n if (!t) return undefined\n return { ...t, transaction: { ...t.transaction, ...(state !== undefined ? { confirmations: t.transaction.block_id > 0 ? state - t.transaction.block_id + 1 : 0 } : {}) } } as BlockchairTxDashboard\n } catch (e) {\n if (e instanceof NotFound) return undefined\n throw e\n }\n }\n\n /** Several transactions in one call (Blockchair takes up to 10 comma-separated hashes). */\n async getTransactionDashboards(txids: string[]): Promise<Map<string, BlockchairTxDashboard>> {\n const out = new Map<string, BlockchairTxDashboard>()\n for (let i = 0; i < txids.length; i += 10) {\n const slice = txids.slice(i, i + 10)\n const { data, state } = await this.request(`dashboards/transactions/${slice.join(',')}`, {}, undefined, (v): v is Record<string, BlockchairTxDashboard | null> =>\n isRecord(v) && Object.values(v).every((t) => t === null || isDashboard(t)))\n for (const [hash, t] of Object.entries(data)) {\n if (!t) continue\n const confirmations = state !== undefined && t.transaction.block_id > 0 ? state - t.transaction.block_id + 1 : 0\n out.set(hash, { ...t, transaction: { ...t.transaction, confirmations } } as BlockchairTxDashboard)\n }\n }\n return out\n }\n\n async getOutput(txid: string, vout: number): Promise<SpentOutput | undefined> {\n const d = await this.getTransactionDashboard(txid)\n const o = d?.outputs.find((x) => x.index === vout)\n return o ? { value: BigInt(o.value), script: hexToBytes(o.script_hex) } : undefined\n }\n\n async getTransactionInfo(txid: string): Promise<ZcashTxInfo | undefined> {\n const d = await this.getTransactionDashboard(txid)\n if (!d) return undefined\n const t = d.transaction as BlockchairTxRow & { confirmations?: number }\n const info: ZcashTxInfo = { txid: t.hash, blockHeight: t.block_id > 0 ? t.block_id : -1, confirmations: t.confirmations ?? 0 }\n if (typeof t.fee === 'number') info.fee = BigInt(t.fee)\n const time = blockchairTime(t.time)\n if (time !== undefined) info.blockTime = time\n return info\n }\n\n async broadcast(rawTx: string): Promise<string> {\n const body = `data=${encodeURIComponent(rawTx)}`\n const url = this.url('push/transaction')\n const res = await fetchWithTimeout(this.fetchFn, url, { method: 'POST', headers: { 'content-type': 'application/x-www-form-urlencoded' }, body }, this.timeoutMs, this.base)\n let env: Partial<Envelope<{ transaction_hash?: string } | null>> = {}\n try { env = (await res.json()) as typeof env } catch { /* handled below */ }\n const hash = env.data?.transaction_hash\n if (hash) return hash\n const reason = env.context?.error ?? `${res.status} ${res.statusText}`\n // A rejected transaction is the node's verdict, not a transport failure — a plain Error (not NetworkError), so failover does not retry it elsewhere.\n throw new Error(`Broadcast rejected: ${reason}`)\n }\n\n async getBlockHeight(): Promise<number> {\n const { data } = await this.request('stats', {}, undefined, (v): v is { best_block_height: number } => isRecord(v) && isInt(v.best_block_height))\n if (data.best_block_height <= 0) throw new NetworkError('Blockchair reported no block height', { provider: this.base })\n return data.best_block_height\n }\n}\n\nclass NotFound extends Error { constructor() { super('not found'); this.name = 'NotFound' } }\n","import { NetworkError } from '@anywalletkit/core'\n\nexport const DEFAULT_TIMEOUT_MS = 15_000\n\n/** fetch with a per-request timeout when the runtime has `AbortSignal.timeout` (Hermes needs runtime-hermes for it). */\nexport async function fetchWithTimeout(fetchFn: typeof fetch, url: string, init: RequestInit | undefined, timeoutMs: number, provider: string): Promise<Response> {\n const signal = typeof AbortSignal !== 'undefined' && typeof AbortSignal.timeout === 'function' ? AbortSignal.timeout(timeoutMs) : undefined\n try {\n return await fetchFn(url, { ...init, ...(signal ? { signal } : {}) })\n } catch (e) {\n throw new NetworkError(`Request failed: ${url}`, { provider, cause: e })\n }\n}\n\nexport const isRecord = (v: unknown): v is Record<string, unknown> => typeof v === 'object' && v !== null && !Array.isArray(v)\nexport const isHex64 = (v: unknown): v is string => typeof v === 'string' && /^[0-9a-fA-F]{64}$/.test(v)\nexport const isIntString = (v: unknown): v is string => typeof v === 'string' && /^-?\\d+$/.test(v)\nexport const isInt = (v: unknown): v is number => typeof v === 'number' && Number.isInteger(v)\n","/**\n * Zcash Blockbook REST transport — the same `/api/v2` surface as Bitcoin's\n * (NOWNodes `https://zec-blockbook.nownodes.io` with an `api-key` header, any\n * self-hosted Blockbook built for Zcash). Serves testnet too.\n */\nimport { NetworkError } from '@anywalletkit/core'\nimport { hexToBytes } from './encoding.js'\nimport { DEFAULT_TIMEOUT_MS, fetchWithTimeout, isInt, isIntString, isRecord } from './http.js'\nimport type { SpentOutput, Utxo, ZcashClient, ZcashTxInfo } from './types.js'\n\nexport interface BlockbookVin { txid?: string; vout?: number; n?: number; isAddress?: boolean; addresses?: string[]; value?: string }\nexport interface BlockbookVout { n: number; isAddress?: boolean; addresses?: string[]; value?: string; hex?: string }\nexport interface BlockbookTxDetails {\n txid: string\n blockHeight: number\n confirmations: number\n blockTime?: number\n fees?: string\n hex?: string\n vin?: BlockbookVin[]\n vout?: BlockbookVout[]\n}\n\nexport class ZcashBlockbookClient implements ZcashClient {\n private readonly base: string\n private readonly headers: Record<string, string>\n private readonly fetchFn: typeof fetch\n private readonly timeoutMs: number\n\n constructor(config: { url: string; headers?: Record<string, string> }, fetchFn: typeof fetch = globalThis.fetch, timeoutMs = DEFAULT_TIMEOUT_MS) {\n this.base = config.url.replace(/\\/+$/, '').replace(/\\/api$/, '')\n this.headers = { accept: 'application/json', ...(config.headers ?? {}) }\n this.fetchFn = fetchFn\n this.timeoutMs = timeoutMs\n }\n\n async connect(): Promise<void> {}\n async close(): Promise<void> {}\n\n private async get<T>(path: string, check: (v: unknown) => v is T): Promise<T> {\n const url = `${this.base}/api${path}`\n const res = await fetchWithTimeout(this.fetchFn, url, { headers: this.headers }, this.timeoutMs, this.base)\n if (!res.ok) throw new NetworkError(`Blockbook request failed: ${res.status} ${res.statusText} (${url})`, { provider: this.base })\n let body: unknown\n try { body = await res.json() } catch (e) { throw new NetworkError(`Blockbook returned non-JSON for ${url}`, { provider: this.base, cause: e }) }\n if (!check(body)) throw new NetworkError(`Blockbook returned an unexpected shape for ${url}`, { provider: this.base })\n return body\n }\n\n async getBalance(address: string) {\n const data = await this.get(`/v2/address/${address}?details=basic`, (v): v is { balance: string; unconfirmedBalance: string } => isRecord(v) && isIntString(v.balance) && isIntString(v.unconfirmedBalance))\n return { confirmed: BigInt(data.balance), unconfirmed: BigInt(data.unconfirmedBalance) }\n }\n\n async listUnspent(address: string): Promise<Utxo[]> {\n const data = await this.get(`/v2/utxo/${address}`, (v): v is Array<{ txid: string; vout: number; value: string; height?: number }> =>\n Array.isArray(v) && v.every((u) => isRecord(u) && typeof u.txid === 'string' && isInt(u.vout) && isIntString(u.value)))\n return data.map((u) => ({ txid: u.txid, vout: u.vout, value: BigInt(u.value), height: u.height && u.height > 0 ? u.height : -1 }))\n }\n\n private static isTx(v: unknown): v is BlockbookTxDetails {\n return isRecord(v) && typeof v.txid === 'string' && isInt(v.blockHeight) && isInt(v.confirmations)\n }\n\n async getTransactionDetails(txid: string): Promise<BlockbookTxDetails | undefined> {\n try { return await this.get(`/v2/tx/${txid}`, ZcashBlockbookClient.isTx) } catch (e) {\n if (e instanceof NetworkError && /\\b(400|404)\\b/.test(e.message)) return undefined\n throw e\n }\n }\n\n async getTransaction(txid: string): Promise<string> {\n const tx = await this.get(`/v2/tx/${txid}`, ZcashBlockbookClient.isTx)\n if (typeof tx.hex !== 'string' || !tx.hex) throw new NetworkError(`Transaction ${txid} has no hex data`, { provider: this.base })\n return tx.hex\n }\n\n async getOutput(txid: string, vout: number): Promise<SpentOutput | undefined> {\n const tx = await this.getTransactionDetails(txid)\n const o = tx?.vout?.find((x) => x.n === vout)\n if (!o || !isIntString(o.value) || typeof o.hex !== 'string') return undefined\n return { value: BigInt(o.value), script: hexToBytes(o.hex) }\n }\n\n async getTransactionInfo(txid: string): Promise<ZcashTxInfo | undefined> {\n const tx = await this.getTransactionDetails(txid)\n if (!tx) return undefined\n const info: ZcashTxInfo = { txid: tx.txid, blockHeight: tx.blockHeight > 0 ? tx.blockHeight : -1, confirmations: tx.confirmations }\n if (isIntString(tx.fees)) info.fee = BigInt(tx.fees)\n if (typeof tx.blockTime === 'number') info.blockTime = tx.blockTime\n return info\n }\n\n async broadcast(rawTx: string): Promise<string> {\n const data = await this.get(`/v2/sendtx/${rawTx}`, (v): v is { result?: string; error?: { message?: string } | string } => isRecord(v))\n if (data.error) throw new Error(`Broadcast rejected: ${typeof data.error === 'string' ? data.error : data.error.message ?? 'broadcast failed'}`)\n if (!data.result) throw new NetworkError('Blockbook returned no txid', { provider: this.base })\n return data.result\n }\n\n async getBlockHeight(): Promise<number> {\n const data = await this.get('/v2', (v): v is { blockbook?: { bestHeight?: number } } => isRecord(v))\n const h = data.blockbook?.bestHeight\n if (typeof h !== 'number' || h <= 0) throw new NetworkError('Blockbook did not report a block height', { provider: this.base })\n return h\n }\n}\n","import { NetworkError } from '@anywalletkit/core'\nimport { BlockchairClient } from './blockchair.js'\nimport { ZcashBlockbookClient } from './blockbook.js'\nimport { DEFAULT_TIMEOUT_MS } from './http.js'\nimport type { ZcashClient, ZcashClientConfig, ZcashConfig } from './types.js'\n\nconst isClient = (c: unknown): c is ZcashClient => typeof c === 'object' && c !== null && typeof (c as ZcashClient).listUnspent === 'function'\n\nfunction toClient(c: ZcashClientConfig | ZcashClient, fetchFn: typeof fetch | undefined, timeoutMs: number): ZcashClient {\n if (isClient(c)) return c\n switch (c.type) {\n case 'blockchair': return new BlockchairClient(c.clientConfig ?? {}, fetchFn, timeoutMs)\n case 'blockbook-http': return new ZcashBlockbookClient(c.clientConfig, fetchFn, timeoutMs)\n default: throw new Error(`Unknown Zcash client type: ${String((c as { type: string }).type)}`)\n }\n}\n\nconst METHODS = ['connect', 'close', 'getBalance', 'listUnspent', 'getTransaction', 'getOutput', 'getTransactionInfo', 'broadcast', 'getBlockHeight'] as const\n\n/**\n * One client, or a failover client over the list: each call walks the list in\n * order, `retries` extra rounds. A node's rejection of a broadcast (plain\n * Error) is final — only transport failures (NetworkError) move on.\n */\nexport function createClient(config: ZcashConfig): ZcashClient | undefined {\n if (config.client === undefined) return undefined\n const timeoutMs = config.timeoutMs ?? DEFAULT_TIMEOUT_MS\n const list = (Array.isArray(config.client) ? config.client : [config.client]).map((c) => toClient(c, config.fetch, timeoutMs))\n if (list.length === 0) return undefined\n if (list.length === 1) return list[0]!\n const attempts = list.length + (config.retries ?? 3)\n const call = (method: (typeof METHODS)[number]) => async (...args: unknown[]) => {\n let last: unknown\n for (let i = 0; i < attempts; i++) {\n const c = list[i % list.length]! as unknown as Record<string, (...a: unknown[]) => Promise<unknown>>\n try { return await c[method]!.apply(c, args) } catch (e) {\n if (method === 'broadcast' && !(e instanceof NetworkError)) throw e\n last = e\n }\n }\n throw new NetworkError(`All Zcash clients failed for ${method}`, { cause: last })\n }\n const out = {} as Record<(typeof METHODS)[number], (...args: unknown[]) => Promise<unknown>>\n for (const m of METHODS) out[m] = call(m)\n return out as unknown as ZcashClient\n}\n","/**\n * Zcash signed messages (zcashd `signmessage` / `verifymessage`): the Bitcoin\n * scheme with the `Zcash Signed Message:\\n` magic. hash = sha256d(varint(prefix)\n * ‖ prefix ‖ varint(len) ‖ message); header byte = 27 + recovery + 4\n * (compressed key); output base64 of header ‖ r ‖ s. RFC-6979 deterministic, low-S.\n */\nimport { sha256 } from '@noble/hashes/sha2.js'\nimport { secp256k1 } from '@noble/curves/secp256k1.js'\nimport { base64 } from '@scure/base'\nimport type { Signer } from '@anywalletkit/core'\nimport { compactSize, utf8ToBytes } from './encoding.js'\n\nconst MAGIC = 'Zcash Signed Message:\\n'\nconst PREFIX = utf8ToBytes(MAGIC)\n\n/** Hash of a signed message (`Zcash Signed Message:` prefix, double SHA-256). */\nexport function magicHash(message: string | Uint8Array): Uint8Array {\n const msg = typeof message === 'string' ? utf8ToBytes(message) : message\n const p = compactSize(PREFIX.length), l = compactSize(msg.length)\n const buf = new Uint8Array(p.length + PREFIX.length + l.length + msg.length)\n let o = 0\n for (const part of [p, PREFIX, l, msg]) { buf.set(part, o); o += part.length }\n return sha256(sha256(buf))\n}\n\n/** Encode `r‖s` + recovery id as a base64 signature (compressed-key header 31 + recovery). */\nexport function encodeMessageSignature(rs: Uint8Array, recovery: number): string {\n if (rs.length !== 64 || recovery > 3) throw new Error('Expected a 64-byte r‖s signature and a recovery id 0..3.')\n const out = new Uint8Array(65)\n out[0] = 27 + 4 + recovery\n out.set(rs, 1)\n return base64.encode(out)\n}\n\n/** Sign through a {@link Signer} (`ecdsa-recoverable`, context `zcash-message`). */\nexport async function signMessageWith(message: string | Uint8Array, signer: Signer): Promise<string> {\n const sig = await signer.sign(magicHash(message), { scheme: 'ecdsa-recoverable', context: 'zcash-message' })\n return encodeMessageSignature(sig.subarray(0, 64), sig[64]!)\n}\n\n/** Recover the compressed public key from a message signature, or undefined when malformed. */\nexport function recoverMessagePublicKey(message: string | Uint8Array, signature: string): Uint8Array | undefined {\n let bytes: Uint8Array\n try { bytes = base64.decode(signature) } catch { return undefined }\n if (bytes.length !== 65) return undefined\n const flag = bytes[0]! - 27\n if (flag < 0 || flag > 15) return undefined\n const recovered = new Uint8Array(65)\n recovered[0] = flag & 3\n recovered.set(bytes.subarray(1), 1)\n try {\n const pub = secp256k1.recoverPublicKey(recovered, magicHash(message), { prehash: false })\n return pub.length === 33 ? pub : secp256k1.Point.fromBytes(pub).toBytes(true)\n } catch { return undefined }\n}\n","import { LocalSigner, SignerError, WalletManager, isSeedSigner, type FeeRates, type Signer } from '@anywalletkit/core'\nimport { WalletAccountZcash } from './account.js'\nimport { MARGINAL_FEE } from './fee.js'\nimport { WalletAccountReadOnlyZcash } from './read-only-account.js'\nimport type { ZcashConfig, ZcashNetwork } from './types.js'\n\n/** SLIP-44 coin type: 133 for mainnet, 1 for testnet. */\nexport const coinType = (network: ZcashNetwork): 133 | 1 => (network === 'mainnet' ? 133 : 1)\n\n/**\n * One seed → Zcash transparent accounts at m/44'/133'/0'/0/i (BIP-44, the path\n * Zashi, YWallet, Ledger and Trezor use for the transparent receiver) — t1… on\n * mainnet, tm… on testnet. Paths may be relative to the purpose/coin prefix\n * (\"0'/0/i\") or given in full.\n *\n * Built with a secp256k1 `Signer` instead of a seed, the manager wraps it:\n * a derivable `SeedSigner` yields `getAccount(i)` children below its path; a\n * leaf or external signer is `getAccount(0)`.\n */\nexport class WalletManagerZcash extends WalletManager<WalletAccountZcash, ZcashConfig> {\n constructor(seedOrSigner: string | Uint8Array | Signer, config: ZcashConfig = {}) {\n super(seedOrSigner, config)\n }\n\n /** `m/44'/133'` on mainnet (coin type 1 on testnet); account `i` is at `basePath/0'/0/i`. */\n get basePath(): string {\n return `m/44'/${coinType(this._config.network ?? 'mainnet')}'`\n }\n\n async getAccount(index = 0): Promise<WalletAccountZcash> {\n return this.getAccountByPath(`${this.basePath}/0'/0/${index}`)\n }\n\n async getAccountByPath(path: string): Promise<WalletAccountZcash> {\n const full = path.startsWith('m/') ? path : `${this.basePath}/${path}`\n const cached = this._accounts.get(full)\n if (cached) return cached\n const external = this.externalSigner()\n if (external) return this.fromSigner(external, full)\n return this.cachedAccount(full, () => {\n const signer = LocalSigner.leafFromSeed(this.seedBytes(), 'secp256k1', full)\n return new WalletAccountZcash(signer, signer.publicKey, full, this._config)\n })\n }\n\n private async fromSigner(signer: Signer, path: string): Promise<WalletAccountZcash> {\n this.requireSigner('secp256k1')\n let rel: string | undefined\n let key = 'external'\n if (isSeedSigner(signer)) {\n if (path === signer.path) key = path\n else if (path.startsWith(`${signer.path}/`)) { rel = path.slice(signer.path.length + 1); key = path }\n else throw new SignerError(`The injected signer sits at ${signer.path}; it cannot provide ${path}.`)\n } else if (path !== `${this.basePath}/0'/0/0` && path !== 'external') {\n throw new SignerError(`An external signer has one account; ${path} is not derivable from it.`)\n }\n return this.signerAccount(key, signer, rel, (leaf, publicKey) => new WalletAccountZcash(leaf, publicKey, key, this._config))\n }\n\n /** A read-only account for any transparent address, with this manager's config. */\n getReadOnlyAccount(address: string): WalletAccountReadOnlyZcash {\n return new WalletAccountReadOnlyZcash(address, this._config)\n }\n\n /** ZIP-317 has no fee market: every tier is the 5000-zatoshi marginal fee per logical action. */\n async getFeeRates(): Promise<FeeRates> {\n return { slow: MARGINAL_FEE, normal: MARGINAL_FEE, fast: MARGINAL_FEE }\n }\n}\n","import { InsufficientFundsError, LocalSigner, SignerError, feeLimit, requireCurve, type IWalletAccount, type IWalletAccountReadOnly, type Signer, type TransferResult, type WriteOptions } from '@anywalletkit/core'\nimport { secp256k1 } from '@noble/curves/secp256k1.js'\nimport { DUST_LIMIT, addressFromPublicKey } from './address.js'\nimport { UnsafeTransactionError, assertSafe, describeTransaction, type DescribeContext } from './describe.js'\nimport { bytesToHex } from './encoding.js'\nimport { signMessageWith } from './message.js'\nimport { WalletAccountReadOnlyZcash, type SpendPlan } from './read-only-account.js'\nimport { FINAL_SEQUENCE, branchIdForHeight, p2pkhScriptSig, parseTx, serializeTx, sighashAll, txid as txidOf, type TransparentTxV5 } from './tx.js'\nimport type { SpentOutput, ZcashConfig, ZcashNetwork, ZcashSpend, ZcashTransaction, ZcashTransferOptions, ZcashTxDescription } from './types.js'\n\nexport { addressFromPublicKey }\n\n/** t-address for a compressed public key. */\nexport function addressFor(publicKey: Uint8Array, network: ZcashNetwork = 'mainnet'): string {\n return addressFromPublicKey(publicKey, network)\n}\n\n/** ZIP-203 default: a transaction expires 40 blocks (~50 min) after it was built. */\nexport const DEFAULT_EXPIRY_DELTA = 40\n\ninterface Built {\n tx: TransparentTxV5\n hex: string\n txid: string\n fee: bigint\n plan: SpendPlan\n desc: ZcashTxDescription\n}\n\n/**\n * Signing Zcash account — BIP-44 P2PKH at m/44'/133'/0'/0/i (t1…). The key never\n * enters this package: every input is one `signer.sign(...)` call over the\n * ZIP-244 signature digest computed here (`ecdsa`, DER-encoded + SIGHASH_ALL\n * into the scriptSig); messages are `ecdsa-recoverable` over the Zcash magic hash.\n *\n * Every spend is resolved to a full description (\"what you sign\") and run through\n * the hard safety checks (fee ceiling, recipient/amount exactness, change\n * ownership) before signing AND before broadcast — also for caller-supplied raw hex.\n */\nexport class WalletAccountZcash extends WalletAccountReadOnlyZcash implements IWalletAccount {\n /** UTXOs and the tip height come from the network before signing. */\n readonly needsNetwork = true\n /** Derivation path, or `external` for an external signer. */\n readonly path: string\n /** Compressed secp256k1 public key. */\n readonly publicKey: Uint8Array\n /** The signer that holds the key. */\n readonly signer: Signer\n private _disposed = false\n private _readOnly: WalletAccountReadOnlyZcash | undefined\n\n /** `publicKey` is the signer's compressed secp256k1 key (33 bytes); it is needed synchronously for the address. */\n constructor(signer: Signer, publicKey: Uint8Array, path: string, config: ZcashConfig = {}) {\n super(addressFromPublicKey(publicKey, config.network ?? 'mainnet'), config)\n this.signer = requireCurve(signer, 'secp256k1')\n if (!this.signer.schemes.includes('ecdsa')) throw new SignerError(`A Zcash account needs a signer with the 'ecdsa' scheme (has: ${this.signer.schemes.join(', ')}).`)\n this.publicKey = publicKey\n this.path = path\n }\n\n /** Back-compat: wrap a raw derived key in a {@link LocalSigner} (the account takes ownership; it cannot derive). */\n static fromPrivateKey(privateKey: Uint8Array, publicKey: Uint8Array, path: string, config: ZcashConfig = {}): WalletAccountZcash {\n return new WalletAccountZcash(LocalSigner.fromPrivateKey('secp256k1', privateKey, publicKey, path), publicKey, path, config)\n }\n\n /** Account index for the standard m/44'/133'/0'/0/i path. */\n get index(): number | undefined {\n const m = /^m\\/44'\\/(133|1)'\\/0'\\/0\\/(\\d+)$/.exec(this.path)\n return m ? Number(m[2]) : undefined\n }\n\n private live(): void {\n if (this._disposed) throw new SignerError('This account has been disposed.')\n }\n\n /** Zcash message signature (zcashd `signmessage` encoding), base64. */\n async sign(message: string | Uint8Array): Promise<string> {\n this.live()\n return signMessageWith(message, this.signer)\n }\n\n private ctx(intended?: { to: string; value: bigint }): DescribeContext {\n return { network: this._network, ownAddress: this.address, intended, maxFee: this.maxFee }\n }\n\n /** Lock time + expiry + branch id from the tip (or the config override). */\n private async chainParams(): Promise<{ lockTime: number; expiryHeight: number; consensusBranchId: number }> {\n const tip = await this.tipHeight()\n const delta = this._config.expiryDelta ?? DEFAULT_EXPIRY_DELTA\n const consensusBranchId = this._config.consensusBranchId ?? branchIdForHeight(tip)\n const lockTime = tip !== undefined && this._config.antiFeeSniping !== false ? tip : 0\n const expiryHeight = tip !== undefined && delta > 0 ? tip + delta : 0\n return { lockTime, expiryHeight, consensusBranchId }\n }\n\n /** Sign every input through the signer; the scriptSig is `<DER ‖ 0x01> <pubkey>`. */\n private async signInputs(tx: TransparentTxV5, spent: SpentOutput[]): Promise<void> {\n for (let i = 0; i < tx.inputs.length; i++) {\n const digest = sighashAll(tx, i, spent)\n const rs = await this.signer.sign(digest, { scheme: 'ecdsa', context: 'zcash-sighash' })\n const der = secp256k1.Signature.fromBytes(rs, 'compact').toBytes('der')\n tx.inputs[i]!.scriptSig = p2pkhScriptSig(der, this.publicKey)\n }\n }\n\n protected async buildSignedTransaction(spend: ZcashSpend): Promise<Built> {\n this.live()\n const plan = await this.planSpend(spend)\n const params = await this.chainParams()\n const tx: TransparentTxV5 = {\n ...params,\n inputs: plan.utxos.map((u) => ({ txid: u.txid, vout: u.vout, scriptSig: new Uint8Array(0), sequence: FINAL_SEQUENCE })),\n outputs: [{ value: plan.amount, script: plan.recipient.script }, ...(plan.change > 0n ? [{ value: plan.change, script: this.scriptPubKey }] : [])],\n }\n const spent: SpentOutput[] = plan.utxos.map((u) => ({ value: u.value, script: this.scriptPubKey }))\n const have = plan.utxos.reduce((s, u) => s + u.value, 0n)\n if (have < plan.amount + plan.fee) throw new InsufficientFundsError(plan.amount + plan.fee, have, 'ZEC')\n await this.signInputs(tx, spent)\n const ctx = this.ctx({ to: spend.to, value: plan.amount })\n const desc = describeTransaction(tx, spent, ctx)\n assertSafe(desc, ctx)\n const bytes = serializeTx(tx)\n return { tx, hex: bytesToHex(bytes), txid: txidOf(tx), fee: plan.fee, plan, desc }\n }\n\n private checkMax(fee: bigint, limit: bigint | number | undefined, op: string) {\n if (limit !== undefined && fee > BigInt(limit)) throw new Error(`Exceeded maximum fee cost for ${op} operation.`)\n }\n\n /** The outputs a raw transaction spends, fetched through the client (the wire format carries no values). */\n private async spentOutputs(tx: TransparentTxV5): Promise<SpentOutput[]> {\n const client = this.requireClient('inspect a raw transaction')\n const out: SpentOutput[] = []\n for (const i of tx.inputs) {\n const o = await client.getOutput(i.txid, i.vout)\n if (!o) throw new Error(`Prevout ${i.txid}:${i.vout} not found.`)\n out.push(o)\n }\n return out\n }\n\n /** Describe a raw signed tx (needs the network for prevouts) and run the safety checks. */\n private async describeRaw(rawHex: string): Promise<{ tx: TransparentTxV5; desc: ZcashTxDescription }> {\n const tx = parseTx(rawHex)\n const ctx = this.ctx()\n const desc = describeTransaction(tx, await this.spentOutputs(tx), ctx)\n assertSafe(desc, ctx)\n return { tx, desc }\n }\n\n /** \"What you sign\": the fully resolved spend (signed, NOT broadcast) or a caller's raw hex. */\n async describeTransaction(tx: ZcashTransaction): Promise<ZcashTxDescription> {\n if (typeof tx === 'string') return (await this.describeRaw(tx)).desc\n return (await this.buildSignedTransaction(tx)).desc\n }\n\n /** Sign without broadcasting. Returns the raw transaction hex. Raw hex input is returned unchanged. */\n async signTransaction(tx: ZcashTransaction, options: WriteOptions = {}): Promise<string> {\n this.live()\n if (typeof tx === 'string') return tx\n const built = await this.buildSignedTransaction(tx)\n this.checkMax(built.fee, feeLimit(this._config.transactionMaxFee, options), 'transaction')\n return built.hex\n }\n\n override async quoteSendTransaction(tx: ZcashTransaction): Promise<{ fee: bigint }> {\n if (typeof tx === 'string') return { fee: (await this.describeRaw(tx)).desc.fee }\n return super.quoteSendTransaction(tx)\n }\n\n async sendTransaction(tx: ZcashTransaction, options: WriteOptions = {}): Promise<TransferResult> {\n this.live()\n const client = this.requireClient('send transactions')\n let rawHex: string, hash: string, fee: bigint\n if (typeof tx === 'string') {\n const { tx: parsed, desc } = await this.describeRaw(tx)\n rawHex = tx; hash = txidOf(parsed); fee = desc.fee\n } else {\n const built = await this.buildSignedTransaction(tx)\n rawHex = built.hex; hash = built.txid; fee = built.fee\n }\n this.checkMax(fee, feeLimit(this._config.transactionMaxFee, options), 'transaction')\n const id = await client.broadcast(rawHex)\n return { hash: id || hash, fee }\n }\n\n /** Native ZEC only (`token` is rejected). Subject to `transferMaxFee`. */\n async transfer(o: ZcashTransferOptions, writeOptions: WriteOptions = {}): Promise<TransferResult> {\n if (o.token) throw new Error('Tokens are not supported on the zcash blockchain.')\n this.live()\n const client = this.requireClient('transfer')\n const built = await this.buildSignedTransaction({ to: o.recipient, value: o.amount })\n this.checkMax(built.fee, feeLimit(this._config.transferMaxFee, writeOptions), 'transfer')\n const id = await client.broadcast(built.hex)\n return { hash: id || built.txid, fee: built.fee }\n }\n\n /** The same address as a {@link WalletAccountReadOnlyZcash}. */\n toReadOnlyAccount(): IWalletAccountReadOnly {\n this._readOnly ??= new WalletAccountReadOnlyZcash(this.address, this._config)\n return this._readOnly\n }\n\n dispose(): void {\n this._disposed = true\n this.signer.dispose()\n }\n}\n\nexport { DUST_LIMIT, UnsafeTransactionError }\n","import { InsufficientFundsError, NetworkError, type IWalletAccountReadOnly } from '@anywalletkit/core'\nimport { DUST_LIMIT, addressFromPublicKey, decodeAddress, outputSize, type DecodedAddress } from './address.js'\nimport { createClient } from './client.js'\nimport { DEFAULT_MAX_FEE } from './describe.js'\nimport { MAX_UTXO_INPUTS, selectAll, selectCoins, type CoinSelection } from './fee.js'\nimport { recoverMessagePublicKey } from './message.js'\nimport { CAIP2, type ZcashClient, type ZcashConfig, type ZcashMaxSpendableResult, type ZcashNetwork, type ZcashReceipt, type ZcashSpend, type ZcashTransferOptions } from './types.js'\n\n/** A coin selection for one spend, with the decoded recipient. */\nexport interface SpendPlan extends CoinSelection {\n /** Zatoshis the recipient gets (the requested value — never reduced). */\n amount: bigint\n recipient: DecodedAddress\n}\n\nconst toBig = (v: bigint | number | string): bigint => (typeof v === 'bigint' ? v : BigInt(typeof v === 'string' ? v.trim() : Math.round(v)))\n\n/** Watch-only Zcash account: balances, quotes, receipts, message verification. No key. */\nexport class WalletAccountReadOnlyZcash implements IWalletAccountReadOnly {\n /** The transparent address. */\n readonly address: string\n readonly chain: string\n /** The address's scriptPubKey. */\n readonly scriptPubKey: Uint8Array\n /** Script type of the address. */\n readonly scriptKind: DecodedAddress['kind']\n protected readonly _config: ZcashConfig\n protected readonly _client: ZcashClient | undefined\n protected readonly _network: ZcashNetwork\n\n constructor(address: string, config: ZcashConfig = {}) {\n this._config = config\n this._network = config.network ?? 'mainnet'\n const decoded = decodeAddress(address, this._network)\n this.address = address.trim()\n this.scriptPubKey = decoded.script\n this.scriptKind = decoded.kind\n this.chain = CAIP2[this._network]\n this._client = createClient(config)\n }\n\n protected requireClient(what: string): ZcashClient {\n if (!this._client) throw new NetworkError(`The wallet must be connected to a client to ${what}.`)\n return this._client\n }\n\n /** Fee ceiling in zatoshis: `ZcashConfig.maxFee` or the default. */\n get maxFee(): bigint {\n return this._config.maxFee !== undefined ? toBig(this._config.maxFee) : DEFAULT_MAX_FEE\n }\n\n /** The transparent address. */\n async getAddress(): Promise<string> { return this.address }\n\n /** Confirmed plus incoming mempool value (the transports do not expose pending spends of our own outputs). */\n async getBalance(): Promise<bigint> {\n const { confirmed, unconfirmed } = await this.requireClient('read balances').getBalance(this.address)\n return confirmed + unconfirmed\n }\n\n /** Always throws: Zcash has no tokens. */\n async getTokenBalance(_token: string): Promise<bigint> {\n throw new Error(\"The 'getTokenBalance' method is not supported on the zcash blockchain.\")\n }\n\n /** Coin selection for a spend (ZIP-317 fee). Validates the recipient and the dust floor first. */\n protected async planSpend(spend: ZcashSpend): Promise<SpendPlan> {\n if (this.scriptKind !== 'p2pkh') throw new Error(`Cannot build spends from a ${this.scriptKind} address; only P2PKH (t1…) accounts spend.`)\n const amount = toBig(spend.value)\n const recipient = decodeAddress(spend.to, this._network)\n if (amount < DUST_LIMIT) throw new Error(`The amount must be at least the dust limit (${DUST_LIMIT} zatoshis).`)\n const utxos = await this.requireClient('plan a spend').listUnspent(this.address)\n if (utxos.length === 0) throw new InsufficientFundsError(amount, 0n, 'ZEC')\n const selection = selectCoins({\n utxos,\n target: amount,\n recipientOutputSize: outputSize(recipient.script),\n changeOutputSize: outputSize(this.scriptPubKey),\n maxInputs: this._config.maxInputs ?? MAX_UTXO_INPUTS,\n ...(spend.fee !== undefined ? { fee: toBig(spend.fee) } : {}),\n })\n return { ...selection, amount, recipient }\n }\n\n /** ZIP-317 fee of a spend in zatoshis. */\n async quoteSendTransaction(tx: ZcashSpend): Promise<{ fee: bigint }> {\n const { fee } = await this.planSpend(tx)\n return { fee }\n }\n\n /** ZIP-317 fee of a transfer in zatoshis. */\n async quoteTransfer(o: ZcashTransferOptions): Promise<{ fee: bigint }> {\n if (o.token) throw new Error('Tokens are not supported on the zcash blockchain.')\n return this.quoteSendTransaction({ to: o.recipient, value: o.amount })\n }\n\n /** Everything spendable in ONE transaction to a single output, no change. */\n async getMaxSpendable(opts: { to?: string; fee?: bigint | number } = {}): Promise<ZcashMaxSpendableResult> {\n const utxos = await this.requireClient('plan a spend').listUnspent(this.address)\n const outScript = opts.to ? decodeAddress(opts.to, this._network).script : this.scriptPubKey\n const sweep = selectAll({ utxos, outputSize: outputSize(outScript), maxInputs: this._config.maxInputs ?? MAX_UTXO_INPUTS, ...(opts.fee !== undefined ? { fee: toBig(opts.fee) } : {}) })\n const amount = sweep.amount >= DUST_LIMIT ? sweep.amount : 0n\n return { amount, fee: amount > 0n ? sweep.fee : 0n, changeValue: 0n, inputs: amount > 0n ? sweep.utxos.length : 0 }\n }\n\n /** Undefined until the transaction is mined. */\n async getTransactionReceipt(hash: string): Promise<ZcashReceipt | undefined> {\n if (!/^[0-9a-fA-F]{64}$/.test(hash)) throw new Error(\"The 'getTransactionReceipt(hash)' method requires a valid transaction hash.\")\n const info = await this.requireClient('fetch transaction receipts').getTransactionInfo(hash)\n if (!info || info.blockHeight <= 0) return undefined\n return { hash, status: 1, blockNumber: BigInt(info.blockHeight), confirmations: info.confirmations, ...(info.fee !== undefined ? { fee: info.fee } : {}) }\n }\n\n /** Recover the key from a Zcash message signature and compare its P2PKH address with ours. */\n async verify(message: string | Uint8Array, signature: string): Promise<boolean> {\n const pub = recoverMessagePublicKey(message, signature)\n if (!pub) return false\n try { return addressFromPublicKey(pub, this._network) === this.address } catch { return false }\n }\n\n /** Chain tip for lock time / expiry; undefined when the transport cannot tell. */\n protected async tipHeight(): Promise<number | undefined> {\n if (!this._client) return undefined\n try { return await this._client.getBlockHeight() } catch { return undefined }\n }\n}\n","/**\n * Activity history for Zcash transparent addresses: a `HistorySource` over\n * Blockchair's address dashboard (transaction hashes, newest first) and\n * transaction dashboards (inputs / outputs with addresses and values, fetched\n * ten at a time). Shielded legs of a transaction show up only as the\n * transparent value that entered or left it.\n */\nimport type { ChainTransfer, ChainTx, HistoryPage, HistoryQuery, HistorySource } from '@anywalletkit/core'\nimport { BlockchairClient, blockchairTime, type BlockchairTxDashboard } from './blockchair.js'\nimport { DEFAULT_TIMEOUT_MS } from './http.js'\nimport { CAIP2 } from './types.js'\n\n/** Options for {@link createZcashHistory}. */\nexport interface ZcashHistoryOptions {\n /** Blockchair base (`https://api.blockchair.com/zcash`); optional API key. */\n blockchairUrl?: string\n key?: string\n fetch?: typeof fetch\n timeoutMs?: number\n /** Rows per page (max 100). Default: the query limit, capped at 100. */\n pageSize?: number\n}\n\nexport interface ZcashHistoryRaw {\n tx: BlockchairTxDashboard\n ownIn: bigint\n ownOut: bigint\n}\n\nexport interface ZcashChainTx extends ChainTx { raw: ZcashHistoryRaw }\n\nexport interface ZcashHistoryPage extends HistoryPage {\n items: ZcashChainTx[]\n offset: number\n total?: number\n}\n\n/** Zcash transparent-address history from Blockchair. Build it with {@link createZcashHistory}. */\nexport interface ZcashHistorySource extends HistorySource {\n listActivity(address: string, query?: HistoryQuery): Promise<ZcashHistoryPage>\n getTransaction(hash: string, address: string): Promise<ZcashChainTx | undefined>\n}\n\n/** The history backend failed. */\nexport class HistoryUnavailableError extends Error {\n readonly chain: string\n readonly reason: string\n constructor(chain: string, reason: string) {\n super(`History unavailable for ${chain}: ${reason}`)\n this.name = 'HistoryUnavailableError'\n this.chain = chain\n this.reason = reason\n }\n}\n\nconst DEFAULT_LIMIT = 25\nconst MAX_PAGE_SIZE = 100\n\nexport interface ZcashHistoryCursor { v: 1; o: number; s: number }\n\nexport function encodeCursor(c: ZcashHistoryCursor): string {\n return `${c.v}:${c.o}:${c.s}`\n}\n\nexport function decodeCursor(s: string): ZcashHistoryCursor {\n const m = /^1:(\\d+):(\\d+)$/.exec(s)\n if (!m) throw new Error('@anywalletkit/wallet-zcash: malformed history cursor')\n const o = Number(m[1]), size = Number(m[2])\n if (size < 1) throw new Error('@anywalletkit/wallet-zcash: malformed history cursor')\n return { v: 1, o, s: size }\n}\n\nexport function mapDashboardTx(chain: string, address: string, d: BlockchairTxDashboard): ZcashChainTx {\n let ownIn = 0n, ownOut = 0n, sentToOthers = 0n\n for (const i of d.inputs) if (i.recipient === address) ownIn += BigInt(i.value)\n for (const o of d.outputs) { if (o.recipient === address) ownOut += BigInt(o.value); else sentToOthers += BigInt(o.value) }\n const firstInput = d.inputs.find((i) => i.recipient)?.recipient\n const firstOther = d.outputs.find((o) => o.recipient && o.recipient !== address)?.recipient\n const transfers: ChainTransfer[] = []\n let from: string, to: string | null, nativeValue: bigint\n if (ownIn > 0n) {\n from = address\n to = firstOther ?? address\n nativeValue = firstOther ? sentToOthers : ownOut\n if (nativeValue > 0n) transfers.push({ token: null, from: address, to, amount: nativeValue })\n } else {\n from = firstInput ?? (d.inputs.length === 0 ? 'shielded' : 'coinbase')\n to = address\n nativeValue = ownOut\n if (nativeValue > 0n) transfers.push({ token: null, from, to: address, amount: nativeValue })\n }\n const t = d.transaction as BlockchairTxDashboard['transaction'] & { confirmations?: number }\n const confirmed = t.block_id > 0\n const out: ZcashChainTx = {\n chain, hash: t.hash, time: blockchairTime(t.time) ?? 0, status: confirmed ? 'confirmed' : 'pending', address, from, to, nativeValue, transfers,\n raw: { tx: d, ownIn, ownOut },\n }\n if (typeof t.fee === 'number') out.fee = BigInt(t.fee)\n if (confirmed) out.block = BigInt(t.block_id)\n return out\n}\n\n/** Blockchair link for a transaction. */\nexport function zcashExplorerTxUrl(hash: string): string {\n return `https://blockchair.com/zcash/transaction/${hash}`\n}\n\n/**\n * A history source for transparent Zcash addresses backed by Blockchair (mainnet).\n *\n * @throws Error when no `fetch` is available.\n */\nexport function createZcashHistory(options: ZcashHistoryOptions = {}): ZcashHistorySource {\n const chain = CAIP2.mainnet\n const fetchFn = options.fetch ?? globalThis.fetch\n if (typeof fetchFn !== 'function') throw new Error('@anywalletkit/wallet-zcash: no global fetch; pass `fetch` in the options')\n const client = new BlockchairClient({ ...(options.blockchairUrl ? { url: options.blockchairUrl } : {}), ...(options.key ? { key: options.key } : {}) }, fetchFn, options.timeoutMs ?? DEFAULT_TIMEOUT_MS)\n const wrap = async <T>(run: () => Promise<T>): Promise<T> => {\n try { return await run() } catch (e) { throw new HistoryUnavailableError(chain, e instanceof Error ? e.message : String(e)) }\n }\n\n return {\n chain,\n\n async listActivity(address: string, query: HistoryQuery = {}): Promise<ZcashHistoryPage> {\n const cursor = query.cursor ? decodeCursor(query.cursor) : undefined\n const pageSize = cursor?.s ?? Math.min(MAX_PAGE_SIZE, Math.max(1, Math.floor(options.pageSize ?? query.limit ?? DEFAULT_LIMIT)))\n const offset = cursor?.o ?? 0\n const { hashes, total } = await wrap(() => client.listTransactions(address, pageSize, offset))\n const dashboards = hashes.length ? await wrap(() => client.getTransactionDashboards(hashes)) : new Map()\n let items = hashes.map((h) => dashboards.get(h)).filter((d): d is BlockchairTxDashboard => !!d).map((d) => mapDashboardTx(chain, address, d))\n items.sort((a, b) => (b.block === undefined ? 1 : a.block === undefined ? -1 : (b.block > a.block ? 1 : b.block < a.block ? -1 : 0)) || b.time - a.time)\n let more = total !== undefined ? offset + hashes.length < total : hashes.length === pageSize\n if (query.since !== undefined) {\n const since = query.since\n if (items.some((t) => t.status === 'confirmed' && t.time < since)) more = false\n items = items.filter((t) => t.status !== 'confirmed' || t.time >= since)\n }\n const page: ZcashHistoryPage = { items, offset, ...(total !== undefined ? { total } : {}) }\n if (more) page.cursor = encodeCursor({ v: 1, o: offset + hashes.length, s: pageSize })\n return page\n },\n\n async getTransaction(hash: string, address: string): Promise<ZcashChainTx | undefined> {\n const d = await wrap(() => client.getTransactionDashboard(hash))\n return d ? mapDashboardTx(chain, address, d) : undefined\n },\n\n explorerTxUrl: zcashExplorerTxUrl,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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AC/D,aAAO,IAAI,eAAe,OAAO,SAAS,CAAC,IAAI;AAAA,IACjD;AAAA,IAEA,eAAe;AAAA,EACjB;AACF;","names":["inputSizes","txid","import_core","import_core","h","txid","t","import_core","txid","h","import_core","import_sha2","import_base","PREFIX","import_core","import_core","import_secp256k1","import_core","h"]}