@anywalletkit/wallet-zcash

中文文档
0.5.1发布于 2026/11/03Apache-2.0TypeScriptESM + CJS构建来源已验证近 30 天下载 2188

Zcash wallet for Any Wallet Kit: transparent t-addresses (BIP-44 coin 133), v5 transactions with ZIP-244 signature hashing, ZIP-317 fees, Blockchair / Blockbook transports. Shielded pools are out of scope.

原始使用文档
文档目录6 节
  1. Install
  2. What a spend is
  3. Safety checks
  4. Message signing
  5. Transports
  6. Activity history

@anywalletkit/wallet-zcash

npm

Zcash transparent accounts for Any Wallet Kit — BIP-44 m/44'/133'/0'/0/i, t1… addresses (the transparent receiver Zashi, YWallet, Ledger and Trezor derive from the same seed). Pure Uint8Array, @noble / @scure only, runs in Hermes.

Install

npm install @anywalletkit/wallet-zcash
# or: pnpm add @anywalletkit/wallet-zcash  ·  yarn add @anywalletkit/wallet-zcash

On npm: @anywalletkit/wallet-zcash, published from the release workflow with provenance.

import WalletManagerZcash from '@anywalletkit/wallet-zcash'

const wallet = new WalletManagerZcash(seedPhrase, {
  client: [
    { type: 'blockchair' },                                                   // public, no key
    { type: 'blockbook-http', clientConfig: { url: 'https://zec-blockbook.nownodes.io', headers: { 'api-key': KEY } } },
  ],
  maxFee: 100_000n,                                                           // zatoshi ceiling (default 1 000 000 = 0.01 ZEC)
})
const account = await wallet.getAccount(0)

const preview = await account.describeTransaction({ to: 't1…', value: 5_000_000n })
//   { kind: 'zcash-transfer', version: 5, consensusBranchId, inputs, outputs: [{ role: 'recipient' | 'change' }],
//     fee, conventionalFee, size, lockTime, expiryHeight, txid, warnings }

await account.transfer({ recipient: 't1…', amount: 5_000_000n })             // zatoshis
await account.sendTransaction({ to: 't1…', value: 5_000_000n, fee: 20_000n }) // explicit fee (still ≤ maxFee)
const hex = await account.signTransaction({ to: 't1…', value: 5_000_000n })   // sign only
const max = await account.getMaxSpendable()                                   // sweep amount after fee
wallet.dispose()

What a spend is

A v5 transaction (ZIP-225) with transparent inputs and outputs and empty Sapling / Orchard bundles. Ids and signature hashes follow ZIP-244: BLAKE2b-256 digests personalized with the consensus branch id, so a signature is only valid under the upgrade it was made for. The branch id is the one in force at tip + 1, the block the transaction lands in (branchIdForHeight: NU5 → NU6 → NU6.1 → NU6.3 "Ironwood", active since block 3 428 143), or consensusBranchId from the config when a new upgrade activates before the package learns its id. On testnet and regtest, whose upgrades activate at other heights, consensusBranchId is required. The expiry is tip + 1 + expiryDelta; without a tip nothing is signed (a transaction with expiry 0 never expires).

Fees are ZIP-317: 5000 zatoshis × max(2, logical actions), logical actions = max(⌈Σ input bytes / 150⌉, ⌈Σ output bytes / 34⌉) — a 1-in-2-out spend pays 10 000 zatoshis, no fee market. Coin selection is largest-first until the inputs cover amount + fee; change below the 546-zatoshi dust floor is folded into the fee. nLockTime is the tip height (anti-fee-sniping) and nExpiryHeight tip + 40 (ZIP-203), so an unmined transaction expires in under an hour instead of lingering.

The ZIP-244 implementation is pinned by mined mainnet transactions in the tests: parse → serialize round-trip, txid equality and ECDSA verification of every on-chain signature over the digest this package computes.

Safety checks

Before signing and before broadcasting (also for caller-supplied raw hex): fee ≤ maxFee, outputs ≤ inputs, exactly one output is the requested recipient / amount and every other output is our own address. Warnings (not blocks): fee below the conventional fee (nodes may not relay), fee over 10 % of the amount, dust output, no change, no expiry.

Shielded destinations are refused by name: unified u1…, Sapling zs1…, Sprout zc…. Sending to a shielded address and receiving on one need a shielded wallet (note-commitment tree sync + prover) — out of scope for this package.

Message signing

sign(message) is zcashd's signmessage: sha256d("\x16Zcash Signed Message:\n" ‖ len ‖ message), header 31 + recovery (compressed key), base64. verify recovers the key and compares the P2PKH address.

Transports

typeBackendNotes
blockchairhttps://api.blockchair.com/zcashpublic, CORS, UTXOs incl. mempool, raw tx, push/transaction; optional key; mainnet only
blockbook-httpany Zcash Blockbook (NOWNodes zec-blockbook.nownodes.io, self-hosted)/api/v2/{address,utxo,tx,sendtx}; headers for API keys; testnet too

A list fails over in order; a node's refusal of a broadcast is final (not retried on the next transport) unless an endpoint before it never answered. A broadcast with no definitive answer (no response, a timeout, a 5xx, an HTML 502) throws BroadcastUnknownError (maybeSent, hash = the txid computed before sending): do not spend the coins again. "Already in the mempool / block chain" returns the txid.

Activity history

createZcashHistory() (from @anywalletkit/wallet-zcash/history) is a HistorySource over Blockchair: one transaction = one native transfer in the owner's direction; shielded legs appear only as the transparent value that entered or left.

版本与发布记录

@anywalletkit/wallet-zcash 共发布 12 个版本,首次发布于 2026/10/25;过去 12 个月发布了 12 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.5.1latest2026/11/035 天前
0.5.02026/10/309 天前
0.4.02026/10/2810 天前
0.3.12026/10/2811 天前
0.3.02026/10/2712 天前
0.2.62026/10/2612 天前

关于 @anywalletkit/wallet-zcash 的常见问题

@anywalletkit/wallet-zcash 是什么?

Zcash wallet for Any Wallet Kit: transparent t-addresses (BIP-44 coin 133), v5 transactions with ZIP-244 signature hashing, ZIP-317 fees, Blockchair / Blockbook transports. Shielded pools are out of scope.

如何安装 @anywalletkit/wallet-zcash?

在项目目录运行 npm install @anywalletkit/wallet-zcash,或使用 pnpm add / yarn add / bun add。

@anywalletkit/wallet-zcash 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@anywalletkit/wallet-zcash 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@anywalletkit/wallet-zcash 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@anywalletkit/wallet-zcash 可以商用吗?

@anywalletkit/wallet-zcash 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@anywalletkit/wallet-zcash 的下载量有多少?

根据 npm 官方下载统计,@anywalletkit/wallet-zcash 在 2026/10/06 – 2026/11/04 这 30 天内被下载 2,188 次,日均约 73 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@anywalletkit/wallet-zcash 还在维护吗?

最新版本 0.5.1 发布于 2026/11/03(5 天前);至今共发布 12 个版本,其中过去 12 个月发布了 12 个;首次发布于 2026/10/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。