/** * Client-Side UTXO Fetcher * * Fetches spendable UTXOs from the indexed backend API. * This avoids the slow merkle tree scanning that the SDK does. * * Supports two types of UTXOs: * 1. Shield commitments - from original shield() calls * 2. Change notes - from partial unshield TRANSACT events */ import type { ShieldCommitment, MerkleProofResponse } from './types'; export interface DecryptedNote { value: bigint; random: bigint; notePublicKey: bigint; tokenAddress: string; } export interface SpendableUTXO { commitment: ShieldCommitment; merkleProof: MerkleProofResponse; note: DecryptedNote; nullifier: string; tree: number; position: number; } /** * Compute nullifier for a UTXO * nullifier = poseidon(nullifyingKey, position) */ export declare function computeNullifier(nullifyingKey: bigint, position: number): string; /** * Fetch spendable UTXOs for a user * * This fetches both: * 1. Original shield commitments * 2. Change notes from partial unshield TRANSACT events * * @param signerAddress - EOA address that signed * @param viewingPrivateKey - Derived viewing private key * @param masterPublicKey - Derived master public key * @param nullifyingKey - Derived nullifying key * @param tokenAddress - Optional filter by token */ export declare function fetchSpendableUTXOs(signerAddress: string, viewingPrivateKey: Uint8Array, masterPublicKey: bigint, nullifyingKey: bigint, tokenAddress?: string, chainId?: number): Promise; /** * Lightweight UTXO check - only fetches commitments and nullifier status * Does NOT fetch merkle proofs (avoids rate limiting during polling) * * Use this for polling/checking, then call fetchSpendableUTXOs when ready to process * * IMPORTANT: This function now discovers BOTH original shields AND change notes from * partial unshields. Change notes are discovered by checking nullifier status of * original shields and looking at TRANSACT events that created new outputs. */ export declare function fetchSpendableUTXOsLightweight(signerAddress: string, viewingPrivateKey: Uint8Array, masterPublicKey: bigint, nullifyingKey: bigint, tokenAddress?: string, chainId?: number): Promise>; /** * Upgrade lightweight UTXOs to full SpendableUTXOs by fetching merkle proofs */ export declare function upgradeToFullUTXOs(lightweightUtxos: Array<{ commitment: ShieldCommitment; note: DecryptedNote; nullifier: string; position: number; tree: number; }>, chainId?: number): Promise; /** * Get total spendable balance for a token */ export declare function getSpendableBalance(utxos: SpendableUTXO[], tokenAddress: string): bigint; /** * Select UTXOs to cover a target amount * Uses simple greedy algorithm - largest first */ export declare function selectUTXOsForAmount(utxos: SpendableUTXO[], targetAmount: bigint, tokenAddress: string): SpendableUTXO[];