import type { CompactScanNote, RelayerEncryptedNote } from "../relayer/types.js"; import { type NoteCipherScanTelemetry, type NoteCipherVersion } from "./migrationTelemetry.js"; /** * Finding your own notes in the public feed. * * The compact feed is deliberately anonymous: every row is ciphertext plus a * one-byte view tag, and nothing on it says who a note belongs to. You find * yours by trial decryption. The view tag exists to make that cheap — it * rejects ~255/256 of other people's rows with one hash instead of a full * decrypt. */ /** Server-side page cap (notes.constants COMPACT_SCAN_MAX_LIMIT). */ export declare const COMPACT_SCAN_MAX_LIMIT = 1000; /** Server-side cap per fetch-by-commitment request. */ export declare const MAX_COMMITMENTS_PER_FETCH = 50; /** A feed row that decrypted under your key. */ export interface ScannedNote { /** Value in base units. */ amount: bigint; /** 32-byte blinding factor recovered from the cipher. */ blinding: Uint8Array; /** Commitment hex, as stored. */ commitment: string; leafIndex?: number | null; treeId?: number | null; mint?: string | null; timestamp?: number; txSignature?: string; /** Which encryption target successfully opened this note. */ cipherVersion: NoteCipherVersion; /** The raw feed row this came from. */ source: CompactScanNote; } export interface ScanCompactNotesOptions { /** Rows per request. Capped at COMPACT_SCAN_MAX_LIMIT. */ pageSize?: number; /** Resume from a previous run's `nextCursor`. */ cursor?: string; /** Stop after this many pages. Unlimited by default. */ maxPages?: number; /** Called after each page, for progress reporting. Return false to stop. */ onPage?: (progress: { scanned: number; matched: number; cursor: string | null; /** Aggregate-only counters; contains no note or wallet identifiers. */ telemetry: NoteCipherScanTelemetry; }) => boolean | void; /** When supplied, decrypted plaintext must reproduce the claimed commitment. */ notePublicKey?: bigint; } export interface ScanCompactNotesResult { /** Rows that decrypted under your key. */ notes: ScannedNote[]; /** Feed rows examined. */ scanned: number; /** * Cursor to resume from. Null means the feed was exhausted; a string means * scanning stopped early (maxPages, or onPage returning false). */ nextCursor: string | null; /** Aggregate-only local scan counters. The SDK never uploads these. */ telemetry: NoteCipherScanTelemetry; } /** * Walk the compact feed and return the notes that belong to this key. * * Paginates to exhaustion by default. The X25519 private key is derived once * and reused across every row rather than per row — that derivation dominates * the cost otherwise. * * @param walletSecretKey full 64-byte keypair.secretKey */ export declare function scanCompactNotes(walletSecretKey: Uint8Array, options?: ScanCompactNotesOptions): Promise; /** * Scan only v2 notes with the independent view secret key. * * This grants note discovery and plaintext recovery without exposing the * Poseidon spending key or the wallet secret. Legacy wallet-key v1 notes are * intentionally invisible here and must be swept by a first-party wallet. */ export declare function scanCompactNotesWithViewKey(viewSecretKey: Uint8Array, options: ScanCompactNotesOptions & { notePublicKey: bigint; }): Promise; /** * Look up stored notes by commitment, chunked to the server's limit. * * Requests are issued concurrently. Commitments the relayer does not know are * simply absent from the result — the array is not positional. */ export declare function fetchNotesByCommitment(commitments: string[], options?: { walletPublicKey?: string; }): Promise;