import { type MerkleRoot } from '../db/schema/merkle.js';
import { type MerkleProof } from './merkle.js';
import type { ID } from '../common/types.js';
/**
 * Configuration for MerkleService
 */
export interface MerkleServiceConfig {
    /** Aggregation window in milliseconds (default: 1 hour) */
    aggregationWindowMs?: number;
    /** Minimum proofs required for aggregation (default: 1) */
    minProofsForAggregation?: number;
    /** Maximum proofs per tree (default: 10000) */
    maxProofsPerTree?: number;
}
/**
 * Result of adding a proof to the aggregation queue
 */
export interface QueueResult {
    queued: boolean;
    queueId: string;
    proofId: string;
}
/**
 * Result of an aggregation run
 */
export interface AggregationResult {
    success: boolean;
    rootId?: string;
    rootHash?: string;
    leafCount?: number;
    error?: string;
}
/**
 * Merkle root with additional metadata
 */
export interface MerkleRootInfo extends MerkleRoot {
    /** Whether this root has been anchored to a blockchain */
    anchored: boolean;
}
/**
 * Full Merkle proof response with proof details
 */
export interface MerkleProofResponse {
    found: boolean;
    proofId: string;
    merkleProof?: MerkleProof;
    rootId?: string;
    rootHash?: string;
    anchorTx?: string | null;
    anchorChain?: string | null;
    anchoredAt?: string | null;
    createdAt?: string;
}
/**
 * Service for managing Merkle tree aggregation of proofs
 */
export declare class MerkleService {
    private db;
    private config;
    private initialized;
    private aggregationTimer;
    constructor(config?: MerkleServiceConfig);
    /**
     * Initialize the service
     */
    initialize(): Promise<void>;
    /**
     * Ensure service is initialized
     */
    private ensureInitialized;
    /**
     * Queue a proof for Merkle aggregation
     *
     * @param proofId - The proof ID
     * @param proofHash - The proof's hash
     * @returns Queue result
     */
    queueProof(proofId: string, proofHash: string): Promise<QueueResult>;
    /**
     * Get pending proofs from the queue
     *
     * @param limit - Maximum number of proofs to fetch
     * @param olderThan - Only fetch proofs older than this date
     * @returns Array of pending proofs
     */
    getPendingProofs(limit?: number, olderThan?: Date): Promise<Array<{
        id: string;
        proofId: string;
        proofHash: string;
        queuedAt: Date;
    }>>;
    /**
     * Aggregate pending proofs into a Merkle tree
     *
     * @returns Aggregation result
     */
    aggregatePendingProofs(): Promise<AggregationResult>;
    /**
     * Get Merkle proof for a specific proof
     *
     * @param proofId - The proof ID to get Merkle proof for
     * @returns Merkle proof response
     */
    getMerkleProof(proofId: ID): Promise<MerkleProofResponse>;
    /**
     * Verify a Merkle proof for a specific proof
     *
     * @param proofId - The proof ID
     * @param proofHash - The proof's hash
     * @param expectedRoot - Optional expected root hash
     * @returns True if the proof is valid and included in the tree
     */
    verifyMerkleProof(proofId: string, proofHash: string, expectedRoot?: string): Promise<{
        valid: boolean;
        error?: string;
    }>;
    /**
     * Get list of recent Merkle roots
     *
     * @param limit - Maximum number of roots to return
     * @param includeUnanchored - Whether to include unanchored roots
     * @returns Array of Merkle root info
     */
    listRoots(limit?: number, includeUnanchored?: boolean): Promise<MerkleRootInfo[]>;
    /**
     * Get a specific Merkle root by ID
     *
     * @param rootId - The root ID
     * @returns The Merkle root info or undefined
     */
    getRoot(rootId: string): Promise<MerkleRootInfo | undefined>;
    /**
     * Get a Merkle root by its hash
     *
     * @param rootHash - The root hash
     * @returns The Merkle root info or undefined
     */
    getRootByHash(rootHash: string): Promise<MerkleRootInfo | undefined>;
    /**
     * Set anchor information for a Merkle root
     *
     * @param rootId - The root ID
     * @param anchorTx - The anchor transaction hash
     * @param anchorChain - The anchor chain (e.g., 'ethereum')
     * @returns True if the anchor was set
     */
    setAnchor(rootId: string, anchorTx: string, anchorChain: string): Promise<boolean>;
    /**
     * Get unanchored roots for blockchain anchoring
     *
     * @param limit - Maximum number of roots to return
     * @returns Array of unanchored Merkle roots
     */
    getUnanchoredRoots(limit?: number): Promise<MerkleRoot[]>;
    /**
     * Start the scheduled aggregation job
     *
     * @param intervalMs - Interval between aggregation runs (default: aggregation window)
     */
    startAggregationJob(intervalMs?: number): void;
    /**
     * Stop the scheduled aggregation job
     */
    stopAggregationJob(): void;
    /**
     * Get aggregation statistics
     */
    getStats(): Promise<{
        totalRoots: number;
        totalLeaves: number;
        pendingProofs: number;
        anchoredRoots: number;
    }>;
}
/**
 * Create a new MerkleService instance
 */
export declare function createMerkleService(config?: MerkleServiceConfig): MerkleService;
/**
 * Get the singleton MerkleService instance
 */
export declare function getMerkleService(): MerkleService;
//# sourceMappingURL=merkle-service.d.ts.map