UNPKG

ndwallet-core

Version:

Core cryptographic library for NDWallet browser environments

68 lines (67 loc) 2.3 kB
export type NetworkType = 'bitcoin' | 'litecoin' | 'ethereum' | 'polygon' | 'binance' | 'tron' | 'solana' | 'monero' | 'zcash' | 'xrp' | 'avalanche' | 'cardano' | 'polkadot'; export interface WalletStoredShares { local?: string; server?: string; backup?: string; } export interface Wallet { name: string; addresses: Map<NetworkType, string>; accountIndex: number; storedShares: WalletStoredShares; _seedPhrase?: string; } /** * Type for wallet creation options */ export type WalletCreateOptions = { seedPhrase: string; name?: string; accountIndex?: number; backup: { recoveryPassword: string; secretAnswer?: string; secretQuestionId?: number; }; }; export interface WalletRestoreOptions { shares: string[]; accountIndex?: number; network?: NetworkType; } export interface SeedPhraseRecoveryOptions { shares?: string[]; } /** * Generates a new BIP39 seed phrase * @returns {string} A new random seed phrase */ export declare function generateSeedPhrase(): string; /** * Creates a new wallet using the options provided * @param {string} email - User email * @param {WalletCreateOptions} options - Wallet creation options * @returns {Wallet} The created wallet */ export declare function createWallet(email: string, options: WalletCreateOptions): Promise<Wallet>; /** * Gets the address for a specific network and account index * @param {Object} wallet - The wallet object * @param {string} [network] - Optional network to get address for (defaults to wallet's network) * @param {number} [accountIndex] - Optional account index (defaults to wallet's account index) * @returns {string} The wallet address */ /** * Reconstructs and returns the seed phrase from a wallet * @param {Object} wallet - The wallet object * @param {Object} [options] - Options for retrieving the seed phrase * @param {Array<string>} [options.shares] - Shares to use for reconstruction (if not using the wallet's stored shares) * @returns {string} The retrieved seed phrase */ /** * Helper function to derive an address from a seed * @param {Uint8Array} seed - The seed bytes * @param {string} network - The network * @param {number} accountIndex - The account index * @returns {string} The derived address */