zypherscan-zcash-wasm
v0.1.4
Published
High-performance Rust-based WebAssembly SDK for Zcash. Provides efficient private transaction scanning (trial decryption) and key utilities for JavaScript/TypeScript environments (Node.js & Web).
Downloads
27
Readme
Zcash WASM Scanning SDK
High-performance Rust-based WebAssembly SDK for Zcash. Provides efficient private transaction scanning (trial decryption) and key utilities for JavaScript/TypeScript environments (Node.js & Web).
Features
- High-Performance Scanning: Batch trial decryption for Orchard actions using WASM.
- Privacy Handling: Decrypt transaction specific details (memos, amounts) securely.
- Address Management: Parse Unified Addresses (UA).
- Cross-Platform: Works in both Browser and Node.js.
Installation
1. In this project (local dev)
# Build (required)
wasm-pack build --target nodejs --out-dir pkg-node
# Install deps
npm install2. In an External Project
If you have published this package to NPM or are installing via git/local path:
# Install via NPM/pnpm/yarn
pnpm install zypherscan-zcash-wasmThen import normally in your code:
import {
get_addresses,
batch_filter_compact_outputs,
} from "zypherscan-zcash-wasm";Prerequisite: Building the SDK
To use this SDK in a Node.js environment (like the CLI scanner), build it with the nodejs target:
# Install wasm-pack
npm install -g wasm-pack
# Build for Node.js
wasm-pack build --target nodejs --out-dir pkg-nodeUsage Example
1. Basic Setup & Scanning
import {
batch_filter_compact_outputs,
get_addresses,
} from "zypherscan-zcash-wasm";
async function main() {
// 1. Setup Keys
// Note: Addresses must be derived from a Unified Address string, not raw keys.
const ua = "u1...";
const addresses = JSON.parse(get_addresses(ua));
console.log("Orchard Address:", addresses.orchard);
// 2. Scan Compact Outputs (from Lightwalletd)
const outputs = [
{
txid: "...",
height: 123456,
nullifier: "hex...",
cmx: "hex...",
ephemeral_key: "hex...",
ciphertext: "hex...",
},
];
// match against your Viewing Key (UFVK)
const ufvk = "uview...";
const matchesJson = batch_filter_compact_outputs(
JSON.stringify(outputs),
ufvk
);
console.log("Matches:", JSON.parse(matchesJson));
}2. Live Scanner CLI
This repository includes a fully functional CLI tool to scan the Zcash blockchain for transactions.
Setup:
# Install dependencies
npm install
# Build WASM
wasm-pack build --target nodejs --out-dir pkg-nodeRun Scanner:
npm startFollow the interactive prompts:
- Lightwalletd URL: e.g.,
lightwalletd.zypherscan.com - UFVK: Your Unified Full Viewing Key.
- Birthday Height: Block height to start scanning from.
- Unified Address: (Optional) Your UA for display purposes.
API Reference
get_addresses(ua: string) -> string (JSON)
Parses a Unified Address and returns its component receivers (Orchard, Sapling, Transparent).
- Input: Unified Address string (
u1...). - Returns: JSON string
{ orchard: "...", sapling: "...", transparent: "..." }.
batch_filter_compact_outputs(json_outputs: string, ufvk: string) -> string (JSON)
Scans a batch of compact outputs to find those owned by the viewing key.
- Input: JSON array of compact output objects, UFVK string.
- Returns: JSON array of matches
{ txid: "...", index: ... }.
decrypt_memo(tx_hex: string, ufvk: string) -> string (JSON)
Decrypts a full transaction hex to retrieve amounts, memos, and directions.
- Input: Raw transaction hex, UFVK string.
- Output: JSON array of decrypted outputs.
License
MIT
