/**
 * Wallet worker thread entry.
 *
 * Lives in its OWN Node `worker_threads` worker so the Midnight wallet SDK's
 * Effect.ts Fiber scheduler — which monopolises the microtask queue while a
 * chain sync is running — only blocks THIS thread's event loop. The main
 * cds-serve thread stays responsive for OData requests and CAP DB writes.
 *
 * Communication: per-call `MessageChannel`. Main thread posts
 *   { kind: 'rpc', method, args, port: MessagePort }
 * and the worker replies on `port` with
 *   { ok: true, result } | { ok: false, error: string }
 *
 * Push events (worker → main, on `parentPort`):
 *   - { kind: 'state-save', sessionId, sdkVersion, blobs }
 *     emitted ~every 30 s while a facade is active so the main thread can
 *     persist via standard `cds.connect.to('db').run(...)`.
 *   - { kind: 'log', level, message }
 *     surfaces worker-side console.log/warn lines into the main thread's
 *     unified log stream.
 *
 * Surface: init / waitForSyncedState / serializeState / evict, plus
 * balanceUnboundTransaction / submitTransaction /
 * registerNightUtxosForDustGeneration for the deploy path.
 */
import { type MessagePort } from 'node:worker_threads';
export interface RpcRequest {
    kind: 'rpc';
    method: string;
    args: unknown;
    port: MessagePort;
}
export interface RpcErrorPayload {
    name: string;
    message: string;
}
export interface RpcOk {
    ok: true;
    result: unknown;
}
export interface RpcErr {
    ok: false;
    error: RpcErrorPayload;
}
export interface InitArgs {
    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;
    };
}
