"use strict";
/**
 * DUST registration.
 *
 * Per docs.midnight.network/guides/generating-dust-programmatically, NIGHT
 * UTXOs must be registered for DUST generation before they start producing
 * the fee-token DUST over time. On preprod the initial DUST accrual takes
 * 1-2 minutes after a successful registration tx.
 *
 * Implementation: a single RPC to the wallet worker (`walletRegisterDustGeneration`).
 * The worker owns the wallet SDK and runs the entire flow in its own event
 * loop — waitForSyncedState → filter unregistered NIGHT UTXOs → build the
 * registration recipe → finalizeRecipe (ZK proof via proof-server) → submit.
 * No SDK objects ever cross the thread boundary.
 *
 * The caller (`srv/sessions/wallet-sessions.ts::registerForDustGeneration`)
 * ensures the worker has been initialised for `cacheKey` via
 * `getOrBuildWalletFacade(...)` before invoking this function.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.registerNightUtxosForDust = registerNightUtxosForDust;
exports.deregisterNightUtxosFromDust = deregisterNightUtxosFromDust;
const wallet_worker_client_1 = require("../midnight/wallet-worker-client");
async function registerNightUtxosForDust(args) {
    // The worker holds the facade (initialised by getOrBuildWalletFacade in
    // the caller). We delegate the whole flow via one RPC; the worker returns
    // primitive values that survive the thread boundary cleanly.
    return (0, wallet_worker_client_1.walletRegisterDustGeneration)({
        sessionId: args.cacheKey,
        dustReceiverAddress: args.dustReceiverAddress,
        syncTimeoutMs: args.syncTimeoutMs
    });
}
async function deregisterNightUtxosFromDust(args) {
    return (0, wallet_worker_client_1.walletDeregisterDustGeneration)({
        sessionId: args.cacheKey,
        syncTimeoutMs: args.syncTimeoutMs
    });
}
