import { WalletMonitorTask } from './tasks/WalletMonitorTask';
import { WalletStorageManager } from '../storage/WalletStorageManager';
import { TaskPurgeParams } from './tasks/TaskPurge';
import { Chain, ProvenTransactionStatus } from '../sdk/types';
import { ReviewActionResult } from '../sdk/WalletStorage.interfaces';
import { BlockHeader, WalletServices } from '../sdk/WalletServices.interfaces';
import { Services } from '../services/Services';
import { ChaintracksClientApi } from '../services/chaintracker/chaintracks/Api/ChaintracksClientApi';
import { Chaintracks } from '../services/chaintracker/chaintracks/Chaintracks';
export type MonitorStorage = WalletStorageManager;
export interface MonitorOptions {
    chain: Chain;
    services: Services | WalletServices;
    storage: MonitorStorage;
    chaintracks: ChaintracksClientApi;
    chaintracksWithEvents?: Chaintracks;
    /**
     * How many msecs to wait after each getMerkleProof service request.
     */
    msecsWaitPerMerkleProofServiceReq: number;
    taskRunWaitMsecs: number;
    abandonedMsecs: number;
    unprovenAttemptsLimitTest: number;
    unprovenAttemptsLimitMain: number;
    /**
     * Stable callback token for ARC SSE event streaming.
     * When set, TaskArcadeSSE will open an SSE connection to Arcade's
     * /events endpoint and receive real-time transaction status updates.
     * Must match the X-CallbackToken header sent during broadcast.
     */
    callbackToken?: string;
    /** Load persisted SSE lastEventId (e.g. from SQLite) for catchup on startup */
    loadLastSSEEventId?: () => Promise<string | undefined>;
    /** Save SSE lastEventId to persistent storage */
    saveLastSSEEventId?: (lastEventId: string) => Promise<void>;
    /** The react-native-sse EventSource class for SSE support in React Native */
    EventSourceClass?: any;
    /**
     * These are hooks for a wallet-toolbox client to get transaction updates.
     */
    onTransactionBroadcasted?: (broadcastResult: ReviewActionResult) => Promise<void>;
    onTransactionProven?: (txStatus: ProvenTransactionStatus) => Promise<void>;
    onTransactionStatusChanged?: (txid: string, newStatus: string) => Promise<void>;
}
/**
 * Background task to make sure transactions are processed, transaction proofs are received and propagated,
 * and potentially that reorgs update proofs that were already received.
 */
export declare class Monitor {
    static createDefaultWalletMonitorOptions(chain: Chain, storage: MonitorStorage, services?: Services, chaintracks?: Chaintracks): MonitorOptions;
    options: MonitorOptions;
    services: Services | WalletServices;
    chain: Chain;
    storage: MonitorStorage;
    chaintracks: ChaintracksClientApi;
    chaintracksWithEvents?: Chaintracks;
    reorgSubscriptionPromise?: Promise<string>;
    headersSubscriptionPromise?: Promise<string>;
    onTransactionBroadcasted?: (broadcastResult: ReviewActionResult) => Promise<void>;
    onTransactionProven?: (txStatus: ProvenTransactionStatus) => Promise<void>;
    onTransactionStatusChanged?: (txid: string, newStatus: string) => Promise<void>;
    constructor(options: MonitorOptions);
    destroy(): Promise<void>;
    static readonly oneSecond = 1000;
    static readonly oneMinute: number;
    static readonly oneHour: number;
    static readonly oneDay: number;
    static readonly oneWeek: number;
    /**
     * _tasks are typically run by the scheduler but may also be run by runTask.
     */
    _tasks: WalletMonitorTask[];
    /**
     * _otherTasks can be run by runTask but not by scheduler.
     */
    _otherTasks: WalletMonitorTask[];
    _tasksRunning: boolean;
    defaultPurgeParams: TaskPurgeParams;
    addAllTasksToOther(): void;
    /**
     * Default tasks with settings appropriate for a single user storage
     * possibly with sync'ing enabled
     */
    addDefaultTasks(): void;
    /**
     * Tasks appropriate for multi-user storage
     * without sync'ing enabled.
     */
    addMultiUserTasks(): void;
    addTask(task: WalletMonitorTask): void;
    removeTask(name: string): void;
    runTask(name: string): Promise<string>;
    runOnce(): Promise<void>;
    _runAsyncSetup: boolean;
    _tasksRunningPromise?: PromiseLike<void>;
    resolveCompletion: ((value: void | PromiseLike<void>) => void) | undefined;
    startTasks(): Promise<void>;
    logEvent(event: string, details?: string): Promise<void>;
    stopTasks(): void;
    lastNewHeader: BlockHeader | undefined;
    lastNewHeaderWhen: Date | undefined;
    /**
     * Process new chain header event received from Chaintracks
     *
     * Kicks processing 'unconfirmed' and 'unmined' request processing.
     *
     * @param reqs
     */
    processNewBlockHeader(header: BlockHeader): void;
    /**
     * This is a function run from a TaskSendWaiting Monitor task.
     *
     * This allows the user of wallet-toolbox to 'subscribe' for transaction broadcast updates.
     *
     * @param broadcastResult
     */
    callOnBroadcastedTransaction(broadcastResult: ReviewActionResult): void;
    /**
     * This is a function run from a TaskCheckForProofs Monitor task.
     *
     * This allows the user of wallet-toolbox to 'subscribe' for transaction updates.
     *
     * @param txStatus
     */
    callOnProvenTransaction(txStatus: ProvenTransactionStatus): void;
    /**
     * Called by TaskArcadeSSE when an SSE status event is received from Arcade.
     */
    callOnTransactionStatusChanged(txid: string, newStatus: string): void;
    /**
     * Fetch pending transaction status events from Arcade on demand.
     * Call this on app open, balance refresh, transaction list view, etc.
     */
    fetchSSEEvents(): Promise<number>;
    deactivatedHeaders: DeactivedHeader[];
    /**
     * Process reorg event received from Chaintracks
     *
     * Reorgs can move recent transactions to new blocks at new index positions.
     * Affected transaction proofs become invalid and must be updated.
     *
     * It is possible for a transaction to become invalid.
     *
     * Coinbase transactions always become invalid.
     */
    processReorg(depth: number, oldTip: BlockHeader, newTip: BlockHeader, deactivatedHeaders?: BlockHeader[]): void;
    /**
     * Handler for new header events from Chaintracks.
     *
     * To minimize reorg processing, new headers are aged before processing via TaskNewHeader.
     * Therefore this handler is intentionally a no-op.
     *
     * @param header
     */
    processHeader(header: BlockHeader): void;
}
export interface DeactivedHeader {
    /**
     * To control aging of notification before pursuing updated proof data.
     */
    whenMsecs: number;
    /**
     * Number of attempts made to process the header.
     * Supports returning deactivation notification to the queue if proof data is not yet available.
     */
    tries: number;
    /**
     * The deactivated block header.
     */
    header: BlockHeader;
}
//# sourceMappingURL=Monitor.d.ts.map