caravan-x
Version:
A terminal-based utility for managing Caravan multisig wallets in regtest mode. This tool simplifies development and testing with Caravan by providing an easy-to-use interface
86 lines (85 loc) • 2.19 kB
TypeScript
/**
* Snapshot Service for Caravan-X
* Handles saving and restoring blockchain states in regtest mode
*/
import { BlockchainSnapshot } from "../types/config";
import { BitcoinRpcClient } from "./rpc";
export interface SnapshotOptions {
name: string;
description?: string;
tags?: string[];
includeWallets?: string[];
scenario?: string;
}
export interface SnapshotDiff {
snapshot1: BlockchainSnapshot;
snapshot2: BlockchainSnapshot;
blocksDiff: number;
walletsDiff: {
added: string[];
removed: string[];
common: string[];
};
heightDiff: number;
}
export declare class SnapshotService {
private readonly rpc;
private readonly snapshotsDir;
private readonly bitcoinDataDir;
constructor(rpc: BitcoinRpcClient, snapshotsDir: string, bitcoinDataDir: string);
/**
* Create a snapshot of the current blockchain state
*/
createSnapshot(options: SnapshotOptions): Promise<BlockchainSnapshot>;
/**
* Restore a snapshot
*/
restoreSnapshot(snapshotId: string, options?: {
stopBitcoin?: boolean;
restartBitcoin?: boolean;
}): Promise<void>;
/**
* List all snapshots
*/
listSnapshots(): Promise<BlockchainSnapshot[]>;
/**
* Get a specific snapshot by ID or name
*/
getSnapshot(idOrName: string): Promise<BlockchainSnapshot | null>;
/**
* Delete a snapshot
*/
deleteSnapshot(snapshotId: string): Promise<void>;
/**
* Compare two snapshots
*/
diffSnapshots(snapshot1Id: string, snapshot2Id: string): Promise<SnapshotDiff>;
/**
* Generate a unique snapshot ID
*/
private generateSnapshotId;
/**
* Save snapshot reference
*/
private saveSnapshotReference;
/**
* Save snapshots list
*/
private saveSnapshotsList;
/**
* Copy directory recursively
*/
private copyDirectory;
/**
* Create tar.gz archive
*/
private createTarGz;
/**
* Extract tar.gz archive
*/
private extractTarGz;
/**
* Auto-snapshot based on interval
*/
createAutoSnapshot(): Promise<BlockchainSnapshot>;
}