/** * Factory for creating web wallets. * * This consolidates the common wallet setup used by both yours-wallet * (browser extension) and 1sat-website (React app). */ import { PrivateKey } from "@bsv/sdk"; import { Monitor, StorageClient, Wallet, WalletStorageManager } from "@bsv/wallet-toolbox-mobile/out/src/index.client.js"; import { OneSatServices } from "../services/OneSatServices"; import { type FullSyncResult, type FullSyncStage } from "./fullSync"; type Chain = "main" | "test"; /** * Configuration for creating a web wallet. */ export interface WebWalletConfig { /** Private key - can be PrivateKey instance, WIF string, or hex string */ privateKey: PrivateKey | string; /** Network: 'main' or 'test' */ chain: Chain; /** Fee model. Default: { model: 'sat/kb', value: 100 } */ feeModel?: { model: "sat/kb"; value: number; }; /** Remote storage URL. If provided, attempts to connect for cloud backup. */ remoteStorageUrl?: string; /** Unique identifier for this storage instance. Must be persisted by the consuming application and reused across sessions. Different devices should use different values to isolate sync state. */ storageIdentityKey: string; /** Callback when a transaction is broadcasted (called after remote sync if connected) */ onTransactionBroadcasted?: (txid: string) => void; /** Callback when a transaction is proven (called after remote sync if connected) */ onTransactionProven?: (txid: string, blockHeight: number) => void; } /** * Result of wallet creation. */ export interface WebWalletResult { /** Wallet instance */ wallet: Wallet; /** 1Sat services for API access */ services: OneSatServices; /** Monitor for transaction lifecycle (not started - call monitor.startTasks() when ready) */ monitor: Monitor; /** Cleanup function - stops monitor, destroys wallet */ destroy: () => Promise; /** Full sync with remote backup (only available if remoteStorageUrl was provided and connected) */ fullSync?: (onProgress?: (stage: FullSyncStage, message: string) => void) => Promise; /** Storage manager (for debugging/diagnostics) */ storage: WalletStorageManager; /** Remote storage client (for debugging/diagnostics, undefined if not connected) */ remoteStorage?: StorageClient; } /** * Create a web wallet with storage, services, and monitor. * * @example * ```typescript * const { wallet, services, monitor, destroy } = await createWebWallet({ * privateKey: identityWif, * chain: 'main', * storageIdentityKey: 'device-unique-id', * }); * * // Wire up monitor callbacks * monitor.onTransactionProven = async (status) => console.log('Proven:', status.txid); * * // Start monitor when ready * monitor.startTasks(); * ``` */ export declare function createWebWallet(config: WebWalletConfig): Promise; export {};