/**
 * Main-thread side of the wallet-worker RPC.
 *
 * Spawns ONE Node `worker_threads` worker, holds a handle for the lifetime of
 * the cds-serve process, and exposes a typed async API that maps to the
 * worker's message handlers.
 *
 * RPC shape: per-call `MessageChannel`. We send `{ kind: 'rpc', method, args,
 * port: port1 }` (transferring port1's MessagePort to the worker), then await
 * a single message on `port2` carrying `{ ok, result | error }`.
 *
 * Push events from the worker — `state-save` and `log` — are handled by
 * listeners registered via `setStateSaveSink(...)` and the default log relay.
 * The save sink is where we wire CAP `db.run` from the main thread (which is
 * NOT blocked by the wallet SDK because the SDK now lives in the worker).
 */
import type { CapDbPrivateStateProvider } from './CapDbPrivateStateProvider';
export interface WalletInitArgs {
    sessionId: string;
    seedHex: string;
    networkId: 'preprod' | 'testnet' | 'mainnet' | 'undeployed' | 'devnet' | 'qanet' | 'preview';
    indexerHttpUrl: string;
    indexerWsUrl: string;
    proofServerUrl: string;
    relayUrl: string;
    restoreBlobs?: {
        shielded?: string;
        unshielded?: string;
        dust?: string;
    };
}
export interface SerializedBlobs {
    shielded?: string;
    unshielded?: string;
    dust?: string;
}
export type StateSaveSink = (event: {
    sessionId: string;
    sdkVersion: string;
    blobs: SerializedBlobs;
}) => void | Promise<void>;
export declare function registerPrivateStateProvider(proxyId: string, provider: CapDbPrivateStateProvider): void;
export declare function unregisterPrivateStateProvider(proxyId: string): void;
/**
 * Start the worker. Idempotent: a second call returns the existing client.
 * Resolves when the worker has emitted its `ready` message.
 */
export declare function startWalletWorker(): Promise<void>;
/**
 * Stop the worker. Safe to call multiple times. Waits up to `timeoutMs` for
 * graceful exit before terminating.
 */
export declare function stopWalletWorker(timeoutMs?: number): Promise<void>;
/**
 * Register the callback that receives push 'state-save' events from the
 * worker. Called by the persistence layer at startup.
 */
export declare function setStateSaveSink(sink: StateSaveSink | undefined): void;
export declare function walletInit(args: WalletInitArgs): Promise<{
    facadeReady: boolean;
    alreadyExisted: boolean;
    sdkVersion?: string;
}>;
export declare function walletWaitForSyncedState(sessionId: string, timeoutMs?: number): Promise<{
    synced: true;
}>;
export declare function walletSerializeState(sessionId: string): Promise<{
    sdkVersion: string;
    blobs: SerializedBlobs;
}>;
export declare function walletEvict(sessionId: string): Promise<{
    evicted: boolean;
}>;
export declare function walletPing(): Promise<{
    ok: true;
    ts: number;
}>;
/**
 * End-to-end NIGHT-UTXO registration for DUST generation.
 * Single RPC that wraps wait-sync → filter → register → finalize → submit.
 * `syncTimeoutMs: 0` (or omitted) waits indefinitely for sync; provide a
 * positive number to bound the wait for tests.
 */
export declare function walletRegisterDustGeneration(args: {
    sessionId: string;
    dustReceiverAddress?: string;
    syncTimeoutMs?: number;
}): Promise<{
    txId: string | null;
    registeredCount: number;
    totalNightUtxos: number;
    dustReceiverAddress: string;
}>;
/**
 * Symmetric pair to `walletRegisterDustGeneration`. Deregisters all
 * registered NIGHT UTXOs so they become spendable. Per-UTXO narrowing
 * is a follow-up; today this is all-or-nothing.
 */
export declare function walletDeregisterDustGeneration(args: {
    sessionId: string;
    syncTimeoutMs?: number;
}): Promise<{
    txId: string | null;
    deregisteredCount: number;
    totalNightUtxos: number;
}>;
/**
 * Send NIGHT to any Midnight address. Ledger is auto-detected from the
 * receiver's Bech32m prefix (mn_shield-addr_ vs mn_addr_).
 *
 * Amount is a decimal string parseable as bigint (NIGHT atoms) — strings
 * avoid the precision pitfalls of JS Number when atom counts exceed 2^53.
 */
export declare function walletTransferNight(args: {
    sessionId: string;
    receiverAddress: string;
    amount: string;
    ttlIso?: string;
    syncTimeoutMs?: number;
}): Promise<{
    txId: string;
    toLedger: 'shielded' | 'unshielded';
    amount: string;
    receiverAddress: string;
}>;
/**
 * Move NIGHT from shielded → unshielded ledger. Always targets the
 * wallet's own unshielded address (no third-party recipient parameter
 * for this primitive).
 */
export declare function walletUnshieldNight(args: {
    sessionId: string;
    amount: string;
    ttlIso?: string;
    syncTimeoutMs?: number;
}): Promise<{
    txId: string;
    amount: string;
    unshieldedReceiverAddress: string;
}>;
/** Symmetric counterpart: unshielded → shielded for own funds. */
export declare function walletShieldNight(args: {
    sessionId: string;
    amount: string;
    ttlIso?: string;
    syncTimeoutMs?: number;
}): Promise<{
    txId: string;
    amount: string;
    shieldedReceiverAddress: string;
}>;
/**
 * Snapshot of the wallet's balances. Read-only — no transaction is
 * built or submitted. All amounts are decimal-string bigint to avoid
 * Number precision loss.
 */
export declare function walletGetBalance(args: {
    sessionId: string;
    syncTimeoutMs?: number;
}): Promise<{
    shieldedNight: string;
    unshieldedNight: string;
    dustBalance: string;
    registeredNightUtxoCount: number;
    totalNightUtxoCount: number;
}>;
/**
 * Pre-flight fee estimate for `walletTransferNight`. Builds the recipe
 * but does NOT finalize (no proof generation) or submit. Returns dust
 * atoms as decimal string.
 */
export declare function walletEstimateTransferFee(args: {
    sessionId: string;
    receiverAddress: string;
    amount: string;
    ttlIso?: string;
    syncTimeoutMs?: number;
}): Promise<{
    fee: string;
    toLedger: 'shielded' | 'unshielded';
}>;
/**
 * Pre-flight fee estimate for shield/unshield ledger shifts. Builds the
 * `initSwap` recipe without finalizing. `direction` selects which way.
 */
export declare function walletEstimateSwapFee(args: {
    sessionId: string;
    direction: 'shield' | 'unshield';
    amount: string;
    ttlIso?: string;
    syncTimeoutMs?: number;
}): Promise<{
    fee: string;
    direction: 'shield' | 'unshield';
}>;
export interface WorkerContractRegistration {
    artifactPath: string;
    privateStateId: string;
    zkConfigPath: string;
}
export interface WalletDeployContractArgs {
    sessionId: string;
    /** Ephemeral key tying the worker-side PS proxy back to a main-side provider. */
    proxyId: string;
    contractName: string;
    registration: WorkerContractRegistration;
    indexerHttpUrl: string;
    indexerWsUrl: string;
    proofServerUrl: string;
    networkId: 'preprod' | 'testnet' | 'mainnet' | 'undeployed' | 'devnet' | 'qanet' | 'preview';
    /** User-supplied private state for the new contract. Plain JSON-able value. */
    initialPrivateState: unknown;
}
export interface WalletSubmitContractCallArgs {
    sessionId: string;
    proxyId: string;
    contractName: string;
    registration: WorkerContractRegistration;
    contractAddress: string;
    circuit: string;
    args: unknown[];
    indexerHttpUrl: string;
    indexerWsUrl: string;
    proofServerUrl: string;
    networkId: 'preprod' | 'testnet' | 'mainnet' | 'undeployed' | 'devnet' | 'qanet' | 'preview';
    /**
     * Per-call ZK-predicate witnesses for `commitValue`/`provePredicate`
     * (decimal value + 64-hex salt). Forwarded to the witness factory so the
     * hidden value never leaves as a circuit arg. Omitted for other circuits.
     */
    witnessValues?: {
        attestedValue: string;
        valueSalt: string;
    };
}
/**
 * Deploy a Compact-emitted contract through the wallet worker. The worker
 * owns the SDK and the wallet facade; private-state CRUD round-trips back to
 * the main-side provider registered under `proxyId`.
 *
 * Returns primitives only (no SDK objects cross the thread boundary).
 */
export declare function walletDeployContract(args: WalletDeployContractArgs): Promise<{
    txHash: string;
    contractAddress: string;
    onChainStatus: string;
}>;
/**
 * Invoke a circuit on a deployed contract through the worker. Same wiring as
 * `walletDeployContract`. Returns the submission txHash + on-chain status.
 */
export declare function walletSubmitContractCall(args: WalletSubmitContractCallArgs): Promise<{
    txHash: string;
    onChainStatus: string;
}>;
/** Test-only: reset the singleton so subsequent calls re-spawn. */
export declare function __resetWalletWorkerForTests(): void;
